contador 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.2.0
data/contador.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{contador}
8
- s.version = "1.0.1"
7
+ s.name = "contador"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ivan Acosta-Rubio"]
12
- s.date = %q{2011-04-01}
13
- s.description = %q{This gem counts the numbers of words in a string. It returns each word and the multiplicity}
14
- s.email = %q{ivan@bakedweb.net}
12
+ s.date = "2012-11-14"
13
+ s.description = "This gem counts the numbers of words in a string. It returns each word and the multiplicity"
14
+ s.email = "ivan@bakedweb.net"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.md",
@@ -33,17 +33,16 @@ Gem::Specification.new do |s|
33
33
  "spec/contador_spec.rb",
34
34
  "spec/spec.opts"
35
35
  ]
36
- s.homepage = %q{http://github.com/ivanacostarubio/contador}
36
+ s.homepage = "http://github.com/ivanacostarubio/contador"
37
37
  s.licenses = ["MIT"]
38
38
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.7}
40
- s.summary = %q{This gem counts the numbers of words in a string. It returns each word and the multiplicity}
39
+ s.rubygems_version = "1.8.24"
40
+ s.summary = "This gem counts the numbers of words in a string. It returns each word and the multiplicity"
41
41
  s.test_files = [
42
42
  "spec/contador_spec.rb"
43
43
  ]
44
44
 
45
45
  if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
46
  s.specification_version = 3
48
47
 
49
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/lib/contador.rb CHANGED
@@ -12,7 +12,7 @@ class Contador
12
12
 
13
13
  def delete_omits
14
14
  $omits.split(' ').each do |word|
15
- @final.delete(word.to_sym)
15
+ @final.delete(word)
16
16
  end
17
17
  end
18
18
 
@@ -21,7 +21,7 @@ class Contador
21
21
  end
22
22
 
23
23
  def omit(word)
24
- @final.delete(word.to_sym)
24
+ @final.delete(word)
25
25
  end
26
26
 
27
27
  private
@@ -29,8 +29,8 @@ class Contador
29
29
  def split_string_into_hash
30
30
  string.split(' ').each do |word|
31
31
  begin
32
- word.gsub!(/\W+/, '')
33
- key = word.downcase.to_sym
32
+ word.gsub!(/[^0-9A-Za-z[-]_\s]/, '')
33
+ key = word.downcase
34
34
  if @final.has_key?(key)
35
35
  @final[key] += 1
36
36
  else
@@ -42,3 +42,7 @@ class Contador
42
42
  end
43
43
  end
44
44
  end
45
+
46
+
47
+
48
+
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
- require 'lib/contador'
3
+ require './lib/contador'
4
4
 
5
5
  describe Contador do
6
6
  it "returns an empty string for nothing " do
@@ -10,33 +10,38 @@ describe Contador do
10
10
 
11
11
  it "handles a single word" do
12
12
  contador = Contador.new("cuenta")
13
- contador.multiplicity.should == {:cuenta => 1}
13
+ contador.multiplicity.should == {"cuenta" => 1}
14
14
  end
15
15
 
16
16
  it "handles a couple of words" do
17
17
  contador = Contador.new("estudio estudio")
18
- contador.multiplicity.should == {:estudio => 2}
18
+ contador.multiplicity.should == {"estudio" => 2}
19
19
  end
20
20
 
21
21
  it "handles multiple single words" do
22
22
  contador = Contador.new("estudio estudio estudio estudio estudio estudio")
23
- contador.multiplicity.should == {:estudio => 6}
23
+ contador.multiplicity.should == {"estudio" => 6}
24
24
  end
25
25
 
26
26
  it "handles real sentences" do
27
27
  contador = Contador.new("Cuando voy a estudiar me siento muy bien")
28
- contador.multiplicity.should == {:cuando => 1, :voy => 1, :a => 1, :estudiar => 1, :me => 1, :siento => 1, :muy => 1, :bien => 1}
28
+ contador.multiplicity.should == {"cuando" => 1, "voy" => 1, "a" => 1, "estudiar" => 1, "me" => 1, "siento" => 1, "muy" => 1, "bien" => 1}
29
29
  end
30
30
 
31
31
  it "handles duplicates words in sentences" do
32
32
  contador = Contador.new("Ruby es depinga. Muy depinga.")
33
- contador.multiplicity.should == {:ruby => 1, :es => 1, :depinga => 2, :muy => 1}
33
+ contador.multiplicity.should == {"ruby" => 1, "es" => 1, "depinga" => 2, "muy" => 1}
34
34
  end
35
35
 
36
36
  it "handles weir case" do
37
37
  contador = Contador.new("Esto esta depinga. Depinga esta esto.")
