network_executive 0.0.4 → 0.0.7
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/README.md +53 -24
- data/app/assets/fonts/network_executive/league_gothic.css +13 -0
- data/app/assets/fonts/network_executive/league_gothic.svg +148 -0
- data/app/assets/fonts/network_executive/league_gothic.ttf +0 -0
- data/app/assets/fonts/network_executive/league_gothic.woff +0 -0
- data/app/assets/javascripts/network_executive/components/iframe_notifier.coffee +14 -0
- data/app/assets/javascripts/network_executive/components/namespace.coffee +1 -0
- data/app/assets/javascripts/network_executive/components/osd.coffee +65 -0
- data/app/assets/javascripts/network_executive/components/photo_player.coffee +55 -0
- data/app/assets/javascripts/network_executive/components/postman.coffee +23 -0
- data/app/assets/javascripts/network_executive/components/set_top_box.coffee +81 -0
- data/app/assets/javascripts/network_executive/components/tweet_player.coffee +95 -0
- data/app/assets/javascripts/network_executive/components/you_tube_player.coffee +85 -0
- data/app/assets/javascripts/network_executive/slideshow.coffee +6 -0
- data/app/assets/javascripts/network_executive/twitter.coffee +7 -0
- data/app/assets/javascripts/network_executive/you_tube.coffee +8 -0
- data/app/assets/javascripts/network_executive.coffee +10 -0
- data/app/assets/stylesheets/network_executive/{gui_components.css → components/gui_components.css} +0 -0
- data/app/assets/stylesheets/network_executive/{normalize.css → components/normalize.css} +0 -0
- data/app/assets/stylesheets/network_executive/{osd.css → components/osd.css} +6 -34
- data/app/assets/stylesheets/network_executive/components/osd_guide.css +43 -0
- data/app/assets/stylesheets/network_executive/components/photo_player.css +61 -0
- data/app/assets/stylesheets/network_executive/{smpte.css → components/smpte.css} +0 -0
- data/app/assets/stylesheets/network_executive/components/tweet_player.css +60 -0
- data/app/assets/stylesheets/network_executive/components/you_tube_player.css +12 -0
- data/app/assets/stylesheets/network_executive/off_air.css +5 -0
- data/app/assets/stylesheets/network_executive/slideshow.css +4 -0
- data/app/assets/stylesheets/network_executive/twitter.css +5 -0
- data/app/assets/stylesheets/network_executive/you_tube.css +3 -0
- data/app/assets/stylesheets/{network_executive/application.css → network_executive.css} +5 -5
- data/app/controllers/network_executive/components_controller.rb +4 -0
- data/app/controllers/network_executive/guide_controller.rb +41 -0
- data/app/controllers/network_executive/programs_controller.rb +9 -0
- data/app/helpers/network_executive/network_helper.rb +6 -0
- data/app/models/network_executive/channel.rb +15 -14
- data/app/models/network_executive/guide.rb +65 -0
- data/app/models/network_executive/program.rb +69 -5
- data/app/models/network_executive/viewer.rb +4 -0
- data/app/programs/network_executive/off_air.rb +18 -0
- data/app/views/network_executive/components/slideshow.html.erb +20 -0
- data/app/views/network_executive/components/twitter.html.erb +16 -0
- data/app/views/network_executive/components/you_tube.html.erb +13 -0
- data/app/views/network_executive/guide/index.html.erb +30 -0
- data/app/views/network_executive/network/index.html.erb +3 -3
- data/app/views/network_executive/programs/off_air.html.erb +13 -0
- data/config/routes.rb +7 -1
- data/lib/network_executive/channel_schedule.rb +65 -0
- data/lib/network_executive/components/photo_player.rb +48 -0
- data/lib/network_executive/components/tweet_player.rb +48 -0
- data/lib/network_executive/components/you_tube_player.rb +15 -0
- data/lib/network_executive/components.rb +3 -0
- data/lib/network_executive/engine.rb +29 -3
- data/lib/network_executive/off_air_schedule.rb +18 -0
- data/lib/network_executive/producer.rb +3 -3
- data/lib/network_executive/program_schedule.rb +96 -0
- data/lib/network_executive/program_schedule_proxy.rb +55 -0
- data/lib/network_executive/scheduled_program.rb +26 -0
- data/lib/network_executive/scheduling.rb +15 -21
- data/lib/network_executive/time_calculations.rb +10 -0
- data/lib/network_executive/version.rb +1 -1
- data/lib/network_executive.rb +2 -1
- data/network_executive.gemspec +5 -0
- data/spec/models/channel_spec.rb +30 -12
- data/spec/models/{lineup_spec.rb → guide_spec.rb} +28 -6
- data/spec/models/program_spec.rb +46 -3
- data/spec/models/viewer_spec.rb +9 -1
- data/spec/programs/off_air_spec.rb +9 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/unit/channel_schedule_spec.rb +67 -0
- data/spec/unit/components/photo_player_spec.rb +76 -0
- data/spec/unit/components/tweet_player_spec.rb +68 -0
- data/spec/unit/components/you_tube_player_spec.rb +17 -0
- data/spec/unit/off_air_schedule_spec.rb +28 -0
- data/spec/unit/producer_spec.rb +2 -4
- data/spec/unit/program_schedule_proxy_spec.rb +102 -0
- data/spec/unit/program_schedule_spec.rb +191 -0
- data/spec/unit/scheduled_program_spec.rb +57 -0
- data/spec/unit/scheduling_spec.rb +61 -72
- data/vendor/assets/javascripts/bigtext.js +264 -0
- metadata +185 -44
- data/app/assets/javascripts/application.js +0 -13
- data/app/assets/javascripts/network_executive/osd.js +0 -62
- data/app/assets/javascripts/network_executive/set_top_box.js +0 -45
- data/app/controllers/network_executive/lineup_controller.rb +0 -11
- data/app/models/network_executive/channel_schedule.rb +0 -13
- data/app/models/network_executive/lineup.rb +0 -74
- data/app/models/network_executive/lineup_range.rb +0 -34
- data/app/models/network_executive/program_schedule.rb +0 -148
- data/app/views/network_executive/lineup/index.html.erb +0 -26
- data/spec/models/channel_schedule_spec.rb +0 -29
- data/spec/models/lineup_range_spec.rb +0 -65
- data/spec/models/program_schedule_spec.rb +0 -399
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# Example
|
|
2
|
-
# every :monday, play:'morning_show'
|
|
3
|
-
# every :day, play:'stoplight', for_the_first:'15mins', of:'each hour'
|
|
4
|
-
# every :day, play:'stoplight', for_the_first:'15mins', of:'each hour', starting_at:'11am'
|
|
5
|
-
# every :day, play:'stoplight', for_the_first:'15mins', of:'each hour', ending_at:'11am'
|
|
6
|
-
# every :day, play:'stoplight', for_the_first:'15mins', of:'each hour', starting_at:'10am', ending_at:'11am'
|
|
7
|
-
# every :day, play:'tweets', for_the_last: '15mins', of:'every hour'
|
|
8
|
-
# every :day, play:'sales', for_the_first:'15mins', of:'each hour', between:'2pm and 5pm'
|
|
9
|
-
# every :friday, play:'lunch_menu', between:'11am and 13pm', commercial_free:true
|
|
10
|
-
|
|
11
|
-
module NetworkExecutive
|
|
12
|
-
|
|
13
|
-
class ProgramSchedule
|
|
14
|
-
attr_accessor :day, :program_name
|
|
15
|
-
|
|
16
|
-
Weekdays = %w{sunday monday tuesday wednesday thursday friday saturday}
|
|
17
|
-
BaseDate = { month:2, day:15, year:1978 }
|
|
18
|
-
|
|
19
|
-
def initialize( day, options = {} )
|
|
20
|
-
options.symbolize_keys!
|
|
21
|
-
|
|
22
|
-
raise ProgramNameError unless options[:play]
|
|
23
|
-
|
|
24
|
-
if options[:starting_at] || options[:ending_at]
|
|
25
|
-
range = []
|
|
26
|
-
range << ( options[:starting_at] || '12am' )
|
|
27
|
-
range << ( options[:ending_at] || '11:59pm' )
|
|
28
|
-
options[:between] = range.join ' and '
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
self.day = day
|
|
32
|
-
self.program_name = options[:play]
|
|
33
|
-
@between = options[:between]
|
|
34
|
-
@for_the_first = options[:for_the_first]
|
|
35
|
-
@for_the_last = options[:for_the_last]
|
|
36
|
-
@period = options[:of]
|
|
37
|
-
@commercial_free = options[:commercial_free]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def day=( new_day )
|
|
41
|
-
new_day = :any if new_day == :day
|
|
42
|
-
|
|
43
|
-
@day = new_day
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def include?( date )
|
|
47
|
-
day_matches? date \
|
|
48
|
-
and time_matches? date
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def commercials?
|
|
52
|
-
@commercial_free.nil? ? true : !@commercial_free
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def to_s
|
|
56
|
-
inspect
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def inspect
|
|
60
|
-
range = @between || '12am and 11:59pm'
|
|
61
|
-
|
|
62
|
-
%Q{<#{self.class} program_name="#{program_name}" day="#{@day}" between="#{range}" for_the_first="#{@for_the_first || 'nil'}" for_the_last="#{@for_the_last || 'nil'}" commercial_free=#{!commercials?}>}
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
private
|
|
66
|
-
|
|
67
|
-
def day_matches?( date )
|
|
68
|
-
if day == :any
|
|
69
|
-
true
|
|
70
|
-
elsif day.to_s == Weekdays[date.wday]
|
|
71
|
-
true
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def time_matches?( date )
|
|
76
|
-
comparator = date.dup.change BaseDate
|
|
77
|
-
|
|
78
|
-
validations = []
|
|
79
|
-
|
|
80
|
-
validations << time_span.cover?( comparator ) if time_span?
|
|
81
|
-
|
|
82
|
-
validations << pattern.cover?( comparator ) if repeating?
|
|
83
|
-
|
|
84
|
-
validations.none? { |v| v == false }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def time_span?
|
|
88
|
-
@between
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def time_span
|
|
92
|
-
if matches = @between.match( %r{(?<start>\d+:?\w*)\s*\S+\s*(?<stop>\d+:?\w*)} )
|
|
93
|
-
# Normalize the range to an arbitrary date since we only care about Time.
|
|
94
|
-
start = Time.parse( matches[:start] ).change BaseDate
|
|
95
|
-
stop = Time.parse( matches[:stop] ).change BaseDate
|
|
96
|
-
|
|
97
|
-
start...stop
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def repeating?
|
|
102
|
-
@for_the_first || @for_the_last
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def pattern
|
|
106
|
-
return TimePattern.new @period, first:@for_the_first if @for_the_first
|
|
107
|
-
return TimePattern.new @period, last:@for_the_last if @for_the_last
|
|
108
|
-
|
|
109
|
-
raise StandardError, 'No parsable time pattern'
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
class TimePattern
|
|
115
|
-
# TODO: Add support for :period
|
|
116
|
-
def initialize( period, pattern )
|
|
117
|
-
@period = period
|
|
118
|
-
@boundary = pattern.keys.first
|
|
119
|
-
@pattern = parse pattern
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def cover?( date )
|
|
123
|
-
range = if @boundary == :first
|
|
124
|
-
0...@pattern[:value]
|
|
125
|
-
elsif @boundary == :last
|
|
126
|
-
(60 - @pattern[:value])..59
|
|
127
|
-
else
|
|
128
|
-
raise ArgumentError, 'Missing a valid pattern boundary'
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
range.include? date.send( @pattern[:unit] )
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
private
|
|
135
|
-
|
|
136
|
-
def parse( p )
|
|
137
|
-
value, unit = p[@boundary].split( %r{(\d+)\s*(\w+)} )[1..-1]
|
|
138
|
-
|
|
139
|
-
unit = case unit[0]
|
|
140
|
-
when 'm' then :min
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
{ value:value.to_i, unit:unit }
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<table>
|
|
2
|
-
<thead>
|
|
3
|
-
<tr>
|
|
4
|
-
<td></td>
|
|
5
|
-
<% @lineup.times.each do |t| %>
|
|
6
|
-
<th class="guide-time">
|
|
7
|
-
<%= t.strftime '%l:%M' %>
|
|
8
|
-
</th>
|
|
9
|
-
<% end %>
|
|
10
|
-
</tr>
|
|
11
|
-
</thead>
|
|
12
|
-
<tbody>
|
|
13
|
-
<% @lineup[:channels].each do |ch| %>
|
|
14
|
-
<tr>
|
|
15
|
-
<th class="guide-channel">
|
|
16
|
-
<%= link_to ch[:channel], channel_path(ch[:channel]) %>
|
|
17
|
-
</th>
|
|
18
|
-
<% ch[:schedule].each do |sch| %>
|
|
19
|
-
<td class="guide-program">
|
|
20
|
-
<%= sch[:program].program_name.titleize %>
|
|
21
|
-
</td>
|
|
22
|
-
<% end %>
|
|
23
|
-
</tr>
|
|
24
|
-
<% end %>
|
|
25
|
-
</tbody>
|
|
26
|
-
</table>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
describe NetworkExecutive::ChannelSchedule do
|
|
2
|
-
|
|
3
|
-
before do
|
|
4
|
-
Timecop.freeze Time.now.change hour:12, min:0, sec:0
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
subject do
|
|
8
|
-
schedule = double('schedule')
|
|
9
|
-
|
|
10
|
-
schedule.stub(:include?).and_return false, true, false
|
|
11
|
-
|
|
12
|
-
described_class.new [ schedule, schedule, schedule ]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe '#add' do
|
|
16
|
-
before { subject.add( 'foo' ) }
|
|
17
|
-
|
|
18
|
-
it 'should prefix the collection' do
|
|
19
|
-
subject.first.should == 'foo'
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe '#find_by_showtime' do
|
|
24
|
-
it 'should check if the schedule includes the given time' do
|
|
25
|
-
subject.find_by_showtime( Time.now ).should == subject[1]
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
describe NetworkExecutive::LineupRange do
|
|
2
|
-
|
|
3
|
-
before do
|
|
4
|
-
Timecop.freeze Time.now.change hour:12, min:0, sec:0
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
let(:start) { Time.now }
|
|
8
|
-
|
|
9
|
-
let(:stop) { 1.5.hours.from_now }
|
|
10
|
-
|
|
11
|
-
describe '#each' do
|
|
12
|
-
subject do
|
|
13
|
-
times = []
|
|
14
|
-
|
|
15
|
-
described_class.new(start, stop).each { |st| times << st }
|
|
16
|
-
|
|
17
|
-
times
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should yield a showtime for each segment' do
|
|
21
|
-
subject.size.should == 6
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'should yield the start time' do
|
|
25
|
-
subject.first.should == start
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'should yield a rounded stop time' do
|
|
29
|
-
subject.last.should == stop - 15.minutes
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe '#each_with_object' do
|
|
34
|
-
subject do
|
|
35
|
-
my_obj = []
|
|
36
|
-
|
|
37
|
-
described_class.new( start, stop ).each_with_object( my_obj ) do |st, o|
|
|
38
|
-
o << st
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
my_obj
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'should yield the specified object for each segment' do
|
|
45
|
-
subject.size.should == 6
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
describe '#segments' do
|
|
50
|
-
subject { described_class.new( start, stop, interval:interval).segments }
|
|
51
|
-
|
|
52
|
-
context 'with a default interval' do
|
|
53
|
-
let(:interval) { nil }
|
|
54
|
-
|
|
55
|
-
it { should == 6 }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context 'with a half-hour interval' do
|
|
59
|
-
let(:interval) { 30 }
|
|
60
|
-
|
|
61
|
-
it { should == 3 }
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
end
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
describe NetworkExecutive::ProgramSchedule do
|
|
2
|
-
|
|
3
|
-
describe 'without a program name' do
|
|
4
|
-
it 'should raise a ProgramNameError' do
|
|
5
|
-
expect{ described_class.new(:day) }.to raise_error NetworkExecutive::ProgramNameError
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe 'a 24-7 program' do
|
|
10
|
-
subject { described_class.new(:day, play:'my_show') }
|
|
11
|
-
|
|
12
|
-
its(:commercials?) { should be_true }
|
|
13
|
-
|
|
14
|
-
it 'should run at the beginning of the day' do
|
|
15
|
-
Timecop.freeze Time.now.beginning_of_day
|
|
16
|
-
|
|
17
|
-
subject.should include Time.now
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'should run at the middle of the day' do
|
|
21
|
-
Timecop.freeze Time.now.change hours:12
|
|
22
|
-
|
|
23
|
-
subject.should include Time.now
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'should run at the end of the day' do
|
|
27
|
-
Timecop.freeze Time.now.end_of_day
|
|
28
|
-
|
|
29
|
-
subject.should include Time.now
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe 'a weekly, 24-hour program' do
|
|
34
|
-
subject { described_class.new(:thursday, play:'my_show') }
|
|
35
|
-
|
|
36
|
-
it 'should run at the beginning of Thursday' do
|
|
37
|
-
Timecop.freeze Time.now.beginning_of_week + 3.days
|
|
38
|
-
|
|
39
|
-
subject.should include Time.now
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should run at the middle of Thursday' do
|
|
43
|
-
Timecop.freeze( (Time.now.beginning_of_week + 3.days).change hour:12 )
|
|
44
|
-
|
|
45
|
-
subject.should include Time.now
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'should run at the end of Thursday' do
|
|
49
|
-
Timecop.freeze Time.now.end_of_week - 3.days
|
|
50
|
-
|
|
51
|
-
subject.should include Time.now
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'should not run on Monday' do
|
|
55
|
-
Timecop.freeze Time.now.beginning_of_week
|
|
56
|
-
|
|
57
|
-
subject.should_not include Time.now
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe 'a show between 11am and 1pm' do
|
|
62
|
-
describe 'continuously' do
|
|
63
|
-
subject { described_class.new(:day, play:'my_show', between:'11am and 1pm') }
|
|
64
|
-
|
|
65
|
-
it 'should run at 11am' do
|
|
66
|
-
Timecop.freeze Time.now.change hour:11, min:0, sec:0
|
|
67
|
-
|
|
68
|
-
subject.should include Time.now
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'should run at 12pm' do
|
|
72
|
-
Timecop.freeze Time.now.change hour:12
|
|
73
|
-
|
|
74
|
-
subject.should include Time.now
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'should run at 12:59:59pm' do
|
|
78
|
-
Timecop.freeze Time.now.change hour:12, min:59, sec:59
|
|
79
|
-
|
|
80
|
-
subject.should include Time.now
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'should not run at 1pm' do
|
|
84
|
-
Timecop.freeze Time.now.change hour:13
|
|
85
|
-
|
|
86
|
-
subject.should_not include Time.now
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'should not run before 11am' do
|
|
90
|
-
Timecop.freeze Time.now.change hour:10, min:59, sec:59
|
|
91
|
-
|
|
92
|
-
subject.should_not include Time.now
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'should not run after 1pm' do
|
|
96
|
-
Timecop.freeze Time.now.change hour:13, min:0, sec:1
|
|
97
|
-
|
|
98
|
-
subject.should_not include Time.now
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
describe 'for the first 20mins of each hour' do
|
|
103
|
-
subject { described_class.new(:day, play:'my_show', between:'11am and 1pm', for_the_first: '20mins', of:'each hour') }
|
|
104
|
-
|
|
105
|
-
it 'should run at 11am' do
|
|
106
|
-
Timecop.freeze Time.now.change hour:11, min:0, sec:0
|
|
107
|
-
|
|
108
|
-
subject.should include Time.now
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it 'should run at 11:19:59am' do
|
|
112
|
-
Timecop.freeze Time.now.change hour:11, min:19, sec:59
|
|
113
|
-
|
|
114
|
-
subject.should include Time.now
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'should not run at 11:20pm' do
|
|
118
|
-
Timecop.freeze Time.now.change hour:11, min:20, sec:0
|
|
119
|
-
|
|
120
|
-
subject.should_not include Time.now
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it 'should run at 12pm' do
|
|
124
|
-
Timecop.freeze Time.now.change hour:12, min:0, sec:0
|
|
125
|
-
|
|
126
|
-
subject.should include Time.now
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it 'should run at 12:19:59am' do
|
|
130
|
-
Timecop.freeze Time.now.change hour:12, min:19, sec:59
|
|
131
|
-
|
|
132
|
-
subject.should include Time.now
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it 'should not run at 12:20pm' do
|
|
136
|
-
Timecop.freeze Time.now.change hour:12, min:20, sec:0
|
|
137
|
-
|
|
138
|
-
subject.should_not include Time.now
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
describe 'the last 20mins of each hour' do
|
|
143
|
-
subject { described_class.new(:day, play:'my_show', between:'11am and 1pm', for_the_last: '20mins', of:'each hour') }
|
|
144
|
-
|
|
145
|
-
it 'should not run at 11am' do
|
|
146
|
-
Timecop.freeze Time.now.change hour:11, min:0, sec:0
|
|
147
|
-
|
|
148
|
-
subject.should_not include Time.now
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'should run at 11:40am' do
|
|
152
|
-
Timecop.freeze Time.now.change hour:11, min:40, sec:0
|
|
153
|
-
|
|
154
|
-
subject.should include Time.now
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it 'should run at 11:59:59am' do
|
|
158
|
-
Timecop.freeze Time.now.change hour:11, min:59, sec:59
|
|
159
|
-
|
|
160
|
-
subject.should include Time.now
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it 'should not run at 12pm' do
|
|
164
|
-
Timecop.freeze Time.now.change hour:12, min:0, sec:0
|
|
165
|
-
|
|
166
|
-
subject.should_not include Time.now
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it 'should run at 12:40pm' do
|
|
170
|
-
Timecop.freeze Time.now.change hour:12, min:40, sec:0
|
|
171
|
-
|
|
172
|
-
subject.should include Time.now
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'should not run at 12:59:59pm' do
|
|
176
|
-
Timecop.freeze Time.now.change hour:12, min:59, sec:59
|
|
177
|
-
|
|
178
|
-
subject.should include Time.now
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
it 'should not run at 1pm' do
|
|
182
|
-
Timecop.freeze Time.now.change hour:13, min:0, sec:0
|
|
183
|
-
|
|
184
|
-
subject.should_not include Time.now
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
describe 'a show that runs for' do
|
|
190
|
-
describe 'the first' do
|
|
191
|
-
describe '15mins' do
|
|
192
|
-
describe 'of each hour' do
|
|
193
|
-
describe 'continuously' do
|
|
194
|
-
subject { described_class.new(:day, play:'my_show', for_the_first:'15mins', of:'each hour') }
|
|
195
|
-
|
|
196
|
-
it 'should not run at 12:59:59am' do
|
|
197
|
-
Timecop.freeze Time.now.change hour:12, min:59, sec:59
|
|
198
|
-
|
|
199
|
-
subject.should_not include Time.now
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it 'should run at 1:00am' do
|
|
203
|
-
Timecop.freeze Time.now.change hour:1, min:0, sec:0
|
|
204
|
-
|
|
205
|
-
subject.should include Time.now
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it 'should run at 1:14:59am' do
|
|
209
|
-
Timecop.freeze Time.now.change hour:1, min:14, sec:59
|
|
210
|
-
|
|
211
|
-
subject.should include Time.now
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it 'should not run at 1:15am' do
|
|
215
|
-
Timecop.freeze Time.now.change hour:1, min:15, sec:0
|
|
216
|
-
|
|
217
|
-
subject.should_not include Time.now
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
describe 'starting at 2pm' do
|
|
222
|
-
subject { described_class.new(:day, play:'my_show', for_the_first:'15mins', of:'each hour', starting_at:'2pm') }
|
|
223
|
-
|
|
224
|
-
it 'should not run at 1pm' do
|
|
225
|
-
Timecop.freeze Time.now.change hour:13, min:0, sec:0
|
|
226
|
-
|
|
227
|
-
subject.should_not include Time.now
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
it 'should run at 2pm' do
|
|
231
|
-
Timecop.freeze Time.now.change hour:14, min:0, sec:0
|
|
232
|
-
|
|
233
|
-
subject.should include Time.now
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it 'should run at 2:14:59pm' do
|
|
237
|
-
Timecop.freeze Time.now.change hour:14, min:14, sec:59
|
|
238
|
-
|
|
239
|
-
subject.should include Time.now
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it 'should not run at 2:15pm' do
|
|
243
|
-
Timecop.freeze Time.now.change hour:14, min:15, sec:0
|
|
244
|
-
|
|
245
|
-
subject.should_not include Time.now
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
it 'should not run at 10:59:59pm' do
|
|
249
|
-
Timecop.freeze Time.now.change hour:22, min:59, sec:59
|
|
250
|
-
|
|
251
|
-
subject.should_not include Time.now
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it 'should run at 11pm' do
|
|
255
|
-
Timecop.freeze Time.now.change hour:23, min:0, sec:0
|
|
256
|
-
|
|
257
|
-
subject.should include Time.now
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
it 'should not run at 11:15pm' do
|
|
261
|
-
Timecop.freeze Time.now.change hour:23, min:15, sec:0
|
|
262
|
-
|
|
263
|
-
subject.should_not include Time.now
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
describe 'ending at 2pm' do
|
|
268
|
-
subject { described_class.new(:day, play:'my_show', for_the_first:'15mins', of:'each hour', ending_at:'2pm') }
|
|
269
|
-
|
|
270
|
-
it 'should run at 12am' do
|
|
271
|
-
Timecop.freeze Time.now.change hour:0, min:0, sec:0
|
|
272
|
-
|
|
273
|
-
subject.should include Time.now
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
it 'should run at 12:14:59am' do
|
|
277
|
-
Timecop.freeze Time.now.change hour:0, min:14, sec:59
|
|
278
|
-
|
|
279
|
-
subject.should include Time.now
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
it 'should not run at 12:15am' do
|
|
283
|
-
Timecop.freeze Time.now.change hour:0, min:15, sec:0
|
|
284
|
-
|
|
285
|
-
subject.should_not include Time.now
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
it 'should run at 1am' do
|
|
289
|
-
Timecop.freeze Time.now.change hour:1, min:0, sec:0
|
|
290
|
-
|
|
291
|
-
subject.should include Time.now
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
it 'should not run at 2pm' do
|
|
295
|
-
Timecop.freeze Time.now.change hour:14, min:0, sec:0
|
|
296
|
-
|
|
297
|
-
subject.should_not include Time.now
|
|
298
|
-
end
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
describe 'of every hour' do
|
|
303
|
-
subject { described_class.new(:day, play:'my_show', for_the_first:'15mins', of:'every hour') }
|
|
304
|
-
|
|
305
|
-
it 'should not run at 12:59:59am' do
|
|
306
|
-
Timecop.freeze Time.now.change hour:12, min:59, sec:59
|
|
307
|
-
|
|
308
|
-
subject.should_not include Time.now
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
it 'should run at 1:00am' do
|
|
312
|
-
Timecop.freeze Time.now.change hour:1, min:0, sec:0
|
|
313
|
-
|
|
314
|
-
subject.should include Time.now
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
it 'should run at 1:14:59am' do
|
|
318
|
-
Timecop.freeze Time.now.change hour:1, min:14, sec:59
|
|
319
|
-
|
|
320
|
-
subject.should include Time.now
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
it 'should not run at 1:15am' do
|
|
324
|
-
Timecop.freeze Time.now.change hour:1, min:15, sec:0
|
|
325
|
-
|
|
326
|
-
subject.should_not include Time.now
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
describe 'the last' do
|
|
333
|
-
describe '15mins' do
|
|
334
|
-
describe 'of each hour' do
|
|
335
|
-
subject { described_class.new(:day, play:'my_show', for_the_last:'15mins', of:'each hour') }
|
|
336
|
-
|
|
337
|
-
it 'should not run at 1:44:59am' do
|
|
338
|
-
Timecop.freeze Time.now.change hour:1, min:44, sec:59
|
|
339
|
-
|
|
340
|
-
subject.should_not include Time.now
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
it 'should run at 1:45am' do
|
|
344
|
-
Timecop.freeze Time.now.change hour:1, min:45, sec:0
|
|
345
|
-
|
|
346
|
-
subject.should include Time.now
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
it 'should run at 1:59:59am' do
|
|
350
|
-
Timecop.freeze Time.now.change hour:1, min:59, sec:59
|
|
351
|
-
|
|
352
|
-
subject.should include Time.now
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
it 'should not run at 2am' do
|
|
356
|
-
Timecop.freeze Time.now.change hour:2, min:0, sec:0
|
|
357
|
-
|
|
358
|
-
subject.should_not include Time.now
|
|
359
|
-
end
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
describe 'of every hour' do
|
|
363
|
-
subject { described_class.new(:day, play:'my_show', for_the_last:'15mins', of:'every hour') }
|
|
364
|
-
|
|
365
|
-
it 'should not run at 1:44:59am' do
|
|
366
|
-
Timecop.freeze Time.now.change hour:1, min:44, sec:59
|
|
367
|
-
|
|
368
|
-
subject.should_not include Time.now
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
it 'should run at 1:45am' do
|
|
372
|
-
Timecop.freeze Time.now.change hour:1, min:45, sec:0
|
|
373
|
-
|
|
374
|
-
subject.should include Time.now
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
it 'should run at 1:59:59am' do
|
|
378
|
-
Timecop.freeze Time.now.change hour:1, min:59, sec:59
|
|
379
|
-
|
|
380
|
-
subject.should include Time.now
|
|
381
|
-
end
|
|
382
|
-
|
|
383
|
-
it 'should not run at 2am' do
|
|
384
|
-
Timecop.freeze Time.now.change hour:2, min:0, sec:0
|
|
385
|
-
|
|
386
|
-
subject.should_not include Time.now
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
end
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
describe 'a commercial-free show' do
|
|
394
|
-
subject { described_class.new(:day, play:'my_show', commercial_free:true) }
|
|
395
|
-
|
|
396
|
-
its(:commercials?) { should be_false }
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
end
|