elapsed_watch 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0a4cd545cf031a3a912f3b7c6851043b6cf4069
4
- data.tar.gz: 0a244c7f158357cf4f4e2f2cf29bd3c1027ff0d1
3
+ metadata.gz: d4a32dc7d72d3da2e5f898dd7167393eb989124f
4
+ data.tar.gz: 244caddcbfb97fa2bf71a2d3203d523c2c6e2c58
5
5
  SHA512:
6
- metadata.gz: dd245efb45ede736ff03c18d19a1b1a04a85fe15fdca506c6bfa8b2a222081a1fe1ddb2b67284faa443a6dd48e0f7a6a7eb5e246637f4cd2c74654e7d31b789b
7
- data.tar.gz: 15734b55c4e1d9efebde81511ec7dbfaa26418e070d27cc510f4615f42547d348b04c332d507899f977503d82a02dcd21cef18df160b17e85282cf8e2b41b208
6
+ metadata.gz: 30b7fe96c6a571346591741588b6973967b01f7b390fb958d2fbe92a1e463e79bd8b59690c9118ac824531eb06276183eeda0d3a03e592ad2a200a5f26ba1e7b
7
+ data.tar.gz: 4d5a7a90df196c3690ecced7da3db2bafd4fe0cdf6d10272525abf7be06e4b2a0c99a82bc57265f1999cc607517c3bf629563087fe244ea3bc00283bccced8e7
data/Gemfile CHANGED
@@ -4,10 +4,12 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development, :test do
7
- gem 'guard'
7
+ gem 'guard','~> 2'
8
8
  gem 'guard-bundler'
9
9
  gem 'guard-rspec'
10
10
  gem 'guard-cucumber'
11
11
  gem 'timecop'
12
+ gem 'growl'
13
+ gem 'growl_notify'
12
14
  end
13
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- elapsed_watch (1.0.0)
4
+ elapsed_watch (1.1.0)
5
+ chronic
5
6
  chronic_duration
6
7
  methadone (~> 1.3.0)
7
8
 
@@ -13,8 +14,11 @@ GEM
13
14
  cucumber (>= 1.1.1)
14
15
  rspec-expectations (>= 2.7.0)
15
16
  builder (3.2.2)
17
+ celluloid (0.15.2)
18
+ timers (~> 1.1.0)
16
19
  childprocess (0.3.9)
17
20
  ffi (~> 1.0, >= 1.0.11)
21
+ chronic (0.10.2)
18
22
  chronic_duration (0.10.2)
19
23
  numerizer (~> 0.1.1)
20
24
  coderay (1.0.9)
@@ -27,33 +31,36 @@ GEM
27
31
  diff-lcs (1.2.4)
28
32
  ffi (1.9.0)
29
33
  formatador (0.2.4)
30
- gherkin (2.12.1)
34
+ gherkin (2.12.2)
31
35
  multi_json (~> 1.3)
32
- guard (1.8.2)
36
+ growl (1.0.3)
37
+ growl_notify (0.0.3)
38
+ rb-appscript
39
+ guard (2.2.2)
33
40
  formatador (>= 0.2.4)
34
- listen (>= 1.0.0)
35
- lumberjack (>= 1.0.2)
36
- pry (>= 0.9.10)
37
- thor (>= 0.14.6)
38
- guard-bundler (1.0.0)
39
- bundler (~> 1.0)
40
- guard (~> 1.1)
41
+ listen (~> 2.1)
42
+ lumberjack (~> 1.0)
43
+ pry (>= 0.9.12)
44
+ thor (>= 0.18.1)
45
+ guard-bundler (0.1.3)
46
+ bundler (>= 1.0.0)
47
+ guard (>= 0.2.2)
41
48
  guard-cucumber (1.4.0)
42
49
  cucumber (>= 1.2.0)
43
50
  guard (>= 1.1.0)
44
- guard-rspec (3.0.2)
45
- guard (>= 1.8)
46
- rspec (~> 2.13)
47
- json (1.8.0)
48
- listen (1.3.1)
51
+ guard-rspec (4.0.3)
52
+ guard (>= 2.1.1)
53
+ rspec (~> 2.14)
54
+ json (1.8.1)
55
+ listen (2.1.1)
56
+ celluloid (>= 0.15.2)
49
57
  rb-fsevent (>= 0.9.3)
50
58
  rb-inotify (>= 0.9)
51
- rb-kqueue (>= 0.2)
52
59
  lumberjack (1.0.4)
