scheduled_resource 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/time_pix.js.coffee +20 -2
- data/lib/scheduled_resource.rb +65 -164
- data/lib/scheduled_resource/config.rb +115 -0
- data/lib/scheduled_resource/helper.rb +12 -13
- data/lib/scheduled_resource/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea444d3e4889204a4908f8551a04f106a3f44790
|
4
|
+
data.tar.gz: b6291de573f780226d71b4f815d32214b7df5eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd239e9b46dd9bf90b8bd287ab8247b78b2f125a78e0a92bbdc34a5cf3522b3875fc7d2518c608c7026e19eea8951c779b1a8a5b5e20046228ceb47e78198332
|
7
|
+
data.tar.gz: e75af2e6464b0ee799c8f5a64582c9fff89357196ad535227877c5a8777f5f4346595e8bbb8bbd93477cb7f4e7d5ea7a6ee2ec92843c76a7b8c3c7d7a699a1df
|
@@ -9,6 +9,9 @@ class @TimePix # Ultimately, an angular $service
|
|
9
9
|
$('#scrollbar-hider').css('width', @pixWindow + 61 + 'px' )
|
10
10
|
|
11
11
|
|
12
|
+
##############################################################################
|
13
|
+
# 'meta' part of latest returned json + overall display data
|
14
|
+
#
|
12
15
|
@baseTime: 0
|
13
16
|
@timeWindow: (3 * 3600)
|
14
17
|
@pixWindow: 750 # Matching width of #scrolling-container
|
@@ -27,6 +30,7 @@ class @TimePix # Ultimately, an angular $service
|
|
27
30
|
@thi = @thi && Math.max( @thi, @meta.t2 ) || @meta.t2
|
28
31
|
@inc = @meta.inc
|
29
32
|
@timeWindow = @meta.visible_time if @meta.visible_time
|
33
|
+
##############################################################################
|
30
34
|
|
31
35
|
@next_hi: -> @thi + @timeWindow
|
32
36
|
@next_lo: -> @tlo - @timeWindow
|
@@ -44,6 +48,12 @@ class @TimePix # Ultimately, an angular $service
|
|
44
48
|
"left: #{@secs_to_pix_scale(s - @baseTime)}px; " +
|
45
49
|
"width: #{@secs_to_pix_scale(e-s)-4}px;"
|
46
50
|
|
51
|
+
# Reactjs prefers this variant
|
52
|
+
@style_geo_hash: (block) ->
|
53
|
+
[s, e] = [block.starttime, block.endtime] # per margins V
|
54
|
+
left: "#{@secs_to_pix_scale(s - @baseTime)}px"
|
55
|
+
width: "#{@secs_to_pix_scale(e-s)-4}px"
|
56
|
+
|
47
57
|
@row_kind: (tag) -> # may/may not belong here.
|
48
58
|
tag.split('_')[0]
|
49
59
|
|
@@ -91,9 +101,9 @@ class @TimePix # Ultimately, an angular $service
|
|
91
101
|
r_vis_time = l_vis_time + @timeWindow
|
92
102
|
|
93
103
|
if r_vis_time > @thi
|
94
|
-
|
104
|
+
@expand_data 'more_data'
|
95
105
|
else if l_vis_time < @tlo
|
96
|
-
|
106
|
+
@expand_data 'less_data'
|
97
107
|
else
|
98
108
|
if new Date() - @scroll_monitor.scroll_timestamp > 1000
|
99
109
|
filter_justify_tweaks( sc ) # Try to make scrolled-off content visible
|
@@ -101,3 +111,11 @@ class @TimePix # Ultimately, an angular $service
|
|
101
111
|
|
102
112
|
setTimeout @scroll_monitor, 100
|
103
113
|
|
114
|
+
|
115
|
+
# Angular-vs-react issues
|
116
|
+
@expand_data: (method_name) ->
|
117
|
+
if TopResourceSchedule?
|
118
|
+
TopResourceSchedule[method_name]()
|
119
|
+
else
|
120
|
+
RsrcListCtrlScope.$apply RsrcListCtrlScope[method_name]
|
121
|
+
return
|
data/lib/scheduled_resource.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
require 'scheduled_resource/version'
|
8
8
|
require 'scheduled_resource/resource_use_block'
|
9
9
|
require 'scheduled_resource/helper'
|
10
|
+
require 'scheduled_resource/config'
|
10
11
|
|
11
12
|
require 'z_time_header'
|
12
13
|
require 'z_time_header_day'
|
@@ -24,7 +25,7 @@ require 'z_time_label_hour'
|
|
24
25
|
# schedule. An instance ties together:
|
25
26
|
#
|
26
27
|
# 1. A resource class (eg Room),
|
27
|
-
# 2. An id, and
|
28
|
+
# 2. An id (string), and
|
28
29
|
# 3. Strings / html snippets (eg, label, title) for the DOM.
|
29
30
|
#
|
30
31
|
# The id (2 above) is used to
|
@@ -41,15 +42,7 @@ require 'z_time_label_hour'
|
|
41
42
|
#
|
42
43
|
# Items 1 and 2 are are combined (with a '_') to form "tags" (ids) for the DOM.
|
43
44
|
#
|
44
|
-
# See also: ResourceUseBlock.
|
45
|
-
#
|
46
|
-
#--
|
47
|
-
# Config is loaded from config/schedule.yml:
|
48
|
-
# all_resources:: Resources in display order.
|
49
|
-
# rsrcs_by_kind:: A hash with resources grouped by kind (resource class).
|
50
|
-
# rsrc_of_tag:: Indexed by text tag: kind_subid.
|
51
|
-
# \visible_time:: Span of time window.
|
52
|
-
#++
|
45
|
+
# See also: ResourceUseBlock, Config.
|
53
46
|
#
|
54
47
|
# When queried with an array of ids and a time interval, the class
|
55
48
|
# method <tt>get_all_blocks(ids, t1, t2)</tt> of a <em>resource use</em>
|
@@ -63,172 +56,84 @@ require 'z_time_label_hour'
|
|
63
56
|
#
|
64
57
|
class ScheduledResource
|
65
58
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
59
|
+
class_attribute :rsrc_of_tag
|
60
|
+
self.rsrc_of_tag = {}
|
61
|
+
|
62
|
+
class << self
|
63
|
+
# (ScheduledResource protocol) Returns a hash where each key is an
|
64
|
+
# <tt>rid</tt> and the value is an array of resource use
|
65
|
+
# blocks in the interval <tt>t1...t2</tt>, ordered by
|
66
|
+
# <tt>starttime</tt>.
|
67
|
+
#
|
68
|
+
# What <em>in</em> means depends on <em>inc</em>. If inc(remental) is
|
69
|
+
# false, the client is building the interval from scratch. If "hi", it is
|
70
|
+
# an addition to an existing interval on the high side. Similarly
|
71
|
+
# for "lo". This is to avoid re-transmitting blocks that span the
|
72
|
+
# current time boundaries on the client.
|
73
|
+
#
|
74
|
+
# Here the resource is a channel and the use blocks are programs.
|
75
|
+
#
|
76
|
+
# ==== Parameters
|
77
|
+
# * <tt>config</tt> - A configuration instance.
|
78
|
+
# * <tt>t1</tt> - Start time.
|
79
|
+
# * <tt>t2</tt> - End time.
|
80
|
+
# * <tt>inc</tt> - One of nil, "lo", "hi" (See above).
|
81
|
+
#
|
82
|
+
# ==== Returns
|
83
|
+
# * <tt>Hash</tt> - Each key is an <tt>rid</tt>; value is a list of blocks.
|
84
|
+
def get_all_blocks(config, t1, t2, inc)
|
85
|
+
blockss = {}
|
86
|
+
|
87
|
+
config.rsrcs_by_kind.each do |kind, rsrcs|
|
88
|
+
rub_class = config.block_class_for_resource_name kind
|
89
|
+
rids = rsrcs.map{ |r| r.sub_id }
|
90
|
+
ru_blkss = rub_class.get_all_blocks rids, t1, t2, inc
|
91
|
+
|
92
|
+
add_rubs_of_kind kind, ru_blkss, blockss
|
93
|
+
end
|
98
94
|
|
99
|
-
|
95
|
+
blockss
|
100
96
|
end
|
101
97
|
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
# ==== Parameters
|
107
|
-
# * <tt>name</tt> - The class name (string) of a schedule resource.
|
108
|
-
#
|
109
|
-
# ==== Returns
|
110
|
-
# * <tt>Class</tt> - The class representing the <em>use</em> of that resource for an interval of time.
|
111
|
-
def self.block_class_for_resource_name( name )
|
112
|
-
config[:block_class_for_resource_kind][name].constantize
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
# ==== Returns
|
117
|
-
# * <tt>Array[ScheduledResource]</tt> - List of configured ScheduledResources.
|
118
|
-
def self.resource_list; config[:all_resources] end
|
119
|
-
|
120
|
-
# ==== Returns
|
121
|
-
# * <tt>Time</tt> - The configured width of the visible time window.
|
122
|
-
def self.visible_time; config[:visible_time] end
|
123
|
-
|
124
|
-
|
125
|
-
#--
|
126
|
-
# Restore configuration from session.
|
127
|
-
#
|
128
|
-
# When we depend on data in the configuration to satisfy a query we are not
|
129
|
-
# being RESTful. On the other hand we are not maintaining changeable state
|
130
|
-
# here -- it's just a cache. If there <em>were</em> changeable state it
|
131
|
-
# would likely be kept, eg, in a per-user table in the database.
|
132
|
-
#++
|
133
|
-
def self.ensure_config( session ) # :nodoc:
|
134
|
-
return if (self.config ||= session[:schedule_config])
|
135
|
-
|
136
|
-
config_from_yaml( session )
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
# ToDo: Generalize this so configuration can be loaded on per-user.
|
141
|
-
# Process configuration file.
|
142
|
-
def self.config_from_yaml( session )
|
143
|
-
config_from_yaml1
|
144
|
-
config_from_yaml2 session
|
145
|
-
config
|
146
|
-
end
|
147
|
-
|
98
|
+
def compose_tag( kind, sub_id ); "#{kind}_#{sub_id}" end
|
148
99
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
# * <tt>kind</tt> - Class name (string) of a scheduled resource.
|
154
|
-
# * <tt>sub_id</tt> - Id (string), selecting a resource instance. The two are combined and used as a unique tag in the DOM as id and class attributes as well as in server code.
|
155
|
-
def self.get_for( kind, sub_id )
|
156
|
-
tag = compose_tag( kind, sub_id )
|
157
|
-
config[:rsrc_of_tag][ tag ] || self.new( kind, sub_id )
|
158
|
-
end
|
159
|
-
|
160
|
-
def self.compose_tag( kind, sub_id ); "#{kind}_#{sub_id}" end
|
100
|
+
def make_resource_of_kind( klass, rid )
|
101
|
+
klass = klass.constantize if klass.is_a? String # ToDo: Trim this.
|
102
|
+
get_for( klass.name, rid )
|
103
|
+
end
|
161
104
|
|
162
|
-
def self.config_from_yaml1()
|
163
|
-
self.config = { all_resources: [],
|
164
|
-
rsrc_of_tag: {},
|
165
|
-
block_class_for_resource_kind: {}
|
166
|
-
}
|
167
|
-
yml = YAML.load_file CONFIG_FILE
|
168
105
|
|
169
|
-
|
170
|
-
|
106
|
+
private
|
107
|
+
# A caching one-of-each-sort constructor.
|
108
|
+
#
|
109
|
+
# ==== Parameters
|
110
|
+
# * <tt>kind</tt> - Class name (string) of a scheduled resource.
|
111
|
+
# * <tt>rid</tt> - Id (string), selecting a resource instance. The two are combined and used as a unique tag in the DOM as id and class attributes as well as in server code.
|
112
|
+
def get_for( kind, rid )
|
113
|
+
tag = compose_tag( kind, rid )
|
114
|
+
# config[:rsrc_of_tag][ tag ] || self.new( kind, rid )
|
115
|
+
rsrc_of_tag[ tag ] || new( kind, rid )
|
171
116
|
end
|
172
117
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
118
|
+
def add_rubs_of_kind( kind, ru_blkss, blockss )
|
119
|
+
ru_blkss.each do |rid, blks|
|
120
|
+
rsrc = get_for( kind, rid )
|
121
|
+
rubs = blks.map{ |blk| ResourceUseBlock.new rsrc, blk }
|
122
|
+
blockss[ rsrc ] = rubs
|
178
123
|
end
|
179
124
|
end
|
180
125
|
|
181
|
-
vt = yml['visibleTime']
|
182
|
-
config[:visible_time] = vt ? (eval vt) : 3.hours
|
183
|
-
|
184
|
-
t0 = yml['timeRangeMin']
|
185
|
-
config[:time_range_min] = t0 ? (eval t0) : (Time.now - 1.week)
|
186
|
-
|
187
|
-
tn = yml['timeRangeMax']
|
188
|
-
config[:time_range_max] = tn ? (eval tn) : (Time.now + 1.week)
|
189
|
-
|
190
|
-
config
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
def self.add_resources(rsrcs)
|
195
|
-
rs = config[:all_resources]
|
196
|
-
rsrcs.each{ |rsrc| rs.include?( rsrc ) || rs << rsrc }
|
197
|
-
end
|
198
|
-
|
199
|
-
|
200
|
-
def self.config_from_yaml2( session )
|
201
|
-
config[:rsrcs_by_kind] = resource_list.group_by{ |r| r.kind }
|
202
|
-
|
203
|
-
config[:rsrcs_by_kind].each do |kind, rsrcs|
|
204
|
-
klass = kind.constantize
|
205
|
-
rsrcs.each {|rsrc| klass.decorate_resource rsrc }
|
206
|
-
end
|
207
|
-
|
208
|
-
session[:schedule_config] = config
|
209
|
-
end
|
210
|
-
|
211
|
-
def self.make_resource_of_kind( klass, rid )
|
212
|
-
klass = eval klass if klass.class == String
|
213
|
-
get_for( klass.name, rid )
|
214
|
-
end
|
215
|
-
|
216
|
-
def self.add_rubs_of_kind( kind, ru_blkss, blockss )
|
217
|
-
ru_blkss.each do |rid, blks|
|
218
|
-
rsrc = get_for( kind, rid )
|
219
|
-
rubs = blks.map{ |blk| ResourceUseBlock.new rsrc, blk }
|
220
|
-
blockss[ rsrc ] = rubs
|
221
|
-
end
|
222
126
|
end
|
223
127
|
|
224
128
|
|
225
129
|
public
|
226
130
|
|
227
131
|
# Instance methods
|
228
|
-
def initialize( kind,
|
229
|
-
@tag = self.class.send( :compose_tag, kind,
|
132
|
+
def initialize( kind, rid ) # :nodoc:
|
133
|
+
# @tag = self.class.send( :compose_tag, kind, rid )
|
134
|
+
@tag = self.class.compose_tag( kind, rid )
|
230
135
|
@label = @title = nil
|
231
|
-
|
136
|
+
self.class.rsrc_of_tag[@tag] = self
|
232
137
|
end
|
233
138
|
|
234
139
|
# ==== Returns
|
@@ -247,15 +152,11 @@ class ScheduledResource
|
|
247
152
|
"<#ScheduledResource \"#{@tag}\">"
|
248
153
|
end
|
249
154
|
|
250
|
-
|
155
|
+
attr_writer :label, :title
|
251
156
|
def label(); @label || @tag end
|
252
|
-
|
253
|
-
def label=(val)
|
254
|
-
@label = val
|
255
|
-
end
|
256
|
-
|
257
157
|
def title(); @title || @tag end
|
258
158
|
|
159
|
+
|
259
160
|
# ==== Returns
|
260
161
|
# * <tt>String</tt> - CSS classes automatically generated for the DOM row representing this SchedResource.
|
261
162
|
def css_classes_for_row(); "rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row" end # Row + row -- really?
|
@@ -0,0 +1,115 @@
|
|
1
|
+
class ScheduledResource # Think module
|
2
|
+
|
3
|
+
# Config is loaded from config/schedule.yml:
|
4
|
+
# ResourceKinds:: A list of string pairs: [ resource class, use_block class ]
|
5
|
+
# Resources:: A list of: [ ResourceKind resource_id... ]
|
6
|
+
# visibleTime:: Span of time window (seconds).
|
7
|
+
# timeRangeMin::
|
8
|
+
# timeRangeMax::
|
9
|
+
|
10
|
+
# Schedule configuration data itself is fairly brief and generally
|
11
|
+
# can be kept in the session. An instance of this class (though
|
12
|
+
# reflecting the same information) isn't suitable for session
|
13
|
+
# storage. It is more useful for processing a request and also
|
14
|
+
# mediates (later) changes to the configuration.
|
15
|
+
class Config
|
16
|
+
|
17
|
+
attr_reader :visible_time, :time_range_min, :time_range_max
|
18
|
+
attr_reader :resource_list
|
19
|
+
|
20
|
+
# For now we have a single, static configuration...
|
21
|
+
CONFIG_FILE = "config/resource_schedule.yml"
|
22
|
+
#--
|
23
|
+
# Restore configuration from session or base as needed.
|
24
|
+
#
|
25
|
+
# When we depend on data in the configuration to satisfy a query we are not
|
26
|
+
# being RESTful. On the other hand we are not maintaining changeable state
|
27
|
+
# here -- it's just a cache. If there <em>were</em> changeable state it
|
28
|
+
# would likely be kept, eg, in a per-user table in the database.
|
29
|
+
#++
|
30
|
+
def self.ensure( session ) # fka ensure_config
|
31
|
+
yml_string = session[:schedule_config]
|
32
|
+
return new( YAML.load(yml_string) ) if yml_string
|
33
|
+
|
34
|
+
from_base( session )
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# ToDo: Generalize this so configuration can be loaded on per-user.
|
39
|
+
def self.from_base( session ) # fka config_from_yaml1
|
40
|
+
yml = YAML.load_file CONFIG_FILE
|
41
|
+
session[:schedule_config] = yml.to_yaml
|
42
|
+
new( yml )
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# (hi-lock-face-buffer "yml\\[.*\\]" 'hi-yellow)
|
47
|
+
# A Hash, as from a yml file.
|
48
|
+
def initialize( yml ) # fka config_from_yaml
|
49
|
+
@yml = yml
|
50
|
+
@resource_list = [] # fka :all_resources
|
51
|
+
@block_class_for_resource_kind = {}
|
52
|
+
|
53
|
+
yml['ResourceKinds'].each do |key, val| # {"Channel" => "Program"...}
|
54
|
+
@block_class_for_resource_kind[key] = val # class name (string)
|
55
|
+
end
|
56
|
+
|
57
|
+
do_resource_kind_lists( yml['Resources'] || [] )
|
58
|
+
|
59
|
+
|
60
|
+
# Eval is FAR TOO DANGEROUS for user input. Rather, parse a string
|
61
|
+
# into (number).(unit) (maybe a couple of other patterns) to sanitize.
|
62
|
+
vt = yml['visibleTime']
|
63
|
+
@visible_time = vt ? (eval vt) : 3.hours
|
64
|
+
|
65
|
+
t0 = yml['timeRangeMin']
|
66
|
+
@time_range_min = t0 ? (eval t0) : (Time.now - 1.week)
|
67
|
+
|
68
|
+
tn = yml['timeRangeMax']
|
69
|
+
@time_range_max = tn ? (eval tn) : (Time.now + 1.week)
|
70
|
+
|
71
|
+
|
72
|
+
rsrcs_by_kind.each do |kind, rsrcs| # fka config_from_yaml2
|
73
|
+
klass = kind.constantize
|
74
|
+
rsrcs.each {|rsrc| klass.decorate_resource rsrc }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Resource Kind Lists,
|
80
|
+
# Each line (in yml format) is a ResourceKind followed by rids
|
81
|
+
# such as "Channel 702 703 ..."
|
82
|
+
def do_resource_kind_lists( rkls )
|
83
|
+
rkls.each do |rkl|
|
84
|
+
rkl = rkl.split(/[, ]+/) # ["Channel", "702", "703" ...]
|
85
|
+
rk = rkl.shift
|
86
|
+
rsrcs = rkl.map{|rid| ScheduledResource.make_resource_of_kind(rk, rid)}
|
87
|
+
|
88
|
+
add_resources rsrcs
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Hmm... DOM Row uniqueness vs resource (tag) uniqueness.
|
94
|
+
def add_resources(rsrcs)
|
95
|
+
rsrcs.each do |rsrc|
|
96
|
+
@resource_list << rsrc unless @resource_list.include? rsrc
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def rsrcs_by_kind
|
101
|
+
@resource_list.group_by{ |r| r.kind }
|
102
|
+
end
|
103
|
+
|
104
|
+
# ==== Parameters
|
105
|
+
# * <tt>name</tt> - The class name (string) of a schedule resource.
|
106
|
+
#
|
107
|
+
# ==== Returns
|
108
|
+
# * <tt>Class</tt> - The class representing the <em>use</em> of that resource for an interval of time.
|
109
|
+
def block_class_for_resource_name( name )
|
110
|
+
@block_class_for_resource_kind[name].constantize
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -3,9 +3,9 @@ class ScheduledResource
|
|
3
3
|
|
4
4
|
module Helper
|
5
5
|
|
6
|
-
def ensure_schedule_config
|
7
|
-
meth = params[:reset] ? :
|
8
|
-
ScheduledResource.send( meth, session )
|
6
|
+
def ensure_schedule_config # fka :config_from_yaml : :ensure_config
|
7
|
+
meth = params[:reset] ? :from_base : :ensure
|
8
|
+
@config = ScheduledResource::Config.send( meth, session )
|
9
9
|
end
|
10
10
|
|
11
11
|
def default_time_param
|
@@ -15,7 +15,7 @@ class ScheduledResource
|
|
15
15
|
|
16
16
|
def set_schedule_query_params(p = params)
|
17
17
|
@t1 = p[:t1] || default_time_param
|
18
|
-
@t2 = p[:t2] || @t1 + ScheduledResource.visible_time
|
18
|
+
@t2 = p[:t2] || @t1 + @config.visible_time # ScheduledResource.visible_time
|
19
19
|
@inc= p[:inc]
|
20
20
|
end
|
21
21
|
|
@@ -32,19 +32,20 @@ class ScheduledResource
|
|
32
32
|
@t1 = Time.at(@t1.to_i)
|
33
33
|
@t2 = Time.at(@t2.to_i)
|
34
34
|
|
35
|
-
@rsrcs
|
35
|
+
@rsrcs = @config.resource_list # ScheduledResource.resource_list
|
36
36
|
|
37
|
-
@blockss = ScheduledResource.get_all_blocks(@t1, @t2, @inc)
|
37
|
+
@blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)
|
38
38
|
|
39
39
|
json_adjustments
|
40
40
|
end
|
41
41
|
|
42
|
-
def min_time; ScheduledResource.config[:time_range_min]
|
43
|
-
def max_time; ScheduledResource.config[:time_range_max]
|
42
|
+
def min_time; @config.time_range_min.to_i end # ScheduledResource.config[:time_range_min]
|
43
|
+
def max_time; @config.time_range_max.to_i end # ScheduledResource.config[:time_range_max]
|
44
44
|
|
45
|
-
# Always send starttime/endtime attributes as Integer values (UTC)
|
46
|
-
# used to size and place the
|
47
|
-
# ZTime* classes
|
45
|
+
# Always send starttime/endtime attributes as Integer values (UTC)
|
46
|
+
# -- they are used to size and place the use_blocks. Timezone is
|
47
|
+
# configured separately in the ZTime* classes
|
48
|
+
# (config/resource_schedule.yml).
|
48
49
|
def json_adjustments
|
49
50
|
@blockss.each do |rsrc, blocks|
|
50
51
|
blocks.each do |block|
|
@@ -58,8 +59,6 @@ class ScheduledResource
|
|
58
59
|
}
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
62
|
end
|
64
63
|
|
65
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scheduled_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Cannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- lib/assets/javascripts/use_block.js.coffee
|
170
170
|
- lib/assets/stylesheets/scheduled_resource.css.scss
|
171
171
|
- lib/scheduled_resource.rb
|
172
|
+
- lib/scheduled_resource/config.rb
|
172
173
|
- lib/scheduled_resource/helper.rb
|
173
174
|
- lib/scheduled_resource/resource_use_block.rb
|
174
175
|
- lib/scheduled_resource/version.rb
|
@@ -199,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
200
|
version: '0'
|
200
201
|
requirements: []
|
201
202
|
rubyforge_project:
|
202
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.4.5
|
203
204
|
signing_key:
|
204
205
|
specification_version: 4
|
205
206
|
summary: Display how something is used over time.
|