rocketwheel-command 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +130 -0
- data/Rakefile +2 -0
- data/bin/rocket +15 -0
- data/lib/rocketwheel/command/cli/build.rb +56 -0
- data/lib/rocketwheel/command/cli/deploy.rb +92 -0
- data/lib/rocketwheel/command/cli/encode.rb +65 -0
- data/lib/rocketwheel/command/cli/new.rb +59 -0
- data/lib/rocketwheel/command/cli/versions.rb +12 -0
- data/lib/rocketwheel/command/cli.rb +89 -0
- data/lib/rocketwheel/command/encoder.rb +72 -0
- data/lib/rocketwheel/command/manifest.rb +47 -0
- data/lib/rocketwheel/command/player.rb +65 -0
- data/lib/rocketwheel/command/version.rb +5 -0
- data/lib/rocketwheel/command.rb +17 -0
- data/lib/rocketwheel-command.rb +1 -0
- data/rocketwheel-command.gemspec +29 -0
- data/templates/project/2.1.2/Rocketfile.yml +25 -0
- data/templates/project/2.1.2/source/images/.empty_directory +0 -0
- data/templates/project/2.1.2/source/index.html.tt +27 -0
- data/templates/project/2.1.2/source/videos/.empty_directory +0 -0
- data/templates/transloadit.yml +16 -0
- metadata +185 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Eric J. Holmes
|
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,130 @@
|
|
1
|
+
# Rocketwheel Command
|
2
|
+
|
3
|
+
Command line tool for encoding, building and deploying player packages.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
To install the gem:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install rocketwheel-command
|
11
|
+
```
|
12
|
+
|
13
|
+
To update the gem:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem update rocketwheel-command
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Directory structure
|
22
|
+
|
23
|
+
```
|
24
|
+
+ source
|
25
|
+
+ videos
|
26
|
+
+ images
|
27
|
+
index.html.erb
|
28
|
+
Rocketfile.yml
|
29
|
+
```
|
30
|
+
|
31
|
+
Rocketfile.yml
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
s3:
|
35
|
+
key: AKIAJ3SV...
|
36
|
+
secret: SIhLOJGkT9S...
|
37
|
+
bucket: bucket
|
38
|
+
path: folder/to/deploy/to
|
39
|
+
|
40
|
+
playlist:
|
41
|
+
- image: 'images/video1.png'
|
42
|
+
title: 'Welcome to Vault PromoMats'
|
43
|
+
description: 'An overview of Veeva Vault PromoMats'
|
44
|
+
file: 'videos/video1.mp4'
|
45
|
+
|
46
|
+
player:
|
47
|
+
autostart: true
|
48
|
+
|
49
|
+
transloadit:
|
50
|
+
key: 123425adwa....
|
51
|
+
secret: 8ajd82u2jad...
|
52
|
+
```
|
53
|
+
|
54
|
+
**Versions**
|
55
|
+
|
56
|
+
Lists the various versions of the player.
|
57
|
+
|
58
|
+
```bash
|
59
|
+
rocket versions
|
60
|
+
```
|
61
|
+
|
62
|
+
**New**
|
63
|
+
|
64
|
+
Start a new project with the default template.
|
65
|
+
|
66
|
+
```bash
|
67
|
+
rocket new foobar
|
68
|
+
```
|
69
|
+
|
70
|
+
**Build**
|
71
|
+
|
72
|
+
Copies all files from the `./source` directory to the `./build` directory,
|
73
|
+
compiles any erb templates, and downloads and installs the player into the
|
74
|
+
`./build` directory.
|
75
|
+
|
76
|
+
```bash
|
77
|
+
rocket build
|
78
|
+
```
|
79
|
+
|
80
|
+
[ERB templates](http://www.stuartellis.eu/articles/erb/) (files ending in .tt, which have ruby code embedded) are rendered with the following local variables assigned:
|
81
|
+
|
82
|
+
* `player_options`: A hash of player options.
|
83
|
+
* `playlist`: An array of hashes, representing the playlist.
|
84
|
+
|
85
|
+
**Encode**
|
86
|
+
|
87
|
+
Using [transloadit](http://transloadit.com), encodes all files in `./source/videos` and places them in `./build/videos`
|
88
|
+
|
89
|
+
```bash
|
90
|
+
rocket encode
|
91
|
+
```
|
92
|
+
|
93
|
+
By default, it will use [these](./templates/transloadit.yml) transloadit steps,
|
94
|
+
but you can override the steps by specifiying them as the `transloadit.steps`
|
95
|
+
key in the Rocketfile.yml. See the [transloadit docs](https://transloadit.com/docs)
|
96
|
+
for more information.
|
97
|
+
|
98
|
+
**Deploy**
|
99
|
+
|
100
|
+
Uploads all files in the `./build` directory to S3. Uses the credentials from
|
101
|
+
the `s3` key in your Rocketfile.yml.
|
102
|
+
|
103
|
+
```bash
|
104
|
+
rocket deploy
|
105
|
+
```
|
106
|
+
|
107
|
+
## Releasing
|
108
|
+
|
109
|
+
To release a new version of the gem:
|
110
|
+
|
111
|
+
1. Bump the version number in [./lib/rocketwheel/command/version.rb](./lib/rocketwheel/command/version.rb)
|
112
|
+
2. Commit changes and tag the commit with the version number.
|
113
|
+
|
114
|
+
```bash
|
115
|
+
git commit -am "Bumped version"
|
116
|
+
git tag x.x.x && git push && git push --tags
|
117
|
+
```
|
118
|
+
3. Push the gem to [rubygems](http://rubygems.org)
|
119
|
+
|
120
|
+
```bash
|
121
|
+
rake release
|
122
|
+
```
|
123
|
+
|
124
|
+
## Contributing
|
125
|
+
|
126
|
+
1. Fork it
|
127
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
128
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
129
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
130
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/rocket
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rocketwheel/command'
|
5
|
+
Bundler.require if File.exists?('Gemfile')
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'rocketwheel/command/cli'
|
9
|
+
Rocketwheel::Command::CLI::Base.start
|
10
|
+
rescue Interrupt => e
|
11
|
+
puts "\nQuitting..."
|
12
|
+
exit 1
|
13
|
+
rescue SystemExit => e
|
14
|
+
exit e.status
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Rocketwheel::Command::CLI
|
2
|
+
class Build < Base
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
namespace :build
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.expand_path("./")
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'build', 'Build the source files into a deployable package.'
|
12
|
+
method_option :source,
|
13
|
+
:aliases => '-s',
|
14
|
+
:desc => 'Source directory to build from.',
|
15
|
+
:default => 'source'
|
16
|
+
method_option :destination,
|
17
|
+
:aliases => '-d',
|
18
|
+
:desc => 'Directory to store the build.',
|
19
|
+
:default => 'build'
|
20
|
+
def build
|
21
|
+
directory source, destination
|
22
|
+
player.download_and_unzip(File.join(destination, 'demoplayer'))
|
23
|
+
rescue Rocketwheel::Command::PlayerNotFound => e
|
24
|
+
raise Thor::Error, "#{e.message} Run `rocket versions` to see a full list of available players."
|
25
|
+
end
|
26
|
+
|
27
|
+
no_tasks do
|
28
|
+
def player_options
|
29
|
+
manifest.player_options
|
30
|
+
end
|
31
|
+
|
32
|
+
def playlist
|
33
|
+
manifest.playlist
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def player
|
40
|
+
Rocketwheel::Command::Player.version(version)
|
41
|
+
end
|
42
|
+
|
43
|
+
def version
|
44
|
+
manifest.version
|
45
|
+
end
|
46
|
+
|
47
|
+
def source
|
48
|
+
options[:source]
|
49
|
+
end
|
50
|
+
|
51
|
+
def destination
|
52
|
+
options[:destination]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'fog'
|
2
|
+
require 'mime/types'
|
3
|
+
|
4
|
+
module Rocketwheel::Command::CLI
|
5
|
+
class Deploy < Base
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
namespace :deploy
|
9
|
+
|
10
|
+
desc 'deploy', 'Push a directory to s3.'
|
11
|
+
method_option :dir,
|
12
|
+
:aliases => '-d',
|
13
|
+
:desc => 'Build directory to deploy.',
|
14
|
+
:default => 'build'
|
15
|
+
def deploy
|
16
|
+
invoke Task, [directory, config]
|
17
|
+
end
|
18
|
+
|
19
|
+
class Task < Thor::Group
|
20
|
+
argument :source
|
21
|
+
argument :config
|
22
|
+
|
23
|
+
def upload
|
24
|
+
files_to_upload.each do |file|
|
25
|
+
upload_file(file) if File.file?(file)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def upload_file(file)
|
32
|
+
key = File.join(prefix, file.sub(/#{source}\/?/, ''))
|
33
|
+
mime = MIME::Types.type_for(file).first
|
34
|
+
say_status :uploading, key, :green
|
35
|
+
bucket.files.create(
|
36
|
+
:key => key,
|
37
|
+
:body => File.read(file),
|
38
|
+
:public => true,
|
39
|
+
:content_type => mime
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def bucket
|
44
|
+
@bucket ||= s3.directories.get(bucket_name, :prefix => prefix)
|
45
|
+
end
|
46
|
+
|
47
|
+
def s3
|
48
|
+
@s3 ||= Fog::Storage.new(
|
49
|
+
:provider => 'AWS',
|
50
|
+
:aws_access_key_id => aws_key,
|
51
|
+
:aws_secret_access_key => aws_secret
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def files_to_upload
|
56
|
+
Dir["#{source}/**/**"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def aws_key
|
60
|
+
config.key
|
61
|
+
end
|
62
|
+
|
63
|
+
def aws_secret
|
64
|
+
config.secret
|
65
|
+
end
|
66
|
+
|
67
|
+
def bucket_name
|
68
|
+
config.bucket
|
69
|
+
end
|
70
|
+
|
71
|
+
def prefix
|
72
|
+
config.path
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def directory
|
80
|
+
File.join(File.expand_path('./'), dir)
|
81
|
+
end
|
82
|
+
|
83
|
+
def dir
|
84
|
+
options[:dir]
|
85
|
+
end
|
86
|
+
|
87
|
+
def config
|
88
|
+
manifest.s3
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rocketwheel/command/encoder'
|
2
|
+
|
3
|
+
module Rocketwheel::Command::CLI
|
4
|
+
class Encode < Base
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
namespace :encode
|
8
|
+
|
9
|
+
desc 'encode', 'Encode videos using transloadit.'
|
10
|
+
method_option :source,
|
11
|
+
:aliases => '-s',
|
12
|
+
:desc => 'Directory where the unencoded videos are stored.',
|
13
|
+
:default => 'source/videos'
|
14
|
+
method_option :destination,
|
15
|
+
:aliases => '-d',
|
16
|
+
:desc => 'Directory where the encoded videos will be stored.',
|
17
|
+
:default => 'build/videos'
|
18
|
+
def encode
|
19
|
+
files = Dir["#{File.join(File.expand_path('./'), source)}/**/**"]
|
20
|
+
invoke Task, [files, manifest, File.join(File.expand_path('./'), destination)]
|
21
|
+
end
|
22
|
+
|
23
|
+
class Task < Thor::Group
|
24
|
+
argument :files
|
25
|
+
argument :manifest
|
26
|
+
argument :destination
|
27
|
+
|
28
|
+
def encode
|
29
|
+
files.each do |file|
|
30
|
+
say_status :encoding, File.basename(file)
|
31
|
+
end
|
32
|
+
@encoder = Rocketwheel::Command::Encoder.new(manifest)
|
33
|
+
encoder.encode(files)
|
34
|
+
end
|
35
|
+
|
36
|
+
def wait
|
37
|
+
until encoder.encoded? do sleep 2; end
|
38
|
+
end
|
39
|
+
|
40
|
+
def download
|
41
|
+
encoder.store(destination) do |result|
|
42
|
+
say_status :downloading, result['name']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def encoder
|
49
|
+
@encoder
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def source
|
57
|
+
options[:source]
|
58
|
+
end
|
59
|
+
|
60
|
+
def destination
|
61
|
+
options[:destination]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Rocketwheel::Command::CLI
|
4
|
+
class New < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
namespace :new
|
8
|
+
|
9
|
+
def self.source_root
|
10
|
+
File.join(Rocketwheel::Command.templates, 'project')
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'new [name]', 'Start a new project.'
|
14
|
+
method_option :version,
|
15
|
+
:desc => 'The player version to use. Defaults to latest.'
|
16
|
+
def new(name)
|
17
|
+
directory version, name
|
18
|
+
end
|
19
|
+
|
20
|
+
class NoTemplateDirectory < Directory
|
21
|
+
protected
|
22
|
+
|
23
|
+
def execute!
|
24
|
+
lookup = Thor::Util.escape_globs(source)
|
25
|
+
lookup = config[:recursive] ? File.join(lookup, '**') : lookup
|
26
|
+
lookup = file_level_lookup(lookup)
|
27
|
+
|
28
|
+
files(lookup).sort.each do |file_source|
|
29
|
+
next if File.directory?(file_source)
|
30
|
+
next if config[:exclude_pattern] && file_source.match(config[:exclude_pattern])
|
31
|
+
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
32
|
+
file_destination.gsub!('/./', '/')
|
33
|
+
|
34
|
+
case file_source
|
35
|
+
when /\.empty_directory$/
|
36
|
+
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
|
37
|
+
next if dirname == given_destination
|
38
|
+
base.empty_directory(dirname, config)
|
39
|
+
else
|
40
|
+
destination = base.copy_file(file_source, file_destination, config, &@block)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def directory(source, *args, &block)
|
49
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
50
|
+
destination = args.first || source
|
51
|
+
action NoTemplateDirectory.new(self, source, destination || source, config, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
def version
|
55
|
+
options[:version] || Rocketwheel::Command::Player.latest_version
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rocketwheel::Command::CLI
|
2
|
+
class Versions < Thor
|
3
|
+
namespace :versions
|
4
|
+
|
5
|
+
desc 'versions', 'List player versions'
|
6
|
+
def versions
|
7
|
+
Rocketwheel::Command::Player.all.each do |player|
|
8
|
+
say "#{player.version} - #{player.download_url}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
module Rocketwheel
|
5
|
+
module Command
|
6
|
+
module CLI
|
7
|
+
class Base < Thor
|
8
|
+
class << self
|
9
|
+
def start(*args)
|
10
|
+
# Change flag to a module
|
11
|
+
ARGV.unshift('help') if ARGV.delete('--help')
|
12
|
+
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def filename
|
17
|
+
Rocketwheel::Command::MANIFEST
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Override the Thor help method to find help for subtasks
|
22
|
+
# @param [Symbol, String, nil] meth
|
23
|
+
# @param [Boolean] subcommand
|
24
|
+
# @return [void]
|
25
|
+
def help(meth = nil, subcommand = false)
|
26
|
+
if meth && !self.respond_to?(meth)
|
27
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
28
|
+
klass.start(["-h", task].compact, :shell => self.shell)
|
29
|
+
else
|
30
|
+
list = []
|
31
|
+
Thor::Util.thor_classes_in(Rocketwheel::Command::CLI).each do |klass|
|
32
|
+
list += klass.printable_tasks(false)
|
33
|
+
end
|
34
|
+
list.sort!{ |a,b| a[0] <=> b[0] }
|
35
|
+
|
36
|
+
shell.say "Tasks:"
|
37
|
+
shell.print_table(list, :ident => 2, :truncate => true)
|
38
|
+
shell.say
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Intercept missing methods and search subtasks for them
|
43
|
+
# @param [Symbol] meth
|
44
|
+
def method_missing(meth, *args)
|
45
|
+
meth = meth.to_s
|
46
|
+
|
47
|
+
if self.class.map.has_key?(meth)
|
48
|
+
meth = self.class.map[meth]
|
49
|
+
end
|
50
|
+
|
51
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
52
|
+
|
53
|
+
if klass.nil?
|
54
|
+
tasks_dir = File.join(Dir.pwd, "tasks")
|
55
|
+
|
56
|
+
if File.exists?(tasks_dir)
|
57
|
+
Dir[File.join(tasks_dir, "**/*_task.rb")].each { |f| require f }
|
58
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if klass.nil?
|
63
|
+
raise Thor::Error.new "There's no '#{meth}' command. Try 'rocket help' for a list of commands."
|
64
|
+
else
|
65
|
+
args.unshift(task) if task
|
66
|
+
klass.start(args, :shell => self.shell)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def manifest
|
73
|
+
@manifest ||= begin
|
74
|
+
file = File.join(File.expand_path('./'), self.class.filename)
|
75
|
+
raise Thor::Error, "No #{self.class.filename} file found" unless File.exists?(file)
|
76
|
+
Manifest.from_file(file)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
require 'rocketwheel/command/cli/versions'
|
86
|
+
require 'rocketwheel/command/cli/new'
|
87
|
+
require 'rocketwheel/command/cli/build'
|
88
|
+
require 'rocketwheel/command/cli/encode'
|
89
|
+
require 'rocketwheel/command/cli/deploy'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'transloadit'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
module Rocketwheel
|
7
|
+
module Command
|
8
|
+
class Encoder
|
9
|
+
def initialize(manifest)
|
10
|
+
@manifest = manifest
|
11
|
+
end
|
12
|
+
|
13
|
+
# Public: Starts an encoding job, sending the files to transloadit.
|
14
|
+
def encode(files)
|
15
|
+
files = files.map { |file| open(file) }
|
16
|
+
@response = transloadit.assembly(assembly).submit! *files
|
17
|
+
end
|
18
|
+
|
19
|
+
def encoded?
|
20
|
+
response.reload!
|
21
|
+
response.completed?
|
22
|
+
end
|
23
|
+
|
24
|
+
def store(destination)
|
25
|
+
response['results'].each do |name, result|
|
26
|
+
result.each do |result|
|
27
|
+
yield result if block_given?
|
28
|
+
folder = File.join(destination, name)
|
29
|
+
FileUtils.mkdir_p(folder)
|
30
|
+
filename = File.join(folder, result['name'])
|
31
|
+
download(result['url'], filename)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
attr_accessor :root, :manifest, :response
|
38
|
+
|
39
|
+
def download(url, destination)
|
40
|
+
uri = URI.parse(url)
|
41
|
+
Net::HTTP.start(uri.host) do |http|
|
42
|
+
resp = http.get(uri.path)
|
43
|
+
File.open(destination, 'wb') { |f| f.write(resp.body) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def transloadit
|
48
|
+
@transloadit ||= Transloadit.new(
|
49
|
+
:key => transloadit_config.key,
|
50
|
+
:secret => transloadit_config.secret
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def transloadit_config
|
55
|
+
manifest.transloadit
|
56
|
+
end
|
57
|
+
|
58
|
+
def default_steps
|
59
|
+
YAML.load(File.read(File.join(Rocketwheel::Command.templates, 'transloadit.yml')))['steps']
|
60
|
+
end
|
61
|
+
|
62
|
+
def custom_steps
|
63
|
+
transloadit_config.steps
|
64
|
+
end
|
65
|
+
|
66
|
+
def assembly
|
67
|
+
{ 'steps' => custom_steps || default_steps }
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Rocketwheel
|
4
|
+
module Command
|
5
|
+
class Manifest
|
6
|
+
S3Config = Struct.new(:key, :secret, :bucket, :path)
|
7
|
+
TransloaditConfig = Struct.new(:key, :secret, :steps)
|
8
|
+
|
9
|
+
attr_accessor :content
|
10
|
+
|
11
|
+
def self.from_file(path)
|
12
|
+
new(YAML.load(File.open(path)))
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(hash)
|
16
|
+
@content = hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def version
|
20
|
+
@version ||= content.fetch('version', Player.latest_version)
|
21
|
+
end
|
22
|
+
|
23
|
+
def s3
|
24
|
+
@s3 ||= begin
|
25
|
+
config = content.fetch('s3', Hash.new)
|
26
|
+
S3Config.new(config['key'], config['secret'], config['bucket'], config['path'].to_s)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def playlist
|
31
|
+
@playlist = content.fetch('playlist', [])
|
32
|
+
end
|
33
|
+
|
34
|
+
def player_options
|
35
|
+
@player_options ||= content.fetch('player', Hash.new)
|
36
|
+
end
|
37
|
+
|
38
|
+
def transloadit
|
39
|
+
@transloadit ||= begin
|
40
|
+
config = content.fetch('transloadit', Hash.new)
|
41
|
+
TransloaditConfig.new(config['key'], config['secret'], config['steps'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'zip/zip'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Rocketwheel
|
7
|
+
module Command
|
8
|
+
PlayerNotFound = Class.new(StandardError)
|
9
|
+
|
10
|
+
class Player
|
11
|
+
HOST = 'https://demoplayers.s3.amazonaws.com'
|
12
|
+
|
13
|
+
attr_reader :json
|
14
|
+
|
15
|
+
def initialize(json)
|
16
|
+
@json = json
|
17
|
+
end
|
18
|
+
|
19
|
+
def version
|
20
|
+
json['version']
|
21
|
+
end
|
22
|
+
|
23
|
+
def download_url
|
24
|
+
json['download']
|
25
|
+
end
|
26
|
+
|
27
|
+
def download_and_unzip(destination)
|
28
|
+
file = open(download_url)
|
29
|
+
Zip::ZipFile::open(file) do |zf|
|
30
|
+
zf.each do |e|
|
31
|
+
path = File.join(destination, e.to_s)
|
32
|
+
FileUtils.mkdir_p(File.dirname(path))
|
33
|
+
zf.extract(e, path) { true }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
def json
|
40
|
+
@json ||= JSON.parse(open(File.join(HOST, 'versions.json')).read)
|
41
|
+
end
|
42
|
+
|
43
|
+
def all
|
44
|
+
versions.map { |p| self.new(p) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def latest_version
|
48
|
+
json['latest']
|
49
|
+
end
|
50
|
+
|
51
|
+
def latest
|
52
|
+
version(latest_version)
|
53
|
+
end
|
54
|
+
|
55
|
+
def version(version)
|
56
|
+
all.find { |player| player.version.to_s == version.to_s } || raise(PlayerNotFound, "Version #{version} of the player was not found.")
|
57
|
+
end
|
58
|
+
|
59
|
+
def versions
|
60
|
+
json['versions']
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fog'
|
2
|
+
require 'transloadit'
|
3
|
+
|
4
|
+
require 'rocketwheel/command/version'
|
5
|
+
require 'rocketwheel/command/manifest'
|
6
|
+
|
7
|
+
require 'rocketwheel/command/player'
|
8
|
+
|
9
|
+
module Rocketwheel
|
10
|
+
module Command
|
11
|
+
MANIFEST = 'Rocketfile.yml'
|
12
|
+
|
13
|
+
def self.templates
|
14
|
+
File.expand_path('../../../templates', __FILE__)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rocketwheel/command'
|
@@ -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 'rocketwheel/command/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'rocketwheel-command'
|
8
|
+
gem.version = Rocketwheel::Command::VERSION
|
9
|
+
gem.authors = ["Eric J. Holmes"]
|
10
|
+
gem.email = ["eric@ejholmes.net"]
|
11
|
+
gem.description = %q{Command line tool for encoding, building and deploying demo packages.}
|
12
|
+
gem.summary = %q{Command line tool for encoding, building and deploying demo packages.}
|
13
|
+
gem.homepage = "https://github.com/luminosity-group/rocketwheel-command"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency 'thor', '~> 0.17.0'
|
22
|
+
gem.add_dependency 'transloadit', '~> 1.0.3'
|
23
|
+
gem.add_dependency 'fog', '~> 1.9.0'
|
24
|
+
gem.add_dependency 'rubyzip', '~> 0.9.9'
|
25
|
+
gem.add_dependency 'mime-types', '~> 1.21'
|
26
|
+
|
27
|
+
gem.add_development_dependency 'rake'
|
28
|
+
gem.add_development_dependency 'rspec'
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
version: 2.1.2
|
2
|
+
|
3
|
+
# s3:
|
4
|
+
# key: s3key
|
5
|
+
# secret: s3 secret
|
6
|
+
# bucket: s3 bucket
|
7
|
+
# path: path/to/s3/folder
|
8
|
+
|
9
|
+
# playlist:
|
10
|
+
# - image: 'images/video1.png'
|
11
|
+
# title: 'Title'
|
12
|
+
# description: 'Description'
|
13
|
+
# levels:
|
14
|
+
# - file: 'videos/mp4/video1.mp4'
|
15
|
+
# - file: 'videos/webm/video1.webm'
|
16
|
+
|
17
|
+
# player:
|
18
|
+
# autostart: false
|
19
|
+
|
20
|
+
# transloadit:
|
21
|
+
# key: transloadit key
|
22
|
+
# secret: transloadit secret
|
23
|
+
#
|
24
|
+
# # Custom transloadit steps
|
25
|
+
# steps:
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Title</title>
|
5
|
+
<link rel="stylesheet" href="demoplayer/stylesheets/player.css" type="text/css" media="screen">
|
6
|
+
<script src="demoplayer/javascripts/player.js" type="text/javascript"></script>
|
7
|
+
<meta name="viewport" content="width=880" />
|
8
|
+
<script type="text/javascript">
|
9
|
+
$(function() {
|
10
|
+
Player.setup({
|
11
|
+
playlist: <%= playlist.to_json %>,
|
12
|
+
jwplayer_options: <%= player_options.to_json %>
|
13
|
+
})
|
14
|
+
})
|
15
|
+
</script>
|
16
|
+
</head>
|
17
|
+
<body>
|
18
|
+
<div id="demoplayer-position">
|
19
|
+
<script type="text/x-handlebars">
|
20
|
+
{{#view Player.View styles="inline"}}
|
21
|
+
{{view Player.PlayerView}}
|
22
|
+
{{view Player.PlaylistView}}
|
23
|
+
{{/view}}
|
24
|
+
</script>
|
25
|
+
</div>
|
26
|
+
</body>
|
27
|
+
</html>
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rocketwheel-command
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Eric J. Holmes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.17.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.17.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: transloadit
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fog
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.9.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.9.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rubyzip
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.9
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.9
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mime-types
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.21'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.21'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: Command line tool for encoding, building and deploying demo packages.
|
127
|
+
email:
|
128
|
+
- eric@ejholmes.net
|
129
|
+
executables:
|
130
|
+
- rocket
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- .gitignore
|
135
|
+
- .rspec
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/rocket
|
141
|
+
- lib/rocketwheel-command.rb
|
142
|
+
- lib/rocketwheel/command.rb
|
143
|
+
- lib/rocketwheel/command/cli.rb
|
144
|
+
- lib/rocketwheel/command/cli/build.rb
|
145
|
+
- lib/rocketwheel/command/cli/deploy.rb
|
146
|
+
- lib/rocketwheel/command/cli/encode.rb
|
147
|
+
- lib/rocketwheel/command/cli/new.rb
|
148
|
+
- lib/rocketwheel/command/cli/versions.rb
|
149
|
+
- lib/rocketwheel/command/encoder.rb
|
150
|
+
- lib/rocketwheel/command/manifest.rb
|
151
|
+
- lib/rocketwheel/command/player.rb
|
152
|
+
- lib/rocketwheel/command/version.rb
|
153
|
+
- rocketwheel-command.gemspec
|
154
|
+
- templates/project/2.1.2/Rocketfile.yml
|
155
|
+
- templates/project/2.1.2/source/images/.empty_directory
|
156
|
+
- templates/project/2.1.2/source/index.html.tt
|
157
|
+
- templates/project/2.1.2/source/videos/.empty_directory
|
158
|
+
- templates/transloadit.yml
|
159
|
+
homepage: https://github.com/luminosity-group/rocketwheel-command
|
160
|
+
licenses:
|
161
|
+
- MIT
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ! '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubyforge_project:
|
180
|
+
rubygems_version: 1.8.23
|
181
|
+
signing_key:
|
182
|
+
specification_version: 3
|
183
|
+
summary: Command line tool for encoding, building and deploying demo packages.
|
184
|
+
test_files: []
|
185
|
+
has_rdoc:
|