network_executive 0.0.1.alpha.1 → 0.0.2

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.
Files changed (100) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +15 -1
  3. data/README.md +9 -41
  4. data/Rakefile +38 -1
  5. data/app/assets/javascripts/application.js +13 -0
  6. data/app/assets/javascripts/network_executive/osd.js +46 -0
  7. data/app/assets/javascripts/network_executive/set_top_box.js +44 -0
  8. data/app/assets/stylesheets/network_executive/application.css +16 -0
  9. data/app/assets/stylesheets/network_executive/gui_components.css +17 -0
  10. data/app/assets/stylesheets/network_executive/normalize.css +500 -0
  11. data/app/assets/stylesheets/network_executive/osd.css +33 -0
  12. data/app/assets/stylesheets/network_executive/smpte.css +164 -0
  13. data/app/controllers/network_executive/application_controller.rb +4 -0
  14. data/app/controllers/network_executive/network_controller.rb +9 -0
  15. data/app/helpers/network_executive/network_helper.rb +7 -0
  16. data/app/models/network_executive/channel.rb +46 -0
  17. data/app/models/network_executive/channel_schedule.rb +13 -0
  18. data/app/models/network_executive/lineup.rb +66 -0
  19. data/app/models/network_executive/lineup_range.rb +34 -0
  20. data/app/models/network_executive/network.rb +10 -0
  21. data/app/models/network_executive/program.rb +39 -0
  22. data/app/models/network_executive/program_schedule.rb +148 -0
  23. data/app/models/network_executive/viewer.rb +76 -0
  24. data/app/views/network_executive/network/index.html.erb +39 -0
  25. data/config/routes.rb +7 -0
  26. data/lib/generators/network_executive/install_generator.rb +96 -0
  27. data/lib/generators/network_executive/templates/initializer.erb +5 -0
  28. data/lib/generators/network_executive/uninstall_generator.rb +20 -0
  29. data/lib/network_executive/configuration.rb +26 -0
  30. data/lib/network_executive/engine.rb +28 -0
  31. data/lib/network_executive/producer.rb +36 -0
  32. data/lib/network_executive/scheduling.rb +44 -0
  33. data/lib/network_executive/station/local_affiliate.rb +21 -0
  34. data/lib/network_executive/station.rb +11 -0
  35. data/lib/network_executive/version.rb +1 -1
  36. data/lib/network_executive.rb +18 -3
  37. data/network_executive.gemspec +9 -8
  38. data/spec/dummy/README.rdoc +261 -0
  39. data/spec/dummy/Rakefile +7 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  41. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/{lib/network_executive/templates/config/lineup.rb → spec/dummy/app/mailers/.gitkeep} +0 -0
  45. data/spec/dummy/app/models/.gitkeep +0 -0
  46. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  47. data/spec/dummy/config/application.rb +47 -0
  48. data/spec/dummy/config/boot.rb +10 -0
  49. data/spec/dummy/config/database.yml +25 -0
  50. data/spec/dummy/config/environment.rb +5 -0
  51. data/spec/dummy/config/environments/development.rb +37 -0
  52. data/spec/dummy/config/environments/production.rb +67 -0
  53. data/spec/dummy/config/environments/test.rb +37 -0
  54. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/spec/dummy/config/initializers/inflections.rb +15 -0
  56. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  57. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  58. data/spec/dummy/config/initializers/session_store.rb +8 -0
  59. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  60. data/spec/dummy/config/locales/en.yml +5 -0
  61. data/spec/dummy/config/routes.rb +3 -0
  62. data/spec/dummy/config.ru +4 -0
  63. data/spec/dummy/lib/assets/.gitkeep +0 -0
  64. data/spec/dummy/log/.gitkeep +0 -0
  65. data/spec/dummy/public/404.html +26 -0
  66. data/spec/dummy/public/422.html +26 -0
  67. data/spec/dummy/public/500.html +25 -0
  68. data/spec/dummy/public/favicon.ico +0 -0
  69. data/spec/dummy/script/rails +6 -0
  70. data/spec/generators/install_generator_spec.rb +129 -0
  71. data/spec/generators/uninstall_generator_spec.rb +39 -0
  72. data/spec/helpers/network_helper_spec.rb +7 -0
  73. data/spec/models/channel_schedule_spec.rb +29 -0
  74. data/spec/models/channel_spec.rb +55 -0
  75. data/spec/models/lineup_range_spec.rb +65 -0
  76. data/spec/models/lineup_spec.rb +95 -0
  77. data/spec/models/network_spec.rb +11 -0
  78. data/spec/models/program_schedule_spec.rb +399 -0
  79. data/spec/models/program_spec.rb +37 -0
  80. data/spec/models/viewer_spec.rb +210 -0
  81. data/spec/network_executive_spec.rb +15 -0
  82. data/spec/spec_helper.rb +27 -1
  83. data/spec/unit/configuration_spec.rb +3 -0
  84. data/spec/unit/producer_spec.rb +60 -0
  85. data/spec/unit/scheduling_spec.rb +106 -0
  86. data/spec/unit/station/local_affiliate_spec.rb +41 -0
  87. data/tasks/network_executive_tasks.rake +4 -0
  88. metadata +177 -40
  89. data/lib/network_executive/behaviors/file_system.rb +0 -73
  90. data/lib/network_executive/behaviors/terminal_output.rb +0 -84
  91. data/lib/network_executive/cli.rb +0 -29
  92. data/lib/network_executive/commands/application.rb +0 -64
  93. data/lib/network_executive/commands/server.rb +0 -48
  94. data/lib/network_executive/network.rb +0 -5
  95. data/lib/network_executive/templates/app/channels/.gitkeep +0 -1
  96. data/lib/network_executive/templates/config/my_network.rb +0 -5
  97. data/lib/network_executive/templates/my_network.ru +0 -4
  98. data/lib/network_executive/templates/public/.gitkeep +0 -1
  99. data/spec/commands/application_spec.rb +0 -58
  100. data/spec/commands/server_spec.rb +0 -15
