compter 0.0.1 → 0.0.2

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: 39faaa85605f4a141dc065ddc99a73fa4ec54107
4
- data.tar.gz: eaa2c68d1e008ec6f07ebc33e8fb3c79b9901e28
3
+ metadata.gz: 0c81b4d03dcbb00aefb9922378839367d2db1b97
4
+ data.tar.gz: acba26cf01e4bd0f54b5dcb336ac17678732e6e9
5
5
  SHA512:
6
- metadata.gz: a09f437ad87ceaf4fce361bcb360e559e2e392bbcb9d4f5f0ea1700f47c48af6d23a5ea10a33010e740c930c41ffd6610207cafea2ada9dcf2da32aba05a1375
7
- data.tar.gz: 763281636380016faa8f33620977fcf53f642224d4567692d679442b9f916cf45e4afe52f3826602b766fc4e642c641c529705cd4fbee0e1f83a4f558940efa1
6
+ metadata.gz: 8596d64933c6b11fcf75d7ac5e39e48d6a2fae78dee88f36d2d133ad412490179bbaa69c0bb453f02fcf3dcbc1fbc20a8aa68d4f41da4f6673bd93528af1d33b
7
+ data.tar.gz: 658bf43e9413b2c90283445a2ca90caff69f26ad2feb962e74e03a12f56b6a0cd8dad27e70794ed2f763a0393dc9c714d9f49bdde48686ab0ae4012219f3e300
@@ -5,12 +5,17 @@ module Compter
5
5
  input.scan(text).size
6
6
  end
7
7
 
8
- def count_per_identifiers(identifiers, input)
8
+ def count_per_identifier(identifiers, input)
9
9
  results = Hash.new
10
10
 
11
- identifiers.each do |identifier, text|
12
- results[identifier] = count_occurrences_of(text, input)
11
+ identifiers.each do |identifier, query|
12
+ occurrences = 0
13
13
 
14
+ input.each do |text|
15
+ occurrences += count_occurrences_of(query, text)
16
+ end
17
+
18
+ results[identifier] = occurrences
14
19
  end
15
20
 
16
21
  results
@@ -1,3 +1,3 @@
1
1
  module Compter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/compter_spec.rb CHANGED
@@ -14,14 +14,17 @@ describe "it counts occurrence of text in input" do
14
14
  occurences.should == 1
15
15
  end
16
16
 
17
- it "counts occurences per identifier" do
17
+ it "counts occurences per identifiers on multiple inputs" do
18
18
  identifiers = {"letters" => "abc",
19
19
  "one-to-six" => "123456",
20
20
  "not-found" => "hue"
21
21
  }
22
22
 
23
- occurences_per_identifiers = @compter.count_per_identifiers(identifiers, "123456 abc 789")
23
+ input = ["123456 abc 789", "another string with abc", "123456 once again"]
24
24
 
25
- occurences_per_identifiers.should == {"letters" => 1, "one-to-six" => 1, "not-found" => 0}
25
+ occurences_per_identifiers = @compter.count_per_identifier(identifiers, input)
26
+
27
+ occurences_per_identifiers.should == {"letters" => 2, "one-to-six" => 2, "not-found" => 0}
26
28
  end
29
+
27
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Vereza