sweatshop_gears 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -16
- data/bin/sweatshop-gears +2 -1
- data/lib/robot_sweatshop/gears/metadata.rb +2 -9
- data/lib/robot_sweatshop/gears/packages.rb +25 -13
- data/lib/robot_sweatshop/gears/{binaries.rb → scripts.rb} +8 -8
- data/lib/robot_sweatshop/gears/services.rb +17 -6
- data/lib/robot_sweatshop/gears/sweatshop_gears.eye.eruby +3 -1
- data/lib/robot_sweatshop/gears.rb +1 -1
- data/sweatshop_gears.gemspec +1 -1
- data/test/init_test.rb +1 -1
- data/test/install_test.rb +4 -4
- metadata +3 -6
- data/test/cli.bats +0 -9
- data/test/init.bats +0 -15
- data/test/install.bats +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc3432f3f0c58de91d6369534b3e2c36f21d92c4
|
4
|
+
data.tar.gz: e108f43c71799209c4b1291122b78c38d8f22880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcc421e65836a289b4535c9c785cc8446cbee10e7fe49954112130225fe511130bf172a17969a187864fa335db23275db7c9dcb54e5104ec34fc15fe6120b755
|
7
|
+
data.tar.gz: b4cc260bc7680a529737ab17e9fa1c884a68273980d2bb05137c8744b960d72eaa2777ccda30ed1c9f966274957354072bb010e4af3f09316b5a0ce5a93dc494
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -1,17 +1,7 @@
|
|
1
|
+
require 'terminal-announce'
|
1
2
|
require 'rake'
|
2
3
|
require 'rake/testtask'
|
3
4
|
|
4
|
-
task :bats do
|
5
|
-
`sweatshop stop`
|
6
|
-
$stdout.sync = true
|
7
|
-
puts 'sweatshop-gears'
|
8
|
-
IO.popen "bats #{__dir__}/test --pretty" do |io_stream|
|
9
|
-
while line = io_stream.gets
|
10
|
-
puts line
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
5
|
task :riot do
|
16
6
|
Dir.glob('test/*_test.rb').each do |path|
|
17
7
|
require_relative path
|
@@ -19,11 +9,10 @@ task :riot do
|
|
19
9
|
end
|
20
10
|
|
21
11
|
task :build do
|
22
|
-
|
23
|
-
`
|
24
|
-
|
25
|
-
`gem install sweatshop_gears-*.gem`
|
26
|
-
puts 'Done.'
|
12
|
+
Announce.info 'Building and installing local gem...'
|
13
|
+
puts `rm -rf sweatshop_gears-*.gem`
|
14
|
+
puts `gem build sweatshop_gears.gemspec --force`
|
15
|
+
puts `gem install sweatshop_gears-*.gem`
|
27
16
|
end
|
28
17
|
|
29
18
|
task default: :test
|
data/bin/sweatshop-gears
CHANGED
@@ -5,7 +5,7 @@ require 'commander/import'
|
|
5
5
|
require 'robot_sweatshop/gears'
|
6
6
|
|
7
7
|
program :name, 'Sweatshop Gears'
|
8
|
-
program :version, '1.0.
|
8
|
+
program :version, '1.0.4'
|
9
9
|
program :description, 'Package management for Robot Sweatshop'
|
10
10
|
program :help, 'Author', 'Justin Scott <jvscott@gmail.com>'
|
11
11
|
|
@@ -19,6 +19,7 @@ command :init do |c|
|
|
19
19
|
options.default path: '/usr/local/gears'
|
20
20
|
FileUtils.mkpath options.path
|
21
21
|
Gears::Metadata.download to_path: options.path
|
22
|
+
# TODO: create_runtime_paths not obvious
|
22
23
|
Gears::Metadata.create_runtime_paths # TODO: ensure robot_sweatshop ran and the compiled config exists? Only errors in Services
|
23
24
|
end
|
24
25
|
end
|
@@ -27,15 +27,8 @@ module Gears
|
|
27
27
|
def self.create_runtime_paths
|
28
28
|
config_path = File.expand_path '~/.robot_sweatshop/compiled_config.yaml'
|
29
29
|
config = YAML.load_file config_path
|
30
|
-
FileUtils.mkpath config[:logfile_path]
|
31
|
-
FileUtils.mkpath config[:pidfile_path]
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.download_and_install(package_name, from_path:)
|
35
|
-
metadata_path = "#{from_path}/#{package_name}.yaml"
|
36
|
-
fail "#{package_name} not found" unless File.exist? metadata_path
|
37
|
-
metadata = YAML.load_file metadata_path
|
38
|
-
Gears::Package.install_from metadata
|
30
|
+
FileUtils.mkpath "#{config[:logfile_path]}/gears"
|
31
|
+
FileUtils.mkpath "#{config[:pidfile_path]}/gears"
|
39
32
|
end
|
40
33
|
end
|
41
34
|
end
|
@@ -4,31 +4,43 @@ require 'terminal-announce'
|
|
4
4
|
module Gears
|
5
5
|
module Packages
|
6
6
|
def self.clone(git_repo, to_path:)
|
7
|
+
return if Dir.exist? to_path
|
7
8
|
Git.clone git_repo, File.basename(to_path), path: File.dirname(to_path)
|
8
9
|
end
|
9
10
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
11
|
+
def self.metadata_for(package_name, path)
|
12
|
+
metadata_file = "#{path}/#{package_name}.yaml"
|
13
|
+
fail "Metadata for '#{package_name}' not found" unless File.exist? metadata_file
|
14
|
+
YAML.load_file metadata_file
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def self.install_to(install_path)
|
18
|
+
case metadata['type']
|
19
|
+
when 'script'
|
20
|
+
Gears::Scripts.expose from_path: install_path
|
21
|
+
when 'service'
|
22
|
+
Gears::Services.load from_path: install_path
|
23
|
+
else
|
24
|
+
fail 'Unknown package type'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.expose(plural_type, from_path:)
|
29
|
+
namespace = Gears.const_get plural_type.capitalize.to_sym
|
30
|
+
namespace.send :expose, from_path: from_path
|
20
31
|
end
|
21
32
|
|
22
33
|
def self.install(package_name, from_path:)
|
23
|
-
|
34
|
+
metadata = metadata_for package_name, from_path
|
35
|
+
plural_type = "#{metadata['type']}s"
|
36
|
+
install_path = "#{from_path}/#{plural_type}/#{package_name}"
|
24
37
|
clone metadata['repo'], to_path: install_path
|
25
|
-
Announce.success "#{package_name} downloaded"
|
26
38
|
Gears::Dependencies.install from_path: install_path
|
27
|
-
|
28
|
-
|
39
|
+
expose plural_type, from_path: install_path
|
40
|
+
Announce.success "#{package_name} installed"
|
29
41
|
rescue
|
30
42
|
Announce.failure 'Error occurred, rolling back installation'
|
31
|
-
FileUtils.rm_rf
|
43
|
+
FileUtils.rm_rf install_path
|
32
44
|
end
|
33
45
|
end
|
34
46
|
end
|
@@ -2,17 +2,17 @@ require 'fileutils'
|
|
2
2
|
require 'terminal-announce'
|
3
3
|
|
4
4
|
module Gears
|
5
|
-
# Installs
|
6
|
-
module
|
5
|
+
# Installs Gears script packages
|
6
|
+
module Scripts
|
7
7
|
def self.expose(from_path:)
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
script_name = File.basename from_path
|
9
|
+
original_script = File.expand_path "#{from_path}/#{script_name}"
|
10
|
+
script_link = File.expand_path "#{scripts_path}/#{script_name}"
|
11
11
|
begin
|
12
|
-
FileUtils.symlink
|
13
|
-
Announce.success "Symlinked #{
|
12
|
+
FileUtils.symlink original_script, script_link
|
13
|
+
Announce.success "Symlinked #{script_name}"
|
14
14
|
rescue
|
15
|
-
Announce.warning "#{
|
15
|
+
Announce.warning "#{script_name} already exists"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -3,27 +3,38 @@ require 'terminal-announce'
|
|
3
3
|
require 'erubis'
|
4
4
|
|
5
5
|
module Gears
|
6
|
-
# Installs service
|
6
|
+
# Installs Gears service packages
|
7
7
|
module Services
|
8
|
-
def self.
|
8
|
+
def self.expose(from_path:)
|
9
9
|
service = File.basename from_path
|
10
|
-
dynamically_load_eye
|
10
|
+
dynamically_load_eye from_path
|
11
11
|
Announce.success "Loaded #{service} into Eye"
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.write_and_load(eye_config)
|
15
15
|
eye_file = '/tmp/.sweatshop_gears.eye'
|
16
16
|
File.write eye_file, eye_config
|
17
|
-
puts eye_config
|
18
17
|
puts `eye load #{eye_file}`
|
19
18
|
puts `eye stop sweatshop_gears`
|
20
19
|
File.delete eye_file
|
21
20
|
end
|
22
21
|
|
23
|
-
def self.
|
22
|
+
def self.services_installed_to(install_path)
|
23
|
+
paths = Dir["#{install_path}/*"].select { |path| File.directory? path }
|
24
|
+
paths.map { |path| File.basename path }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parent_path_of(install_path)
|
28
|
+
File.expand_path "#{install_path}/.."
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.dynamically_load_eye(install_path)
|
32
|
+
context = {
|
33
|
+
services: services_installed_to(parent_path_of(install_path)),
|
34
|
+
install_path: File.expand_path(install_path)
|
35
|
+
}
|
24
36
|
input = File.read "#{__dir__}/sweatshop_gears.eye.eruby"
|
25
37
|
eruby = Erubis::Eruby.new input
|
26
|
-
context = { service: service, gears_path: File.expand_path(gears_path) }
|
27
38
|
write_and_load eruby.result(context)
|
28
39
|
end
|
29
40
|
end
|
@@ -15,10 +15,12 @@ Eye.application :sweatshop_gears do
|
|
15
15
|
check :cpu, every: 10.seconds, below: 100, times: 3
|
16
16
|
working_dir CONFIG[:working_path]
|
17
17
|
|
18
|
+
<% for service in services %>
|
18
19
|
process :'<%= service %>' do
|
19
20
|
pid_file "#{PID_PATH}/gears/<%= service %>.pid"
|
20
21
|
stdall "#{LOG_PATH}/gears/<%= service %>.log"
|
21
|
-
start_command "<%=
|
22
|
+
start_command "<%= install_path %>/<%= service %>"
|
22
23
|
daemonize true
|
23
24
|
end
|
25
|
+
<% end %>
|
24
26
|
end
|
data/sweatshop_gears.gemspec
CHANGED
data/test/init_test.rb
CHANGED
@@ -7,5 +7,5 @@ context 'sweatshop-gears init' do
|
|
7
7
|
setup { `bin/sweatshop-gears init --path #{PACKAGES_PATH}` }
|
8
8
|
denies_topic('the output').empty
|
9
9
|
asserts('metadata is downloaded') { File.exist? "#{PACKAGES_PATH}/git-sync.yaml" }
|
10
|
-
denies('packages are downloaded') { File.exist? "#{SWEATSHOP_SCRIPTS_PATH}/git-sync" }
|
10
|
+
denies('packages are downloaded') { File.exist? "#{SWEATSHOP_SCRIPTS_PATH}/scripts/git-sync" }
|
11
11
|
end
|
data/test/install_test.rb
CHANGED
@@ -3,14 +3,14 @@ require_relative 'teststrap'
|
|
3
3
|
context 'sweatshop-gears install' do
|
4
4
|
setup do
|
5
5
|
clean_up_paths
|
6
|
-
%w(git-sync big-green-button).each do |package|
|
6
|
+
%w(git-sync big-green-button reporter).each do |package|
|
7
7
|
`sweatshop-gears install #{package} --path #{PACKAGES_PATH}`
|
8
8
|
end
|
9
9
|
end
|
10
10
|
denies_topic('the output').empty
|
11
|
-
asserts('packages are downloaded') { File.exist? "#{PACKAGES_PATH}/git-sync" }
|
12
|
-
asserts('
|
11
|
+
asserts('packages are downloaded') { File.exist? "#{PACKAGES_PATH}/scripts/git-sync" }
|
12
|
+
asserts('scripts are symlinked') { File.exist? "#{SWEATSHOP_SCRIPTS_PATH}/git-sync" }
|
13
13
|
denies('services are symlinked') { File.exist? "#{SWEATSHOP_SCRIPTS_PATH}/big-green-button" }
|
14
|
-
asserts('services are loaded into Eye') {
|
14
|
+
asserts('all services are loaded into Eye') { `eye info | grep --extended-regexp 'big-green-button|reporter'`.lines.count == 2 }
|
15
15
|
# asserts('dependencies are installed') { ??? }
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweatshop_gears
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -166,18 +166,15 @@ files:
|
|
166
166
|
- Rakefile
|
167
167
|
- bin/sweatshop-gears
|
168
168
|
- lib/robot_sweatshop/gears.rb
|
169
|
-
- lib/robot_sweatshop/gears/binaries.rb
|
170
169
|
- lib/robot_sweatshop/gears/dependencies.rb
|
171
170
|
- lib/robot_sweatshop/gears/metadata.rb
|
172
171
|
- lib/robot_sweatshop/gears/packages.rb
|
172
|
+
- lib/robot_sweatshop/gears/scripts.rb
|
173
173
|
- lib/robot_sweatshop/gears/services.rb
|
174
174
|
- lib/robot_sweatshop/gears/sweatshop_gears.eye.eruby
|
175
175
|
- sweatshop_gears.gemspec
|
176
|
-
- test/cli.bats
|
177
176
|
- test/help_test.rb
|
178
|
-
- test/init.bats
|
179
177
|
- test/init_test.rb
|
180
|
-
- test/install.bats
|
181
178
|
- test/install_test.rb
|
182
179
|
- test/teststrap.rb
|
183
180
|
homepage: http://www.github.com/jscott/sweatshop-gears-cli/
|
data/test/cli.bats
DELETED
data/test/init.bats
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bats
|
2
|
-
|
3
|
-
@test "Downloads the Gears packages" {
|
4
|
-
run sweatshop-gears init --path .test_download_path
|
5
|
-
[ -f .test_download_path/README.md ]
|
6
|
-
}
|
7
|
-
|
8
|
-
@test "Doesn't download any packages" {
|
9
|
-
run sweatshop-gears init --path .test_download_path
|
10
|
-
[ ! -f .test_download_path/packages/big-green-button/README.md ]
|
11
|
-
}
|
12
|
-
|
13
|
-
teardown() {
|
14
|
-
rm -rf .test_download_path
|
15
|
-
}
|
data/test/install.bats
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bats
|
2
|
-
|
3
|
-
@test "Exposes package binaries" {
|
4
|
-
run sweatshop-gears install git-sync --path .test_download_path
|
5
|
-
scripts_path=.robot_sweatshop/scripts
|
6
|
-
[ -f $scripts_path/git-sync ]
|
7
|
-
}
|
8
|
-
|
9
|
-
@test "Doesn't expose services" {
|
10
|
-
run sweatshop-gears install big-green-button --path .test_download_path
|
11
|
-
scripts_path=.robot_sweatshop/scripts
|
12
|
-
[ ! -f $scripts_path/big-green-button ]
|
13
|
-
}
|
14
|
-
|
15
|
-
@test "Loads services into Eye" {
|
16
|
-
eye stop big-green-button
|
17
|
-
run sweatshop-gears install big-green-button --path .test_download_path
|
18
|
-
eye start big-green-button
|
19
|
-
sleep 3
|
20
|
-
[[ $(eye info | grep big-green-button) =~ up ]]
|
21
|
-
}
|
22
|
-
|
23
|
-
@test "Installs dependencies" {
|
24
|
-
skip "I need a gem to be installed that isn't used by Sweatshop or Gears"
|
25
|
-
yes | gem uninstall SOME_GEM --all
|
26
|
-
sweatshop-gears install git-sync --path .test_download_path
|
27
|
-
[[ $(gem list) =~ "SOME_GEM " ]]
|
28
|
-
}
|
29
|
-
|
30
|
-
teardown() {
|
31
|
-
rm -rf .test_download_path
|
32
|
-
}
|