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 +4 -4
- data/lib/compter/counter.rb +8 -3
- data/lib/compter/version.rb +1 -1
- data/spec/compter_spec.rb +6 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c81b4d03dcbb00aefb9922378839367d2db1b97
|
4
|
+
data.tar.gz: acba26cf01e4bd0f54b5dcb336ac17678732e6e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8596d64933c6b11fcf75d7ac5e39e48d6a2fae78dee88f36d2d133ad412490179bbaa69c0bb453f02fcf3dcbc1fbc20a8aa68d4f41da4f6673bd93528af1d33b
|
7
|
+
data.tar.gz: 658bf43e9413b2c90283445a2ca90caff69f26ad2feb962e74e03a12f56b6a0cd8dad27e70794ed2f763a0393dc9c714d9f49bdde48686ab0ae4012219f3e300
|
data/lib/compter/counter.rb
CHANGED
@@ -5,12 +5,17 @@ module Compter
|
|
5
5
|
input.scan(text).size
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
8
|
+
def count_per_identifier(identifiers, input)
|
9
9
|
results = Hash.new
|
10
10
|
|
11
|
-
identifiers.each do |identifier,
|
12
|
-
|
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
|
data/lib/compter/version.rb
CHANGED
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
|
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
|
-
|
23
|
+
input = ["123456 abc 789", "another string with abc", "123456 once again"]
|
24
24
|
|
25
|
-
occurences_per_identifiers
|
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
|