network_executive 0.0.1.alpha.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
metadata CHANGED
@@ -1,52 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: network_executive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.1
5
- prerelease: 6
4
+ version: 0.0.2
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Derek Lindahl
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-18 00:00:00.000000000 Z
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: commander
16
- requirement: &2151939040 !ruby/object:Gem::Requirement
15
+ name: activesupport
16
+ requirement: &2152386920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 4.1.0
21
+ version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151939040
24
+ version_requirements: *2152386920
25
25
  - !ruby/object:Gem::Dependency
26
- name: thin
27
- requirement: &2151938240 !ruby/object:Gem::Requirement
26
+ name: faye-websocket
27
+ requirement: &2152385200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 1.4.1
32
+ version: 0.4.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151938240
35
+ version_requirements: *2152385200
36
36
  - !ruby/object:Gem::Dependency
37
- name: activesupport
38
- requirement: &2151937640 !ruby/object:Gem::Requirement
37
+ name: sass-rails
38
+ requirement: &2152402100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 3.2.0
43
+ version: '3.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2151937640
46
+ version_requirements: *2152402100
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: awesome_print
49
- requirement: &2151936920 !ruby/object:Gem::Requirement
49
+ requirement: &2152401200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,21 +54,32 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2151936920
57
+ version_requirements: *2152401200
58
58
  - !ruby/object:Gem::Dependency
59
- name: rspec
60
- requirement: &2151935940 !ruby/object:Gem::Requirement
59
+ name: rails
60
+ requirement: &2152399480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 2.11.0
65
+ version: 3.2.8
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2151935940
68
+ version_requirements: *2152399480
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: &2152412880 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '2.11'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2152412880
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: fakefs
71
- requirement: &2151935300 !ruby/object:Gem::Requirement
82
+ requirement: &2152411700 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ~>
@@ -76,7 +87,18 @@ dependencies:
76
87
  version: 0.4.0
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *2151935300
90
+ version_requirements: *2152411700
91
+ - !ruby/object:Gem::Dependency
92
+ name: timecop
93
+ requirement: &2152410760 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.4.5
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *2152410760
80
102
  description: An experimental application used to drive displays hung around an office.
81
103
  email:
82
104
  - dlindahl@customink.com
@@ -92,24 +114,90 @@ files:
92
114
  - LICENSE.txt
93
115
  - README.md
94
116
  - Rakefile
117
+ - app/assets/javascripts/application.js
118
+ - app/assets/javascripts/network_executive/osd.js
119
+ - app/assets/javascripts/network_executive/set_top_box.js
120
+ - app/assets/stylesheets/network_executive/application.css
121
+ - app/assets/stylesheets/network_executive/gui_components.css
122
+ - app/assets/stylesheets/network_executive/normalize.css
123
+ - app/assets/stylesheets/network_executive/osd.css
124
+ - app/assets/stylesheets/network_executive/smpte.css
125
+ - app/controllers/network_executive/application_controller.rb
126
+ - app/controllers/network_executive/network_controller.rb
127
+ - app/helpers/network_executive/network_helper.rb
128
+ - app/models/network_executive/channel.rb
129
+ - app/models/network_executive/channel_schedule.rb
130
+ - app/models/network_executive/lineup.rb
131
+ - app/models/network_executive/lineup_range.rb
132
+ - app/models/network_executive/network.rb
133
+ - app/models/network_executive/program.rb
134
+ - app/models/network_executive/program_schedule.rb
135
+ - app/models/network_executive/viewer.rb
136
+ - app/views/network_executive/network/index.html.erb
95
137
  - bin/net_exec
138
+ - config/routes.rb
139
+ - lib/generators/network_executive/install_generator.rb
140
+ - lib/generators/network_executive/templates/initializer.erb
141
+ - lib/generators/network_executive/uninstall_generator.rb
96
142
  - lib/network_executive.rb
97
- - lib/network_executive/behaviors/file_system.rb
98
- - lib/network_executive/behaviors/terminal_output.rb
99
- - lib/network_executive/cli.rb
100
- - lib/network_executive/commands/application.rb
101
- - lib/network_executive/commands/server.rb
102
- - lib/network_executive/network.rb
103
- - lib/network_executive/templates/app/channels/.gitkeep
104
- - lib/network_executive/templates/config/lineup.rb
105
- - lib/network_executive/templates/config/my_network.rb
106
- - lib/network_executive/templates/my_network.ru
107
- - lib/network_executive/templates/public/.gitkeep
143
+ - lib/network_executive/configuration.rb
144
+ - lib/network_executive/engine.rb
145
+ - lib/network_executive/producer.rb
146
+ - lib/network_executive/scheduling.rb
147
+ - lib/network_executive/station.rb
148
+ - lib/network_executive/station/local_affiliate.rb
108
149
  - lib/network_executive/version.rb
