natural_time 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.rdoc +51 -4
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/natural_time.gemspec +17 -22
  5. metadata +27 -22
  6. data/.gitignore +0 -21
data/README.rdoc CHANGED
@@ -4,15 +4,62 @@ NaturalTime outputs a duration in natural language.
4
4
 
5
5
  == Usage
6
6
 
7
- NaturalTime.new(65).to_sentence #=> "1 minute, 5 seconds"
7
+ === Sentence
8
+
9
+ The <tt>to_sentence</tt> method will output the duration in time in natural language
10
+ and formatted like a sentence.
11
+
12
+ NaturalTime.new(65).to_sentence #=> "1 minute and 5 seconds"
8
13
 
9
14
  NaturalTime.new(120).to_sentence #=> "2 minutes"
10
15
 
11
- NaturalTime instances can also be output to an array:
16
+ NaturalTime.new(10000).to_sentence #=> "2 hours, 46 minutes, and 40 seconds"
17
+
18
+ === String
19
+
20
+ The <tt>to_s</tt> command will separate the units with commas but with no "and":
21
+
22
+ NaturalTime.new(65).to_s #=> "1 minute, 5 seconds"
23
+
24
+ NaturalTime.new(10000).to_s #=> "2 hours, 46 minutes, 40 seconds"
25
+
26
+ === Array
27
+
28
+ NaturalTime instances can also be output to an array with <tt>to_a</tt>:
29
+
30
+ NaturalTime.new(65).to_a #=> ["1 minutes", "5 seconds"]
31
+
32
+ NaturalTime.new(120).to_a #=> ["2 minutes"]
33
+
34
+ === Precision
12
35
 
13
- NaturalTime.new(65).to_array #=> ["1 minutes", "5 seconds"]
36
+ NaturalTime can return the amount of time to a specific precision. If all you want is the greatest unit:
37
+
38
+ NaturalTime.new(65, :precision => 1).to_sentence #=> "1 minute"
39
+
40
+ NaturalTime.new(10000, :precision => 1).to_sentence #=> "2 hours"
14
41
 
15
- NaturalTime.new(120).to_array #=> ["2 minutes"]
42
+ NaturalTime.new(10000, :precision => 2).to_sentence #=> "2 hours and 46 minutes"
43
+
44
+ === Distance
45
+
46
+ If you want to use NaturalTime to show an elapsed time and you don't care if it's in the
47
+ past or the future, use the <tt>natural_time</tt> or <tt>to_sentence</tt> methods, or the
48
+ <tt>to_a</tt> method if you need the units in an array.
49
+
50
+ If you're measuring distances that may be in the past or the future, the <tt>distance</tt>
51
+ method will return a sentence indicating how long ago or in the future is your duration.
52
+
53
+ NaturalTime.new(65).distance #=> "1 minute and 5 seconds from now"
54
+
55
+ NaturalTime.new(-65).distance #=> "1 minute and 5 seconds ago"
56
+
57
+ It works with <tt>:precision</tt> too:
58
+
59
+ NaturalTime.new(10000, :precision => 1).distance #=> "2 hours from now"
60
+
61
+ NaturalTime.new(-10000, :precision => 2).distance #=> "2 hours and 46 minutes ago"
62
+
16
63
 
17
64
  == Note on Patches/Pull Requests
18
65
 
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ begin
10
10
  gem.email = "progressions@gmail.com"
11
11
  gem.homepage = "http://github.com/progressions/natural_time"
12
12
  gem.authors = ["Jeff Coleman"]
13
- gem.add_development_dependency "rspec", ">= 1.2.6"
13
+ # gem.add_development_dependency "rspec", ">= 1.2.6"
14
14
  gem.add_runtime_dependency "activesupport", ">= 0"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/natural_time.gemspec CHANGED
@@ -1,58 +1,53 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{natural_time}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
12
- s.date = %q{2010-01-22}
12
+ s.date = %q{2011-04-04}
13
13
  s.description = %q{Smart enumeration of durations in natural language--"4 hours, 3 minutes and 2 seconds"}
14
14
  s.email = %q{progressions@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "History.txt",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/natural_time.rb",
28
- "natural_time.gemspec",
29
- "spec/natural_time_spec.rb",
30
- "spec/spec.opts",
31
- "spec/spec_helper.rb"
21
+ "History.txt",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/natural_time.rb",
27
+ "natural_time.gemspec",
28
+ "spec/natural_time_spec.rb",
29
+ "spec/spec.opts",
30
+ "spec/spec_helper.rb"
32
31
  ]
33
32
  s.homepage = %q{http://github.com/progressions/natural_time}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
33
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.5}
34
+ s.rubygems_version = %q{1.3.7}
37
35
  s.summary = %q{Smart enumeration of durations in natural language}
38
36
  s.test_files = [
39
37
  "spec/natural_time_spec.rb",
40
- "spec/spec_helper.rb"
38
+ "spec/spec_helper.rb"
41
39
  ]
42
40
 
43
41
  if s.respond_to? :specification_version then
44
42
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
43
  s.specification_version = 3
46
44
 
47
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
46
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
50
47
  else
51
- s.add_dependency(%q<rspec>, [">= 1.2.6"])
52
48
  s.add_dependency(%q<activesupport>, [">= 0"])
53
49
  end
54
50
  else
55
- s.add_dependency(%q<rspec>, [">= 1.2.6"])
56
51
  s.add_dependency(%q<activesupport>, [">= 0"])
57
52
  end
58
53
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natural_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
5
11
  platform: ruby
6
12
  authors:
7
13
  - Jeff Coleman
@@ -9,29 +15,23 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-22 00:00:00 -06:00
18
+ date: 2011-04-04 00:00:00 -05:00
13
19
  default_executable:
14
20
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.2.6
24
- version:
25
21
  - !ruby/object:Gem::Dependency
26
22
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
30
26
  requirements:
31
27
  - - ">="
32
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
33
32
  version: "0"
34
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
35
35
  description: Smart enumeration of durations in natural language--"4 hours, 3 minutes and 2 seconds"
36
36
  email: progressions@gmail.com
37
37
  executables: []
@@ -43,7 +43,6 @@ extra_rdoc_files:
43
43
  - README.rdoc
44
44
  files:
45
45
  - .document
46
- - .gitignore
47
46
  - History.txt
48
47
  - LICENSE
49
48
  - README.rdoc
@@ -59,26 +58,32 @@ homepage: http://github.com/progressions/natural_time
59
58
  licenses: []
60
59
 
61
60
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
61
+ rdoc_options: []
62
+
64
63
  require_paths:
65
64
  - lib
66
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
70
73
  version: "0"
71
- version:
72
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
73
76
  requirements:
74
77
  - - ">="
75
78
  - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
76
82
  version: "0"
77
- version:
78
83
  requirements: []
79
84
 
80
85
  rubyforge_project:
81
- rubygems_version: 1.3.5
86
+ rubygems_version: 1.3.7
82
87
  signing_key:
83
88
  specification_version: 3
84
89
  summary: Smart enumeration of durations in natural language
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC