time_constants 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,2 @@
1
+
2
+ v0.1. First release.
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ TimeConstants is Copyright (C) 2011 Twitter, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
+ use this work except in compliance with the License. You may obtain a copy of
5
+ the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+ License for the specific language governing permissions and limitations under
13
+ the License.
@@ -0,0 +1,7 @@
1
+ CHANGELOG
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ Rakefile
6
+ lib/time_constants.rb
7
+ test/unit/time_constants_test.rb
data/README ADDED
@@ -0,0 +1,39 @@
1
+
2
+ TimeConstants
3
+
4
+ Time constants, in seconds, so you don't have to use slow ActiveSupport helpers.
5
+
6
+ == Usage
7
+
8
+ require 'time_constants'
9
+
10
+ You get constants from 0 to 100, except for days, which goes to 500.
11
+
12
+ T_1_SECOND
13
+ T_2_SECONDS
14
+
15
+ T_1_MINUTE
16
+ T_2_MINUTES
17
+
18
+ T_1_HOUR
19
+ T_2_HOURS
20
+
21
+ T_1_DAY
22
+ T_2_DAYS
23
+
24
+ T_1_WEEK
25
+ T_2_WEEKS
26
+
27
+ T_1_MONTH
28
+ T_2_MONTHS
29
+
30
+ T_1_YEAR
31
+ T_2_YEARS
32
+
33
+ T_1_SOLAR_YEAR
34
+ T_2_SOLAR_YEARS
35
+
36
+
37
+ == License
38
+
39
+ Copyright 2011 Twitter, Inc. Licensed under the Apache 2 license. See the included LICENSE file.
@@ -0,0 +1,8 @@
1
+ require 'echoe'
2
+
3
+ Echoe.new("time_constants") do |p|
4
+ p.author = "Evan Weaver"
5
+ p.project = "twitter"
6
+ p.summary = "Time constants, in seconds, so you don't have to use slow ActiveSupport helpers."
7
+ end
8
+
@@ -0,0 +1,14 @@
1
+ class Time
2
+ def self.set_time_constant(number, unit, seconds)
3
+ Object.const_set(constant = "T_#{number}_#{unit}#{number > 1 ? 'S' : ''}", seconds)
4
+ end
5
+ end
6
+
7
+ 101.times { |i| Time.set_time_constant(i, "SECOND", i) }
8
+ 101.times { |i| Time.set_time_constant(i, "MINUTE", i * T_60_SECONDS) }
9
+ 101.times { |i| Time.set_time_constant(i, "HOUR", i * T_60_MINUTES) }
10
+ 501.times { |i| Time.set_time_constant(i, "DAY", i * T_24_HOURS) }
11
+ 101.times { |i| Time.set_time_constant(i, "WEEK", i * T_7_DAYS) }
12
+ 101.times { |i| Time.set_time_constant(i, "MONTH", i * T_30_DAYS) }
13
+ 101.times { |i| Time.set_time_constant(i, "YEAR", i * (T_365_DAYS + T_6_HOURS)) }
14
+ 101.times { |i| Time.set_time_constant(i, "SOLAR_YEAR", i * 31558150) }
@@ -0,0 +1,14 @@
1
+
2
+ require 'test/unit'
3
+ require 'time_constants'
4
+ require 'rubygems'
5
+ require 'activesupport'
6
+
7
+ class TestTimeConstants < Test::Unit::TestCase
8
+ def test_accuracy
9
+ assert_equal 1.hour.to_i, T_1_HOUR
10
+ assert_equal 3.days.to_i, T_3_DAYS
11
+ assert_equal 2.months.to_i, T_2_MONTHS
12
+ assert_equal 20.years.to_i, T_20_YEARS
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{time_constants}
5
+ s.version = "0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Evan Weaver"]
9
+ s.cert_chain = ["/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-public_cert.pem"]
10
+ s.date = %q{2011-02-25}
11
+ s.description = %q{Time constants, in seconds, so you don't have to use slow ActiveSupport helpers.}
12
+ s.email = %q{}
13
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/time_constants.rb"]
14
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "lib/time_constants.rb", "test/unit/time_constants_test.rb", "time_constants.gemspec"]
15
+ s.homepage = %q{http://twitter.github.com/twitter/time_constants/}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Time_constants", "--main", "README"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{twitter}
19
+ s.rubygems_version = %q{1.5.0}
20
+ s.signing_key = %q{/Users/eweaver/p/configuration/gem_certificates/evan_weaver-original-private_key.pem}
21
+ s.summary = %q{Time constants, in seconds, so you don't have to use slow ActiveSupport helpers.}
22
+ s.test_files = ["test/unit/time_constants_test.rb"]
23
+
24
+ if s.respond_to? :specification_version then
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: time_constants
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Evan Weaver
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu
19
+ MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe
20
+ Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x
21
+ GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB
22
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs
23
+ yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A
24
+ Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj
25
+ R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46
26
+ QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT
27
+ QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID
28
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ
29
+ XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt
30
+ JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1
31
+ XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h
32
+ MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5
33
+ hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
34
+ x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
35
+ yZ0=
36
+ -----END CERTIFICATE-----
37
+
38
+ date: 2011-02-25 00:00:00 -08:00
39
+ default_executable:
40
+ dependencies: []
41
+
42
+ description: Time constants, in seconds, so you don't have to use slow ActiveSupport helpers.
43
+ email: ""
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - CHANGELOG
50
+ - LICENSE
51
+ - README
52
+ - lib/time_constants.rb
53
+ files:
54
+ - CHANGELOG
55
+ - LICENSE
56
+ - Manifest
57
+ - README
58
+ - Rakefile
59
+ - lib/time_constants.rb
60
+ - test/unit/time_constants_test.rb
61
+ - time_constants.gemspec
62
+ has_rdoc: true
63
+ homepage: http://twitter.github.com/twitter/time_constants/
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --line-numbers
69
+ - --inline-source
70
+ - --title
71
+ - Time_constants
72
+ - --main
73
+ - README
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 11
91
+ segments:
92
+ - 1
93
+ - 2
94
+ version: "1.2"
95
+ requirements: []
96
+
97
+ rubyforge_project: twitter
98
+ rubygems_version: 1.5.0
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Time constants, in seconds, so you don't have to use slow ActiveSupport helpers.
102
+ test_files:
103
+ - test/unit/time_constants_test.rb
Binary file