timely 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +23 -0
- data/README.txt +31 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/timely/date.rb +18 -0
- data/lib/timely/time.rb +20 -0
- data/lib/timely/version.rb +9 -0
- data/lib/timely.rb +8 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/setup.rb +1585 -0
- data/spec/date_spec.rb +68 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/time_spec.rb +45 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +9 -0
- metadata +80 -0
data/spec/date_spec.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Date do
|
4
|
+
before :each do
|
5
|
+
@date = Date.today - 5
|
6
|
+
|
7
|
+
@hour = 1
|
8
|
+
@minute = 2
|
9
|
+
@second = 3
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should give a time on that date' do
|
13
|
+
@date.should respond_to(:at_time)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'giving a time on that date' do
|
17
|
+
it 'should accept hour, minute, and second' do
|
18
|
+
lambda { @date.at_time(@hour, @minute, @second) }.should_not raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should accept hour and minute' do
|
22
|
+
lambda { @date.at_time(@hour, @minute) }.should_not raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should accept hour' do
|
26
|
+
lambda { @date.at_time(@hour) }.should_not raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should accept no arguments' do
|
30
|
+
lambda { @date.at_time }.should_not raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return a time for the given hour, minute, and second if all three are specified' do
|
34
|
+
expected = Time.local(@date.year, @date.month, @date.day, @hour, @minute, @second)
|
35
|
+
@date.at_time(@hour, @minute, @second).should == expected
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should default second to 0 if unspecified' do
|
39
|
+
expected = Time.local(@date.year, @date.month, @date.day, @hour, @minute, 0)
|
40
|
+
@date.at_time(@hour, @minute).should == expected
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should default minute to 0 if unspecified' do
|
44
|
+
expected = Time.local(@date.year, @date.month, @date.day, @hour, 0, 0)
|
45
|
+
@date.at_time(@hour).should == expected
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should default hour to 0 if unspecified' do
|
49
|
+
expected = Time.local(@date.year, @date.month, @date.day, 0, 0, 0)
|
50
|
+
@date.at_time.should == expected
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should accept a time' do
|
54
|
+
lambda { @date.at_time(Time.now) }.should_not raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return the passed-in time on the date' do
|
58
|
+
@time = Time.now - 12345
|
59
|
+
expected = Time.local(@date.year, @date.month, @date.day, @time.hour, @time.min, @time.sec)
|
60
|
+
@date.at_time(@time).should == expected
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should provide 'at' as an alias" do
|
65
|
+
expected = expected = Time.local(@date.year, @date.month, @date.day, @hour, @minute, @second)
|
66
|
+
@date.at(@hour, @minute, @second).should == expected
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
# this is my favorite way to require ever
|
10
|
+
begin
|
11
|
+
require 'mocha'
|
12
|
+
rescue LoadError
|
13
|
+
require 'rubygems'
|
14
|
+
gem 'mocha'
|
15
|
+
require 'mocha'
|
16
|
+
end
|
17
|
+
|
18
|
+
Spec::Runner.configure do |config|
|
19
|
+
config.mock_with :mocha
|
20
|
+
end
|
21
|
+
|
22
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
23
|
+
require 'timely'
|
data/spec/time_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Time do
|
4
|
+
before :each do
|
5
|
+
@time = Time.now - 12345
|
6
|
+
|
7
|
+
@year = 2005
|
8
|
+
@month = 3
|
9
|
+
@day = 15
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should give that time on a date' do
|
13
|
+
@time.should respond_to(:on_date)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'giving that time on a date' do
|
17
|
+
it 'should accept year, month and day' do
|
18
|
+
lambda { @time.on_date(@year, @month, @day) }.should_not raise_error(ArgumentError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should require year, month, and day' do
|
22
|
+
lambda { @time.on_date(@year, @month) }.should raise_error(ArgumentError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return the same time on the specified year, month, and day' do
|
26
|
+
expected = Time.local(@year, @month, @day, @time.hour, @time.min, @time.sec)
|
27
|
+
@time.on_date(@year, @month, @day).should == expected
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should accept a date' do
|
31
|
+
lambda { @time.on_date(Date.today) }.should_not raise_error(ArgumentError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should return the same time on the specified date' do
|
35
|
+
@date = Date.today - 2345
|
36
|
+
expected = Time.local(@date.year, @date.month, @date.day, @time.hour, @time.min, @time.sec)
|
37
|
+
@time.on_date(@date).should == expected
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should provide 'on' as an alias" do
|
42
|
+
expected = Time.local(@year, @month, @day, @time.hour, @time.min, @time.sec)
|
43
|
+
@time.on(@year, @month, @day).should == expected
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
data/tasks/website.rake
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: timely
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yossef Mendelssohn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-08 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: adds some convenience methods to Date and Time to easily create times on specific dates
|
17
|
+
email:
|
18
|
+
- ymendel@pobox.com
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- History.txt
|
25
|
+
- License.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- README.txt
|
28
|
+
files:
|
29
|
+
- History.txt
|
30
|
+
- License.txt
|
31
|
+
- Manifest.txt
|
32
|
+
- README.txt
|
33
|
+
- Rakefile
|
34
|
+
- config/hoe.rb
|
35
|
+
- config/requirements.rb
|
36
|
+
- lib/timely.rb
|
37
|
+
- lib/timely/version.rb
|
38
|
+
- lib/timely/date.rb
|
39
|
+
- lib/timely/time.rb
|
40
|
+
- script/console
|
41
|
+
- script/destroy
|
42
|
+
- script/generate
|
43
|
+
- setup.rb
|
44
|
+
- spec/spec.opts
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- spec/date_spec.rb
|
47
|
+
- spec/time_spec.rb
|
48
|
+
- tasks/deployment.rake
|
49
|
+
- tasks/environment.rake
|
50
|
+
- tasks/rspec.rake
|
51
|
+
- tasks/website.rake
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://yomendel.rubyforge.org
|
54
|
+
post_install_message: ""
|
55
|
+
rdoc_options:
|
56
|
+
- --main
|
57
|
+
- README.txt
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project: yomendel
|
75
|
+
rubygems_version: 1.1.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: adds some convenience methods to Date and Time to easily create times on specific dates
|
79
|
+
test_files: []
|
80
|
+
|