53
60
  methadone (1.3.0)
54
61
  bundler
55
62
  method_source (0.8.2)
56
- multi_json (1.8.0)
63
+ multi_json (1.8.2)
57
64
  multi_test (0.0.2)
58
65
  numerizer (0.1.1)
59
66
  pry (0.9.12.2)
@@ -61,24 +68,24 @@ GEM
61
68
  method_source (~> 0.8)
62
69
  slop (~> 3.4)
63
70
  rake (0.9.6)
71
+ rb-appscript (0.6.1)
64
72
  rb-fsevent (0.9.3)
65
73
  rb-inotify (0.9.2)
66
74
  ffi (>= 0.5.0)
67
- rb-kqueue (0.2.0)
68
- ffi (>= 0.5.0)
69
75
  rdoc (4.0.1)
70
76
  json (~> 1.4)
71
77
  rspec (2.14.1)
72
78
  rspec-core (~> 2.14.0)
73
79
  rspec-expectations (~> 2.14.0)
74
80
  rspec-mocks (~> 2.14.0)
75
- rspec-core (2.14.5)
76
- rspec-expectations (2.14.2)
81
+ rspec-core (2.14.6)
82
+ rspec-expectations (2.14.3)
77
83
  diff-lcs (>= 1.1.3, < 2.0)
78
- rspec-mocks (2.14.3)
84
+ rspec-mocks (2.14.4)
79
85
  slop (3.4.6)
80
86
  thor (0.18.1)
81
87
  timecop (0.6.3)
88
+ timers (1.1.0)
82
89
 
83
90
  PLATFORMS
84
91
  ruby
@@ -87,11 +94,13 @@ DEPENDENCIES
87
94
  aruba
88
95
  bundler (~> 1.3)
89
96
  elapsed_watch!
90
- guard
97
+ growl
98
+ growl_notify
99
+ guard (~> 2)
91
100
  guard-bundler
92
101
  guard-cucumber
93
102
  guard-rspec
94
- rake (~> 0.9.2)
103
+ rake
95
104
  rdoc
96
105
  rspec
97
106
  timecop
data/Guardfile CHANGED
@@ -6,7 +6,7 @@ guard 'cucumber', :cli => '--color --format pretty' do
6
6
  watch('bin/elapsed_watch') { 'features' }
7
7
  end
8
8
 
9
- guard :rspec, :cli => '--color --format documentation' do
9
+ guard :rspec, :cmd => 'bundle exec rspec --color --format documentation', all_on_start: true do
10
10
  watch(%r{^spec/.+_spec\.rb$})
11
11
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
12
12
  watch('spec/spec_helper.rb') { "spec" }
@@ -17,3 +17,5 @@ guard 'bundler' do
17
17
  watch('Gemfile')
18
18
  watch(/^.+\.gemspec/)
19
19
  end
20
+
21
+
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency('rdoc')
24
24
  spec.add_development_dependency('aruba')
25
- spec.add_development_dependency('rake', '~> 0.9.2')
26
25
  spec.add_development_dependency('rspec')
27
26
  spec.add_development_dependency('timecop')
28
27
 
29
28
  spec.add_dependency('methadone', '~> 1.3.0')
29
+ spec.add_dependency('chronic')
30
30
  spec.add_dependency('chronic_duration')
31
31
 
32
32
  end
@@ -1,7 +1,21 @@
1
+ =begin rdoc
2
+
3
+ event.rb -- defines the Class ElapsedWatch::Event for holding events
4
+
5
+ * Time-stamp: <2013-11-04 06:26:02 tamara>
6
+ * Copyright (C) 2013 Tamara Temple Web Development
7
+ * Author: Tamara Temple <tamouse@gmail.com>
8
+ * License: MIT
9
+
10
+ =end
11
+
12
+
13
+ require 'chronic'
1
14
  require 'chronic_duration'
2
15
  require 'yaml'
3
16
  require 'erb'
4
17
  require 'time'
18
+ require 'methadone'
5
19
 
6
20
  module ElapsedWatch
7
21
 
@@ -11,31 +25,22 @@ module ElapsedWatch
11
25
  # The format for events occuring in the future
12
26
  FUTURE_EVENT_FORMAT = "%s in %s"
13
27
 