data/.gitignore CHANGED
@@ -16,3 +16,9 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+
20
+ # Dummy Rails App for testing
21
+ log/*.log
22
+ spec/dummy/log/*.log
23
+ spec/dummy/tmp/
24
+ spec/dummy/.sass-cache
data/Gemfile CHANGED
@@ -1,4 +1,18 @@
1
1
  source 'https://rubygems.org'
2
+ ruby '1.9.3'
2
3
 
3
- # Specify your gem's dependencies in network_executive.gemspec
4
+ # Declare your gem's dependencies in network_executive.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
4
7
  gemspec
8
+
9
+ # jquery-rails is used by the dummy application
10
+ gem 'jquery-rails'
11
+
12
+ # Declare any dependencies that are still in development here instead of in
13
+ # your gemspec. These might include edge Rails or gems from your path or
14
+ # Git. Remember to move these dependencies to your gemspec before releasing
15
+ # your gem to rubygems.org.
16
+
17
+ # To use debugger
18
+ # gem 'debugger'
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Network Executive
2
2
 
3
- An experimental application used to drive displays hung around an office.
3
+ An experimental Rails engine used to drive displays hung around an office.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,12 +16,9 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install network_executive
18
18
 
19
- Create a new Network:
19
+ Run the installation script:
20
20
 
21
- $ net_exec new [YOUR_NETWORK_NAME]
22
-
23
- This will create a new directory that matches your network name and populate it
24
- with an application scaffold.
21
+ $ rails g network_executive:install
25
22
 
26
23
  All that's left is to start building your network!
27
24
 
@@ -57,41 +54,6 @@ Clearing an EAS will be made by accessing `/all_clear`. Doing so will return the
57
54
 
58
55
  If multiple EAS' are active, the correct EAS will be cleared.
59
56
 
60
- ## Channel Line-up
61
-
62
- A JSON file that defines the various Programs (URLs to visit) and then they should be delivered.
63
-
64
- // In `channels/my_channel_name.json`
65
- {
66
- name : 'My Channel Name', // Examples: Marketing, Sales, Technology, etc. Be creative!
67
- url : '/my_channel_name', // Optional. Automatically inferred from the Channel Name
68
- logo : '/logos/my_channel_logo.png, // Optional. Automatically inferred from the Channel Name. Defaults to `nil`
69
- ticker : 'host.com/my_ticker_feed.xml', // Optional. Specifying a URL will add a new ticker to the bottom for the screen with the feed's data
70
- on_air : '6am'
71
- line_up : [
72
- {
73
- url : 'http://www.cnn.com',
74
- airs : '30 * * * *' // Every 30 minutes (from https://github.com/ncb000gt/node-cron,
75
- // https://github.com/mattpat/node-schedule and http://www.openjs.com/scripts/jslibrary/demos/crontab.php)
76
- runtime : '30min', // How do runtimes affect air times?
77
- commercial_free : true, // Optional. Disables any commericals. Defaults to FALSE.
78
- username : 'my_username', // Optional. Necessary for Basic Auth ?
79
- password : 'my_password' // Optional. Necessary for Basic Auth ?
80
- },{
81
- url : 'http://www.flickr.com/photos/USER/sets/1234/show/',
82
- airs : '60 * * * *'
83
- }
84
- ],
85
- commercials : [
86
- '/spot_1', // Local ad. Inherits all defaults.
87
- {
88
- url : 'http://example.com/spot_2', // Remote ad.
89
- airs : '9am to 10am' // Air only in the morning.
90
- runtime : '15s' // Optional. `Xs`, `Xm`, or `Xh` where `X` is an integer. Defaults to 30 seconds.
91
- }
92
- ]
93
- }
94
-
95
57
  ## Commercials
96
58
 
97
59
  Commercials provide a fun and interesting way to break up the monotony of viewing analytics data all day. Be creative!
@@ -125,6 +87,12 @@ While commercials are ignored, EAS messages will still pre-empt programming.
125
87
  * _Clicker_ - Client-side slide out remote to change channels/networks?
126
88
  * _On-Demand_ - Change to and stay at a specific channel. "Live" to exit.* _On-Demand_ - Change to and stay at a specific channel. "Live" to exit.1
127
89
 
90
+ ## TODO
91
+
92
+ * Raise an exception if there are no channels to ease bootstrapping for new users
93
+ * Swap out jQuery for Zepto?
94
+ * Add http://brad.is/coding/BigScreen/
95
+
128
96
  ## Contributing
129
97
 
130
98
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,38 @@
1
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'NetworkExecutive'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require_tree ./network_executive
@@ -0,0 +1,46 @@
1
+ ;(function($) {
2
+ var autoHideTimer = null;
3
+
4
+ var osd = document.getElementById('osd');
5
+
6
+ var autoHide = function() {
7
+ if( osd.classList.contains('active') ) {
8
+ osd.classList.remove('active');
9
+ }
10
+ };
11
+
12
+ // detect mouse movement and scale display
13
+ document.addEventListener('mousemove', function(e) {
14
+ clearTimeout( autoHideTimer );
15
+
16
+ if( !osd.contains('active') ) {
17
+ osd.classList.add('active');
18
+ }
19
+
20
+ autoHideTimer = setTimeout(autoHide, 1000);
21
+ });
22
+
23
+ // Update the timestamp
24
+ var months = 'January February March April May June July August September October November December'.split(' ');
25
+ setInterval(function() {
26
+ var time,
27
+ date,
28
+ now = new Date(),
29
+ mon = now.getMonth(),
30
+ d = now.getDate(),
31
+ y = now.getFullYear(),
32
+ h = now.getHours(),
33
+ min = now.getMinutes(),
34
+ a = h > 12 ? 'pm' : 'am';
35
+
36
+ h = h > 12 ? h - 12 : h;
37
+ min = min < 10 ? '0'+min : min;
38
+ time = h + ':' + min + a;
39
+
40
+ date = months[mon] + ' ' + d + ', ' + y;
41
+
42
+ $('.osd-now-time')[0].innerHTML = time;
43
+ $('.osd-now-date')[0].innerHTML = date;
44
+ }, 1000);
45
+
46
+ })( document.querySelectorAll.bind(document) );
@@ -0,0 +1,44 @@
1
+ ;(function() {
2
+
3
+ var channel = window.location.pathname.split('/')[2];
4
+
5
+ if( channel ) {
6
+ console.log( 'tune in to channel:', channel );
7
+
8
+ document.getElementById('smpte_message').innerHTML = 'Establishing uplink...';
9
+
10
+ var source = new EventSource('/tune_in/' + channel);
11
+
12
+ source.addEventListener('open', function(e) {
13
+ document.getElementById('smpte_message').innerHTML = 'Awaiting transmission...';
14
+ // Connection was opened.
15
+ console.log('[open]', e);
16
+ }, false);
17
+
18
+ source.addEventListener('message', function(e) {
19
+ console.log( '[message]', e.data );
20
+
21
+ var payload = JSON.parse( e.data );
22
+
23
+ document.getElementById('smpte').style.display = 'none';
24
+
25
+ document.getElementById('program').setAttribute('src', payload.url);
26
+ }, false);
27
+
28
+ source.addEventListener('error', function(e) {
29
+ if (e.eventPhase == EventSource.CLOSED) {
30
+ console.log('[closed]', e);
31
+ document.getElementById('smpte_message').innerHTML = 'Transmission lost...';
32
+ document.getElementById('program').setAttribute('src', 'about:blank');
33
+ // Move this functionality to a class for better cross-browser support
34
+ document.getElementById('smpte').style.display = '-webkit-box';
35
+ // Connection was closed.
36
+ } else {
37
+ console.log('[closed]', e);
38
+ }
39
+ }, false);
40
+ } else {
41
+ document.getElementById('smpte_message').innerHTML = 'No signal';
42
+ }
43
+
44
+ })();
@@ -0,0 +1,16 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require ./normalize
12
+ *= require ./gui_components
13
+ *= require ./smpte
14
+ *= require ./osd
15
+ *= require_self
16
+ */
@@ -0,0 +1,17 @@
1
+ body {
2
+ text-rendering: optimizeLegibility;
3
+ }
4
+
5
+ .gui-comp {
6
+ position: absolute;
7
+ top: 0;
8
+ right: 0;
9
+ bottom: 0;
10
+ left: 0;
11
+ }
12
+
13
+ #program {
14
+ width: 100%;
15
+ height: 100%;
16
+ border: 0;
17
+ }