numeral 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +6 -1
- data/Rakefile +4 -11
- data/VERSION +1 -1
- data/lib/numeral.rb +2 -0
- data/ruby.watchr +1 -1
- data/spec/numeral_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -5
- metadata +10 -11
- data/.gitignore +0 -10
data/README.rdoc
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
= numeral
|
2
2
|
|
3
|
-
|
3
|
+
Numeral parses natural language numbers like 'three' and '1/3' to ruby Rational numbers. It is ideally suited to applications where user input is integer or fraction oriented. For example:
|
4
4
|
|
5
|
+
include Numeral
|
6
|
+
parse_num('1/3') + parse_num('two') + parse_num('2/3') == 3
|
7
|
+
|
8
|
+
Numeral will also gracefully handle floating point numbers such as '.5' and '3.14' as well as regular integer values.
|
9
|
+
|
5
10
|
== Note on Patches/Pull Requests
|
6
11
|
|
7
12
|
* Fork the project.
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.email = "brady@drw.com"
|
11
11
|
gem.homepage = "http://github.com/benrady/numeral"
|
12
12
|
gem.authors = ["Ben Rady"]
|
13
|
-
gem.add_development_dependency "rspec", ">=
|
13
|
+
gem.add_development_dependency "rspec", ">= 2.0.0"
|
14
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
15
|
end
|
16
16
|
Jeweler::GemcutterTasks.new
|
@@ -18,16 +18,9 @@ rescue LoadError
|
|
18
18
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
19
|
end
|
20
20
|
|
21
|
-
require '
|
22
|
-
|
23
|
-
|
24
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
-
end
|
26
|
-
|
27
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
-
spec.libs << 'lib' << 'spec'
|
29
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
-
spec.rcov = true
|
21
|
+
require 'rspec/core/rake_task'
|
22
|
+
RSpec::Core::RakeTask.new do |t|
|
23
|
+
t.rspec_opts = ["--color"]
|
31
24
|
end
|
32
25
|
|
33
26
|
task :spec => :check_dependencies
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/numeral.rb
CHANGED
data/ruby.watchr
CHANGED
data/spec/numeral_spec.rb
CHANGED
@@ -8,6 +8,14 @@ describe Numeral do
|
|
8
8
|
parse_num("foobar").should be_nil
|
9
9
|
end
|
10
10
|
|
11
|
+
it "returns nil for a nil input" do
|
12
|
+
parse_num(nil).should == nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns nil for an empty input" do
|
16
|
+
parse_num('').should == nil
|
17
|
+
end
|
18
|
+
|
11
19
|
describe "parses" do
|
12
20
|
|
13
21
|
it "digits" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numeral
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Rady
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-13 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 15
|
30
30
|
segments:
|
31
|
-
- 1
|
32
31
|
- 2
|
33
|
-
-
|
34
|
-
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 2.0.0
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id001
|
37
37
|
description: Converts natural text like 'twelve', '1/3' and '15' to Rational ruby numbers
|
@@ -45,7 +45,6 @@ extra_rdoc_files:
|
|
45
45
|
- README.rdoc
|
46
46
|
files:
|
47
47
|
- .document
|
48
|
-
- .gitignore
|
49
48
|
- .rvmrc
|
50
49
|
- LICENSE
|
51
50
|
- README.rdoc
|
@@ -61,8 +60,8 @@ homepage: http://github.com/benrady/numeral
|
|
61
60
|
licenses: []
|
62
61
|
|
63
62
|
post_install_message:
|
64
|
-
rdoc_options:
|
65
|
-
|
63
|
+
rdoc_options: []
|
64
|
+
|
66
65
|
require_paths:
|
67
66
|
- lib
|
68
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|