hosts_updater 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 447729cac82faec999f5fbc226a8a6a2fdcae437
4
- data.tar.gz: 29f83fae3b068051b9569035e80e11d58a42400b
3
+ metadata.gz: f2eb07e28d3e57d43aafd0040ad133a48af96d9a
4
+ data.tar.gz: e9c767da9dfedb5cb372efb3c41c3896dc825f95
5
5
  SHA512:
6
- metadata.gz: 3f3035cba8e46cdceb97cd4e2a691c0bbd6668a6b2660d03f029c8079ee680132653b284e1cd4d671302475a37a0ee1f4fc05017d7b1c351372a9e9295d34454
7
- data.tar.gz: 73f32364b6ed734af8bced01154bb0e25e6da12e07be867d091b2dee235b79ab299844b8b662444ea8d48f9dac0956091cc860eed8bff07814b9a5aadcf87b91
6
+ metadata.gz: af37d143427cfe6b4971f41a816b103360d3d5884c14c572715142ed534d144e53865338888100d654f018a0e220919313fe5bb3e795c442bf5ed92e3af649b4
7
+ data.tar.gz: 58a9c208f8e45379014d7e7d75f6ab61c930595f6a42867fb14c2fe91995bed6ced67761ae250abf4de7cf2db84fc753d6e0d01fa11a4b66fa2786c25299135d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.3
4
+
5
+ - add `--clear` flag that will remove all fetched records from blacklist
6
+
3
7
  ## 1.0.2
4
8
 
5
9
  - fix for `uninintialized constant FileUtils` error (@scharfie)
data/bin/hosts-updater CHANGED
@@ -13,6 +13,10 @@ OptionParser.new do |opts|
13
13
  exit
14
14
  end
15
15
 
16
+ opts.on("-c", "--clear", "Clear all blacklisted hosts") do |clear|
17
+ options[:clear] = clear
18
+ end
19
+
16
20
  opts.on("--hosts-file [PATH]", "Path to hosts file to write (default: /etc/hosts)") do |file|
17
21
  options[:hosts_file] = file
18
22
  end
@@ -33,7 +37,6 @@ OptionParser.new do |opts|
33
37
  options[:hosts_whitelist_name] = file
34
38
  end
35
39
 
36
-
37
40
  opts.on("-i", "--ip", "Redirect all blacklisted domains to following IP (default: 0.0.0.0)") do |ip|
38
41
  options[:id] = ip
39
42
  end
data/lib/hosts_updater.rb CHANGED
@@ -13,6 +13,7 @@ class HostsUpdater
13
13
  }
14
14
 
15
15
  DEFAULT_OPTIONS = {
16
+ :clear => false,
16
17
  :hosts_file => '/etc/hosts',
17
18
  :hosts_directory => '/etc/hosts.d/',
18
19
  :hosts_auto_name => 'hosts.auto',
@@ -106,17 +107,20 @@ class HostsUpdater
106
107
  # Combine hosts.custom and hosts.auto files into one and write to hosts_location.
107
108
  # Domains listed in hosts.whitelist are ommited from hosts.auto list, but not from hosts.custom
108
109
  def update_hosts_file
109
- auto = Hosts::File.read(hosts_auto_location).elements
110
- auto.reject! { |el| ! el.is_a? Aef::Hosts::Entry }
111
- auto.reject! { |el| whitelist.include? el.name }
112
- auto.each do |el|
113
- el.address = @options[:ip]
114
- end
115
-
116
110
  hosts = Hosts::File.new(@options[:hosts_file])
117
111
  hosts.elements = Hosts::File.read(hosts_custom_location).elements
118
- hosts.elements << Hosts::EmptyElement.new
119
- hosts.elements << Hosts::Section.new('HOSTS-UPDATER', :elements => auto)
112
+
113
+ unless @options[:clear]
114
+ auto = Hosts::File.read(hosts_auto_location).elements
115
+ auto.reject! { |el| ! el.is_a? Aef::Hosts::Entry }
116
+ auto.reject! { |el| whitelist.include? el.name }
117
+ auto.each do |el|
118
+ el.address = @options[:ip]
119
+ end
120
+ hosts.elements << Hosts::EmptyElement.new
121
+ hosts.elements << Hosts::Section.new('HOSTS-UPDATER', :elements => auto)
122
+ end
123
+
120
124
  logger.debug "Writing to #{@options[:hosts_file]}"
121
125
  hosts.write
122
126
  end
@@ -1,3 +1,3 @@
1
1
  class HostsUpdater
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hosts_updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Potocki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hosts
@@ -62,8 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 2.2.2
65
+ rubygems_version: 2.4.5
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Update your /etc/hosts with list of unwanted domains
69
69
  test_files: []
70
+ has_rdoc: