doit 0.2.4

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79a433db8959ba8237dbc94e440e09e81cf8cac6
4
+ data.tar.gz: ae14003d0bb47603b5b84cb65952ba89a68135f5
5
+ SHA512:
6
+ metadata.gz: 418fe282ab06d1b9bdf7293702eb03251855937194114d68967616ff89402c58ff8d23272bfe02cdd5cd3b90f146b2e920d8597d4ecee883011cc6d0fb4a5e31
7
+ data.tar.gz: 80b566ffc7fbdb1af2752b366c05c958f414d26930c51e06b4198e493c7b71ae49f59c51ebc15ef9cc6862ec69c87eade97dee6d699055ee631c4be861519a65
data/.doit/hello ADDED
@@ -0,0 +1,2 @@
1
+ echo Hello
2
+ pwd
data/.doit/hello.yml ADDED
@@ -0,0 +1,13 @@
1
+ env:
2
+ - DIR=tmp OPTION=y
3
+ - x=<%= 1 + 3 %>
4
+ a:
5
+ - 1
6
+ where:
7
+ - doit
8
+ # - bob@sample.com
9
+ # - alice@customer.com
10
+ # - app@localhost
11
+ # - login@localhost
12
+ # - docu@localhost
13
+ # - hour4@localhost
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.2
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ bundler_args: "--without development"
2
+ script: bundle exec rake
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.3
data/.watchr ADDED
@@ -0,0 +1,51 @@
1
+ HH = '#' * 22 unless defined?(HH)
2
+ H = '#' * 5 unless defined?(H)
3
+
4
+ def usage
5
+ puts <<-EOS
6
+ Ctrl-\\ or ctrl-4 Running all tests
7
+ Ctrl-C Exit
8
+ EOS
9
+ end
10
+
11
+ def run(cmd)
12
+ puts "#{HH} #{Time.now} #{HH}"
13
+ puts "#{H} #{cmd}"
14
+ system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
15
+ end
16
+
17
+ def run_it(type, file)
18
+ case type
19
+ when 'test'; run %Q{ruby -I"lib:test" -rubygems #{file}}
20
+ else; puts "#{H} unknown type: #{type}, file: #{file}"
21
+ end
22
+ end
23
+
24
+ def run_all_tests
25
+ puts "\n#{HH} Running all tests #{HH}\n"
26
+ %w{test}.each { |dir| run "rake #{dir}" if File.exists?(dir) }
27
+ end
28
+
29
+ def run_matching_files(base)
30
+ base = base.split('_').first
31
+ %w{test spec}.each { |type|
32
+ files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
33
+ run_it type, files.join(' ') unless files.empty?
34
+ }
35
+ end
36
+
37
+ %w{test spec}.each { |type|
38
+ watch("#{type}/#{type}_helper\.rb") { run_all_tests }
39
+ watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
40
+ }
41
+ %w{rb erb haml slim}.each { |type|
42
+ watch(".*/.*\.#{type}") { |m|
43
+ run_matching_files("#{m[0].split('/').last.split('.').first}")
44
+ }
45
+ }
46
+
47
+ # Ctrl-\ or ctrl-4
48
+ Signal.trap('QUIT') { run_all_tests }
49
+ # Ctrl-C
50
+ Signal.trap('INT') { abort("Interrupted\n") }
51
+ usage
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'micro-optparse'
4
+
5
+ group :test do
6
+ gem 'simplecov', require: false
7
+ end
8
+
9
+ group :test, :development do
10
+ gem 'rake'
11
+ gem 'watchr'
12
+ end
13
+
14
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ doit (0.2.4)
5
+ micro-optparse
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ docile (1.1.5)
11
+ micro-optparse (1.2.0)
12
+ multi_json (1.10.1)
13
+ rake (10.3.2)
14
+ simplecov (0.9.1)
15
+ docile (~> 1.1.0)
16
+ multi_json (~> 1.0)
17
+ simplecov-html (~> 0.8.0)
18
+ simplecov-html (0.8.0)
19
+ watchr (0.7)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ doit!
26
+ micro-optparse
27
+ rake
28
+ simplecov
29
+ watchr
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2014 Dittmar Krall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ Doit
2
+ ====
3
+
4
+ Executes good old shell/bash scripts locally as well as remotely.
5
+ The environment is set by a ".yml" configuration file.
6
+ An array environment variable triggers multiple calls of the script.
7
+
8
+ Installation
9
+ ------------
10
+ gem install doit
11
+
12
+ Usage
13
+ -----
14
+ doit script... [options]
15
+ doit push
16
+ doit deploy tag
17
+
18
+ Options
19
+ -------
20
+ -l, --[no-]list Lists available scripts
21
+ -r, --remote ["host"] remote host or comma separated hosts
22
+ -s, --[no-]silent run silently; suppress output
23
+ -v, --[no-]verbose Enable verbose output
24
+ -n, --[no-]noop Suppress execution of commannds
25
+ -h, --help Show this message
26
+ -V, --version Print version
27
+
28
+ File Structure
29
+ --------------
30
+ ~/.doit/deploy # chmod +x .doit/deploy
31
+ ~/.doit/deploy.yml
32
+ $PROJ/.doit/deploy.yml # overwrites
33
+ $PROJ/.doit/push # chmod +x .doit/deploy
34
+ $PROJ/.doit/push.yml
35
+
36
+ $PROJ/.doit/push
37
+ ----------------
38
+ if ! (git status | grep 'nothing to commit'); then
39
+ echo "push: commits are pending"
40
+ exit 1
41
+ fi
42
+
43
+ current_branch=`git rev-parse --abbrev-ref HEAD`
44
+ echo "**** branch is '$current_branch'"
45
+
46
+ case $current_branch in
47
+ development)
48
+ git checkout master && git merge --no-ff development &&
49
+ git push origin master
50
+ git checkout development
51
+ ;;
52
+ master)
53
+ git push origin master
54
+ ;;
55
+ esac
56
+
57
+ ~/.doit/deploy
58
+ --------------
59
+ uname -a
60
+ git status
61
+
62
+ ~/.doit/deploy.yml
63
+ ------------------
64
+ env:
65
+ - DIR=tmp OPTION=run
66
+ - DIR=proj OPTION=list
67
+ where:
68
+ - bob@sample.com
69
+ - alice@customer.com
70
+
71
+ Copyright (c) 2014 [Dittmar Krall], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'bundler/gem_tasks'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs.push 'test'
7
+ t.pattern = 'test/*_test.rb'
8
+ end
9
+
10
+ desc 'Default: run unit tests.'
11
+ task :default => :test
data/bin/doit ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib/', __FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'doit'
7
+ require 'micro-optparse'
8
+ require 'globals'
9
+
10
+ options = Parser.new do |p|
11
+ p.banner = "Usage: doit script... [options] # execute locally or remotely"
12
+ p.version = "doit #{Globals::VERSION}"
13
+ p.option :list, 'Lists available scripts'
14
+ p.option :remote, 'remote host or comma separated hosts', default: ['host'], optional: true
15
+ p.option :silent, 'run silently; suppress output'
16
+ p.option :verbose, 'Enable verbose output'
17
+ p.option :noop, 'Suppress execution of commannds'
18
+ end.process!
19
+
20
+ Doit.start(options)
data/doit.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require 'globals'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'doit'
6
+ gem.version = Globals::VERSION
7
+ gem.summary = "Simple local & remote script executor"
8
+ gem.description = "Run good old shell/bash scripts locally or remotely(ssh)."
9
+
10
+ gem.authors = ['Dittmar Krall']
11
+ gem.email = 'dittmar.krall@matique.de'
12
+ gem.homepage = 'http://www.matique.de'
13
+ gem.license = 'MIT'
14
+
15
+ gem.add_dependency 'micro-optparse', '~> 0'
16
+
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- test`.split("\n")
19
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ gem.require_paths = ["lib"]
21
+
22
+ end
data/lib/doit.rb ADDED
@@ -0,0 +1,69 @@
1
+ require 'my'
2
+ require 'run'
3
+ require 'import'
4
+ require 'what'
5
+
6
+ class Doit
7
+
8
+ def self.start(options)
9
+ @options = options
10
+ list if options[:list]
11
+
12
+ script = ARGV.shift
13
+ str = ARGV.map { |x| "\"#{x}\"" }.join(' ')
14
+ @argv = str.empty? ? '' : "set #{str}\n"
15
+ execute(script) if script
16
+ end
17
+
18
+ def self.options
19
+ @options || {}
20
+ end
21
+
22
+ def self.list
23
+ hsh = Import.list
24
+ hsh.sort.each { |abb, long|
25
+ puts "#{abb}\t- #{long}"
26
+ lines = `grep -i 'usage\\|summary' #{long} | grep '^#'`.split("\n")
27
+ lines.each { |line|
28
+ next unless line
29
+ next if line.empty?
30
+ puts "\t #{line}"
31
+ }
32
+ }
33
+ end
34
+
35
+ def self.execute(name)
36
+ Import.init(name)
37
+ unless Import.script
38
+ puts "doit: script '#{name}' not found"
39
+ return
40
+ end
41
+ What.init(Import.script, Import.config)
42
+
43
+ where_loop
44
+ end
45
+
46
+ private
47
+ def self.where_loop
48
+ What.where.each { |w|
49
+ matrix_loop(w)
50
+ }
51
+ end
52
+
53
+ def self.matrix_loop(w)
54
+ What.matrix.each { |mm|
55
+ prefix = mm.empty? ? '' : "#{What.to_env(mm)}\n"
56
+
57
+ What.env.each { |en|
58
+ prefix2 = en.empty? ? '' : "#{en}\n"
59
+
60
+ cmds = Import.script
61
+ cmds = @argv + prefix + prefix2 + cmds
62
+ Run.init cmds, w
63
+ Run.info if options[:verbose]
64
+ Run.run
65
+ }
66
+ }
67
+ end
68
+
69
+ end
data/lib/globals.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Globals
2
+ VERSION = '0.2.4'
3
+ end
data/lib/import.rb ADDED
@@ -0,0 +1,61 @@
1
+ require 'pathname'
2
+ require 'erb'
3
+
4
+ class Import
5
+
6
+ def self.script; @script; end
7
+ def self.config; @config; end
8
+
9
+ def self.init(name)
10
+ @script = read(name)
11
+ @config = ERB.new(read("#{name}.yml") || '').result
12
+ info
13
+ end
14
+
15
+ # returns Hash { 'pull' => '/home/dk/.doit/pull', ... }
16
+ def self.list
17
+ @list ||= list2
18
+ end
19
+
20
+ def self.info
21
+ return unless Doit.options[:verbose]
22
+
23
+ My.verbose "SCRIPT", @script
24
+ My.verbose "CONFIG(yml)", @config
25
+ end
26
+
27
+
28
+ private
29
+ def self.list2
30
+ res = {}
31
+ Pathname.pwd.descend { |dir|
32
+ doit_dir = dir + '.doit'
33
+ next unless File.directory?(doit_dir)
34
+
35
+ lst = []
36
+ Dir.entries(doit_dir).each { |name|
37
+ name = File.join(doit_dir, name)
38
+
39
+ next unless File.executable?(name)
40
+ next if File.directory?(name)
41
+
42
+ lst << name
43
+ }
44
+ lst.each { |itm| res[File.basename(itm)] = itm }
45
+ }
46
+ res
47
+ end
48
+
49
+ def self.read(name)
50
+ try_ascend(".doit/#{name}")
51
+ end
52
+
53
+ def self.try_ascend(filename)
54
+ Pathname.pwd.ascend { |dir|
55
+ str = dir + filename
56
+ return File.read(str) if File.exists?(str)
57
+ }
58
+ nil
59
+ end
60
+
61
+ end
data/lib/my.rb ADDED
@@ -0,0 +1,16 @@
1
+ class My
2
+
3
+ def self.verbose(what, txt)
4
+ marker = '*'*4
5
+ arr = txt
6
+ arr = txt ? txt.split("\n") : '' unless Array === txt
7
+ if arr.length > 1
8
+ puts "#{marker} #{what} #{marker}"
9
+ puts txt
10
+ puts marker
11
+ else
12
+ puts "#{marker} #{what}: #{txt}"
13
+ end
14
+ end
15
+
16
+ end
data/lib/run.rb ADDED
@@ -0,0 +1,42 @@
1
+ class Run
2
+
3
+ def self.ssh; @ssh; end
4
+
5
+ def self.init(cmds, where)
6
+ aster = '*'*24
7
+ puts "#{aster} #{where} #{aster}"
8
+ @ssh = nil
9
+ @cmds = cmds
10
+
11
+ if where.include?('@')
12
+ arr = where.split(':')
13
+ host = arr.first
14
+ dir = arr.length > 1 ? arr.last : nil
15
+ else
16
+ host = nil
17
+ dir = where
18
+ end
19
+
20
+ @cmds = "cd; cd #{dir}\n" + @cmds unless dir && dir.empty?
21
+ @ssh = "ssh #{host}" if host
22
+ end
23
+
24
+ def self.info
25
+ My.verbose('SSH', @ssh)
26
+ My.verbose('cmds', @cmds)
27
+ end
28
+
29
+ def self.run
30
+ here = '___EOS___'
31
+ silent = Doit.options[:silent] ? '>/dev/null' : ''
32
+ cmd = "cat <<'#{here}\' | #{@ssh} bash -i -l #{silent} 2>&1"
33
+ cmds = "#{cmd}\n#{@cmds}#{here}\n"
34
+
35
+ unless Doit.options[:noop]
36
+ IO.popen(cmds) { |p| p.each { |f| puts f } }
37
+ else
38
+ My.verbose('noop', cmds)
39
+ end
40
+ end
41
+
42
+ end
data/lib/what.rb ADDED
@@ -0,0 +1,60 @@
1
+ require 'yaml'
2
+ require 'doit'
3
+
4
+ class What
5
+
6
+ def self.matrix; @matrix; end
7
+ def self.where; @where; end
8
+ def self.env; @env; end
9
+
10
+ def self.init(script, config)
11
+ @matrix = nil
12
+ @yml = (config && YAML.load(config)) || {}
13
+
14
+ @where = @yml.delete('where')
15
+ @env = @yml.delete('env')
16
+ @env ||= ['']
17
+ @env = [@env].flatten.compact
18
+
19
+ remote = Doit.options[:remote]
20
+ @where = remote if remote
21
+ @where ||= Dir.pwd # default is current directory
22
+ @where = [@where].flatten.compact
23
+
24
+ build_matrix
25
+ @matrix ||= []
26
+ @matrix = [@matrix] unless Array === @matrix.first
27
+ @matrix.map! { |m| m.flatten.inject({}) { |hsh, h| hsh.merge(h) } }
28
+ info
29
+ end
30
+
31
+ def self.to_env(hsh)
32
+ arr = hsh.collect { |key, value| "#{key.to_s.upcase}=#{value}" }
33
+ arr.join ' '
34
+ end
35
+
36
+ def self.info
37
+ return unless Doit.options[:verbose]
38
+
39
+ My.verbose "where", @where
40
+ My.verbose "matrix", @matrix
41
+ My.verbose "env", @env
42
+ end
43
+
44
+
45
+ private
46
+ def self.build_matrix
47
+ unless @yml.empty?
48
+ key, value = @yml.first
49
+ @yml.delete(key)
50
+ add_to_matrix(key, value)
51
+ build_matrix
52
+ end
53
+ end
54
+
55
+ def self.add_to_matrix(key, val)
56
+ arr = Array === val ? val.collect {|v| [{key => v}] } : [{key => val}]
57
+ @matrix = @matrix ? @matrix.product(arr) : arr
58
+ end
59
+
60
+ end
data/test/doit_test.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'test_helper'
2
+ require 'doit'
3
+
4
+ describe Doit do
5
+
6
+ before do
7
+ Doit.start({})
8
+ end
9
+
10
+ it "start" do
11
+ out = noop { }
12
+ assert_equal '', out
13
+ end
14
+
15
+ it "options" do
16
+ assert_equal({}, Doit.options)
17
+ end
18
+
19
+ it "list" do
20
+ out = noop {
21
+ Doit.list
22
+ }
23
+ assert_match /\/\.doit/, out
24
+ end
25
+
26
+ it "execute" do
27
+ out, err = capture_io do
28
+ Doit.execute('hello')
29
+ end
30
+ assert_match /\nHello\n/, out
31
+ end
32
+
33
+ it "execute with unknown script" do
34
+ out, err = capture_io do
35
+ Doit.execute('______unknown______')
36
+ end
37
+ assert_match /not found/, out
38
+ end
39
+
40
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+ require 'import'
3
+ require 'doit'
4
+ require 'my'
5
+
6
+ describe Import do
7
+
8
+ it "init fails with empty" do
9
+ assert_raises(Errno::EISDIR) { Import.init('') }
10
+ end
11
+
12
+ it "init" do
13
+ Import.init('hello')
14
+ end
15
+
16
+ it "list" do
17
+ Import.init('hello')
18
+ assert_match /\/\.doit\/hello$/, Import.list['hello']
19
+ end
20
+
21
+ it "info" do
22
+ out = noop({verbose: true}) {
23
+ Import.init('hello')
24
+ Import.info
25
+ }
26
+ assert_match /SCRIPT/, out
27
+ assert_match /CONFIG/, out
28
+ end
29
+
30
+ it "coverage: script" do
31
+ Import.script
32
+ end
33
+
34
+ it "coverage: config" do
35
+ Import.config
36
+ end
37
+
38
+ end
data/test/my_test.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ require 'my'
3
+
4
+ describe My do
5
+
6
+ it "verbose" do
7
+ h = 'hello'
8
+ out, err = capture_io do
9
+ My.verbose('a', h)
10
+ end
11
+ assert_match /#{h}/, out
12
+ end
13
+
14
+ it "verbose text" do
15
+ h = 'hello'
16
+ out, err = capture_io do
17
+ My.verbose('a', "#{h}\nx\n")
18
+ end
19
+ assert_match /#{h}/, out
20
+ end
21
+
22
+ end
data/test/run_test.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'test_helper'
2
+ require 'run'
3
+ require 'my'
4
+ require 'doit'
5
+
6
+ describe Run do
7
+
8
+ it "coverage #info" do
9
+ out, err = capture_io do
10
+ Run.init('', '')
11
+ Run.info
12
+ end
13
+ end
14
+
15
+ it "where '' returns nil" do
16
+ out, err = capture_io do
17
+ Run.init('', '')
18
+ assert_equal nil, Run.ssh
19
+ end
20
+ end
21
+
22
+ it "where 'a' returns nil" do
23
+ out, err = capture_io do
24
+ Run.init('', 'a')
25
+ assert_equal nil, Run.ssh
26
+ end
27
+ end
28
+
29
+ it "where 'a@b' returns 'ssh a@b'" do
30
+ out, err = capture_io do
31
+ Run.init('', 'a@b')
32
+ assert_equal 'ssh a@b', Run.ssh
33
+ end
34
+ end
35
+
36
+ it "where 'a@b:c' returns 'ssh a@b'" do
37
+ out, err = capture_io do
38
+ Run.init('', 'a@b:c')
39
+ assert_equal 'ssh a@b', Run.ssh
40
+ end
41
+ end
42
+
43
+ it "coverage #run" do
44
+ out, err = capture_io do
45
+ Run.init('', '')
46
+ Run.run
47
+ end
48
+ end
49
+
50
+ it "coverage #run noop" do
51
+ out = noop {
52
+ Run.init('', '')
53
+ Run.run
54
+ }
55
+ assert_match /EOS/, out
56
+ end
57
+
58
+ end
@@ -0,0 +1,19 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter 'test'
4
+ command_name 'Minitest'
5
+ end
6
+
7
+ require 'minitest/autorun'
8
+
9
+ def noop(options = {noop: true}, &block)
10
+ return 'noop: missing block' unless block
11
+
12
+ out = '---'
13
+ Doit.stub :options, options do
14
+ out, err = capture_io do
15
+ block.call
16
+ end
17
+ end
18
+ out
19
+ end
data/test/what_test.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+ require 'what'
3
+ require 'my'
4
+
5
+ describe What do
6
+
7
+ it "is robust against empty params" do
8
+ What.init('', '')
9
+ assert_equal [Dir.pwd], What.where
10
+ assert_equal [{}], What.matrix
11
+ end
12
+
13
+ it "#to_env({}) must be ''" do
14
+ assert_equal '', What.to_env({})
15
+ end
16
+
17
+ it "to_env converts variable to uppercase" do
18
+ assert_equal 'A=1', What.to_env({a: 1})
19
+ end
20
+
21
+ it "coverage: #info" do
22
+ Doit.stub :options, {verbose: true} do
23
+ out, err = capture_io do
24
+ What.init('', '')
25
+ What.info
26
+ end
27
+ end
28
+ end
29
+
30
+ it "builds simple matrix" do
31
+ What.init('', "a: 1\n")
32
+ assert_equal [{"a"=>1}], What.matrix
33
+ end
34
+
35
+ it "builds matrix" do
36
+ What.init('', "a:\n - 1\n - 2\n")
37
+ assert_equal [{"a"=>1}, {"a"=>2}], What.matrix
38
+ end
39
+
40
+ it "builds product matrix" do
41
+ What.init('', "a:\n - 1\nb:\n - 3\n - 4\n")
42
+ assert_equal [{"a"=>1, "b"=>3}, {"a"=>1, "b"=>4}], What.matrix
43
+ end
44
+
45
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.4
5
+ platform: ruby
6
+ authors:
7
+ - Dittmar Krall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: micro-optparse
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Run good old shell/bash scripts locally or remotely(ssh).
28
+ email: dittmar.krall@matique.de
29
+ executables:
30
+ - doit
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".doit/hello"
35
+ - ".doit/hello.yml"
36
+ - ".ruby-version"
37
+ - ".travis.yml"
38
+ - ".watchr"
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - bin/doit
45
+ - doit.gemspec
46
+ - lib/doit.rb
47
+ - lib/globals.rb
48
+ - lib/import.rb
49
+ - lib/my.rb
50
+ - lib/run.rb
51
+ - lib/what.rb
52
+ - test/doit_test.rb
53
+ - test/import_test.rb
54
+ - test/my_test.rb
55
+ - test/run_test.rb
56
+ - test/test_helper.rb
57
+ - test/what_test.rb
58
+ homepage: http://www.matique.de
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Simple local & remote script executor
82
+ test_files:
83
+ - test/doit_test.rb
84
+ - test/import_test.rb
85
+ - test/my_test.rb
86
+ - test/run_test.rb
87
+ - test/test_helper.rb
88
+ - test/what_test.rb