pretty_time 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/lib/pretty_time/core.rb +135 -0
- data/lib/pretty_time.rb +4 -0
- data/pretty_time.gemspec +71 -0
- data/spec/pretty_time/core_spec.rb +127 -0
- data/spec/spec_helper.rb +12 -0
- metadata +138 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.7)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
git (1.2.5)
|
7
|
+
i18n (0.5.0)
|
8
|
+
jeweler (1.5.2)
|
9
|
+
bundler (~> 1.0.0)
|
10
|
+
git (>= 1.2.5)
|
11
|
+
rake
|
12
|
+
rake (0.8.7)
|
13
|
+
rcov (0.9.9)
|
14
|
+
rspec (2.3.0)
|
15
|
+
rspec-core (~> 2.3.0)
|
16
|
+
rspec-expectations (~> 2.3.0)
|
17
|
+
rspec-mocks (~> 2.3.0)
|
18
|
+
rspec-core (2.3.1)
|
19
|
+
rspec-expectations (2.3.0)
|
20
|
+
diff-lcs (~> 1.1.2)
|
21
|
+
rspec-mocks (2.3.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
activesupport
|
28
|
+
bundler (~> 1.0.0)
|
29
|
+
i18n
|
30
|
+
jeweler (~> 1.5.2)
|
31
|
+
rcov
|
32
|
+
rspec (~> 2.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Anuj Dutta
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= pretty_time
|
2
|
+
|
3
|
+
Serializes time in seconds to pretty time string and vica-versa.
|
4
|
+
|
5
|
+
== Contributing to pretty_time
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Anuj Dutta. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "pretty_time"
|
16
|
+
gem.homepage = "http://github.com/andhapp/pretty_time"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Serialize time}
|
19
|
+
gem.description = %Q{Serializes time to pretty time string and vica-versa}
|
20
|
+
gem.email = "anuj@andhapp.com"
|
21
|
+
gem.authors = ["Anuj Dutta"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "pretty_time #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#
|
2
|
+
# Simple time serializer with two main functionalities:
|
3
|
+
# 1. Takes a time in seconds and converts it into a pretty string
|
4
|
+
# 2. Takes a pretty string and converts it into time in seconds
|
5
|
+
#
|
6
|
+
# Dependencies:
|
7
|
+
# ActiveSupport
|
8
|
+
#
|
9
|
+
module PrettyTime
|
10
|
+
|
11
|
+
#
|
12
|
+
# Serializes(if you will) time in seconds supplied as integer to a
|
13
|
+
# pretty time string
|
14
|
+
# Example:
|
15
|
+
#
|
16
|
+
# PrettyTime.load(130) # 2 minutes 10 seconds
|
17
|
+
#
|
18
|
+
def self.load(time_in_sec)
|
19
|
+
pretty_time.load(time_in_sec)
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# De-serializes(if you will) a pretty time into time in seconds
|
24
|
+
# Example:
|
25
|
+
#
|
26
|
+
# PrettyTime.dump('2 minutes 10 seconds') # 130
|
27
|
+
#
|
28
|
+
def self.dump(time_as_pretty_string)
|
29
|
+
pretty_time.dump(time_as_pretty_string)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Creates an instance of itself if one does not exist
|
34
|
+
#
|
35
|
+
def self.pretty_time
|
36
|
+
@pretty_time ||= Core.new
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Core class which provides the entry point to other useful methods
|
41
|
+
#
|
42
|
+
class Core
|
43
|
+
|
44
|
+
HOURS = "hours"
|
45
|
+
MINUTES = "minutes"
|
46
|
+
SECONDS = "seconds"
|
47
|
+
|
48
|
+
#
|
49
|
+
# Core method that does all the work
|
50
|
+
#
|
51
|
+
def load(time_in_sec)
|
52
|
+
hours, minutes, seconds = hours_and_minutes_and_seconds(time_in_sec)
|
53
|
+
|
54
|
+
pretty_time_string = ""
|
55
|
+
|
56
|
+
if has_hours?(hours)
|
57
|
+
pretty_time_string << "#{with_suffix(hours, HOURS)}"
|
58
|
+
end
|
59
|
+
|
60
|
+
if has_minutes?(minutes)
|
61
|
+
if has_hours?(hours)
|
62
|
+
pretty_time_string << " "
|
63
|
+
end
|
64
|
+
pretty_time_string << "#{with_suffix(minutes, MINUTES)}"
|
65
|
+
end
|
66
|
+
|
67
|
+
if has_seconds?(seconds)
|
68
|
+
if has_hours?(hours) || has_minutes?(minutes)
|
69
|
+
pretty_time_string << " "
|
70
|
+
end
|
71
|
+
pretty_time_string << "#{with_suffix(seconds, SECONDS)}"
|
72
|
+
end
|
73
|
+
|
74
|
+
pretty_time_string
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Core method that does all the work
|
79
|
+
#
|
80
|
+
def dump(time_as_pretty_string)
|
81
|
+
if match = /^(\d+) (hours?) (\d+) (minutes?) (\d+) (seconds?)/.match(time_as_pretty_string)
|
82
|
+
return match[1].to_i.send(:"#{match[2]}").to_i + match[3].to_i.send("#{match[4]}").to_i + match[5].to_i
|
83
|
+
elsif match = /^(\d+) (hours?) (\d+) (minutes?)/.match(time_as_pretty_string)
|
84
|
+
return match[1].to_i.send(:"#{match[2]}").to_i + match[3].to_i.send("#{match[4]}").to_i
|
85
|
+
elsif match = /^(\d+) (minutes?) (\d+) (seconds?)/.match(time_as_pretty_string)
|
86
|
+
return match[1].to_i.send(:"#{match[2]}").to_i + match[3].to_i
|
87
|
+
elsif match = /^(\d+) (hours?) (\d+) (seconds?)/.match(time_as_pretty_string)
|
88
|
+
return match[1].to_i.send(:"#{match[2]}").to_i + match[3].to_i
|
89
|
+
end
|
90
|
+
time_as_pretty_string.gsub(/ hours?| minutes?| seconds?/, '').to_i.send(:"#{$&.strip}")
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
# Converts time in seconds to an array of hours, minutes and seconds
|
96
|
+
def hours_and_minutes_and_seconds(time_in_sec)
|
97
|
+
minutes, seconds = minutes_and_seconds(time_in_sec)
|
98
|
+
hours = 0
|
99
|
+
if minutes >= 60
|
100
|
+
hours = minutes / 60
|
101
|
+
minutes = minutes % 60
|
102
|
+
end
|
103
|
+
[hours, minutes, seconds]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Converts time in seconds to an array of minutes and seconds
|
107
|
+
def minutes_and_seconds(time_in_sec)
|
108
|
+
[time_in_sec / 60, time_in_sec % 60]
|
109
|
+
end
|
110
|
+
|
111
|
+
# Checks if supplied value is zero
|
112
|
+
def non_zero?(value)
|
113
|
+
value != 0
|
114
|
+
end
|
115
|
+
|
116
|
+
# Adds the correct suffix
|
117
|
+
# Example:
|
118
|
+
#
|
119
|
+
# 1 hour
|
120
|
+
# 3 hours
|
121
|
+
def with_suffix(value, type)
|
122
|
+
if value > 1
|
123
|
+
return "#{value} #{type}"
|
124
|
+
end
|
125
|
+
|
126
|
+
return "#{value} #{type.gsub(/s$/, '')}"
|
127
|
+
end
|
128
|
+
|
129
|
+
alias :has_hours? :non_zero?
|
130
|
+
alias :has_minutes? :non_zero?
|
131
|
+
alias :has_seconds? :non_zero?
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
data/lib/pretty_time.rb
ADDED
data/pretty_time.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pretty_time}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Anuj Dutta"]
|
12
|
+
s.date = %q{2011-05-01}
|
13
|
+
s.description = %q{Serializes time to pretty time string and vica-versa}
|
14
|
+
s.email = %q{anuj@andhapp.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/pretty_time.rb",
|
29
|
+
"lib/pretty_time/core.rb",
|
30
|
+
"pretty_time.gemspec",
|
31
|
+
"spec/pretty_time/core_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/andhapp/pretty_time}
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.6.2}
|
38
|
+
s.summary = %q{Serialize time}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/pretty_time/core_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<activesupport>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<i18n>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
60
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
66
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
67
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
68
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "PrettyTime" do
|
4
|
+
|
5
|
+
context "On request to #dump" do
|
6
|
+
|
7
|
+
it 'should convert A hours to X seconds' do
|
8
|
+
PrettyTime.dump("4 hours").should == 4.hours.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should convert B minutes to X seconds' do
|
12
|
+
PrettyTime.dump("40 minutes").should == 40.minutes.to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return X seconds as X seconds' do
|
16
|
+
PrettyTime.dump("40 seconds").should == 40
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should convert A hours B minutes to X seconds' do
|
20
|
+
PrettyTime.dump("4 hours 40 minutes").should == 4.hours.to_i + 40.minutes.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should convert B minutes C seconds to X seconds' do
|
24
|
+
PrettyTime.dump("40 minutes 30 seconds").should == 40.minutes.to_i + 30
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should convert A hours C seconds to X seconds' do
|
28
|
+
PrettyTime.dump("4 hours 30 seconds").should == 4.hours.to_i + 30
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should convert A hours B minutes C seconds to X seconds' do
|
32
|
+
PrettyTime.dump("4 hours 40 minutes 30 seconds").should == 4.hours.to_i + 40.minutes.to_i + 30
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with fence post cases" do
|
36
|
+
|
37
|
+
it 'should convert 1 hour to 3600 seconds' do
|
38
|
+
PrettyTime.dump("1 hour").should == 3600
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should convert 1 minute to 60 seconds' do
|
42
|
+
PrettyTime.dump("1 minute").should == 60
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should return 1 second as 1 second' do
|
46
|
+
PrettyTime.dump("1 second").should == 1
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should convert 1 hour 1 minute to 3660 seconds' do
|
50
|
+
PrettyTime.dump("1 hour 1 minute").should == 3660
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should convert 1 minute 1 second to 61 seconds' do
|
54
|
+
PrettyTime.dump("1 minute 1 second").should == 61
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should convert 1 hour 1 minute 1 second to 3661 seconds' do
|
58
|
+
PrettyTime.dump("1 hour 1 minute 1 second").should == 3661
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "On request to #load" do
|
64
|
+
|
65
|
+
it 'should convert 7200 seconds to 2 hours' do
|
66
|
+
PrettyTime.load(2.hours).should == "2 hours"
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should convert 600 seconds to 10 minutes' do
|
70
|
+
PrettyTime.load(10.minutes.to_i).should == "10 minutes"
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should return 59 seconds as 59 seconds' do
|
74
|
+
PrettyTime.load(59).should == "59 seconds"
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should convert 7800 seconds to 2 hours 10 minutes' do
|
78
|
+
PrettyTime.load(2.hours.to_i + 10.minutes.to_i).should == "2 hours 10 minutes"
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should convert 7210 seconds to 2 hours 10 seconds' do
|
82
|
+
PrettyTime.load(2.hours.to_i + 10).should == "2 hours 10 seconds"
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should convert 130 seconds to 2 minutes 10 seconds' do
|
86
|
+
PrettyTime.load(2.minutes.to_i + 10).should == "2 minutes 10 seconds"
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should convert 7810 seconds to 2 hours 10 minutes 10 seconds' do
|
90
|
+
PrettyTime.load(2.hours.to_i + 10.minutes.to_i + 10).should == "2 hours 10 minutes 10 seconds"
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with fence post cases" do
|
94
|
+
|
95
|
+
it 'should convert 3600 seconds to 1 hour' do
|
96
|
+
PrettyTime.load(1.hours).should == "1 hour"
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should convert 60 seconds to 1 minute' do
|
100
|
+
PrettyTime.load(1.minute.to_i).should == "1 minute"
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should return 1 second as 1 second' do
|
104
|
+
PrettyTime.load(1).should == "1 second"
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should convert 3660 seconds to 1 hour 1 minute' do
|
108
|
+
PrettyTime.load(1.hours.to_i + 1.minute.to_i).should == "1 hour 1 minute"
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should convert 3601 seconds to 1 hour 1 second' do
|
112
|
+
PrettyTime.load(1.hours.to_i + 1).should == "1 hour 1 second"
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should convert 61 seconds to 1 minute 1 second' do
|
116
|
+
PrettyTime.load(1.minutes.to_i + 1).should == "1 minute 1 second"
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should convert 3661 seconds to 1 hour 1 minute 1 second' do
|
120
|
+
PrettyTime.load(1.hours.to_i + 1.minutes.to_i + 1).should == "1 hour 1 minute 1 second"
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require(:development)
|
6
|
+
|
7
|
+
require 'pretty_time'
|
8
|
+
require 'active_support'
|
9
|
+
require 'active_support/core_ext/numeric'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pretty_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anuj Dutta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-01 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.0
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jeweler
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.2
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rcov
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: activesupport
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: i18n
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *id006
|
82
|
+
description: Serializes time to pretty time string and vica-versa
|
83
|
+
email: anuj@andhapp.com
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- .document
|
93
|
+
- .rspec
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- VERSION
|
100
|
+
- lib/pretty_time.rb
|
101
|
+
- lib/pretty_time/core.rb
|
102
|
+
- pretty_time.gemspec
|
103
|
+
- spec/pretty_time/core_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
has_rdoc: true
|
106
|
+
homepage: http://github.com/andhapp/pretty_time
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 425365761
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: "0"
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.6.2
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Serialize time
|
136
|
+
test_files:
|
137
|
+
- spec/pretty_time/core_spec.rb
|
138
|
+
- spec/spec_helper.rb
|