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 ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.3@reverse_chronic
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source "http://rubygems.org"
2
+ gem 'active_support'
3
+ gem 'i18n'
4
+ gem 'guard'
5
+ gem 'guard-rspec'
2
6
 
3
7
  # Specify your gem's dependencies in reverse_chronic.gemspec
4
8
  gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
@@ -1,3 +1,3 @@
1
1
  module ReverseChronic
2
- VERSION = "0.0.1.alpha"
2
+ VERSION = "0.0.1.beta"
3
3
  end
@@ -1,5 +1,15 @@
1
1
  require "reverse_chronic/version"
2
2
 
3
3
  module ReverseChronic
4
- # Your code goes here...
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
@@ -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.alpha
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: &2154728720 !ruby/object:Gem::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: *2154728720
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
- has_rdoc:
67
+ test_files:
68
+ - spec/reverse_chronic_spec.rb
69
+ - spec/spec_helper.rb