109
150
  - network_executive.gemspec
110
- - spec/commands/application_spec.rb
111
- - spec/commands/server_spec.rb
151
+ - spec/dummy/README.rdoc
152
+ - spec/dummy/Rakefile
153
+ - spec/dummy/app/assets/javascripts/application.js
154
+ - spec/dummy/app/assets/stylesheets/application.css
155
+ - spec/dummy/app/controllers/application_controller.rb
156
+ - spec/dummy/app/helpers/application_helper.rb
157
+ - spec/dummy/app/mailers/.gitkeep
158
+ - spec/dummy/app/models/.gitkeep
159
+ - spec/dummy/app/views/layouts/application.html.erb
160
+ - spec/dummy/config.ru
161
+ - spec/dummy/config/application.rb
162
+ - spec/dummy/config/boot.rb
163
+ - spec/dummy/config/database.yml
164
+ - spec/dummy/config/environment.rb
165
+ - spec/dummy/config/environments/development.rb
166
+ - spec/dummy/config/environments/production.rb
167
+ - spec/dummy/config/environments/test.rb
168
+ - spec/dummy/config/initializers/backtrace_silencers.rb
169
+ - spec/dummy/config/initializers/inflections.rb
170
+ - spec/dummy/config/initializers/mime_types.rb
171
+ - spec/dummy/config/initializers/secret_token.rb
172
+ - spec/dummy/config/initializers/session_store.rb
173
+ - spec/dummy/config/initializers/wrap_parameters.rb
174
+ - spec/dummy/config/locales/en.yml
175
+ - spec/dummy/config/routes.rb
176
+ - spec/dummy/lib/assets/.gitkeep
177
+ - spec/dummy/log/.gitkeep
178
+ - spec/dummy/public/404.html
179
+ - spec/dummy/public/422.html
180
+ - spec/dummy/public/500.html
181
+ - spec/dummy/public/favicon.ico
182
+ - spec/dummy/script/rails
183
+ - spec/generators/install_generator_spec.rb
184
+ - spec/generators/uninstall_generator_spec.rb
185
+ - spec/helpers/network_helper_spec.rb
186
+ - spec/models/channel_schedule_spec.rb
187
+ - spec/models/channel_spec.rb
188
+ - spec/models/lineup_range_spec.rb
189
+ - spec/models/lineup_spec.rb
190
+ - spec/models/network_spec.rb
191
+ - spec/models/program_schedule_spec.rb
192
+ - spec/models/program_spec.rb
193
+ - spec/models/viewer_spec.rb
194
+ - spec/network_executive_spec.rb
112
195
  - spec/spec_helper.rb
196
+ - spec/unit/configuration_spec.rb
197
+ - spec/unit/producer_spec.rb
198
+ - spec/unit/scheduling_spec.rb
199
+ - spec/unit/station/local_affiliate_spec.rb
200
+ - tasks/network_executive_tasks.rake
113
201
  homepage: https://github.com/dlindahl/network_executive
114
202
  licenses: []
115
203
  post_install_message:
@@ -125,9 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
213
  required_rubygems_version: !ruby/object:Gem::Requirement
126
214
  none: false
127
215
  requirements:
128
- - - ! '>'
216
+ - - ! '>='
129
217
  - !ruby/object:Gem::Version
130
- version: 1.3.1
218
+ version: '0'
219
+ segments:
220
+ - 0
221
+ hash: -3920884458192808867
131
222
  requirements: []
132
223
  rubyforge_project:
133
224
  rubygems_version: 1.8.10
@@ -135,6 +226,52 @@ signing_key:
135
226
  specification_version: 3
136
227
  summary: An experimental application used to drive displays hung around an office.
137
228
  test_files:
