blocklist 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/blocklist.gemspec +2 -2
- data/lib/blocklist/cli.rb +5 -1
- data/spec/blocklist/cli_spec.rb +17 -1
- metadata +2 -2
data/blocklist.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.name = 'blocklist'
|
4
4
|
s.summary = "Blocklist manages /etc/hosts"
|
5
5
|
s.description = "Blocklist manages /etc/hosts with the goal of routing distracting websites to localhost. It also works well as an ad blocker."
|
6
|
-
s.version = '0.1.
|
7
|
-
s.date = '2009-09-
|
6
|
+
s.version = '0.1.2'
|
7
|
+
s.date = '2009-09-16'
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Wes Oldenbeuving"]
|
10
10
|
s.email = "narnach@gmail.com"
|
data/lib/blocklist/cli.rb
CHANGED
@@ -28,7 +28,11 @@ class Blocklist
|
|
28
28
|
|
29
29
|
def add
|
30
30
|
block_name = @argv.shift
|
31
|
-
block = @bl.block(block_name)
|
31
|
+
unless block = @bl.block(block_name)
|
32
|
+
block = Blocklist::Block.new(block_name)
|
33
|
+
@bl.blocks << block
|
34
|
+
end
|
35
|
+
|
32
36
|
|
33
37
|
domains = block.lines.map {|line| line.domains}.flatten
|
34
38
|
saved_domains = @argv.map do |domain|
|
data/spec/blocklist/cli_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Blocklist::Cli do
|
|
11
11
|
before(:each) do
|
12
12
|
FakeFS.activate!
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
after(:each) do
|
16
16
|
FakeFS.deactivate!
|
17
17
|
end
|
@@ -49,6 +49,22 @@ describe Blocklist::Cli do
|
|
49
49
|
cli.run
|
50
50
|
File.read('/etc/hosts').should == <<-STR
|
51
51
|
# localhost
|
52
|
+
127.0.0.1 example.org www.example.org
|
53
|
+
STR
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should create a new block if it does not exist yet' do
|
57
|
+
fake_hosts <<-STR
|
58
|
+
# localhost
|
59
|
+
127.0.0.1 localhost
|
60
|
+
STR
|
61
|
+
cli = Blocklist::Cli.new(%w[add example example.org])
|
62
|
+
cli.run
|
63
|
+
File.read('/etc/hosts').should == <<-STR
|
64
|
+
# localhost
|
65
|
+
127.0.0.1 localhost
|
66
|
+
|
67
|
+
# example
|
52
68
|
127.0.0.1 example.org www.example.org
|
53
69
|
STR
|
54
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blocklist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes Oldenbeuving
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-16 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|