time_units 0.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.
- data/.gitignore +6 -0
- data/Gemfile +17 -0
- data/Guardfile +8 -0
- data/LICENSE +22 -0
- data/README.md +13 -0
- data/Rakefile +18 -0
- data/lib/time_units.rb +2 -0
- data/lib/time_units/units.rb +20 -0
- data/lib/time_units/version.rb +3 -0
- data/specs/spec_helper.rb +25 -0
- data/specs/unit/units_spec.rb +27 -0
- data/time_units.gemspec +15 -0
- metadata +63 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
|
7
|
+
group(:test) do
|
8
|
+
gem 'schmurfy-bacon'
|
9
|
+
gem 'mocha', '~> 0.10.0'
|
10
|
+
gem 'factory_girl'
|
11
|
+
|
12
|
+
gem 'simplecov'
|
13
|
+
gem 'guard'
|
14
|
+
gem 'guard-bacon'
|
15
|
+
gem 'rb-fsevent'
|
16
|
+
gem 'growl'
|
17
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
# parameters:
|
3
|
+
# output => the formatted to use
|
4
|
+
# backtrace => number of lines, nil = everything
|
5
|
+
guard 'bacon', :output => "BetterOutput", :backtrace => nil do
|
6
|
+
watch(%r{^lib/time_units/(.+)\.rb$}) { |m| "specs/unit/#{m[1]}_spec.rb" }
|
7
|
+
watch(%r{specs/.+\.rb$})
|
8
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Julien Ammous
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
task :default => :test
|
6
|
+
|
7
|
+
task :test do
|
8
|
+
require 'bacon'
|
9
|
+
|
10
|
+
ENV['COVERAGE'] = "1"
|
11
|
+
|
12
|
+
Dir[File.expand_path('../specs/**/*_spec.rb', __FILE__)].each do |file|
|
13
|
+
puts "File: #{file}:"
|
14
|
+
load(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
data/lib/time_units.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module TimeUnits
|
3
|
+
def seconds() self end
|
4
|
+
def minutes() 60 * seconds end
|
5
|
+
def hours() 60 * minutes end
|
6
|
+
def days() 24 * hours end
|
7
|
+
def weeks() 7 * days end
|
8
|
+
def months() 4* weeks end
|
9
|
+
def years() 365 * days end
|
10
|
+
|
11
|
+
def ago; Time.now - seconds; end
|
12
|
+
def from_now; Time.now + seconds; end
|
13
|
+
|
14
|
+
instance_methods.select{|m| m !~ /__/}.each do |plural|
|
15
|
+
singular = plural.to_s.chop
|
16
|
+
alias_method singular, plural
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Numeric.send(:include, TimeUnits)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'bacon'
|
5
|
+
|
6
|
+
if ENV['COVERAGE']
|
7
|
+
Bacon.allow_focused_run = false
|
8
|
+
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter ".*_spec"
|
12
|
+
add_filter "/helpers/"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift( File.expand_path('../../lib' , __FILE__) )
|
18
|
+
require 'time_units'
|
19
|
+
|
20
|
+
# require 'bacon/ext/mocha'
|
21
|
+
# require 'bacon/ext/em'
|
22
|
+
|
23
|
+
# Thread.abort_on_exception = true
|
24
|
+
|
25
|
+
Bacon.summary_on_exit()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe 'TimeUnits' do
|
4
|
+
should 'works' do
|
5
|
+
1.second.should == 1
|
6
|
+
60.seconds.should == 60
|
7
|
+
120.seconds.should == 120
|
8
|
+
|
9
|
+
1.minute.should == 60
|
10
|
+
1.minutes.should == 60
|
11
|
+
|
12
|
+
1.hour.should == 60*60
|
13
|
+
2.hours.should == 60*60*2
|
14
|
+
|
15
|
+
1.days.should == 60*60*24
|
16
|
+
2.days.should == 60*60*24*2
|
17
|
+
|
18
|
+
1.week.should == 60*60*24*7
|
19
|
+
3.week.should == 60*60*24*7*3
|
20
|
+
|
21
|
+
1.month.should == 4.weeks
|
22
|
+
2.month.should == 8.weeks
|
23
|
+
|
24
|
+
1.year.should == 365.days
|
25
|
+
2.year.should == 365.days * 2
|
26
|
+
end
|
27
|
+
end
|
data/time_units.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/time_units/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Julien Ammous"]
|
6
|
+
gem.email = ["schmurfy@gmail.com"]
|
7
|
+
gem.summary = %q{Some time helpers}
|
8
|
+
gem.homepage = "https://github.com/schmurfy/time_units"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.name = "time_units"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = TimeUnits::VERSION
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: time_units
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Julien Ammous
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-09 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- schmurfy@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- Guardfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/time_units.rb
|
28
|
+
- lib/time_units/units.rb
|
29
|
+
- lib/time_units/version.rb
|
30
|
+
- specs/spec_helper.rb
|
31
|
+
- specs/unit/units_spec.rb
|
32
|
+
- time_units.gemspec
|
33
|
+
homepage: https://github.com/schmurfy/time_units
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
hash: 351868374792162314
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
hash: 351868374792162314
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.11
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Some time helpers
|
63
|
+
test_files: []
|