138
- - spec/commands/application_spec.rb
139
- - spec/commands/server_spec.rb
229
+ - spec/dummy/README.rdoc
230
+ - spec/dummy/Rakefile
231
+ - spec/dummy/app/assets/javascripts/application.js
232
+ - spec/dummy/app/assets/stylesheets/application.css
233
+ - spec/dummy/app/controllers/application_controller.rb
234
+ - spec/dummy/app/helpers/application_helper.rb
235
+ - spec/dummy/app/mailers/.gitkeep
236
+ - spec/dummy/app/models/.gitkeep
237
+ - spec/dummy/app/views/layouts/application.html.erb
238
+ - spec/dummy/config.ru
239
+ - spec/dummy/config/application.rb
240
+ - spec/dummy/config/boot.rb
241
+ - spec/dummy/config/database.yml
242
+ - spec/dummy/config/environment.rb
243
+ - spec/dummy/config/environments/development.rb
244
+ - spec/dummy/config/environments/production.rb
245
+ - spec/dummy/config/environments/test.rb
246
+ - spec/dummy/config/initializers/backtrace_silencers.rb
247
+ - spec/dummy/config/initializers/inflections.rb
248
+ - spec/dummy/config/initializers/mime_types.rb
249
+ - spec/dummy/config/initializers/secret_token.rb
250
+ - spec/dummy/config/initializers/session_store.rb
251
+ - spec/dummy/config/initializers/wrap_parameters.rb
252
+ - spec/dummy/config/locales/en.yml
253
+ - spec/dummy/config/routes.rb
254
+ - spec/dummy/lib/assets/.gitkeep
255
+ - spec/dummy/log/.gitkeep
256
+ - spec/dummy/public/404.html
257
+ - spec/dummy/public/422.html
258
+ - spec/dummy/public/500.html
259
+ - spec/dummy/public/favicon.ico
260
+ - spec/dummy/script/rails
261
+ - spec/generators/install_generator_spec.rb
262
+ - spec/generators/uninstall_generator_spec.rb
263
+ - spec/helpers/network_helper_spec.rb
264
+ - spec/models/channel_schedule_spec.rb
265
+ - spec/models/channel_spec.rb
266
+ - spec/models/lineup_range_spec.rb
267
+ - spec/models/lineup_spec.rb
268
+ - spec/models/network_spec.rb
269
+ - spec/models/program_schedule_spec.rb
270
+ - spec/models/program_spec.rb
271
+ - spec/models/viewer_spec.rb
272
+ - spec/network_executive_spec.rb
140
273
  - spec/spec_helper.rb
