rtm-time 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1,2 @@
1
- --color
1
+ --color -f d
2
+
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ source "http://rubygems.org"
6
6
  # Include everything needed to run rake, tests, features, etc.
7
7
  group :development do
8
8
  gem "rspec"
9
+ gem "rr"
9
10
  gem "bundler"
10
11
  gem "jeweler"
11
12
  gem "rcov", ">= 0"
@@ -9,6 +9,7 @@ GEM
9
9
  rake
10
10
  rake (0.9.2.2)
11
11
  rcov (0.9.11)
12
+ rr (1.0.4)
12
13
  rspec (2.7.0)
13
14
  rspec-core (~> 2.7.0)
14
15
  rspec-expectations (~> 2.7.0)
@@ -25,4 +26,5 @@ DEPENDENCIES
25
26
  bundler
26
27
  jeweler
27
28
  rcov
29
+ rr
28
30
  rspec
@@ -1,6 +1,7 @@
1
1
  = rtm-time
2
2
 
3
- A simple parser for RTM's estimate time string
3
+ * simple parser for RTM's estimate time string
4
+ * convenience method convert from various object to ISO8601(UTC) time string
4
5
 
5
6
  == Contributing to rtm-time
6
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
File without changes
File without changes
@@ -0,0 +1,32 @@
1
+ require 'time'
2
+
3
+ module RtmTime
4
+ class InvalidTime < StandardError; end
5
+
6
+ #
7
+ # convert from various object to ISO8601(UTC) string
8
+ #
9
+ # [param] Object
10
+ # [return] String
11
+ #
12
+ def self.iso8601( time = Time.now )
13
+ t = nil
14
+
15
+ case time
16
+ when String
17
+ t = Time.parse(time)
18
+ when Integer
19
+ t = Time.at(time)
20
+ when Time
21
+ t = time
22
+ else
23
+ if time.respond_to? :to_time
24
+ t = time.to_time
25
+ else
26
+ raise InvalidTime, time
27
+ end
28
+ end
29
+
30
+ t.utc.iso8601 if t
31
+ end
32
+ end
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe RtmTime do
4
+ describe 'iso8601' do
5
+ before {
6
+ ENV['TZ'] = 'JST-9'
7
+ }
8
+
9
+ context 'with no args' do
10
+ subject {
11
+ RtmTime.iso8601
12
+ }
13
+ it {
14
+ should == Time.now.utc.iso8601
15
+ }
16
+ end
17
+ context 'with string' do
18
+ subject {
19
+ RtmTime.iso8601( '2011-12-01' )
20
+ }
21
+ it {
22
+ should == '2011-11-30T15:00:00Z'
23
+ }
24
+ end
25
+ context 'with integer' do
26
+ subject {
27
+ RtmTime.iso8601(1322665200)
28
+ }
29
+ it {
30
+ should == '2011-11-30T15:00:00Z'
31
+ }
32
+ end
33
+ context 'with time object' do
34
+ subject {
35
+ RtmTime.iso8601(Time.parse('2011-12-01'))
36
+ }
37
+ it {
38
+ should == '2011-11-30T15:00:00Z'
39
+ }
40
+ end
41
+ context 'with other object respond_to :to_time' do
42
+ subject {
43
+ RtmTime.iso8601(Date.parse('2011-12-01'))
44
+ }
45
+ it {
46
+ should == '2011-11-30T15:00:00Z'
47
+ }
48
+ end
49
+ context 'with other object not respond_to :to_time' do
50
+ subject {
51
+ RtmTime.iso8601( %w(2011-12-01) )
52
+ }
53
+ it {
54
+ lambda { subject }.should raise_error(RtmTime::InvalidTime)
55
+ }
56
+ end
57
+ end
58
+ end
@@ -8,5 +8,5 @@ require 'rtm-time'
8
8
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
9
 
10
10
  RSpec.configure do |config|
