numbers_in_words 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,6 @@
1
1
  require 'numbers_in_words'
2
2
  require 'numbers_in_words/duck_punch'
3
+
4
+ require "codeclimate-test-reporter"
5
+ CodeClimate::TestReporter.start
6
+
@@ -2,105 +2,105 @@ require './spec/spec_helper'
2
2
 
3
3
  describe WordsInNumbers do
4
4
  it "should do the digits 0-10" do
5
- "zero" .in_numbers.should == 0
6
- "one" .in_numbers.should == 1
7
- "two" .in_numbers.should == 2
8
- "three" .in_numbers.should == 3
9
- "four" .in_numbers.should == 4
10
- "five" .in_numbers.should == 5
11
- "six" .in_numbers.should == 6
12
- "seven" .in_numbers.should == 7
13
- "eight" .in_numbers.should == 8
14
- "nine" .in_numbers.should == 9
5
+ expect("zero" .in_numbers).to eq(0)
6
+ expect("one" .in_numbers).to eq(1)
7
+ expect("two" .in_numbers).to eq(2)
8
+ expect("three" .in_numbers).to eq(3)
9
+ expect("four" .in_numbers).to eq(4)
10
+ expect("five" .in_numbers).to eq(5)
11
+ expect("six" .in_numbers).to eq(6)
12
+ expect("seven" .in_numbers).to eq(7)
13
+ expect("eight" .in_numbers).to eq(8)
14
+ expect("nine" .in_numbers).to eq(9)
15
15
  end
16
16
 
17
17
  it "should handle numbers for which there is one word" do
18
- "ten" .in_numbers.should == 10
19
- "eleven" .in_numbers.should == 11
20
- "twelve" .in_numbers.should == 12
21
- "thirteen" .in_numbers.should == 13
22
- "fourteen" .in_numbers.should == 14
23
- "fifteen" .in_numbers.should == 15
24
- "sixteen" .in_numbers.should == 16
25
- "seventeen" .in_numbers.should == 17
26
- "eighteen" .in_numbers.should == 18
27
- "nineteen" .in_numbers.should == 19
28
- "twenty" .in_numbers.should == 20
18
+ expect("ten" .in_numbers).to eq(10)
19
+ expect("eleven" .in_numbers).to eq(11)
20
+ expect("twelve" .in_numbers).to eq(12)
21
+ expect("thirteen" .in_numbers).to eq(13)
22
+ expect("fourteen" .in_numbers).to eq(14)
23
+ expect("fifteen" .in_numbers).to eq(15)
24
+ expect("sixteen" .in_numbers).to eq(16)
25
+ expect("seventeen" .in_numbers).to eq(17)
26
+ expect("eighteen" .in_numbers).to eq(18)
27
+ expect("nineteen" .in_numbers).to eq(19)
28
+ expect("twenty" .in_numbers).to eq(20)
29
29
  end
30
30
 
31
31
  it "should handle two word numbers up to 100" do
32
- "twenty one" .in_numbers.should == 21
33
- "twenty two" .in_numbers.should == 22
34
- "twenty three" .in_numbers.should == 23
35
- "twenty four" .in_numbers.should == 24
36
- "twenty five" .in_numbers.should == 25
37
- "twenty six" .in_numbers.should == 26
38
- "twenty seven" .in_numbers.should == 27
39
- "twenty eight" .in_numbers.should == 28
40
- "seventy six" .in_numbers.should == 76
41
- "ninety nine" .in_numbers.should == 99
32
+ expect("twenty one" .in_numbers).to eq(21)
33
+ expect("twenty two" .in_numbers).to eq(22)
34
+ expect("twenty three" .in_numbers).to eq(23)
35
+ expect("twenty four" .in_numbers).to eq(24)
36
+ expect("twenty five" .in_numbers).to eq(25)
37
+ expect("twenty six" .in_numbers).to eq(26)
38
+ expect("twenty seven" .in_numbers).to eq(27)
39
+ expect("twenty eight" .in_numbers).to eq(28)
40
+ expect("seventy six" .in_numbers).to eq(76)
41
+ expect("ninety nine" .in_numbers).to eq(99)
42
42
  end
43
43
 
44
44
  it "should handle hundreds" do
