doit 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +2 -6
- data/.gitignore +1 -0
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.watchr +1 -0
- data/Gemfile +5 -4
- data/Gemfile.lock +40 -21
- data/LICENSE +19 -15
- data/README.md +23 -17
- data/Rakefile +7 -7
- data/bin/doit +13 -13
- data/doit.gemspec +17 -20
- data/lib/doit.rb +19 -21
- data/lib/globals.rb +11 -12
- data/lib/import.rb +18 -21
- data/lib/my.rb +2 -2
- data/lib/run.rb +12 -16
- data/lib/what.rb +21 -24
- data/test/doit_test.rb +12 -14
- data/test/import_test.rb +16 -18
- data/test/my_test.rb +8 -10
- data/test/run_test.rb +17 -19
- data/test/test_helper.rb +8 -8
- data/test/what_test.rb +16 -18
- metadata +6 -28
- data/.rubocop.yml +0 -11
- data/.travis.yml +0 -22
- data/.watchr +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e350eab55fbf17ac838b54fe284bf0e39321cb4610139c42b4e88bef6b06162e
|
4
|
+
data.tar.gz: bb0778176d1b47f029674b4a983ad9524c77aab238decc853cf9614f9ea329b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb6766a4cb0f732f8391fc38321dc1c0bef3c206540cd9253b751d36d1a324dfb33e7e1dc6ddfae78cabee539543a482e6a4642fe1e929272b2c8915eb11098
|
7
|
+
data.tar.gz: e7b35b90c92d138f405e78123fadb5286d87bd5c2f4a6ef3d1b15ccf12c3e68ba5029b8565cbf4e817b2b513031d561001ca2fd38dc4ec49465631391339087a
|
data/.github/workflows/rake.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
|
2
2
|
name: Rake
|
3
3
|
|
4
|
-
#on: [push, pull_request]
|
5
4
|
on: [push]
|
6
5
|
|
7
6
|
jobs:
|
@@ -9,16 +8,13 @@ jobs:
|
|
9
8
|
strategy:
|
10
9
|
fail-fast: false
|
11
10
|
matrix:
|
12
|
-
# os: [ubuntu-latest, macos-latest]
|
13
11
|
os: [ubuntu-latest]
|
14
|
-
|
15
|
-
# ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
|
16
|
-
ruby: ["2.7.2", "2.7.3", "3.0.1"]
|
12
|
+
ruby: ["2.7", "3.0", "3.2", head]
|
17
13
|
test_command: ["bundle exec rake test"]
|
18
14
|
runs-on: ${{ matrix.os }}
|
19
15
|
|
20
16
|
steps:
|
21
|
-
- uses: actions/checkout@
|
17
|
+
- uses: actions/checkout@v3
|
22
18
|
- uses: ruby/setup-ruby@v1
|
23
19
|
with:
|
24
20
|
ruby-version: ${{ matrix.ruby }}
|
data/.gitignore
CHANGED
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails-
|
1
|
+
rails-7.0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-3.2.2
|
data/.watchr
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/home/dk/shared/.watchr-gem
|
data/Gemfile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
6
|
+
gem "observr"
|
7
|
+
gem "ricecream"
|
8
|
+
gem "standard", require: false
|
9
|
+
gem "simplecov", require: false
|
9
10
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
doit (1.0.
|
4
|
+
doit (1.0.3)
|
5
5
|
micro-optparse (~> 1)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,48 +9,67 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
docile (1.4.0)
|
12
|
+
json (2.6.3)
|
13
|
+
language_server-protocol (3.17.0.3)
|
14
|
+
lint_roller (1.0.0)
|
12
15
|
micro-optparse (1.2.1)
|
13
|
-
minitest (5.
|
16
|
+
minitest (5.18.0)
|
14
17
|
observr (1.0.5)
|
15
|
-
parallel (1.
|
16
|
-
parser (3.
|
18
|
+
parallel (1.23.0)
|
19
|
+
parser (3.2.2.1)
|
17
20
|
ast (~> 2.4.1)
|
18
|
-
rainbow (3.
|
19
|
-
rake (13.0.
|
20
|
-
regexp_parser (2.
|
21
|
+
rainbow (3.1.1)
|
22
|
+
rake (13.0.6)
|
23
|
+
regexp_parser (2.8.0)
|
21
24
|
rexml (3.2.5)
|
22
|
-
|
25
|
+
ricecream (0.2.1)
|
26
|
+
rubocop (1.50.2)
|
27
|
+
json (~> 2.3)
|
23
28
|
parallel (~> 1.10)
|
24
|
-
parser (>= 3.
|
29
|
+
parser (>= 3.2.0.0)
|
25
30
|
rainbow (>= 2.2.2, < 4.0)
|
26
31
|
regexp_parser (>= 1.8, < 3.0)
|
27
|
-
rexml
|
28
|
-
rubocop-ast (>= 1.
|
32
|
+
rexml (>= 3.2.5, < 4.0)
|
33
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
29
34
|
ruby-progressbar (~> 1.7)
|
30
|
-
unicode-display_width (>=
|
31
|
-
rubocop-ast (1.
|
32
|
-
parser (>= 3.
|
33
|
-
|
34
|
-
|
35
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
36
|
+
rubocop-ast (1.28.0)
|
37
|
+
parser (>= 3.2.1.0)
|
38
|
+
rubocop-performance (1.16.0)
|
39
|
+
rubocop (>= 1.7.0, < 2.0)
|
40
|
+
rubocop-ast (>= 0.4.0)
|
41
|
+
ruby-progressbar (1.13.0)
|
42
|
+
simplecov (0.22.0)
|
35
43
|
docile (~> 1.1)
|
36
44
|
simplecov-html (~> 0.11)
|
37
45
|
simplecov_json_formatter (~> 0.1)
|
38
46
|
simplecov-html (0.12.3)
|
39
|
-
simplecov_json_formatter (0.1.
|
40
|
-
|
47
|
+
simplecov_json_formatter (0.1.4)
|
48
|
+
standard (1.28.0)
|
49
|
+
language_server-protocol (~> 3.17.0.2)
|
50
|
+
lint_roller (~> 1.0)
|
51
|
+
rubocop (~> 1.50.2)
|
52
|
+
standard-custom (~> 1.0.0)
|
53
|
+
standard-performance (~> 1.0.1)
|
54
|
+
standard-custom (1.0.0)
|
55
|
+
lint_roller (~> 1.0)
|
56
|
+
standard-performance (1.0.1)
|
57
|
+
lint_roller (~> 1.0)
|
58
|
+
rubocop-performance (~> 1.16.0)
|
59
|
+
unicode-display_width (2.4.2)
|
41
60
|
|
42
61
|
PLATFORMS
|
43
62
|
x86_64-linux
|
44
63
|
|
45
64
|
DEPENDENCIES
|
46
|
-
bundler (~> 2)
|
47
65
|
doit!
|
48
66
|
micro-optparse (~> 1)
|
49
67
|
minitest (~> 5)
|
50
68
|
observr
|
51
69
|
rake (~> 13)
|
52
|
-
|
70
|
+
ricecream
|
53
71
|
simplecov
|
72
|
+
standard
|
54
73
|
|
55
74
|
BUNDLED WITH
|
56
|
-
2.
|
75
|
+
2.4.10
|
data/LICENSE
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
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:
|
3
|
+
Copyright (c) 2022-2023 Dittmar Krall (www.matiq.com)
|
9
4
|
|
10
|
-
|
11
|
-
|
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
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
Doit
|
2
|
-
|
1
|
+
# Doit
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/doit.png)](http://badge.fury.io/rb/doit)
|
3
4
|
|
4
5
|
Executes good old shell/bash scripts locally as well as remotely.
|
5
6
|
The environment is set by a ".yml" configuration file.
|
@@ -9,18 +10,18 @@ The "where" in the configuration indicates where to run the script.
|
|
9
10
|
|
10
11
|
See examples below.
|
11
12
|
|
12
|
-
Installation
|
13
|
-
|
13
|
+
## Installation
|
14
|
+
|
14
15
|
gem install doit
|
15
16
|
|
16
|
-
Usage
|
17
|
-
|
17
|
+
## Usage
|
18
|
+
|
18
19
|
doit script... [options]
|
19
20
|
doit push
|
20
21
|
doit deploy tag
|
21
22
|
|
22
|
-
Options
|
23
|
-
|
23
|
+
## Options
|
24
|
+
|
24
25
|
-l, --[no-]list Lists available scripts
|
25
26
|
-r, --remote ["host"] remote host or comma separated hosts
|
26
27
|
-e, --[no-]each Lists each remote command (no execution)
|
@@ -31,16 +32,16 @@ Options
|
|
31
32
|
-V, --version Print version
|
32
33
|
|
33
34
|
|
34
|
-
File Structure
|
35
|
-
|
35
|
+
## File Structure
|
36
|
+
|
36
37
|
~/.doit/deploy # chmod +x .doit/deploy
|
37
38
|
~/.doit/deploy.yml
|
38
39
|
$PROJ/.doit/deploy.yml # overwrites $HOME(~/) script/configuration
|
39
40
|
$PROJ/.doit/push # chmod +x .doit/push
|
40
41
|
$PROJ/.doit/push.yml
|
41
42
|
|
42
|
-
$PROJ/.doit/push
|
43
|
-
|
43
|
+
## $PROJ/.doit/push
|
44
|
+
|
44
45
|
#! /bin/sh
|
45
46
|
if ! (git status | grep 'nothing to commit'); then
|
46
47
|
echo "push: commits are pending"
|
@@ -61,13 +62,13 @@ $PROJ/.doit/push
|
|
61
62
|
;;
|
62
63
|
esac
|
63
64
|
|
64
|
-
~/.doit/deploy
|
65
|
-
|
65
|
+
## ~/.doit/deploy
|
66
|
+
|
66
67
|
uname -a
|
67
68
|
git status
|
68
69
|
|
69
|
-
~/.doit/deploy.yml
|
70
|
-
|
70
|
+
## ~/.doit/deploy.yml
|
71
|
+
|
71
72
|
env:
|
72
73
|
- DIR=tmp OPTION=run
|
73
74
|
- DIR=proj OPTION=list
|
@@ -75,4 +76,9 @@ $PROJ/.doit/push
|
|
75
76
|
- bob@sample.com
|
76
77
|
- alice@customer.com
|
77
78
|
|
78
|
-
|
79
|
+
## Miscellaneous
|
80
|
+
|
81
|
+
Copyright (c) 2014-2023 Dittmar Krall (www.matiq.com),
|
82
|
+
released under the MIT license:
|
83
|
+
|
84
|
+
* https://opensource.org/licenses/MIT
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "rake"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "bundler/gem_tasks"
|
4
4
|
|
5
5
|
Rake::TestTask.new do |t|
|
6
|
-
t.libs.push
|
7
|
-
t.pattern =
|
6
|
+
t.libs.push "test"
|
7
|
+
t.pattern = "test/*_test.rb"
|
8
8
|
end
|
9
9
|
|
10
|
-
desc
|
11
|
-
task :
|
10
|
+
desc "Default: run unit tests."
|
11
|
+
task default: :test
|
data/bin/doit
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("../lib/", __dir__)
|
4
4
|
# $:.unshift lib unless $:.include?(lib)
|
5
5
|
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
7
|
+
require "doit"
|
8
|
+
require "micro-optparse"
|
9
|
+
require "globals"
|
10
|
+
require "what"
|
11
11
|
|
12
12
|
options = Parser.new do |p|
|
13
|
-
p.banner =
|
13
|
+
p.banner = "Usage: doit script... [options] # execute locally or remotely"
|
14
14
|
p.version = "doit #{Globals::VERSION}"
|
15
|
-
p.option :list,
|
16
|
-
p.option :each,
|
17
|
-
p.option :remote,
|
18
|
-
default:
|
19
|
-
p.option :silent,
|
20
|
-
p.option :verbose,
|
21
|
-
p.option :noop,
|
15
|
+
p.option :list, "Lists available scripts"
|
16
|
+
p.option :each, "Lists each remote command (no execution)"
|
17
|
+
p.option :remote, "Remote host or comma separated hosts",
|
18
|
+
default: "...", optional: true
|
19
|
+
p.option :silent, "Run silently; suppress output"
|
20
|
+
p.option :verbose, "Enable verbose output"
|
21
|
+
p.option :noop, "Suppress execution of commannds"
|
22
22
|
end.process!
|
23
23
|
|
24
24
|
Doit.start(options)
|
data/doit.gemspec
CHANGED
@@ -1,28 +1,25 @@
|
|
1
|
-
$LOAD_PATH.push File.expand_path(
|
2
|
-
require
|
1
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
2
|
+
require "globals"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
5
|
+
s.name = "doit"
|
6
6
|
s.version = Globals::VERSION
|
7
|
-
s.summary =
|
8
|
-
s.description =
|
7
|
+
s.summary = "Simple local & remote script executor"
|
8
|
+
s.description = "Run good old shell/bash scripts locally or remotely(ssh)."
|
9
9
|
|
10
|
-
s.authors
|
11
|
-
s.email
|
12
|
-
s.homepage =
|
13
|
-
s.license
|
10
|
+
s.authors = ["Dittmar Krall"]
|
11
|
+
s.email = "dittmar.krall@matiq.de"
|
12
|
+
s.homepage = "http://www.matiq.de"
|
13
|
+
s.license = "MIT"
|
14
14
|
|
15
|
-
s.add_dependency
|
15
|
+
s.add_dependency "micro-optparse", "~> 1"
|
16
16
|
|
17
|
-
s.files
|
18
|
-
s.
|
19
|
-
|
20
|
-
|
21
|
-
s.require_paths = ['lib']
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`
|
19
|
+
.split("\n").map { |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
22
21
|
|
23
|
-
s.add_development_dependency
|
24
|
-
s.add_development_dependency
|
25
|
-
|
26
|
-
s.add_development_dependency 'micro-optparse', '~> 1'
|
27
|
-
s.add_development_dependency 'minitest', '~> 5'
|
22
|
+
s.add_development_dependency "rake", "~> 13"
|
23
|
+
s.add_development_dependency "micro-optparse", "~> 1"
|
24
|
+
s.add_development_dependency "minitest", "~> 5"
|
28
25
|
end
|
data/lib/doit.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require 'import'
|
1
|
+
require "my"
|
2
|
+
require "run"
|
3
|
+
require "import"
|
4
|
+
require "ricecream"
|
6
5
|
|
7
6
|
Doit = Object.new
|
8
7
|
class << Doit
|
9
|
-
|
10
8
|
def start(options)
|
11
9
|
@options = options
|
12
|
-
list
|
10
|
+
list if options[:list]
|
13
11
|
|
14
12
|
script = ARGV.shift
|
15
|
-
str = ARGV.map { |x| "\"#{x}\"" }.join(
|
16
|
-
@argv = str.empty? ?
|
17
|
-
execute(script)
|
13
|
+
str = ARGV.map { |x| "\"#{x}\"" }.join(" ")
|
14
|
+
@argv = str.empty? ? "" : "set #{str}\n"
|
15
|
+
execute(script) if script
|
18
16
|
end
|
19
17
|
|
20
18
|
def options
|
@@ -26,14 +24,14 @@ class << Doit
|
|
26
24
|
hsh = Import.list
|
27
25
|
hsh.sort.each { |abb, long|
|
28
26
|
puts "#{abb}\t- #{long}"
|
29
|
-
next
|
27
|
+
next unless options[:verbose]
|
30
28
|
|
31
|
-
lines = `grep -i
|
29
|
+
lines = `grep -i "usage\\|summary" #{long} | grep "^#"`.split("\n")
|
32
30
|
lines.each { |line|
|
33
|
-
|
34
|
-
|
31
|
+
next unless line
|
32
|
+
next if line.empty?
|
35
33
|
|
36
|
-
|
34
|
+
puts "\t #{line}"
|
37
35
|
}
|
38
36
|
}
|
39
37
|
end
|
@@ -48,10 +46,11 @@ class << Doit
|
|
48
46
|
|
49
47
|
What.where.each { |w| puts "doit #{name} -r #{w}" } if options[:each]
|
50
48
|
|
51
|
-
where_loop
|
49
|
+
where_loop unless options[:each]
|
52
50
|
end
|
53
51
|
|
54
|
-
|
52
|
+
private
|
53
|
+
|
55
54
|
def where_loop
|
56
55
|
What.where.each { |w|
|
57
56
|
matrix_loop(w)
|
@@ -60,18 +59,17 @@ class << Doit
|
|
60
59
|
|
61
60
|
def matrix_loop(where)
|
62
61
|
What.matrix.each { |mm|
|
63
|
-
prefix = mm.empty? ?
|
62
|
+
prefix = mm.empty? ? "" : "#{What.to_env(mm)}\n"
|
64
63
|
|
65
64
|
What.env.each { |en|
|
66
|
-
prefix2 = en.empty? ?
|
65
|
+
prefix2 = en.empty? ? "" : "#{en}\n"
|
67
66
|
|
68
67
|
cmds = Import.script
|
69
68
|
cmds = @argv + prefix + prefix2 + cmds
|
70
69
|
Run.init cmds, where
|
71
|
-
Run.info
|
70
|
+
Run.info if options[:verbose]
|
72
71
|
Run.run
|
73
72
|
}
|
74
73
|
}
|
75
74
|
end
|
76
|
-
|
77
75
|
end
|
data/lib/globals.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
# rubocop: disable all
|
2
|
-
|
3
1
|
module Globals
|
4
|
-
VERSION =
|
5
|
-
# VERSION =
|
6
|
-
# VERSION =
|
7
|
-
# VERSION =
|
8
|
-
# VERSION =
|
9
|
-
# VERSION =
|
10
|
-
# VERSION =
|
11
|
-
# VERSION =
|
12
|
-
# VERSION =
|
13
|
-
# VERSION =
|
2
|
+
VERSION = "1.0.3" # 2023-04-27
|
3
|
+
# VERSION = "1.0.2" # 2021-06-26
|
4
|
+
# VERSION = "1.0.1" # 2021-04-21
|
5
|
+
# VERSION = "1.0.0" # 2020-10-26
|
6
|
+
# VERSION = "0.3.9" # 2020-07-17
|
7
|
+
# VERSION = "0.3.8" # 2020-02-26
|
8
|
+
# VERSION = "0.3.7" # 2019-10-15
|
9
|
+
# VERSION = "0.3.6" # 2019-03-06
|
10
|
+
# VERSION = "0.3.5" # 2018-09-11
|
11
|
+
# VERSION = "0.3.4" # 2018-08-19
|
12
|
+
# VERSION = "0.3.3"
|
14
13
|
end
|
data/lib/import.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'erb'
|
1
|
+
require "pathname"
|
2
|
+
require "erb"
|
5
3
|
|
6
4
|
Import = Object.new
|
7
5
|
class << Import
|
8
|
-
|
9
6
|
def script
|
10
7
|
@script ||= nil
|
11
8
|
@script
|
@@ -17,40 +14,41 @@ class << Import
|
|
17
14
|
end
|
18
15
|
|
19
16
|
def init(name)
|
20
|
-
@script
|
21
|
-
@config
|
17
|
+
@script = read(name)
|
18
|
+
@config = ERB.new(read("#{name}.yml") || "").result
|
22
19
|
info
|
23
20
|
end
|
24
21
|
|
25
|
-
# returns Hash {
|
22
|
+
# returns Hash { "pull" => "/home/dk/.doit/pull", ... }
|
26
23
|
def list
|
27
24
|
@list ||= list2
|
28
25
|
end
|
29
26
|
|
30
27
|
def info
|
31
|
-
return
|
28
|
+
return unless Doit.options[:verbose]
|
32
29
|
|
33
|
-
My.verbose
|
34
|
-
My.verbose
|
30
|
+
My.verbose "SCRIPT", @script
|
31
|
+
My.verbose "CONFIG(yml)", @config
|
35
32
|
end
|
36
33
|
|
37
|
-
|
34
|
+
private
|
35
|
+
|
38
36
|
def list2
|
39
37
|
res = {}
|
40
38
|
Pathname.pwd.descend { |dir|
|
41
|
-
doit_dir = dir +
|
42
|
-
next
|
39
|
+
doit_dir = dir + ".doit"
|
40
|
+
next unless File.directory?(doit_dir)
|
43
41
|
|
44
42
|
lst = []
|
45
43
|
Dir.entries(doit_dir).each { |name|
|
46
|
-
|
44
|
+
name = File.join(doit_dir, name)
|
47
45
|
|
48
|
-
|
49
|
-
|
46
|
+
next unless File.executable?(name)
|
47
|
+
next if File.directory?(name)
|
50
48
|
|
51
|
-
|
49
|
+
lst << name
|
52
50
|
}
|
53
|
-
lst.each { |itm|
|
51
|
+
lst.each { |itm| res[File.basename(itm)] = itm }
|
54
52
|
}
|
55
53
|
res
|
56
54
|
end
|
@@ -62,9 +60,8 @@ class << Import
|
|
62
60
|
def try_ascend(filename)
|
63
61
|
Pathname.pwd.ascend { |dir|
|
64
62
|
str = dir + filename
|
65
|
-
return File.read(str)
|
63
|
+
return File.read(str) if File.exist?(str)
|
66
64
|
}
|
67
65
|
nil
|
68
66
|
end
|
69
|
-
|
70
67
|
end
|
data/lib/my.rb
CHANGED
@@ -4,9 +4,9 @@ My = Object.new
|
|
4
4
|
|
5
5
|
class << My
|
6
6
|
def verbose(what, txt)
|
7
|
-
marker =
|
7
|
+
marker = "*" * 4
|
8
8
|
arr = txt
|
9
|
-
arr = txt ? txt.split("\n") :
|
9
|
+
arr = txt ? txt.split("\n") : "" unless txt.is_a?(Array)
|
10
10
|
if arr.length > 1
|
11
11
|
puts "#{marker} #{what} #{marker}"
|
12
12
|
puts txt
|
data/lib/run.rb
CHANGED
@@ -1,45 +1,41 @@
|
|
1
|
-
# rubocop: disable all
|
2
|
-
|
3
1
|
Run = Object.new
|
4
2
|
class << Run
|
5
|
-
|
6
3
|
attr_reader :ssh
|
7
4
|
|
8
5
|
def init(cmds, where)
|
9
|
-
aster =
|
6
|
+
aster = "*" * 24
|
10
7
|
puts "#{aster} #{where} #{aster}"
|
11
8
|
@ssh = nil
|
12
9
|
@cmds = cmds
|
13
10
|
|
14
|
-
if where.include?(
|
15
|
-
arr = where.split(
|
11
|
+
if where.include?("@")
|
12
|
+
arr = where.split(":")
|
16
13
|
host = arr.first
|
17
|
-
dir = arr.length > 1 ? arr.last : nil
|
14
|
+
dir = (arr.length > 1) ? arr.last : nil
|
18
15
|
else
|
19
16
|
host = nil
|
20
17
|
dir = where
|
21
18
|
end
|
22
19
|
|
23
|
-
@cmds = "cd; cd #{dir}\n" + @cmds
|
24
|
-
@ssh = "ssh #{host}"
|
20
|
+
@cmds = "cd; cd #{dir}\n" + @cmds unless dir&.empty?
|
21
|
+
@ssh = "ssh #{host}" if host
|
25
22
|
end
|
26
23
|
|
27
24
|
def info
|
28
|
-
My.verbose(
|
29
|
-
My.verbose(
|
25
|
+
My.verbose("SSH", @ssh)
|
26
|
+
My.verbose("cmds", @cmds)
|
30
27
|
end
|
31
28
|
|
32
29
|
def run
|
33
|
-
here =
|
34
|
-
silent = Doit.options[:silent] ?
|
35
|
-
cmd = "cat <<'#{here}
|
30
|
+
here = "___EOS___"
|
31
|
+
silent = Doit.options[:silent] ? ">/dev/null" : ""
|
32
|
+
cmd = "cat <<'#{here}' | #{@ssh} bash -i -l #{silent} 2>&1"
|
36
33
|
cmds = "#{cmd}\n#{@cmds}#{here}\n"
|
37
34
|
|
38
35
|
if Doit.options[:noop]
|
39
|
-
My.verbose(
|
36
|
+
My.verbose("noop", cmds)
|
40
37
|
else
|
41
38
|
IO.popen(cmds) { |p| p.each { |f| puts f } }
|
42
39
|
end
|
43
40
|
end
|
44
|
-
|
45
41
|
end
|
data/lib/what.rb
CHANGED
@@ -1,52 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'doit'
|
1
|
+
require "yaml"
|
2
|
+
require "doit"
|
5
3
|
|
6
4
|
What = Object.new
|
7
5
|
class << What
|
8
|
-
|
9
6
|
attr_reader :matrix
|
10
7
|
attr_reader :where
|
11
8
|
attr_reader :env
|
12
9
|
|
13
10
|
def init(config)
|
14
11
|
@matrix = nil
|
15
|
-
@yml
|
12
|
+
@yml = (config && YAML.load(config)) || {}
|
16
13
|
|
17
|
-
@where = @yml.delete(
|
18
|
-
@env
|
19
|
-
@env ||= [
|
20
|
-
@env
|
14
|
+
@where = @yml.delete("where")
|
15
|
+
@env = @yml.delete("env")
|
16
|
+
@env ||= [""]
|
17
|
+
@env = [@env].flatten.compact
|
21
18
|
|
22
19
|
remote = Doit.options[:remote]
|
23
|
-
@where
|
24
|
-
@where ||= Dir.pwd
|
25
|
-
@where
|
20
|
+
@where = remote if remote && remote != "---"
|
21
|
+
@where ||= Dir.pwd # default is current directory
|
22
|
+
@where = [@where].flatten.compact
|
26
23
|
|
27
24
|
build_matrix
|
28
25
|
@matrix ||= []
|
29
|
-
@matrix = [@matrix]
|
26
|
+
@matrix = [@matrix] unless @matrix.first.is_a?(Array)
|
30
27
|
@matrix.map! { |m| m.flatten.inject({}) { |hsh, h| hsh.merge(h) } }
|
31
28
|
info
|
32
29
|
end
|
33
30
|
|
34
31
|
def to_env(hsh)
|
35
32
|
arr = hsh.collect { |key, value| "#{key.to_s.upcase}=#{value}" }
|
36
|
-
arr.join
|
33
|
+
arr.join " "
|
37
34
|
end
|
38
35
|
|
39
36
|
def info
|
40
|
-
return
|
37
|
+
return unless Doit.options[:verbose]
|
41
38
|
|
42
|
-
My.verbose
|
43
|
-
My.verbose
|
44
|
-
My.verbose
|
39
|
+
My.verbose "where", @where
|
40
|
+
My.verbose "matrix", @matrix
|
41
|
+
My.verbose "env", @env
|
45
42
|
end
|
46
43
|
|
47
|
-
|
44
|
+
private
|
45
|
+
|
48
46
|
def build_matrix
|
49
|
-
return
|
47
|
+
return if @yml.empty?
|
50
48
|
|
51
49
|
key, value = @yml.first
|
52
50
|
@yml.delete(key)
|
@@ -56,9 +54,8 @@ class << What
|
|
56
54
|
|
57
55
|
def add_to_matrix(key, val)
|
58
56
|
arr = val.is_a?(Array) ?
|
59
|
-
val.collect { |v| [{
|
60
|
-
[{
|
57
|
+
val.collect { |v| [{key => v}] } :
|
58
|
+
[{key => val}]
|
61
59
|
@matrix = @matrix ? @matrix.product(arr) : arr
|
62
60
|
end
|
63
|
-
|
64
61
|
end
|
data/test/doit_test.rb
CHANGED
@@ -1,53 +1,51 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe Doit do
|
4
|
-
|
5
4
|
before do
|
6
5
|
Doit.start({})
|
7
6
|
end
|
8
7
|
|
9
|
-
it
|
8
|
+
it "start" do
|
10
9
|
out = noop {}
|
11
|
-
assert_equal
|
10
|
+
assert_equal "", out
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
13
|
+
it "options" do
|
15
14
|
assert_equal({}, Doit.options)
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
17
|
+
it "list" do
|
19
18
|
out = noop {
|
20
19
|
Doit.list
|
21
20
|
}
|
22
21
|
assert_match(/\/\.doit/, out)
|
23
22
|
end
|
24
23
|
|
25
|
-
it
|
24
|
+
it "execute" do
|
26
25
|
out, _err = capture_io do
|
27
|
-
Doit.execute(
|
26
|
+
Doit.execute("hello")
|
28
27
|
end
|
29
28
|
assert_match(/\nHello\n/, out)
|
30
29
|
end
|
31
30
|
|
32
|
-
it
|
31
|
+
it "execute with unknown script" do
|
33
32
|
out, _err = capture_io do
|
34
|
-
Doit.execute(
|
33
|
+
Doit.execute("______unknown______")
|
35
34
|
end
|
36
35
|
assert_match(/not found/, out)
|
37
36
|
end
|
38
37
|
|
39
|
-
it
|
38
|
+
it "tests option --each" do
|
40
39
|
out = noop(each: true) {
|
41
|
-
Doit.execute(
|
40
|
+
Doit.execute("hello")
|
42
41
|
}
|
43
42
|
assert_match(/doit hello -r/, out)
|
44
43
|
end
|
45
44
|
|
46
|
-
it
|
45
|
+
it "coverage: list; option -lv" do
|
47
46
|
out = noop(verbose: true, list: true) {
|
48
47
|
Doit.start(verbose: true, list: true)
|
49
48
|
}
|
50
49
|
assert_match(/just a test\n/, out)
|
51
50
|
end
|
52
|
-
|
53
51
|
end
|
data/test/import_test.rb
CHANGED
@@ -1,38 +1,36 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "test_helper"
|
2
|
+
require "import"
|
3
|
+
require "doit"
|
4
|
+
require "my"
|
5
5
|
|
6
6
|
describe Import do
|
7
|
-
|
8
|
-
|
9
|
-
assert_raises(Errno::EISDIR) { Import.init('') }
|
7
|
+
it "init fails with empty" do
|
8
|
+
assert_raises(Errno::EISDIR) { Import.init("") }
|
10
9
|
end
|
11
10
|
|
12
|
-
it
|
13
|
-
Import.init(
|
11
|
+
it "init" do
|
12
|
+
Import.init("hello")
|
14
13
|
end
|
15
14
|
|
16
|
-
it
|
17
|
-
Import.init(
|
18
|
-
assert_match(/\/\.doit\/hello$/, Import.list[
|
15
|
+
it "list" do
|
16
|
+
Import.init("hello")
|
17
|
+
assert_match(/\/\.doit\/hello$/, Import.list["hello"])
|
19
18
|
end
|
20
19
|
|
21
|
-
it
|
20
|
+
it "info" do
|
22
21
|
out = noop(verbose: true) {
|
23
|
-
|
24
|
-
|
22
|
+
Import.init("hello")
|
23
|
+
Import.info
|
25
24
|
}
|
26
25
|
assert_match(/SCRIPT/, out)
|
27
26
|
assert_match(/CONFIG/, out)
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
29
|
+
it "coverage: script" do
|
31
30
|
Import.script
|
32
31
|
end
|
33
32
|
|
34
|
-
it
|
33
|
+
it "coverage: config" do
|
35
34
|
Import.config
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
data/test/my_test.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "test_helper"
|
2
|
+
require "my"
|
3
3
|
|
4
4
|
describe My do
|
5
|
-
|
6
|
-
|
7
|
-
h = 'hello'
|
5
|
+
it "verbose" do
|
6
|
+
h = "hello"
|
8
7
|
out, _err = capture_io do
|
9
|
-
My.verbose(
|
8
|
+
My.verbose("a", h)
|
10
9
|
end
|
11
10
|
assert_match(/#{h}/, out)
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
15
|
-
h =
|
13
|
+
it "verbose text" do
|
14
|
+
h = "hello"
|
16
15
|
out, _err = capture_io do
|
17
|
-
My.verbose(
|
16
|
+
My.verbose("a", "#{h}\nx\n")
|
18
17
|
end
|
19
18
|
assert_match(/#{h}/, out)
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
data/test/run_test.rb
CHANGED
@@ -1,58 +1,56 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "test_helper"
|
2
|
+
require "run"
|
3
|
+
require "my"
|
4
|
+
require "doit"
|
5
5
|
|
6
6
|
describe Run do
|
7
|
-
|
8
|
-
it 'coverage #info' do
|
7
|
+
it "coverage #info" do
|
9
8
|
_out, _err = capture_io do
|
10
|
-
Run.init(
|
9
|
+
Run.init("", "")
|
11
10
|
Run.info
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
14
|
it "where '' returns nil" do
|
16
15
|
_out, _err = capture_io do
|
17
|
-
Run.init(
|
16
|
+
Run.init("", "")
|
18
17
|
assert_equal nil, Run.ssh
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
it "where 'a' returns nil" do
|
23
22
|
_out, _err = capture_io do
|
24
|
-
Run.init(
|
23
|
+
Run.init("", "a")
|
25
24
|
assert_equal nil, Run.ssh
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
it "where 'a@b' returns 'ssh a@b'" do
|
30
29
|
_out, _err = capture_io do
|
31
|
-
Run.init(
|
32
|
-
assert_equal
|
30
|
+
Run.init("", "a@b")
|
31
|
+
assert_equal "ssh a@b", Run.ssh
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
36
35
|
it "where 'a@b:c' returns 'ssh a@b'" do
|
37
36
|
_out, _err = capture_io do
|
38
|
-
Run.init(
|
39
|
-
assert_equal
|
37
|
+
Run.init("", "a@b:c")
|
38
|
+
assert_equal "ssh a@b", Run.ssh
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
|
-
it
|
42
|
+
it "coverage #run" do
|
44
43
|
_out, _err = capture_io do
|
45
|
-
Run.init(
|
44
|
+
Run.init("", "")
|
46
45
|
Run.run
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
it
|
49
|
+
it "coverage #run noop" do
|
51
50
|
out = noop {
|
52
|
-
|
53
|
-
|
51
|
+
Run.init("", "")
|
52
|
+
Run.run
|
54
53
|
}
|
55
54
|
assert_match(/EOS/, out)
|
56
55
|
end
|
57
|
-
|
58
56
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
if ENV[
|
2
|
-
require
|
1
|
+
if ENV["COVERAGE"]
|
2
|
+
require "simplecov"
|
3
3
|
SimpleCov.start do
|
4
|
-
add_filter
|
4
|
+
add_filter "/test/"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
-
require
|
8
|
+
require "what"
|
9
9
|
|
10
|
-
require
|
10
|
+
require "minitest/autorun"
|
11
11
|
|
12
|
-
def noop(options = {
|
13
|
-
return
|
12
|
+
def noop(options = {noop: true}, &block)
|
13
|
+
return "noop: missing block" unless block
|
14
14
|
|
15
|
-
out =
|
15
|
+
out = "---"
|
16
16
|
Doit.stub :options, options do
|
17
17
|
out, _err = capture_io do
|
18
18
|
yield
|
data/test/what_test.rb
CHANGED
@@ -1,44 +1,42 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "test_helper"
|
2
|
+
require "my"
|
3
3
|
|
4
4
|
describe What do
|
5
|
-
|
6
|
-
|
7
|
-
What.init('')
|
5
|
+
it "is robust against empty params" do
|
6
|
+
What.init("")
|
8
7
|
assert_equal [Dir.pwd], What.where
|
9
8
|
assert_equal [{}], What.matrix
|
10
9
|
end
|
11
10
|
|
12
11
|
it "#to_env({}) must be ''" do
|
13
|
-
assert_equal
|
12
|
+
assert_equal "", What.to_env({})
|
14
13
|
end
|
15
14
|
|
16
|
-
it
|
17
|
-
assert_equal
|
15
|
+
it "to_env converts variable to uppercase" do
|
16
|
+
assert_equal "A=1", What.to_env(a: 1)
|
18
17
|
end
|
19
18
|
|
20
|
-
it
|
21
|
-
Doit.stub :options, verbose: true do
|
19
|
+
it "coverage: #info" do
|
20
|
+
Doit.stub :options, {verbose: true} do
|
22
21
|
_out, _err = capture_io do
|
23
|
-
What.init(
|
22
|
+
What.init("")
|
24
23
|
What.info
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
it
|
28
|
+
it "builds simple matrix" do
|
30
29
|
What.init("a: 1\n")
|
31
|
-
assert_equal [{
|
30
|
+
assert_equal [{"a" => 1}], What.matrix
|
32
31
|
end
|
33
32
|
|
34
|
-
it
|
33
|
+
it "builds matrix" do
|
35
34
|
What.init("a:\n - 1\n - 2\n")
|
36
|
-
assert_equal [{
|
35
|
+
assert_equal [{"a" => 1}, {"a" => 2}], What.matrix
|
37
36
|
end
|
38
37
|
|
39
|
-
it
|
38
|
+
it "builds product matrix" do
|
40
39
|
What.init("a:\n - 1\nb:\n - 3\n - 4\n")
|
41
|
-
assert_equal [{
|
40
|
+
assert_equal [{"a" => 1, "b" => 3}, {"a" => 1, "b" => 4}], What.matrix
|
42
41
|
end
|
43
|
-
|
44
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: micro-optparse
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '5'
|
83
69
|
description: Run good old shell/bash scripts locally or remotely(ssh).
|
84
|
-
email: dittmar.krall@
|
70
|
+
email: dittmar.krall@matiq.de
|
85
71
|
executables:
|
86
72
|
- doit
|
87
73
|
extensions: []
|
@@ -91,10 +77,8 @@ files:
|
|
91
77
|
- ".doit/hello.yml"
|
92
78
|
- ".github/workflows/rake.yml"
|
93
79
|
- ".gitignore"
|
94
|
-
- ".rubocop.yml"
|
95
80
|
- ".ruby-gemset"
|
96
81
|
- ".ruby-version"
|
97
|
-
- ".travis.yml"
|
98
82
|
- ".watchr"
|
99
83
|
- Gemfile
|
100
84
|
- Gemfile.lock
|
@@ -115,7 +99,7 @@ files:
|
|
115
99
|
- test/run_test.rb
|
116
100
|
- test/test_helper.rb
|
117
101
|
- test/what_test.rb
|
118
|
-
homepage: http://www.
|
102
|
+
homepage: http://www.matiq.de
|
119
103
|
licenses:
|
120
104
|
- MIT
|
121
105
|
metadata: {}
|
@@ -134,14 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
118
|
- !ruby/object:Gem::Version
|
135
119
|
version: '0'
|
136
120
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.4.10
|
138
122
|
signing_key:
|
139
123
|
specification_version: 4
|
140
124
|
summary: Simple local & remote script executor
|
141
|
-
test_files:
|
142
|
-
- test/doit_test.rb
|
143
|
-
- test/import_test.rb
|
144
|
-
- test/my_test.rb
|
145
|
-
- test/run_test.rb
|
146
|
-
- test/test_helper.rb
|
147
|
-
- test/what_test.rb
|
125
|
+
test_files: []
|
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
#bundler_args: --without production
|
4
|
-
bundle config set without production
|
5
|
-
script: "bundle exec rake test"
|
6
|
-
|
7
|
-
rvm:
|
8
|
-
- 2.7.2 # 2020-10-26
|
9
|
-
# - 2.6.6 # 2020-07-17
|
10
|
-
# - 2.6.5 # 2019-10-29
|
11
|
-
# - 2.6.4 # 2019-10-15
|
12
|
-
# - 2.6.3 # 2019-06-21
|
13
|
-
# - 2.6.1
|
14
|
-
# - 2.5.1
|
15
|
-
# - 2.5.0
|
16
|
-
# - 2.4.1
|
17
|
-
# - 2.3.0 # tested; no longer in CI
|
18
|
-
# - 2.2.3 # tested; no longer in CI
|
19
|
-
# - 2.0.0 # tested; no longer in CI
|
20
|
-
|
21
|
-
notifications:
|
22
|
-
email: false
|
data/.watchr
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
TESTING = %w[test]
|
2
|
-
HH = '#' * 22 unless defined?(HH)
|
3
|
-
H = '#' * 5 unless defined?(H)
|
4
|
-
|
5
|
-
def usage
|
6
|
-
puts <<-EOS
|
7
|
-
Ctrl-\\ or ctrl-4 Running all tests
|
8
|
-
Ctrl-C Exit
|
9
|
-
EOS
|
10
|
-
end
|
11
|
-
|
12
|
-
def run(cmd)
|
13
|
-
puts "#{HH} #{Time.now} #{HH}"
|
14
|
-
puts "#{H} #{cmd}"
|
15
|
-
system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def run_it(type, file)
|
19
|
-
case type
|
20
|
-
when 'test'; run %(bundle exec ruby -I test #{file})
|
21
|
-
else; puts "#{H} unknown type: #{type}, file: #{file}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def run_all_tests
|
26
|
-
puts "\n#{HH} Running all tests #{HH}\n"
|
27
|
-
TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def run_matching_files(base)
|
31
|
-
base = base.split('_').first
|
32
|
-
TESTING.each { |type|
|
33
|
-
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
|
34
|
-
run_it type, files.join(' ') unless files.empty?
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
TESTING.each { |type|
|
39
|
-
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
|
40
|
-
watch('lib/.*\.rb') { run_all_tests }
|
41
|
-
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
|
42
|
-
watch("#{type}/data/(.*)\.rb") { |match|
|
43
|
-
m1 = match[1]
|
44
|
-
run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb")
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
%w[rb erb haml slim].each { |type|
|
49
|
-
watch("app/.*/(.*)\.#{type}") { |match|
|
50
|
-
run_matching_files(match[1])
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
# Ctrl-\ or ctrl-4
|
55
|
-
Signal.trap('QUIT') { run_all_tests }
|
56
|
-
# Ctrl-C
|
57
|
-
Signal.trap('INT') { abort("Interrupted\n") }
|
58
|
-
usage
|