word_bunny 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7a9b42df1c407008d50857ea137ad0febdbe0124
4
+ data.tar.gz: dea6e58ca0638257a6fa0c7007cf1fb6558ab8ac
5
+ SHA512:
6
+ metadata.gz: 39c754589cc819f5cf63c8b8332598b32e782627572cfdc84ee59266a6b5662a34c1ff4499d87451cd4a56e4eaaac80e350ab8df2a2b877899fbef61aaa35e77
7
+ data.tar.gz: 13eccda0a7fe8d39d58b9b6c3e23e4ecd05bb649d05e9c38dbc7bfe942f6f629b6368ca7cdf7d1ee3c16c93dc225c9e4df9d9475751c6e70d344366de921c6ed
@@ -0,0 +1,4 @@
1
+ require 'word_bunny/tallies_words'
2
+
3
+ module WordBunny
4
+ end
@@ -0,0 +1,28 @@
1
+ module WordBunny
2
+ class TalliesWords
3
+ def self.execute text
4
+ results = []
5
+ text = cleanup text
6
+
7
+ text.split.each do |word|
8
+ index = results.find_index {
9
+ |word_count_pair| word_count_pair.first == word
10
+ }
11
+
12
+ unless index
13
+ results << [word, 1]
14
+ else
15
+ results[index][1] += 1
16
+ end
17
+ end
18
+
19
+ results.sort {|a, b| b.last <=> a.last}
20
+ end
21
+
22
+ private
23
+
24
+ def self.cleanup text
25
+ text.downcase.gsub(/[^a-z\s%-]/,'')
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module WordBunny
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: word_bunny
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Marc Ignacio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.14.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.14.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.12.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.12.2
41
+ description: Tallies each word found in a given text.
42
+ email: marcrendlignacio@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/word_bunny/tallies_words.rb
48
+ - lib/word_bunny/version.rb
49
+ - lib/word_bunny.rb
50
+ homepage:
51
+ licenses: []
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.0.3
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Feeds on words, not carrots.
73
+ test_files: []