45
- "one hundred" .in_numbers.should == 100
46
- "two hundred" .in_numbers.should == 200
47
- "three hundred" .in_numbers.should == 300
48
- "nine hundred" .in_numbers.should == 900
49
- "one hundred and seventy six" .in_numbers.should == 176
50
- "one hundred and seventy nine" .in_numbers.should == 179
51
- "nine hundred and ninety nine" .in_numbers.should == 999
45
+ expect("one hundred" .in_numbers).to eq(100)
46
+ expect("two hundred" .in_numbers).to eq(200)
47
+ expect("three hundred" .in_numbers).to eq(300)
48
+ expect("nine hundred" .in_numbers).to eq(900)
49
+ expect("one hundred and seventy six" .in_numbers).to eq(176)
50
+ expect("one hundred and seventy nine" .in_numbers).to eq(179)
51
+ expect("nine hundred and ninety nine" .in_numbers).to eq(999)
52
52
  end
53
53
 
54
54
  it "should handle unusual hundreds" do
55
- "eleven hundred" .in_numbers.should == 1100
56
- "twelve hundred" .in_numbers.should == 1200
57
- "thirteen hundred" .in_numbers.should == 1300
58
- "fifteen hundred" .in_numbers.should == 1500
59
- "nineteen hundred" .in_numbers.should == 1900
55
+ expect("eleven hundred" .in_numbers).to eq(1100)
56
+ expect("twelve hundred" .in_numbers).to eq(1200)
57
+ expect("thirteen hundred" .in_numbers).to eq(1300)
58
+ expect("fifteen hundred" .in_numbers).to eq(1500)
59
+ expect("nineteen hundred" .in_numbers).to eq(1900)
60
60
 
61
61
  end
62
62
  it "should handle thousands" do
63
- "two thousand and one" .in_numbers .should == 2001
64
- "one thousand" .in_numbers .should == 1000
65
- "two thousand" .in_numbers .should == 2000
66
- "three thousand" .in_numbers .should == 3000
67
- "nine thousand" .in_numbers .should == 9000
68
- "nine thousand two hundred" .in_numbers .should == 9200
69
- "nine thousand two hundred and seven" .in_numbers .should == 9207
70
- "nine thousand two hundred and ninety seven" .in_numbers .should == 9297
63
+ expect("two thousand and one" .in_numbers) .to eq(2001)
64
+ expect("one thousand" .in_numbers) .to eq(1000)
65
+ expect("two thousand" .in_numbers) .to eq(2000)
66
+ expect("three thousand" .in_numbers) .to eq(3000)
67
+ expect("nine thousand" .in_numbers) .to eq(9000)
68
+ expect("nine thousand two hundred" .in_numbers) .to eq(9200)
69
+ expect("nine thousand two hundred and seven" .in_numbers) .to eq(9207)
70
+ expect("nine thousand two hundred and ninety seven" .in_numbers) .to eq(9297)
71
71
  end
72
72
 
73
73
  it "should handle larger numbers" do
74
- "one million" .in_numbers .should == 1000000
75
- "two googol five billion and seventy six" .in_numbers .should == (2*10**100 + 5*10**9 + 76)
76
- "thirty seven million" .in_numbers .should == 37 * 10**6
77
- "twenty six googol" .in_numbers .should == 26 * 10**100
74
+ expect("one million" .in_numbers) .to eq(1000000)
75
+ expect("two googol five billion and seventy six" .in_numbers) .to eq(2*10**100 + 5*10**9 + 76)
76
+ expect("thirty seven million" .in_numbers) .to eq(37 * 10**6)
77
+ expect("twenty six googol" .in_numbers) .to eq(26 * 10**100)
78
78
  end
79
79
 
80
80
  it "should handle numbers in hundreds of thousands etc" do
81
- "nine hundred thousand" .in_numbers .should == 900000
82
- "three hundred and fifty seven thousand" .in_numbers .should == 357000
83
- "five million three hundred and fifty seven thousand" .in_numbers .should == 5357000
84
- "nine hundred and ninety nine trillion" .in_numbers .should == 999 * 10**12
81
+ expect("nine hundred thousand" .in_numbers) .to eq(900000)
82
+ expect("three hundred and fifty seven thousand" .in_numbers) .to eq(357000)
83
+ expect("five million three hundred and fifty seven thousand" .in_numbers) .to eq(5357000)
84
+ expect("nine hundred and ninety nine trillion" .in_numbers) .to eq(999 * 10**12)
85
85
  end
