disavow_tool 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8db2e508792ce319b2f11c7e4dd43a3e7d31b875a0c3d80aa97828b600e34e96
4
- data.tar.gz: 868088592ece6710d0326ce9b586c79e072f083cb9bdc2060998c1649552bc87
3
+ metadata.gz: 77189b8d9bcfe6f39a02e4f6f9c1029a8e0195db398a77cc3b41710298b29b48
4
+ data.tar.gz: 7420106da6fe2ff050a538c7d65b76bea2215513a1992d1ec230d8432da52e99
5
5
  SHA512:
6
- metadata.gz: a7e6e2ab72198469ff1ec3cfa68497fbefcfec8eba7746ad1c2e17a087a045f2a8c1539de12642c04841256e83958095a20d0c0bc06b625940baf52c796b0546
7
- data.tar.gz: a4da05637f583bf94cd3b4eb83c234297adf18954339757529e8ace255a008bf6674ed2fa2c80184dcf1002fc624b31695290b7161cfa304e18b58ce74901776
6
+ metadata.gz: bfba74cb97ecbcb18513d916db793aa2504d9c64e3502cfab5719b3452b1ab1d1886532a4370906eaf34b47651169d2ab649a9e958be1af76b62a174e062dee9
7
+ data.tar.gz: 567a7ea282a3a726eeae9ca838f4223a0d126a3812edb035991ca93d836dfdb8c87375ca056ae31d973be8b2735689dcefdecf33a5bcdc4b5854636aa1a0ef2a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- disavow_tool (0.3.0)
4
+ disavow_tool (0.3.2)
5
5
  activesupport
6
6
  colorize
7
7
  nokogiri
@@ -6,7 +6,11 @@ require 'timeout'
6
6
  module DisavowTool
7
7
  class ImportedLinks < List
8
8
 
9
+
10
+
9
11
  def initialize(import_file=nil)
12
+ @menu_options = {whitelist_domain: "W", whitelist_url: "w", whitelist_all_urls: "a",
13
+ disavow_domain: "D", disavow_url: "d", open_in_browser: "o", exit: "."}
10
14
  super(OPTIONS.import_files)
11
15
  end
12
16
 
@@ -29,31 +33,47 @@ module DisavowTool
29
33
  end
30
34
  puts "* URls with this same domain: #{urls_with_same_domain(url)}"
31
35
  puts "*\n#{"*"*100}"
32
- puts menu()
33
- input = $stdin.getch
34
- input = $stdin.getch if open_browser_option(input, url)
35
- case input
36
- when "w"
37
- raise "Command run with no whitelist option" if OPTIONS.whitelist == false
38
- white_list.add_url url
39
- self.delete_url url
40
- when "W"
41
- raise "Command run with no whitelist option" if OPTIONS.whitelist == false
42
- domain = white_list.add_domain_from_url(url)
43
- self.delete_url url
44
- puts "Attempting to remove URLs with the domain #{domain} from imported links to stop anaylsing"
45
- self.delete_urls_if_domains(domain)
46
- when "a"
47
- white_list.add_urls_with_same_domain_as url, self
48
- when "d"
49
- domain = disavowed.add_domain_from_url(url)
50
- self.delete_url url
51
- puts "Attempting to remove URLs with the domain #{domain} from imported links to stop anaylsing"
52
- self.delete_urls_if_domains(domain)
53
- when "u"
54
- disavowed.add_url(url)
55
- self.delete_url url
56
- else raise "Invalid character."
36
+
37
+ loop do
38
+ puts menu()
39
+ input = $stdin.getch
40
+ case input
41
+ when @menu_options[:whitelist_url]
42
+ raise "Command run with no whitelist option" if OPTIONS.whitelist == false
43
+ white_list.add_url url
44
+ self.delete_url url
45
+
46
+ when @menu_options[:whitelist_domain]
47
+ raise "Command run with no whitelist option" if OPTIONS.whitelist == false
48
+ domain = white_list.add_domain_from_url(url)
49
+ self.delete_url url
50
+ puts "Attempting to remove URLs with the domain #{domain} from imported links to stop anaylsing"
51
+ self.delete_urls_if_domains(domain)
52
+
53
+ when @menu_options[:whitelist_all_urls]
54
+ white_list.add_urls_with_same_domain_as url, self
55
+
56
+ when @menu_options[:disavow_domain]
57
+ domain = disavowed.add_domain_from_url(url)
58
+ self.delete_url url
59
+ puts "Attempting to remove URLs with the domain #{domain} from imported links to stop anaylsing"
60
+ self.delete_urls_if_domains(domain)
61
+
62
+ when @menu_options[:disavow_url]
63
+ disavowed.add_url(url)
64
+ self.delete_url url
65
+
66
+ when @menu_options[:open_in_browser]
67
+ open_browser(url)
68
+
69
+ when @menu_options[:exit]
70
+ exit
71
+
72
+ else
73
+ puts "Incorrect option selected"
74
+ end
75
+ next if input == @menu_options[:open_in_browser]
76
+ break if @menu_options.value?(input) unless input == @menu_options[:open_in_browser]
57
77
  end
58
78
  puts "\n\n#{@list.count} Remaining links to analize".blue
59
79
  end
@@ -76,17 +96,22 @@ module DisavowTool
76
96
  :private
77
97
  def menu
78
98
  message = ""
79
- message = "[w] Whitelist url [W] Whitelist the entire domain [a] whitelist as url All urls with this domain\n" if OPTIONS.whitelist
80
- message += "[d] Disavow as domain [u] Disavow as a URL [o] to open the URL."
99
+ if OPTIONS.whitelist
100
+ message = "[#{@menu_options[:whitelist_domain]}] Whitelist as domain "\
101
+ "[#{@menu_options[:whitelist_url]}] Whitelist URL "\
102
+ "[#{@menu_options[:whitelist_all_urls]}] whitelist as url All urls with this domain\n"
103
+ end
104
+ message += "[#{@menu_options[:disavow_domain]}] Disavow as domain "\
105
+ "[#{@menu_options[:disavow_url]}] Disavow as URL\n"\
106
+ "[#{@menu_options[:open_in_browser]}] to open the URL "\
107
+ "[#{@menu_options[:exit]}] to exit"
108
+
81
109
  end
82
110
 
83
- def open_browser_option(input, link)
84
- if input == "o"
85
- if Gem.win_platform? then system "start chrome #{link}" else system "open -a safari #{link}" end
86
- puts "Opening #{link}...".blue
87
- puts menu
88
- return true
89
- end
111
+ def open_browser(link)
112
+ if Gem.win_platform? then system "start chrome #{URL.escape(link)}" else system "open -a safari #{link}" end
113
+ puts "Opening #{link}...".blue
114
+ return true
90
115
  end
91
116
 
92
117
  def website_title(url)
@@ -1,4 +1,5 @@
1
1
  require 'set'
2
+ require 'fileutils'
2
3
 
3
4
  module DisavowTool
4
5
  class List
@@ -112,6 +113,7 @@ module DisavowTool
112
113
  now = Time.now.strftime("%Y%m%d%H")
113
114
  file_name = self.class.to_s.underscore + "_" + now
114
115
  export_file = export_file || EXPORT_PATH + file_name
116
+ FileUtils.mkdir_p File.dirname(export_file)
115
117
  file = File.new(export_file, "w")
116
118
  file.puts "# Exporting #{self.class.to_s.underscore} #{ now }"
117
119
  export_write(file)
@@ -1,3 +1,3 @@
1
1
  module DisavowTool
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disavow_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maesitos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler