epitools 0.4.46 → 0.4.47
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +2 -2
- data/lib/epitools/basetypes.rb +25 -0
- data/spec/basetypes_spec.rb +12 -0
- metadata +8 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.47
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.47"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-25}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/epitools/basetypes.rb
CHANGED
@@ -52,6 +52,31 @@ class Numeric
|
|
52
52
|
def commatize
|
53
53
|
to_s.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2')
|
54
54
|
end
|
55
|
+
|
56
|
+
# Time
|
57
|
+
|
58
|
+
{
|
59
|
+
|
60
|
+
'second' => 1,
|
61
|
+
'minute' => 60,
|
62
|
+
'hour' => 60 * 60,
|
63
|
+
'day' => 60 * 60 * 24,
|
64
|
+
'week' => 60 * 60 * 24 * 7,
|
65
|
+
'month' => 60 * 60 * 24 * 30,
|
66
|
+
'year' => 60 * 60 * 24 * 364.25,
|
67
|
+
|
68
|
+
}.each do |unit, scale|
|
69
|
+
define_method(unit) { self * scale }
|
70
|
+
define_method(unit+'s') { self * scale }
|
71
|
+
end
|
72
|
+
|
73
|
+
def ago
|
74
|
+
Time.now - self
|
75
|
+
end
|
76
|
+
|
77
|
+
def from_now
|
78
|
+
Time.now + self
|
79
|
+
end
|
55
80
|
end
|
56
81
|
|
57
82
|
class Float
|
data/spec/basetypes_spec.rb
CHANGED
@@ -123,6 +123,18 @@ describe Numeric do
|
|
123
123
|
-12983287123.commatize.should == "-12,983,287,123"
|
124
124
|
-12983287123.4411.commatize.should == "-12,983,287,123.4411"
|
125
125
|
end
|
126
|
+
|
127
|
+
it "does time things" do
|
128
|
+
1.second.should == 1
|
129
|
+
1.minute.should == 60
|
130
|
+
2.minutes.should == 120
|
131
|
+
2.hours.should == 120*60
|
132
|
+
2.5.days.should == 3600*24*2.5
|
133
|
+
|
134
|
+
5.days.ago.to_i.should == (Time.now - 5.days).to_i
|
135
|
+
1.year.ago.year.should == Time.now.year - 1
|
136
|
+
5.days.from_now.to_i.should == (Time.now + 5.days).to_i
|
137
|
+
end
|
126
138
|
|
127
139
|
end
|
128
140
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.47
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-06-
|
12
|
+
date: 2011-06-25 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &73254740 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 2.2.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *73254740
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: mechanize
|
28
|
-
requirement: &
|
28
|
+
requirement: &73253840 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *73253840
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sqlite3-ruby
|
39
|
-
requirement: &
|
39
|
+
requirement: &73253590 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *73253590
|
48
48
|
description: Miscellaneous utility libraries to make my life easier.
|
49
49
|
email: chris@ill-logic.com
|
50
50
|
executables: []
|