86
86
  it "should handle negative numbers" do
87
- "minus one" .in_numbers .should == -1
88
- "minus two googol" .in_numbers .should == -2 * 10**100
89
- "minus nine hundred and ninety nine trillion" .in_numbers .should == -999 * 10**12
87
+ expect("minus one" .in_numbers) .to eq(-1)
88
+ expect("minus two googol" .in_numbers) .to eq(-2 * 10**100)
89
+ expect("minus nine hundred and ninety nine trillion" .in_numbers) .to eq(-999 * 10**12)
90
90
  end
91
91
 
92
92
  it "should ignore punctuation and capitalisation" do
93
- "Minus one" .in_numbers .should == -1
94
- "FIVE Million, three hundred and fifty-seVen Thousand" .in_numbers .should == 5357000
95
- "FIVE,,./';';';[] Million, three hundred and fifty-seVen Thousand" .in_numbers .should == 5357000
93
+ expect("Minus one" .in_numbers) .to eq(-1)
94
+ expect("FIVE Million, three hundred and fifty-seVen Thousand" .in_numbers) .to eq(5357000)
95
+ expect("FIVE,,./';';';[] Million, three hundred and fifty-seVen Thousand" .in_numbers) .to eq(5357000)
96
96
 
97
97
  end
98
98
 
99
99
  it "should handle decimal points" do
100
- "one point one" .in_numbers .should == 1.1
100
+ expect("one point one" .in_numbers) .to eq(1.1)
101
101
 
102
- "zero point seven six five three four" .in_numbers .should == 0.76534
103
- "one trillion point six" .in_numbers .should == 10**12 + 0.6
102
+ expect("zero point seven six five three four" .in_numbers) .to eq(0.76534)
103
+ expect("one trillion point six" .in_numbers) .to eq(10**12 + 0.6)
104
104
 
105
105
  long_number = <<-NUMBER
106
106
  nine duotrigintillion seven hundred and seventy seven untrigintillion
@@ -124,11 +124,12 @@ describe WordsInNumbers do
124
124
  million ninety three thousand seven hundred and ninety one point
125
125
  eight nine five six four three two one eight nine five six seven eight
126
126
  NUMBER
127
- long_number.in_numbers.should ==
127
+ expect(long_number.in_numbers).to eq(
128
128
  9777059160806736471970632827836952710801948705683106707757426795746813127465237139153046752803093791.89564321895678
129
+ )
129
130
 
130
- "seventy five point eight four three two seven six nine four five one eight".
131
- in_numbers.should == 75.84327694518
131
+ expect("seventy five point eight four three two seven six nine four five one eight".
132
+ in_numbers).to eq(75.84327694518)
132
133
  end
133
134
 
134
135
  end
metadata CHANGED
@@ -1,77 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbers_in_words
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.0
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mark Burns
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-17 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- type: :runtime
16
- version_requirements: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
14
  name: activesupport
23
- prerelease: false
24
15
  requirement: !ruby/object:Gem::Requirement
25
- none: false
26
16
  requirements:
27
- - - ! '>='
17
+ - - ">="
28
18
  - !ruby/object:Gem::Version
29
19
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- type: :development
20
+ type: :runtime
21
+ prerelease: false
32
22
  version_requirements: !ruby/object:Gem::Requirement
33
- none: false
34
23
  requirements:
35
- - - ! '>='
24
+ - - ">="
36
25
  - !ruby/object:Gem::Version
37
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
38
28
  name: rspec
39
- prerelease: false
40
29
  requirement: !ruby/object:Gem::Requirement
41
- none: false
42
30
  requirements:
43
- - - ! '>='
31
+ - - "~>"
44
32
  - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
33
+ version: 3.4.0
47
34
  type: :development
48
- version_requirements: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- name: debugger
55
35
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
57
- none: false
36
+ version_requirements: !ruby/object:Gem::Requirement
58
37
  requirements:
