fantassh 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f938c65343a5ff9f5620e28edcb6c362bc06eb
4
- data.tar.gz: 20e00024d671a981a137c677ebeba590e533adcc
3
+ metadata.gz: e45839a435156b44ae27bf53f425e2a316aec691
4
+ data.tar.gz: b3231ac37e92ee4080bb6c6c655ec87198a8734d
5
5
  SHA512:
6
- metadata.gz: f5d22fa1cffc5eb16e024f374ccaf4f5edfa781cee4f3272e9b338786904a5e37c842175a703f915808ed5ba51b5aaefaf5318acc37de329f208b6907e0ace9c
7
- data.tar.gz: 9670c393604e09c06e730a2f99943a2444c5c8115c78d54bd0995e5c88bf8d241df23ae8511f311af9f7aa40ffdd067db35ac1201fc6196fd88176e4f6a3536d
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).delete_if { |x| x.empty? }
15
- entries = (all + new_entries).uniq
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
 
@@ -1,3 +1,3 @@
1
1
  module Fantassh
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -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.0
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-19 00:00:00.000000000 Z
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