scheduled_resource 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.
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ class ZTimeLabelDay < ZTimeLabel
4
+
5
+ def self.get_timeblocks(id, t1, t2, inc)
6
+ (super).each do |b|
7
+ b.title = b.starttime.strftime "%a, %b %e"
8
+ b.css_classes = 'ZTimeHeaderDayRow '
9
+ end
10
+ end
11
+
12
+
13
+ def self.end_for_start( t )
14
+ (t.end_of_day + 1).beginning_of_day # 0.00001 or whatever
15
+ end
16
+
17
+ # t is a TimeWithZone or similar
18
+ def self.floor(t)
19
+ t.beginning_of_day
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ class ZTimeLabelHour < ZTimeLabel
4
+
5
+ def self.get_timeblocks(id, t1, t2, inc)
6
+ (super).each do |b|
7
+ t = b.starttime
8
+ b.title = t.strftime('%I:%M').sub(/^0/, '') # '%I'
9
+ b.css_classes = "ZTimeHeaderHourRow #{daylight_class(t)} "
10
+ end
11
+ end
12
+
13
+ def self.daylight_class(t)
14
+ (6...18).include?(t.hour) ? 'dayTimeblock' : 'niteTimeblock'
15
+ end
16
+
17
+ def self.end_for_start( t )
18
+ floor(t) + 15.minutes
19
+ end
20
+
21
+ # t is a TimeWithZone or similar
22
+ def self.floor(t)
23
+ t.change(min: (t.min / 15) * 15)
24
+ end
25
+
26
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scheduled_resource/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scheduled_resource"
8
+ spec.version = ScheduledResource::VERSION
9
+ spec.authors = ["Mike Cannon"]
10
+ spec.email = ["michael.j.cannon@gmail.com"]
11
+ spec.summary = %q{Help display how something is used over time.}
12
+ spec.description = %Q{== README.md:\n#{IO.read 'README.md'}}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails"
22
+ spec.add_dependency "coffee-rails"
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scheduled_resource
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Cannon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: "== README.md:\n#ScheduledResource\n\nThis gem is for displaying how
70
+ things are used\nover time -- a schedule for a set of resources. It\nprovides a
71
+ way to describe what is being displayed,\nalong with utilities and protocols to
72
+ connect them:\n\n - Configuration (specification and management),\n - Query interfaces
73
+ (a REST-like API and internal protocols to query the models), and\n - A basic Rails
74
+ controller implementation.\n\nSo we have a way to configure the schedule, internal\nmethods
75
+ to generate the data, and a way to retrieve\ndata from the client. But the gem
76
+ is largely\nview-framework agnostic. We could use a variety of\nclient-side packages
77
+ or even more traditional Rails\nview templates to generate HTML.\n\nIn any case,
78
+ to get a the most from a display like this\nwe need some client-side code. The
79
+ gem includes\nclient-side modules to:\n\n - Manage <b>time and display geometries</b>
80
+ with \"infinite\" scroll along the time axis.\n - <b>Format display cells</b> in
81
+ ways specific to the resource models.\n - <b>Update text justification</b> as the
82
+ display is scrolled horizontally.\n\n\n## Configuration Management\n\nA **scheduled
83
+ resource** is something that can be\nused for one thing at a time. Say \"Rocky
84
+ & Bullwinkle\"\nis on channel 3 from 10am to 11am on Saturday. Then\n'channel 3'
85
+ is the <u>resource</u> and that showing of\nthe is a <u>resource-use block</u>.
86
+ \ Resources and \nuse-blocks are typically Rails models. Each resource\nand its
87
+ use-blocks get one row in the display. That\nrow has a label to the left with some
88
+ timespan visible\non the rest of the row.\n\nThe <b>ScheduledResource</b> class
89
+ manages resource and\nuse-block class names, id's and labels for a schedule.\nA
90
+ ScheduledResource instance ties together:\n\n 1. A resource class (eg TvStation),\n
91
+ 2. An id (a channel number in this example), and\n 3. Strings and other assets that
92
+ will go into the DOM.\n\nThe id is used to\n - select a resource <em>instance</em>
93
+ and\n - select instances of the <em>resource use block</em> class (eg Program instances).\n\nThe
94
+ id <em>could</em> be a database id but more\noften is something a little more suited
95
+ to human use\nin the configuration. In any case it is used by model\nclass method\n<tt>(resource_use_block_class).get_all_blocks()</tt>\nto
96
+ select the right use-blocks for the resource.\nA resource class name and id are
97
+ are joined with\na '_' to form a tag that also serves as an id for the DOM.\n\nSomething
98
+ else you would expect see in a schedule\nwould be headers and labels -- perhaps
99
+ one row with\nthe date and another row with the hour. Headers and\nlabels also
100
+ fit the model of resources and use_blocks.\nBasic timezone-aware classes (ZTime*)
101
+ for those are\nincluded in this gem.\n\n\n### Configuration File\n\nThe schedule
102
+ configuration comes from\n<tt>config/resource_schedule.yml</tt> which has\nthree
103
+ top-level sections:\n\n- ResourceKinds: A hash where the key is a Resource and
104
+ the value is a UseBlock. (Both are class names),\n- Resources: A list where each
105
+ item is a Resource Class followed by one or more resource ids, and\n- visibleTime:
106
+ \ The visible timespan of the schedule in seconds.\n\nThe example file <tt>config/resource_schedule.yml</tt>\n(installed
107
+ when you run <tt>schedulize</tt>) should be\nenough to display a two-row schedule
108
+ with just the date\nabove and the hour below. Of course you can monkey-patch\nor
109
+ subclass these classes for your own needs.\n\n\n### The schedule API\n\nThe endpoint
110
+ uses parameters <tt>t1</tt> and\n<tt>t2</tt> to specify a time interval for the
111
+ request.\nA third parameter <tt>inc</tt> allows an initial time\nwindow to be expanded
112
+ without repeating blocks that\nspan those boundaries. The time parameters _plus
113
+ the\nconfigured resources_ define the data to be returned.\n\n\n### More About Configuration
114
+ Management\n\nOnce the configuration yaml is loaded that data is\nmaintained in
115
+ the session structure. Of course having\na single configuration file limits the
116
+ application's\nusefulness. A more general approach would be to\nhave a user model
117
+ with login and configuration would\nbe associated with the user.\n\n\n\n\n\n\n##
118
+ Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'scheduled_resource'\n```\n\nAnd
119
+ then execute:\n\n $ bundle\n\nOr install it yourself as:\n\n $ gem install
120
+ scheduled_resource\n\n## Usage\n\nTo Do: Write usage instructions here\n\n## Contributing\n\n1.
121
+ Fork it ( https://github.com/emeyekayee/scheduled_resource/fork )\n2. Create your
122
+ feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git
123
+ commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5.
124
+ Create a new Pull Request\n"
125
+ email:
126
+ - michael.j.cannon@gmail.com
127
+ executables:
128
+ - schedulize
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - LICENSE
135
+ - README.md
136
+ - Rakefile
137
+ - bin/schedulize
138
+ - lib/assets/javascripts/blank.jpg
139
+ - lib/assets/javascripts/justify_tweaks.js
140
+ - lib/assets/javascripts/time_pix.js.coffee
141
+ - lib/assets/javascripts/use_block.js.coffee
142
+ - lib/assets/stylesheets/scheduled_resource.css.scss
143
+ - lib/scheduled_resource.rb
144
+ - lib/scheduled_resource/helper.rb
145
+ - lib/scheduled_resource/resource_use_block.rb
146
+ - lib/scheduled_resource/version.rb
147
+ - lib/z_time_header.rb
148
+ - lib/z_time_header_day.rb
149
+ - lib/z_time_header_hour.rb
150
+ - lib/z_time_label.rb
151
+ - lib/z_time_label_day.rb
152
+ - lib/z_time_label_hour.rb
153
+ - scheduled_resource.gemspec
154
+ homepage: ''
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.2.2
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Help display how something is used over time.
178
+ test_files: []