59
- - - ! '>='
38
+ - - "~>"
60
39
  - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! '#in_words method for integers and #in_numbers for strings'
40
+ version: 3.4.0
41
+ description: "#in_words method for integers and #in_numbers for strings"
63
42
  email:
64
43
  - markthedeveloper@gmail.com
65
- executables: []
44
+ executables:
45
+ - spec
66
46
  extensions: []
67
47
  extra_rdoc_files: []
68
48
  files:
69
- - .gitignore
49
+ - ".codeclimate.yml"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".rubocop.yml"
53
+ - ".travis.yml"
70
54
  - Gemfile
71
- - Gemfile.lock
72
55
  - LICENSE.txt
73
56
  - README.md
74
57
  - Rakefile
58
+ - bin/spec
75
59
  - lib/numbers_in_words.rb
76
60
  - lib/numbers_in_words/duck_punch.rb
77
61
  - lib/numbers_in_words/english/constants.rb
@@ -84,43 +68,38 @@ files:
84
68
  - lib/numbers_in_words/version.rb
85
69
  - numbers_in_words.gemspec
86
70
  - spec/language_writer_spec.rb
71
+ - spec/non_monkey_patch_spec.rb
87
72
  - spec/number_group_spec.rb
88
73
  - spec/numbers_in_words_spec.rb
89
74
  - spec/spec_helper.rb
90
75
  - spec/words_in_numbers_spec.rb
91
76
  homepage: http://github.com/markburns/numbers_in_words
92
77
  licenses: []
78
+ metadata: {}
93
79
  post_install_message:
94
80
  rdoc_options: []
95
81
  require_paths:
96
82
  - lib
97
83
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
84
  requirements:
100
- - - ! '>='
85
+ - - ">="
101
86
  - !ruby/object:Gem::Version
102
- segments:
103
- - 0
104
- hash: -1513551754306869579
105
87
  version: '0'
106
88
  required_rubygems_version: !ruby/object:Gem::Requirement
107
- none: false
108
89
  requirements:
109
- - - ! '>='
90
+ - - ">="
110
91
  - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
- hash: -1513551754306869579
114
92
  version: '0'
115
93
  requirements: []
116
94
  rubyforge_project:
117
- rubygems_version: 1.8.23
95
+ rubygems_version: 2.4.5
118
96
  signing_key:
119
- specification_version: 3
120
- summary: ! 'Example: 123.in_words # => "one hundred and twenty three", "seventy-five
97
+ specification_version: 4
98
+ summary: 'Example: 123.in_words # => "one hundred and twenty three", "seventy-five
121
99
  point eight".in_numbers # = > 75.8'
122
100
  test_files:
123
101
  - spec/language_writer_spec.rb
102
+ - spec/non_monkey_patch_spec.rb
124
103
  - spec/number_group_spec.rb
125
104
  - spec/numbers_in_words_spec.rb
126
105
  - spec/spec_helper.rb
data/Gemfile.lock DELETED
@@ -1,39 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- numbers_in_words (0.2.0)
5
- activesupport
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (3.2.10)
11
- i18n (~> 0.6)
12
- multi_json (~> 1.0)
13
- columnize (0.3.6)
14
- debugger (1.2.3)
15
- columnize (>= 0.3.1)
16
- debugger-linecache (~> 1.1.1)
17
- debugger-ruby_core_source (~> 1.1.5)
18
- debugger-linecache (1.1.2)
19
- debugger-ruby_core_source (>= 1.1.1)
20
- debugger-ruby_core_source (1.1.6)
21
- diff-lcs (1.1.3)
22
- i18n (0.6.1)
23
- multi_json (1.5.0)
24
- rspec (2.12.0)
25
- rspec-core (~> 2.12.0)
26
- rspec-expectations (~> 2.12.0)
27
- rspec-mocks (~> 2.12.0)
28
- rspec-core (2.12.2)
29
- rspec-expectations (2.12.1)
30
- diff-lcs (~> 1.1.3)
31
- rspec-mocks (2.12.1)
32
-
33
- PLATFORMS
34
- ruby
35
-
36
- DEPENDENCIES
37
- debugger
38
- numbers_in_words!
39
- rspec