14
- =begin rdoc
15
-
16
- event.rb -- Class for holding events
17
-
18
- * Time-stamp: <2013-09-13 01:42:22 tamara>
19
- * Copyright (C) 2013 Tamara Temple Web Development
20
- * Author: Tamara Temple <tamouse@gmail.com>
21
- * License: MIT
22
-
23
- == Description
24
-
25
- Defines an object class that deals with individual events.
26
-
27
- Events have a name and a time.
28
-
29
- =end
30
28
 
29
+ # == Description
30
+ #
31
+ # Defines an object class that deals with individual events.
32
+ #
33
+ # Events have a name and a time.
31
34
  class Event
32
35
 
36
+ include Methadone::CLILogging
37
+
33
38
  # Instantiates a new Event object.
34
39
  #
35
40
  # The event_string consists of a tiny piece of YAML that defines
36
41
  # the event. The format is:
37
42
  #
38
- # Event Name: YYYY-MM-DD HH:MM (anything parsable by Time.parse)
43
+ # Event Name: YYYY-MM-DD HH:MM (anything parsable by Chronic.parse)
39
44
  def initialize(event_string)
40
45
  raise "event_string is empty" if event_string.nil? or event_string.empty?
41
46
  ev_yaml = YAML.load(ERB.new(event_string).result)
@@ -45,7 +50,7 @@ Events have a name and a time.
45
50
  case @event_time
46
51
  when String
47
52
  raise "No event time spec: #{event_string}" if @event_time.empty?
48
- @event_time = Time.parse(@event_time)
53
+ @event_time = Chronic.parse(@event_time)
49
54
  when Date
50
55
  @event_time = @event_time.to_time
51
56
  when DateTime
@@ -95,7 +100,7 @@ Events have a name and a time.
95
100
 
96
101
  # Memoizes now
97
102
  def now(use_time=nil)
98
- @now ||= (use_time.nil? ? Time.now : use_time)
103
+ @now ||= use_time ||= Time.now
99
104
  end
100
105
 
101
106
  end
@@ -1,5 +1,5 @@
1
1
  module ElapsedWatch
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
 
4
4
  DESCRIPTION = "
5
5
  Reading a file of events, containing an event name (a string) and a
@@ -41,10 +41,16 @@ describe ElapsedWatch do
41
41
  it{event3.instance_variable_get("@event_time").should eq Time.new(1957)}
42
42
  end
43
43
 
44
+ context "events with only MM-DD given" do
45
+ let(:event4) {ElapsedWatch::Event.new("Birthday: 10-12")}
46
+ it{event4.instance_variable_get("@event_name").should eq "Birthday"}
47
+ it{event4.instance_variable_get("@event_time").should eq Chronic.parse("10-12")}
48
+ end
49
+
50
+
51
+
52
+
44
53
  context "sad paths" do
45
- it "event without a day should fail" do
46
- expect {ElapsedWatch::Event.new("No day: 2013-09")}.to raise_error ArgumentError
47
- end
48
54
  it "event without a date should fail" do
49
55
  expect {ElapsedWatch::Event.new("No date:")}.to raise_error RuntimeError
50
56
  end
@@ -54,8 +60,9 @@ describe ElapsedWatch do
54
60
  it "event with empty name should fail" do
55
61
  expect {ElapsedWatch::Event.new(": 2013-09-01")}.to raise_error Psych::SyntaxError
56
62
  end
57
- it "event with unparsable time spec should fail" do
58
- expect {ElapsedWatch::Event.new("Bad spec: another fine mess")}.to raise_error ArgumentError
63
+ it "event with unparsable time spec should have nil time" do
64
+ event5 = ElapsedWatch::Event.new("Bad spec: another fine mess")
65
+ event5.instance_variable_get("@event_time").should be_nil
59
66
  end
60
67
 
61
68
 
data/spec/spec_helper.rb CHANGED
@@ -16,5 +16,9 @@ RSpec.configure do |config|
16
16
  # config.order = 'random'
17
17
  end
18
18
 
19
+ require 'methadone'
20
+ extend Methadone::CLILogging
21
+ logger.error_level = Logger::DEBUG
22
+
19
23
  require 'elapsed_watch'
20
24
  require 'timecop'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elapsed_watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamara Temple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: 0.9.2
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ~>
81
- - !ruby/object:Gem::Version
82
- version: 0.9.2
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +108,20 @@ dependencies:
122
108
  - - ~>
123
109
  - !ruby/object:Gem::Version
124
110
  version: 1.3.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: chronic
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: chronic_duration
127
127
  requirement: !ruby/object:Gem::Requirement