network_executive 0.0.1.alpha.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.
- data/.gitignore +18 -0
- data/.rvmrc +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +134 -0
- data/Rakefile +1 -0
- data/bin/net_exec +3 -0
- data/lib/network_executive/behaviors/file_system.rb +73 -0
- data/lib/network_executive/behaviors/terminal_output.rb +84 -0
- data/lib/network_executive/cli.rb +29 -0
- data/lib/network_executive/commands/application.rb +64 -0
- data/lib/network_executive/commands/server.rb +48 -0
- data/lib/network_executive/network.rb +5 -0
- data/lib/network_executive/templates/app/channels/.gitkeep +1 -0
- data/lib/network_executive/templates/config/lineup.rb +0 -0
- data/lib/network_executive/templates/config/my_network.rb +5 -0
- data/lib/network_executive/templates/my_network.ru +4 -0
- data/lib/network_executive/templates/public/.gitkeep +1 -0
- data/lib/network_executive/version.rb +3 -0
- data/lib/network_executive.rb +6 -0
- data/network_executive.gemspec +29 -0
- data/spec/commands/application_spec.rb +58 -0
- data/spec/commands/server_spec.rb +15 -0
- data/spec/spec_helper.rb +11 -0
- metadata +140 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ruby-1.9.3-p194@network_executive > /dev/null
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Derek Lindahl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Network Executive
|
2
|
+
|
3
|
+
An experimental application used to drive displays hung around an office.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'network_executive'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install network_executive
|
18
|
+
|
19
|
+
Create a new Network:
|
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.
|
25
|
+
|
26
|
+
All that's left is to start building your network!
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
$ net_exec server
|
31
|
+
|
32
|
+
## Network
|
33
|
+
|
34
|
+
A class that represents a server instance. This is what holds the channel-line up and serves content to the browser.
|
35
|
+
|
36
|
+
### EAS
|
37
|
+
|
38
|
+
#### Creating
|
39
|
+
|
40
|
+
Each Network instance will respond to a POST to `/eas` with POST data that maps to a channel line-up.
|
41
|
+
The provided URL will pre-empt any currently scheduled programming.
|
42
|
+
|
43
|
+
#### Configuring
|
44
|
+
|
45
|
+
On the off chance that multiple EAS' are triggered at the same time, setting a priority will help the Network Executive determine which one
|
46
|
+
should be displayed. A priority of `0` is the highest value.
|
47
|
+
|
48
|
+
In the event of a tie, the most recent EAS will take priority.
|
49
|
+
|
50
|
+
It is up to the individual to be aware of each EAS they plan to trigger and what priority each should have.
|
51
|
+
|
52
|
+
For instance, an EAS for a drop in sales figures should have a lower priority than one indicating a server outage.
|
53
|
+
|
54
|
+
#### Clearing
|
55
|
+
|
56
|
+
Clearing an EAS will be made by accessing `/all_clear`. Doing so will return the viewer to regularly scheduled programming.
|
57
|
+
|
58
|
+
If multiple EAS' are active, the correct EAS will be cleared.
|
59
|
+
|
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
|
+
## Commercials
|
96
|
+
|
97
|
+
Commercials provide a fun and interesting way to break up the monotony of viewing analytics data all day. Be creative!
|
98
|
+
|
99
|
+
The scheduling of commercials is determined by how many commercials are defined and long each program runs for. By default,
|
100
|
+
commercial breaks are taken twice for each 30-minute block of programming.
|
101
|
+
|
102
|
+
## Viewer
|
103
|
+
|
104
|
+
The viewer represents the client-side code that drives the whole end user experience.
|
105
|
+
|
106
|
+
## On-Screen Guide
|
107
|
+
|
108
|
+
The On-Screen Guide allows a viewer access to the entire Network. This provides an easy way to change channels.
|
109
|
+
|
110
|
+
### On-Demand
|
111
|
+
|
112
|
+
On-Demand is an On-Screen Guide feature that allows a viewer to continuously view one specific channel until further notice.
|
113
|
+
|
114
|
+
While commercials are ignored, EAS messages will still pre-empt programming.
|
115
|
+
|
116
|
+
# Ideas
|
117
|
+
|
118
|
+
* _Network_ - An server instance with a specific channel line-up. Think Tech vs. Sales vs. Marketing
|
119
|
+
* _Channel Line-up_ - A JSON/YML file that defines URLs and display times
|
120
|
+
* _EAS_ - Allow a channel to break into the schedule to display important content
|
121
|
+
* _Ticker_ - Allow a separate feed of info. Tweets, metrics, WOWs, etc.
|
122
|
+
* _Network Logo_ - Useful?
|
123
|
+
* _Commericals / PSAs_ - The More You Know?
|
124
|
+
* _Viewer_ - The client-side component. SSEs?
|
125
|
+
* _Clicker_ - Client-side slide out remote to change channels/networks?
|
126
|
+
* _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
|
+
|
128
|
+
## Contributing
|
129
|
+
|
130
|
+
1. Fork it
|
131
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
132
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
133
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
134
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/net_exec
ADDED
@@ -0,0 +1,73 @@
|
|
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
|
@@ -0,0 +1,84 @@
|
|
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
|
@@ -0,0 +1,29 @@
|
|
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
|
@@ -0,0 +1,64 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
.gitkeep
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
.gitkeep
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'network_executive/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "network_executive"
|
8
|
+
gem.version = NetworkExecutive::VERSION
|
9
|
+
gem.authors = ["Derek Lindahl"]
|
10
|
+
gem.email = ["dlindahl@customink.com"]
|
11
|
+
gem.description = %q{An experimental application used to drive displays hung around an office.}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/dlindahl/network_executive"
|
14
|
+
|
15
|
+
gem.required_ruby_version = '>= 1.9.2'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_dependency 'commander', '~> 4.1.0'
|
23
|
+
gem.add_dependency 'thin', '~> 1.4.1'
|
24
|
+
gem.add_dependency 'activesupport', '~> 3.2.0'
|
25
|
+
|
26
|
+
gem.add_development_dependency 'awesome_print'
|
27
|
+
gem.add_development_dependency 'rspec', '~> 2.11.0'
|
28
|
+
gem.add_development_dependency 'fakefs', '~> 0.4.0'
|
29
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'network_executive/commands/server'
|
2
|
+
|
3
|
+
describe NetworkExecutive::Server do
|
4
|
+
|
5
|
+
describe '.start!' do
|
6
|
+
before do
|
7
|
+
described_class.any_instance.stub(:start).and_return true
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { described_class.start! }
|
11
|
+
|
12
|
+
it { should be_a described_class }
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
ENV['RACK_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.filter_run focus: true
|
10
|
+
config.run_all_when_everything_filtered = true
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: network_executive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Derek Lindahl
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: commander
|
16
|
+
requirement: &2151939040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 4.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151939040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thin
|
27
|
+
requirement: &2151938240 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.4.1
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151938240
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: &2151937640 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.2.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2151937640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: awesome_print
|
49
|
+
requirement: &2151936920 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2151936920
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &2151935940 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.11.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2151935940
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fakefs
|
71
|
+
requirement: &2151935300 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.4.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2151935300
|
80
|
+
description: An experimental application used to drive displays hung around an office.
|
81
|
+
email:
|
82
|
+
- dlindahl@customink.com
|
83
|
+
executables:
|
84
|
+
- net_exec
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files: []
|
87
|
+
files:
|
88
|
+
- .gitignore
|
89
|
+
- .rvmrc
|
90
|
+
- .travis.yml
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/net_exec
|
96
|
+
- 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
|
108
|
+
- lib/network_executive/version.rb
|
109
|
+
- network_executive.gemspec
|
110
|
+
- spec/commands/application_spec.rb
|
111
|
+
- spec/commands/server_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: https://github.com/dlindahl/network_executive
|
114
|
+
licenses: []
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.9.2
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>'
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.3.1
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.8.10
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: An experimental application used to drive displays hung around an office.
|
137
|
+
test_files:
|
138
|
+
- spec/commands/application_spec.rb
|
139
|
+
- spec/commands/server_spec.rb
|
140
|
+
- spec/spec_helper.rb
|