timer 0.1.7 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/Gemfile +5 -4
- data/README.rdoc +2 -9
- data/lib/timer.rb +8 -32
- data/timer.gemspec +3 -29
- metadata +9 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e707efa2b6a2d8f76a47ec74549db9c4f0d4d7f
|
4
|
+
data.tar.gz: 37317d1f4122e99e38a68b9d82dc8b873726ddc1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1435e5c0214e51a2f8a0819716e7c9f59f6d1ba714ade3ddb84786575c50c19ff5f2d7b024823663ed120086257da17f32ec10d00d3fb3b592d55ed35e75bc28
|
7
|
+
data.tar.gz: efec1857aa48d6c361a8b726bf41cb0aa3e7572a7b3294afae9abea6a722cd974c42efc6f771c9c818d61af75da7df5767d5dcf53c9dee1a5485d0fd5e18b22e
|
data/Gemfile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem "ruby-growl", ">= 0"
|
4
|
-
gem "progressions-g", ">= 0"
|
5
3
|
gem "activesupport", :require => "active_support"
|
6
4
|
gem "natural_time", ">= 0"
|
7
|
-
|
8
|
-
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem "rspec", ">= 0"
|
8
|
+
gem "timecop", ">= 0"
|
9
|
+
end
|
data/README.rdoc
CHANGED
@@ -14,15 +14,8 @@ Simple timer to display elapsed time of a block.
|
|
14
14
|
# some code in here
|
15
15
|
end
|
16
16
|
|
17
|
-
== Options
|
18
|
-
|
19
|
-
Timer.new takes two optional parameters:
|
20
|
-
|
21
|
-
[title] (string) Growl message title
|
22
|
-
[growl] (boolean) Turn Growl messaging off. It is on by default.
|
23
|
-
|
24
17
|
== Note on Patches/Pull Requests
|
25
|
-
|
18
|
+
|
26
19
|
* Fork the project.
|
27
20
|
* Make your feature addition or bug fix.
|
28
21
|
* Add tests for it. This is important so I don't break it in a
|
@@ -33,4 +26,4 @@ Timer.new takes two optional parameters:
|
|
33
26
|
|
34
27
|
== Copyright
|
35
28
|
|
36
|
-
Copyright (c)
|
29
|
+
Copyright (c) 2013 Isaac Priestley. See LICENSE for details.
|
data/lib/timer.rb
CHANGED
@@ -1,21 +1,17 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'g'
|
3
2
|
require 'natural_time'
|
4
3
|
|
5
4
|
class Timer
|
6
|
-
attr_accessor :title
|
7
|
-
|
8
|
-
DEFAULT_OPTIONS = { :growl => true }
|
9
|
-
|
5
|
+
attr_accessor :title
|
6
|
+
|
10
7
|
def initialize(options={})
|
11
|
-
options
|
8
|
+
options ||= options
|
12
9
|
@title = options[:title]
|
13
|
-
@growl = options[:growl]
|
14
10
|
end
|
15
|
-
|
11
|
+
|
16
12
|
def time(message="", options={})
|
17
13
|
current_title = options[:title] || title
|
18
|
-
|
14
|
+
|
19
15
|
start_time = Time.now
|
20
16
|
begin
|
21
17
|
yield
|
@@ -25,11 +21,7 @@ class Timer
|
|
25
21
|
put_elapsed_time(start_time, Time.now, message, current_title)
|
26
22
|
raise e if e
|
27
23
|
end
|
28
|
-
|
29
|
-
def growl?
|
30
|
-
@growl
|
31
|
-
end
|
32
|
-
|
24
|
+
|
33
25
|
private
|
34
26
|
|
35
27
|
def put_elapsed_time(start_time, end_time, message="", current_title=nil)
|
@@ -42,25 +34,9 @@ class Timer
|
|
42
34
|
e = message + e
|
43
35
|
e += "Elapsed time: #{elapsed_time}"
|
44
36
|
$stdout.puts "\n" + e
|
45
|
-
growl(e, current_title)
|
46
37
|
end
|
47
|
-
|
38
|
+
|
48
39
|
def format_time(duration)
|
49
40
|
NaturalTime.new(duration).to_sentence
|
50
41
|
end
|
51
|
-
|
52
|
-
def growl(message, current_title)
|
53
|
-
if growl?
|
54
|
-
if title
|
55
|
-
g(message, :title => current_title)
|
56
|
-
else
|
57
|
-
g(message)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
rescue StandardError => e
|
61
|
-
# growl isn't turned on, fail silently
|
62
|
-
unless e.message =~ /Connection refused/
|
63
|
-
raise e
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
42
|
+
end
|
data/timer.gemspec
CHANGED
@@ -1,16 +1,11 @@
|
|
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
1
|
Gem::Specification.new do |s|
|
7
2
|
s.name = %q{timer}
|
8
|
-
s.version = "0.
|
3
|
+
s.version = "0.2"
|
9
4
|
|
10
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
6
|
s.authors = ["Isaac Priestley"]
|
12
|
-
s.date = %q{
|
13
|
-
s.description = %q{Simple timer to perform a block and display the elapsed time.
|
7
|
+
s.date = %q{2013-10-14}
|
8
|
+
s.description = %q{Simple timer to perform a block and display the elapsed time.}
|
14
9
|
s.email = %q{progressions@gmail.com}
|
15
10
|
s.extra_rdoc_files = [
|
16
11
|
"LICENSE",
|
@@ -41,36 +36,15 @@ Gem::Specification.new do |s|
|
|
41
36
|
s.specification_version = 3
|
42
37
|
|
43
38
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
-
s.add_runtime_dependency(%q<ruby-growl>, [">= 0"])
|
45
|
-
s.add_runtime_dependency(%q<progressions-g>, [">= 0"])
|
46
39
|
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
47
40
|
s.add_runtime_dependency(%q<natural_time>, [">= 0"])
|
48
|
-
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
49
|
-
s.add_runtime_dependency(%q<timecop>, [">= 0"])
|
50
|
-
s.add_runtime_dependency(%q<ruby-growl>, [">= 0"])
|
51
|
-
s.add_runtime_dependency(%q<progressions-g>, [">= 0"])
|
52
|
-
s.add_runtime_dependency(%q<natural_time>, [">= 0"])
|
53
41
|
else
|
54
|
-
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
55
|
-
s.add_dependency(%q<progressions-g>, [">= 0"])
|
56
42
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
57
43
|
s.add_dependency(%q<natural_time>, [">= 0"])
|
58
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
59
|
-
s.add_dependency(%q<timecop>, [">= 0"])
|
60
|
-
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
61
|
-
s.add_dependency(%q<progressions-g>, [">= 0"])
|
62
|
-
s.add_dependency(%q<natural_time>, [">= 0"])
|
63
44
|
end
|
64
45
|
else
|
65
|
-
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
66
|
-
s.add_dependency(%q<progressions-g>, [">= 0"])
|
67
46
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
68
47
|
s.add_dependency(%q<natural_time>, [">= 0"])
|
69
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
-
s.add_dependency(%q<timecop>, [">= 0"])
|
71
|
-
s.add_dependency(%q<ruby-growl>, [">= 0"])
|
72
|
-
s.add_dependency(%q<progressions-g>, [">= 0"])
|
73
|
-
s.add_dependency(%q<natural_time>, [">= 0"])
|
74
48
|
end
|
75
49
|
end
|
76
50
|
|
metadata
CHANGED
@@ -1,143 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Priestley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby-growl
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: progressions-g
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: activesupport
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: natural_time
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ! '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ! '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: timecop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: ruby-growl
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ! '>='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ! '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: progressions-g
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
17
|
+
- - '>='
|
116
18
|
- !ruby/object:Gem::Version
|
117
19
|
version: '0'
|
118
20
|
type: :runtime
|
119
21
|
prerelease: false
|
120
22
|
version_requirements: !ruby/object:Gem::Requirement
|
121
23
|
requirements:
|
122
|
-
- -
|
24
|
+
- - '>='
|
123
25
|
- !ruby/object:Gem::Version
|
124
26
|
version: '0'
|
125
27
|
- !ruby/object:Gem::Dependency
|
126
28
|
name: natural_time
|
127
29
|
requirement: !ruby/object:Gem::Requirement
|
128
30
|
requirements:
|
129
|
-
- -
|
31
|
+
- - '>='
|
130
32
|
- !ruby/object:Gem::Version
|
131
33
|
version: '0'
|
132
34
|
type: :runtime
|
133
35
|
prerelease: false
|
134
36
|
version_requirements: !ruby/object:Gem::Requirement
|
135
37
|
requirements:
|
136
|
-
- -
|
38
|
+
- - '>='
|
137
39
|
- !ruby/object:Gem::Version
|
138
40
|
version: '0'
|
139
|
-
description: Simple timer to perform a block and display the elapsed time.
|
140
|
-
message if growl is turned on.
|
41
|
+
description: Simple timer to perform a block and display the elapsed time.
|
141
42
|
email: progressions@gmail.com
|
142
43
|
executables: []
|
143
44
|
extensions: []
|
@@ -164,12 +65,12 @@ require_paths:
|
|
164
65
|
- lib
|
165
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
67
|
requirements:
|
167
|
-
- -
|
68
|
+
- - '>='
|
168
69
|
- !ruby/object:Gem::Version
|
169
70
|
version: '0'
|
170
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
72
|
requirements:
|
172
|
-
- -
|
73
|
+
- - '>='
|
173
74
|
- !ruby/object:Gem::Version
|
174
75
|
version: '0'
|
175
76
|
requirements: []
|