broadcast_calendar 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +39 -0
- data/Guardfile +9 -0
- data/MIT-LICENSE +21 -0
- data/README.md +19 -0
- data/Rakefile +10 -0
- data/broadcast_calendar.gemspec +20 -0
- data/lib/broadcast_calendar/version.rb +3 -0
- data/lib/broadcast_calendar.rb +21 -0
- data/spec/broadcast_calendar_spec.rb +56 -0
- data/spec/spec_helper.rb +30 -0
- metadata +78 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2-p180-patched@broadcast_calendar --create
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
broadcast_calendar (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
growl (1.0.3)
|
11
|
+
guard (0.4.2)
|
12
|
+
thor (~> 0.14.6)
|
13
|
+
guard-rspec (0.4.0)
|
14
|
+
guard (>= 0.4.0)
|
15
|
+
guard-spork (0.2.0)
|
16
|
+
guard (>= 0.2.2)
|
17
|
+
spork (>= 0.8.4)
|
18
|
+
rb-fsevent (0.4.0)
|
19
|
+
rspec (2.6.0)
|
20
|
+
rspec-core (~> 2.6.0)
|
21
|
+
rspec-expectations (~> 2.6.0)
|
22
|
+
rspec-mocks (~> 2.6.0)
|
23
|
+
rspec-core (2.6.4)
|
24
|
+
rspec-expectations (2.6.0)
|
25
|
+
diff-lcs (~> 1.1.2)
|
26
|
+
rspec-mocks (2.6.0)
|
27
|
+
spork (0.8.5)
|
28
|
+
thor (0.14.6)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
broadcast_calendar!
|
35
|
+
growl (= 1.0.3)
|
36
|
+
guard-rspec (= 0.4.0)
|
37
|
+
guard-spork (= 0.2.0)
|
38
|
+
rb-fsevent (= 0.4.0)
|
39
|
+
rspec
|
data/Guardfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2011 Mike Subelsky
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# BroadcastCalendar Gem
|
2
|
+
|
3
|
+
This library returns the beginning and ending Gregorian (civil) dates for months in the
|
4
|
+
[broadcast calendar](http://en.wikipedia.org/wiki/Broadcast_calendar).
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
|
8
|
+
gem install broadcast_calendar
|
9
|
+
|
10
|
+
# Usage
|
11
|
+
|
12
|
+
Dates are returned as a Range object.
|
13
|
+
|
14
|
+
> BroadcastCalendar.dates_for(5,2011)
|
15
|
+
=> Mon, 25 Apr 2011..Sun, 29 May 2011
|
16
|
+
|
17
|
+
# Problems? Questions?
|
18
|
+
|
19
|
+
Email <mike@subelsky.com> or file an issue on GitHub. Thanks!
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__))
|
2
|
+
require 'lib/broadcast_calendar/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = %q{broadcast_calendar}
|
6
|
+
s.version = BroadcastCalendar::VERSION
|
7
|
+
s.authors = ["Mike Subelsky"]
|
8
|
+
s.date = Time.now.utc.strftime("%Y-%m-%d")
|
9
|
+
s.email = %q{mike@subelsky.com}
|
10
|
+
s.extra_rdoc_files = %w(README.md)
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.homepage = %q{http://github.com/subelsky/broadcast_calendar}
|
13
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
s.summary = %q{eturns the beginning and ending Gregorian (civil) dates for months in the broadcast calendar.}
|
16
|
+
s.description = %q{Library tht returns the beginning and ending Gregorian (civil) dates for months in the broadcast calendar.}
|
17
|
+
s.test_files = `git ls-files spec`.split("\n")
|
18
|
+
s.add_development_dependency 'rspec'
|
19
|
+
s.license = "MIT"
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
module BroadcastCalendar
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def dates_for(month,year)
|
7
|
+
# find the monday of the first week of the month
|
8
|
+
beginning = Date.civil(year,month,1)
|
9
|
+
|
10
|
+
if (wday = beginning.wday) == 0
|
11
|
+
beginning -= 6
|
12
|
+
else
|
13
|
+
beginning -= wday - 1
|
14
|
+
end
|
15
|
+
|
16
|
+
ending = Date.civil(year,month,-1)
|
17
|
+
ending -= ending.wday # broadcast calendar always ends on Sunday
|
18
|
+
|
19
|
+
beginning..ending
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'broadcast_calendar'
|
2
|
+
|
3
|
+
describe BroadcastCalendar do
|
4
|
+
let(:dates) {
|
5
|
+
{ 2010 =>
|
6
|
+
{ 1 => Date.new(2009,12,28)..Date.new(2010,1,31),
|
7
|
+
2 => Date.new(2010,2,1)..Date.new(2010,2,28),
|
8
|
+
3 => Date.new(2010,3,1)..Date.new(2010,3,28),
|
9
|
+
4 => Date.new(2010,3,29)..Date.new(2010,4,25),
|
10
|
+
5 => Date.new(2010,4,26)..Date.new(2010,5,30),
|
11
|
+
6 => Date.new(2010,5,31)..Date.new(2010,6,27),
|
12
|
+
7 => Date.new(2010,6,28)..Date.new(2010,7,25),
|
13
|
+
8 => Date.new(2010,7,26)..Date.new(2010,8,29),
|
14
|
+
9 => Date.new(2010,8,30)..Date.new(2010,9,26),
|
15
|
+
10 => Date.new(2010,9,27)..Date.new(2010,10,31),
|
16
|
+
11 => Date.new(2010,11,1)..Date.new(2010,11,28),
|
17
|
+
12 => Date.new(2010,11,29)..Date.new(2010,12,26) },
|
18
|
+
|
19
|
+
2011 =>
|
20
|
+
{ 1 => Date.new(2010,12,27)..Date.new(2011,1,30),
|
21
|
+
2 => Date.new(2011,1,31)..Date.new(2011,2,27),
|
22
|
+
3 => Date.new(2011,2,28)..Date.new(2011,3,27),
|
23
|
+
4 => Date.new(2011,3,28)..Date.new(2011,4,24),
|
24
|
+
5 => Date.new(2011,4,25)..Date.new(2011,5,29),
|
25
|
+
6 => Date.new(2011,5,30)..Date.new(2011,6,26),
|
26
|
+
7 => Date.new(2011,6,27)..Date.new(2011,7,31),
|
27
|
+
8 => Date.new(2011,8,1)..Date.new(2011,8,28),
|
28
|
+
9 => Date.new(2011,8,29)..Date.new(2011,9,25),
|
29
|
+
10 => Date.new(2011,9,26)..Date.new(2011,10,30),
|
30
|
+
11 => Date.new(2011,10,31)..Date.new(2011,11,27),
|
31
|
+
12 => Date.new(2011,11,28)..Date.new(2011,12,25) },
|
32
|
+
|
33
|
+
2012 =>
|
34
|
+
{ 1 => Date.new(2011,12,26)..Date.new(2012,1,29),
|
35
|
+
2 => Date.new(2012,1,30)..Date.new(2012,2,26),
|
36
|
+
3 => Date.new(2012,2,27)..Date.new(2012,3,25),
|
37
|
+
4 => Date.new(2012,3,26)..Date.new(2012,4,29),
|
38
|
+
5 => Date.new(2012,4,30)..Date.new(2012,5,27),
|
39
|
+
6 => Date.new(2012,5,28)..Date.new(2012,6,24),
|
40
|
+
7 => Date.new(2012,6,25)..Date.new(2012,7,29),
|
41
|
+
8 => Date.new(2012,7,30)..Date.new(2012,8,26),
|
42
|
+
9 => Date.new(2012,8,27)..Date.new(2012,9,30),
|
43
|
+
10 => Date.new(2012,10,1)..Date.new(2012,10,28),
|
44
|
+
11 => Date.new(2012,10,29)..Date.new(2012,11,25),
|
45
|
+
12 => Date.new(2012,11,26)..Date.new(2012,12,30) }
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
it "converts 2010 dates" do
|
50
|
+
dates.each do |year,months|
|
51
|
+
months.each do |month,range|
|
52
|
+
BroadcastCalendar.dates_for(month,year).should == range
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spork'
|
2
|
+
|
3
|
+
Spork.prefork do
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.mock_with :rspec
|
8
|
+
|
9
|
+
last_gc_run = Time.now
|
10
|
+
|
11
|
+
config.before(:each) do
|
12
|
+
GC.disable
|
13
|
+
end
|
14
|
+
|
15
|
+
config.after(:each) do
|
16
|
+
if Time.now - last_gc_run > 1.0
|
17
|
+
GC.enable
|
18
|
+
GC.start
|
19
|
+
last_gc_run = Time.now
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'rspec/expectations'
|
26
|
+
require 'rspec/core/expecting/with_rspec'
|
27
|
+
end
|
28
|
+
|
29
|
+
Spork.each_run do
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: broadcast_calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Subelsky
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-06-21 00:00:00.000000000 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: &2153156480 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2153156480
|
26
|
+
description: Library tht returns the beginning and ending Gregorian (civil) dates
|
27
|
+
for months in the broadcast calendar.
|
28
|
+
email: mike@subelsky.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rspec
|
36
|
+
- .rvmrc
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- Guardfile
|
40
|
+
- MIT-LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- broadcast_calendar.gemspec
|
44
|
+
- lib/broadcast_calendar.rb
|
45
|
+
- lib/broadcast_calendar/version.rb
|
46
|
+
- spec/broadcast_calendar_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/subelsky/broadcast_calendar
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --charset=UTF-8
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: eturns the beginning and ending Gregorian (civil) dates for months in the
|
75
|
+
broadcast calendar.
|
76
|
+
test_files:
|
77
|
+
- spec/broadcast_calendar_spec.rb
|
78
|
+
- spec/spec_helper.rb
|