reverse_chronic 0.0.1.alpha → 0.0.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/lib/reverse_chronic/version.rb +1 -1
- data/lib/reverse_chronic.rb +11 -1
- data/spec/reverse_chronic_spec.rb +21 -0
- data/spec/spec_helper.rb +11 -0
- metadata +11 -5
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.3@reverse_chronic
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/lib/reverse_chronic.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
require "reverse_chronic/version"
|
2
2
|
|
3
3
|
module ReverseChronic
|
4
|
-
|
4
|
+
class << self
|
5
|
+
def humanize(time)
|
6
|
+
if time.to_date == Date.today
|
7
|
+
'today'
|
8
|
+
elsif Time.now.to_date - 1 == time.to_date
|
9
|
+
'yesterday'
|
10
|
+
else
|
11
|
+
time.strftime('%A, %b%e, %Y')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
5
15
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require './lib/reverse_chronic'
|
3
|
+
|
4
|
+
describe ReverseChronic do
|
5
|
+
it "says now is 'today'" do
|
6
|
+
ReverseChronic.humanize(Time.now).should == 'today'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "says today is 'today'" do
|
10
|
+
ReverseChronic.humanize(Date.today).should == 'today'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "says yesterday 'yesterday'" do
|
14
|
+
ReverseChronic.humanize(Time.now.yesterday).should == 'yesterday'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "calls 2 or more days ago by name" do
|
18
|
+
time = Time.parse('2012-02-05')
|
19
|
+
ReverseChronic.humanize(time).should == 'Sunday, Feb 5, 2012'
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reverse_chronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152502280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152502280
|
25
25
|
description: ''
|
26
26
|
email:
|
27
27
|
- joe@joesak.com
|
@@ -30,11 +30,16 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
|
+
- .rspec
|
34
|
+
- .rvmrc
|
33
35
|
- Gemfile
|
36
|
+
- Guardfile
|
34
37
|
- Rakefile
|
35
38
|
- lib/reverse_chronic.rb
|
36
39
|
- lib/reverse_chronic/version.rb
|
37
40
|
- reverse_chronic.gemspec
|
41
|
+
- spec/reverse_chronic_spec.rb
|
42
|
+
- spec/spec_helper.rb
|
38
43
|
homepage: ''
|
39
44
|
licenses: []
|
40
45
|
post_install_message:
|
@@ -59,5 +64,6 @@ rubygems_version: 1.8.10
|
|
59
64
|
signing_key:
|
60
65
|
specification_version: 3
|
61
66
|
summary: ''
|
62
|
-
test_files:
|
63
|
-
|
67
|
+
test_files:
|
68
|
+
- spec/reverse_chronic_spec.rb
|
69
|
+
- spec/spec_helper.rb
|