274
+ - spec/unit/configuration_spec.rb
275
+ - spec/unit/producer_spec.rb
276
+ - spec/unit/scheduling_spec.rb
277
+ - spec/unit/station/local_affiliate_spec.rb
@@ -1,73 +0,0 @@
1
- require 'active_support/inflector'
2
- require 'network_executive/behaviors/terminal_output'
3
-
4
- module NetworkExecutive
5
- module Behaviors
6
- module FileSystem
7
-
8
- include TerminalOutput
9
-
10
- def directory( source )
11
- say_status 'create', source
12
-
13
- FileUtils.cp_r "#{self.class.source_root}/#{source}", "#{root}/#{source}"
14
- end
15
-
16
- def empty_directory_with_gitkeep( source )
17
- path = "#{root}/#{source}"
18
-
19
- if Dir.exists? path
20
- say_status 'exists', source, :yellow
21
- else
22
- say_status 'create', source
23
- Dir.mkdir path
24
- end
25
-
26
- git_keep path
27
- end
28
-
29
- def git_keep( destination )
30
- create_file "#{destination}/.gitkeep"
31
- end
32
-
33
- def create_file( destination, data = nil, config = {} )
34
- if block_given?
35
- data = yield
36
- end
37
-
38
- File.open(destination, 'w') {|f| f.write data }
39
- end
40
-
41
- # Gets an ERB template at the relative source, executes it and makes a copy
42
- # at the relative destination. If the destination is not given it's assumed
43
- # to be equal to the source removing .tt from the filename.
44
- #
45
- # ==== Parameters
46
- # source<String>:: the relative path to the source root.
47
- # destination<String>:: the relative path to the destination root.
48
- # config<Hash>:: give :verbose => false to not log the status.
49
- #
50
- # ==== Examples
51
- #
52
- # template "README", "doc/README"
53
- #
54
- # template "doc/README"
55
- #
56
- def template( source, *args, &block )
57
- config = args.last.is_a?(Hash) ? args.pop : {}
58
- destination = "#{root}/#{args.first}"
59
-
60
- source = File.expand_path "#{self.class.source_root}/#{source}"
61
- context = instance_eval 'binding'
62
-
63
- create_file destination, nil, config do
64
- content = File.open(source, 'rb') { |f| f.read }
65
- content = ERB.new( content, nil, '-', '@output_buffer').result context
66
- content = block.call content if block
67
- content
68
- end
69
- end
70
-
71
- end
72
- end
73
- end
@@ -1,84 +0,0 @@
1
- module NetworkExecutive
2
- module Behaviors
3
- module TerminalOutput
4
-
5
- # Embed in a String to clear all previous ANSI sequences.
6
- CLEAR = "\e[0m"
7
- # The start of an ANSI bold sequence.
8
- BOLD = "\e[1m"
9
-
10
- # Set the terminal's foreground ANSI color to black.
11
- BLACK = "\e[30m"
12
- # Set the terminal's foreground ANSI color to red.
13
- RED = "\e[31m"
14
- # Set the terminal's foreground ANSI color to green.
15
- GREEN = "\e[32m"
16
- # Set the terminal's foreground ANSI color to yellow.
17
- YELLOW = "\e[33m"
18
- # Set the terminal's foreground ANSI color to blue.
19
- BLUE = "\e[34m"
20
- # Set the terminal's foreground ANSI color to magenta.
21
- MAGENTA = "\e[35m"
22
- # Set the terminal's foreground ANSI color to cyan.
23
- CYAN = "\e[36m"
24
- # Set the terminal's foreground ANSI color to white.
25
- WHITE = "\e[37m"
26
-
27
- # Set the terminal's background ANSI color to black.
28
- ON_BLACK = "\e[40m"
29
- # Set the terminal's background ANSI color to red.
30
- ON_RED = "\e[41m"
31
- # Set the terminal's background ANSI color to green.
32
- ON_GREEN = "\e[42m"
33
- # Set the terminal's background ANSI color to yellow.
34
- ON_YELLOW = "\e[43m"
35
- # Set the terminal's background ANSI color to blue.
36
- ON_BLUE = "\e[44m"
37
- # Set the terminal's background ANSI color to magenta.
38
- ON_MAGENTA = "\e[45m"
39
- # Set the terminal's background ANSI color to cyan.
40
- ON_CYAN = "\e[46m"
41
- # Set the terminal's background ANSI color to white.
42
- ON_WHITE = "\e[47m"
43
-
44
- # Set color by using a string or one of the defined constants. If a third
45
- # option is set to true, it also adds bold to the string. This is based
46
- # on Highline implementation and it automatically appends CLEAR to the end
47
- # of the returned String.
48
- #
49
- def set_color(string, color, bold=false)
50
- color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
51
- bold = bold ? BOLD : ""
52
- "#{bold}#{color}#{string}#{CLEAR}"
53
- end
54
-
55
- # Say a status with the given color and appends the message. Since this
56
- # method is used frequently by actions, it allows nil or false to be given
57
- # in log_status, avoiding the message from being shown. If a Symbol is
58
- # given in log_status, it's used as the color.
59
- #
60
- def say_status(status, message, log_status = true)
61
- return if log_status == false
62
- spaces = " " * (padding + 1)
63
- color = log_status.is_a?(Symbol) ? log_status : :green
64
-
65
- status = status.to_s.rjust(12)
66
- status = set_color status, color, true if color
67
-
68
- $stdout.puts "#{status}#{spaces}#{message}"
69
- $stdout.flush
70
- end
71
-
72
- def padding
73
- @padding ||= 0
74
- end
75
-
76
- # Sets the output padding, not allowing less than zero values.
77
- #
78
- def padding=(value)
79
- @padding = [0, value].max
80
- end
81
-
82
- end
83
- end
84
- end
@@ -1,29 +0,0 @@
1
- require 'commander/import'
2
-
3
- program :name, 'Network Executive'
4
- program :version, NetworkExecutive::VERSION
5
- program :description, 'An experimental application used to drive displays hung around an office. '
6
-
7
- command :new do |c|
8
- c.syntax = 'net_exec new [path]'
9
- c.description = 'Create a new Network Executive installation.'
10
-
11
- c.action do |args, options|
12
- require 'network_executive/commands/application'
13
-
14
- NetworkExecutive::Application.new( args.first ).build_app
15
- end
16
- end
17
-
18
- command :server do |c|
19
- c.syntax = 'net_exec server'
20
- c.description = 'Runs the Network Executive server.'
21
-
22
- c.action do |args, options|
23
- require 'network_executive/commands/server'
24
-
25
- ARGV.shift
26
-
27
- NetworkExecutive::Server.start!
28
- end
29
- end
@@ -1,64 +0,0 @@
1
- require 'network_executive/behaviors/file_system'
2
-
3
- module NetworkExecutive
4
-
5
- class Application
6
- include Behaviors::FileSystem
7
-
8
- attr_accessor :root, :name
9
-
10
- def initialize( root )
11
- self.root = root
12
- end
13
-
14
- def name
15
- @name ||= begin
16
- network_name = root.split('/').last unless root[-1] == '.'
17
-
18
- network_name || 'my_network'
19
- end
20
- end
21
-
22
- def app
23
- directory 'app'
24
- end
25
-
26
- def config
27
- directory 'config'
28
- end
29
-
30
- def log
31
- empty_directory_with_gitkeep 'log'
32
- end
33
-
34
- def public_directory
35
- directory 'public'
36
- end
37
-
38
- def network
39
- template 'config/my_network.rb', "config/#{name}.rb"
40
- end
41
-
42
- def rackup
43
- template 'my_network.ru', "#{name}.ru"
44
- end
45
-
46
- def build_app
47
- Dir.mkdir( root ) unless Dir.exists? root
48
-
49
- app
50
- config
51
- log
52
- public_directory
53
-
54
- network
55
- rackup
56
- end
57
-
58
- def self.source_root
59
- File.expand_path File.join( File.dirname( __FILE__ ), '..', 'templates' )
60
- end
61
-
62
- end
63
-
64
- end
@@ -1,48 +0,0 @@
1
- require 'rack/server'
2
- require 'rack/builder'
3
-
4
- module NetworkExecutive
5
-
6
- class Server < Rack::Server
7
-
8
- def initialize(*)
9
- super
10
-
11
- yield self if block_given?
12
- end
13
-
14
- def start
15
- puts "http://#{options[:Host]}:#{options[:Port]}"
16
- puts "=> Booting Network Executive v#{NetworkExecutive::VERSION}"
17
- trap(:INT) { exit }
18
- puts '=> Ctrl-C to shutdown server'
19
-
20
- super
21
- ensure
22
- puts 'Exiting'
23
- end
24
-
25
- def app
26
- @app ||= super.respond_to?(:to_app) ? super.to_app : super
27
- end
28
-
29
- def default_options
30
- rackup_file = Dir['*.ru'].first
31
-
32
- super.merge({
33
- Port: 3000,
34
- environment: (ENV['RACK_ENV'] || 'development').dup,
35
- config: File.expand_path( rackup_file )
36
- })
37
- end
38
-
39
- class << self
40
- def start!
41
- new do |server|
42
- server.start
43
- end
44
- end
45
- end
46
- end
47
-
48
- end
@@ -1,5 +0,0 @@
1
- module NetworkExecutive
2
- class Network
3
-
4
- end
5
- end
@@ -1 +0,0 @@
1
- .gitkeep
@@ -1,5 +0,0 @@
1
- require 'network_executive'
2
-
3
- class <%= name.to_s.camelize %> < NetworkExecutive::Network
4
- # Your network code goes here...
5
- end
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
- require ::File.expand_path('../config/<%= name %>', __FILE__)
3
-
4
- run <%= name.to_s.camelize %>
@@ -1 +0,0 @@
1
- .gitkeep
@@ -1,58 +0,0 @@
1
- require 'fakefs/spec_helpers'
2
- require 'network_executive/commands/application'
3
-
4
- describe NetworkExecutive::Application do
5
- include FakeFS::SpecHelpers
6
-
7
- it 'should require a path' do
8
- expect { described_class.new }.to raise_error( ArgumentError )
9
- end
10
-
11
- describe '#name' do
12
- context 'with a full path' do
13
- subject { described_class.new('/path/for/my/network/nbc').name }
14
-
15
- it { should == 'nbc' }
16
- end
17
-
18
- context 'with the current path' do
19
- subject { described_class.new('.').name }
20
-
21
- it { should == 'my_network' }
22
- end
23
- end
24
-
25
- describe '#build_app' do
26
- before do
27
- FakeFS::FileSystem.clone 'lib/network_executive/templates'
28
-
29
- described_class.any_instance.stub(:say_status).and_return nil
30
-
31
- described_class.new( 'test_network' ).build_app
32
- end
33
-
34
- it 'should create /app' do
35
- File.should exist 'test_network/app'
36
- end
37
-
38
- it 'should create /config' do
39
- File.should exist 'test_network/config'
40
- end
41
-
42
- it 'should create /config/test_network.rb' do
43
- File.read('test_network/config/test_network.rb').should match 'TestNetwork < NetworkExecutive::Network'
44
- end
45
-
46
- it 'should create /log' do
47
- File.should exist 'test_network/log/.gitkeep'
48
- end
49
-
50
- it 'should create /public' do
51
- File.should exist 'test_network/public'
52
- end
53
-
54
- it 'should create /test_network/test_network.ru' do
55
- File.read('test_network/test_network.ru').should match 'run TestNetwork'
56
- end
57
- end
58
- end