38
- contador.multiplicity.should == {:esto => 2, :esta => 2, :depinga => 2}
38
+ contador.multiplicity.should == {"esto" => 2, "esta" => 2, "depinga" => 2}
39
39
  end
40
+
41
+ it "handles a complex word" do
42
+ contador = Contador.new("Baby-Food")
43
+ contador.multiplicity.should == {"baby-food" => 1}
44
+ end
40
45
 
41
46
  end
42
47
 
@@ -44,18 +49,18 @@ describe Contador, "No sally words" do
44
49
  it "omits some basic words" do
45
50
  contador = Contador.new("y y y precio")
46
51
  contador.omit("y")
47
- contador.multiplicity.should == {:precio => 1}
52
+ contador.multiplicity.should == {"precio" => 1}
48
53
  end
49
54
 
50
55
  it "knows about a constant and omits those words" do
51
56
  $omits = "y"
52
57
  contador = Contador.new("y y y wasa")
53
- contador.multiplicity.should == {:wasa => 1}
58
+ contador.multiplicity.should == {"wasa" => 1}
54
59
  end
55
60
 
56
61
  it "knows about a contant with multiple words" do
57
62
  $omits = "y que yo"
58
63
  contador = Contador.new("y que yo precio")
59
- contador.multiplicity.should == {:precio => 1}
64
+ contador.multiplicity.should == {"precio" => 1}
60
65
  end
61
66
  end
metadata CHANGED
@@ -1,96 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: contador
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ivan Acosta-Rubio
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-04-01 00:00:00 -06:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-11-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
18
+ requirements:
25
19
  - - ~>
26
- - !ruby/object:Gem::Version
27
- hash: 23
28
- segments:
29
- - 1
30
- - 0
31
- - 0
20
+ - !ruby/object:Gem::Version
32
21
  version: 1.0.0
33
22
  type: :development
34
- name: bundler
35
23
  prerelease: false
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: jeweler
32
+ requirement: !ruby/object:Gem::Requirement
39
33
  none: false
40
- requirements:
34
+ requirements:
41
35
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 1
44
- segments:
45
- - 1
46
- - 5
47
- - 1
36
+ - !ruby/object:Gem::Version
48
37
  version: 1.5.1
49
38
  type: :development
50
- name: jeweler
51
39
  prerelease: false
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
63
- type: :development
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.1
46
+ - !ruby/object:Gem::Dependency
64
47
  name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
65
55
  prerelease: false
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
69
65
  none: false
70
- requirements:
71
- - - ">"
72
- - !ruby/object:Gem::Version
73
- hash: 25
74
- segments:
75
- - 1
76
- - 2
77
- - 3
66
+ requirements:
67
+ - - ! '>'
68
+ - !ruby/object:Gem::Version
78
69
  version: 1.2.3
79
70
  type: :development
80
- name: rspec
81
71
  prerelease: false
82
- version_requirements: *id004
83
- description: This gem counts the numbers of words in a string. It returns each word and the multiplicity
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>'
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.3
78
+ description: This gem counts the numbers of words in a string. It returns each word
79
+ and the multiplicity
84
80
  email: ivan@bakedweb.net
85
81
  executables: []
86
-
87
82
  extensions: []
88
-
89
- extra_rdoc_files:
83
+ extra_rdoc_files:
90
84
  - LICENSE.txt
91
85
  - README.md
92
86
  - README.rdoc
93
- files:
87
+ files:
94
88
  - .DS_Store
95
89
  - .document
96
90
  - Gemfile
@@ -105,39 +99,34 @@ files:
105
99
  - lib/contador.rb
106
100
  - spec/contador_spec.rb
107
101
  - spec/spec.opts
108
- has_rdoc: true
109
102
  homepage: http://github.com/ivanacostarubio/contador
110
- licenses:
103
+ licenses:
111
104
  - MIT
112
105
  post_install_message:
113
106
  rdoc_options: []
114
-
115
- require_paths:
107
+ require_paths:
116
108
  - lib
117
- required_ruby_version: !ruby/object:Gem::Requirement
109
+ required_ruby_version: !ruby/object:Gem::Requirement
118
110
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ segments:
124
116
  - 0
125
- version: "0"
126
- required_rubygems_version: !ruby/object:Gem::Requirement
117
+ hash: -1571854133693256542
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
119
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
135
124
  requirements: []
136
-
137
125
  rubyforge_project:
138
- rubygems_version: 1.3.7
126
+ rubygems_version: 1.8.24
139
127
  signing_key:
140
128
  specification_version: 3
141
- summary: This gem counts the numbers of words in a string. It returns each word and the multiplicity
142
- test_files:
129
+ summary: This gem counts the numbers of words in a string. It returns each word and
130
+ the multiplicity
131
+ test_files:
143
132
  - spec/contador_spec.rb