fantassh 0.3.0 → 0.3.1
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 +4 -4
- data/lib/fantassh/entries_file.rb +7 -3
- data/lib/fantassh/history_file.rb +7 -0
- data/lib/fantassh/version.rb +1 -1
- data/spec/lib/history_file_spec.rb +23 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e45839a435156b44ae27bf53f425e2a316aec691
|
4
|
+
data.tar.gz: b3231ac37e92ee4080bb6c6c655ec87198a8734d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3980274712554b5fa377b67d65e3116227bda1f05b6699593eacaf27248c9bd1aaa96c531fc27ef9823846d874ca0ed280f72ff5b5b92a53cfd2c2d9f3735c0
|
7
|
+
data.tar.gz: f03aece7c26d1d5ae76aac5bfbe9d82266b030ce081a1e18c930ccb5ba8b18d067f2e0822394fed818b8fff3aca3377e4789faa48cd51faa3f2b060233de8863
|
@@ -10,9 +10,13 @@ module Fantassh
|
|
10
10
|
File.readlines(file).map(&:strip)
|
11
11
|
end
|
12
12
|
|
13
|
-
def add(new_entries)
|
14
|
-
new_entries = new_entries.map(&:strip).
|
15
|
-
entries =
|
13
|
+
def add(new_entries, reject_duplicates: true)
|
14
|
+
new_entries = new_entries.map(&:strip).reject(&:empty?)
|
15
|
+
entries = all + new_entries
|
16
|
+
|
17
|
+
if reject_duplicates
|
18
|
+
entries.uniq!
|
19
|
+
end
|
16
20
|
|
17
21
|
File.open(file, 'w') do |f|
|
18
22
|
f.puts(entries)
|
@@ -6,6 +6,13 @@ module Fantassh
|
|
6
6
|
def file
|
7
7
|
File.join(@config_dir, 'history')
|
8
8
|
end
|
9
|
+
|
10
|
+
# as opposed to the actual entries files we want to
|
11
|
+
# have duplicates here to properly represent the
|
12
|
+
# user's history
|
13
|
+
def add(new_entries)
|
14
|
+
super(new_entries, reject_duplicates: false)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
data/lib/fantassh/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fantassh/history_file'
|
3
|
+
|
4
|
+
module Fantassh
|
5
|
+
describe HistoryFile do
|
6
|
+
subject { HistoryFile.new(config_dir: '/dir') }
|
7
|
+
|
8
|
+
context "#add" do
|
9
|
+
let(:file) do
|
10
|
+
file = double('file')
|
11
|
+
File.should_receive(:open).with('/dir/history', 'w').and_yield(file)
|
12
|
+
file
|
13
|
+
end
|
14
|
+
|
15
|
+
it "adds a duplicate" do
|
16
|
+
file.should_receive(:puts).with(["host1.com", "host1.com"])
|
17
|
+
subject.stub(all: ["host1.com"])
|
18
|
+
|
19
|
+
subject.add(["host1.com"])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fantassh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Reigel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- spec/lib/entries_file_spec.rb
|
97
97
|
- spec/lib/entries_spec.rb
|
98
98
|
- spec/lib/excluded_entries_file_spec.rb
|
99
|
+
- spec/lib/history_file_spec.rb
|
99
100
|
- spec/lib/history_spec.rb
|
100
101
|
- spec/spec_helper.rb
|
101
102
|
homepage: https://github.com/koffeinfrei/fantassh
|
@@ -129,5 +130,6 @@ test_files:
|
|
129
130
|
- spec/lib/entries_file_spec.rb
|
130
131
|
- spec/lib/entries_spec.rb
|
131
132
|
- spec/lib/excluded_entries_file_spec.rb
|
133
|
+
- spec/lib/history_file_spec.rb
|
132
134
|
- spec/lib/history_spec.rb
|
133
135
|
- spec/spec_helper.rb
|