numeral 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,7 +1,12 @@
1
1
  = numeral
2
2
 
3
- Description goes here.
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", ">= 1.2.9"
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 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
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.0
1
+ 0.2.1
data/lib/numeral.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Numeral
2
2
  def parse_num(text)
3
+ return nil unless text
4
+ return nil if text.length == 0
3
5
  return parse_natural_num(text) if text[/[a-z|A-Z]/]
4
6
  numerator, denominator = text.split('/')
5
7
  return numerator.to_f if numerator.include?('.')
data/ruby.watchr CHANGED
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  def run(files_to_run)
22
22
  puts("Running: #{files_to_run}")
23
- system("clear;spec -cfs #{files_to_run}")
23
+ system("clear;rspec -cfs #{files_to_run}")
24
24
  no_int_for_you
25
25
  end
26
26
 
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
@@ -1,9 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'numeral'
4
- require 'spec'
5
- require 'spec/autorun'
4
+ require 'rspec'
6
5
 
7
- Spec::Runner.configure do |config|
8
-
9
- end
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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: 2010-08-16 00:00:00 -05:00
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: 13
29
+ hash: 15
30
30
  segments:
31
- - 1
32
31
  - 2
33
- - 9
34
- version: 1.2.9
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
- - --charset=UTF-8
63
+ rdoc_options: []
64
+
66
65
  require_paths:
67
66
  - lib
68
67
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## PROJECT::GENERAL
5
- coverage
6
- rdoc
7
- pkg
8
-
9
- ## PROJECT::SPECIFIC
10
- numeral.gemspec