11
-
11
+ config.mock_with :rr
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtm-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-09 00:00:00.000000000Z
12
+ date: 2011-12-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &3859620 !ruby/object:Gem::Requirement
16
+ requirement: &3875330 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *3859620
24
+ version_requirements: *3875330
25
+ - !ruby/object:Gem::Dependency
26
+ name: rr
27
+ requirement: &3875090 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *3875090
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: bundler
27
- requirement: &3859370 !ruby/object:Gem::Requirement
38
+ requirement: &3874790 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,10 +43,10 @@ dependencies:
32
43
  version: '0'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *3859370
46
+ version_requirements: *3874790
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: jeweler
38
- requirement: &3859120 !ruby/object:Gem::Requirement
49
+ requirement: &3874490 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *3859120
57
+ version_requirements: *3874490
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rcov
49
- requirement: &3858870 !ruby/object:Gem::Requirement
60
+ requirement: &3874190 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,7 +65,7 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *3858870
68
+ version_requirements: *3874190
58
69
  description: parse and inspect RTM's estimate time
59
70
  email: wtnabe@gmail.com
60
71
  executables: []
@@ -73,10 +84,11 @@ files:
73
84
  - VERSION
74
85
  - lib/rtm-time.rb
75
86
  - lib/rtm_time.rb
76
- - lib/rtm_time/en.rb
77
- - lib/rtm_time/ja.rb
78
- - rtm-time.gemspec
87
+ - lib/rtm_time/estimate/en.rb
88
+ - lib/rtm_time/estimate/ja.rb
89
+ - lib/rtm_time/iso8601.rb
79
90
  - spec/rtm_time/en_spec.rb
91
+ - spec/rtm_time/iso8601_spec.rb
80
92
  - spec/rtm_time/ja_spec.rb
81
93
  - spec/spec_helper.rb
82
94
  - tasks/git.rake
@@ -95,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
107
  version: '0'
96
108
  segments:
97
109
  - 0
98
- hash: 933625971
110
+ hash: 244705713
99
111
  required_rubygems_version: !ruby/object:Gem::Requirement
100
112
  none: false
101
113
  requirements:
@@ -1,65 +0,0 @@
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{rtm-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 = [%q{wtnabe}]
12
- s.date = %q{2011-12-09}
13
- s.description = %q{parse and inspect RTM's estimate time}
14
- s.email = %q{wtnabe@gmail.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/rtm-time.rb",
29
- "lib/rtm_time.rb",
30
- "lib/rtm_time/en.rb",
31
- "lib/rtm_time/ja.rb",
32
- "rtm-time.gemspec",
33
- "spec/rtm_time/en_spec.rb",
34
- "spec/rtm_time/ja_spec.rb",
35
- "spec/spec_helper.rb",
36
- "tasks/git.rake"
37
- ]
38
- s.homepage = %q{http://github.com/wtnabe/rtm-time}
39
- s.licenses = [%q{BSD}]
40
- s.require_paths = [%q{lib}]
41
- s.rubygems_version = %q{1.8.6}
42
- s.summary = %q{A parser for RTM's estimate time}
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>, [">= 0"])
49
- s.add_development_dependency(%q<bundler>, [">= 0"])
50
- s.add_development_dependency(%q<jeweler>, [">= 0"])
51
- s.add_development_dependency(%q<rcov>, [">= 0"])
52
- else
53
- s.add_dependency(%q<rspec>, [">= 0"])
54
- s.add_dependency(%q<bundler>, [">= 0"])
55
- s.add_dependency(%q<jeweler>, [">= 0"])
56
- s.add_dependency(%q<rcov>, [">= 0"])
57
- end
58
- else
59
- s.add_dependency(%q<rspec>, [">= 0"])
60
- s.add_dependency(%q<bundler>, [">= 0"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
62
- s.add_dependency(%q<rcov>, [">= 0"])
63
- end
64
- end
65
-