Class: HatebloMixedContentsFinder::CLI
- Inherits:
-
Thor
- Object
- Thor
- HatebloMixedContentsFinder::CLI
- Defined in:
- lib/hateblo_mixed_contents_finder/cli.rb
Instance Method Summary collapse
Instance Method Details
#update_all ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hateblo_mixed_contents_finder/cli.rb', line 42 def update_all sleep_sec = [:sleep_sec] path = [:path] count = File.read(path).lines.size puts "[WARNING] Please backup your entries before update!!" print "Do you update #{count} entries? [yes|no]: " res = STDIN.gets.chomp.downcase return unless res == 'yes' client = HatenaClient.new File.foreach(path) do |url| client.update_entry(url.chomp) sleep sleep_sec end puts 'Completed.' end |
#validate_all(site_url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hateblo_mixed_contents_finder/cli.rb', line 10 def validate_all(site_url) entire_page = [:entire_page] limit = [:limit] path = [:path] invalid_contents = MixedContentsFinder.new(entire_page: entire_page).validate_all(site_url, limit: limit) FileUtils.rm(path) if File.exist?(path) File.write(path, invalid_contents.join("\n")) if invalid_contents.empty? puts 'OK💚' else puts "#{invalid_contents.size} errors found. Please open result.txt." end end |
#validate_entry(entry_url) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hateblo_mixed_contents_finder/cli.rb', line 27 def validate_entry(entry_url) entire_page = [:entire_page] invalid_contents = MixedContentsFinder.new(entire_page: entire_page).validate_entry(entry_url) if invalid_contents.empty? puts 'OK💚' else puts puts invalid_contents end end |