doit 0.3.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7e3e55b5782a334d1ace53286a138bdd935a4d09
4
- data.tar.gz: 4fa3b68d8f34263279ae3dff8e1d87a1c7dfbfa0
2
+ SHA256:
3
+ metadata.gz: 3eb0f0645c47b1d209a75de9fcc49d0b99752769764599b0fac889b3ad6423f0
4
+ data.tar.gz: 726b353579f963e6655bf56fdf49dfcd60004826ee838e3bd7f5a6c168e48bd7
5
5
  SHA512:
6
- metadata.gz: ded0af93c825b472874ea32daae00c5e0821ad0132c474fc308d6354e174ed782a1d28a6e5f6548de84cd5e9d7d3f6500104a800970a12a84502d6c72e0bfb39
7
- data.tar.gz: 59310dd1e3791d555998cd37e042247a6c558c79699b3e0c7c8ee308c9536e9640085daa3e4df19465076aab2ea0a4532a06e6844baf1bc9943e662454355216
6
+ metadata.gz: 6234c4eeb92cc4a76c59836f7292e1c806526909e0a74d7dfa5a7a21631c56af1f041d7a149878013def8a9d6ceebd74b2f848d27a4caaec69702742a7807a74
7
+ data.tar.gz: d825858a3dd19251ee4dfaaddaef4aef8e338dfc9d6219be66119a298fc149ff3a7db2fc400051ee699a7d30bc6e11b8152597b55b2fa9963b82f1456e500190
@@ -0,0 +1,30 @@
1
+ # see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
2
+ name: Rake
3
+
4
+ #on: [push, pull_request]
5
+ on: [push]
6
+
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ # os: [ubuntu-latest, macos-latest]
13
+ os: [ubuntu-latest]
14
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
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"]
17
+ test_command: ["bundle exec rake test"]
18
+ runs-on: ${{ matrix.os }}
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ - name: Bundle install
26
+ run: |
27
+ bundle config path /home/runner/bundle
28
+ bundle install
29
+ bundle update
30
+ - run: ${{ matrix.test_command }}
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ inherit_from:
2
+ - ~/configs/.rubocop.yml
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+ Include:
7
+ - 'lib/**/*.rb'
8
+
9
+ Exclude:
10
+ - 'bin/**/*'
11
+ - 'test/**/*'
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ rails-6.1
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.2.0
1
+ ruby-2.7.2
data/.travis.yml CHANGED
@@ -1,8 +1,22 @@
1
1
  language: ruby
2
- sudo: false
2
+
3
+ #bundler_args: --without production
4
+ bundle config set without production
5
+ script: "bundle exec rake test"
6
+
3
7
  rvm:
4
- - 2.0.0
5
- - 2.2.3
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
6
20
 
7
21
  notifications:
8
22
  email: false
data/.watchr CHANGED
@@ -1,3 +1,4 @@
1
+ TESTING = %w[test]
1
2
  HH = '#' * 22 unless defined?(HH)
2
3
  H = '#' * 5 unless defined?(H)
3
4
 
@@ -16,32 +17,37 @@ end
16
17
 
17
18
  def run_it(type, file)
18
19
  case type
19
- when 'test'; run %Q{ruby -I"lib:test" -rubygems #{file}}
20
- when 'spec'; run %Q{spring rspec -X #{file}}
20
+ when 'test'; run %(bundle exec ruby -I test #{file})
21
21
  else; puts "#{H} unknown type: #{type}, file: #{file}"
22
22
  end
23
23
  end
24
24
 
25
25
  def run_all_tests
26
26
  puts "\n#{HH} Running all tests #{HH}\n"
27
- %w{test}.each { |dir| run "rake #{dir}" if File.exists?(dir) }
27
+ TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
28
28
  end
29
29
 
30
30
  def run_matching_files(base)
31
31
  base = base.split('_').first
32
- %w{test spec}.each { |type|
32
+ TESTING.each { |type|
33
33
  files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
34
34
  run_it type, files.join(' ') unless files.empty?
35
35
  }
36
36
  end
37
37
 
38
- %w{test spec}.each { |type|
38
+ TESTING.each { |type|
39
39
  watch("#{type}/#{type}_helper\.rb") { run_all_tests }
40
+ watch('lib/.*\.rb') { run_all_tests }
40
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
+ }
41
46
  }
42
- %w{rb erb haml slim}.each { |type|
43
- watch(".*/.*\.#{type}") { |m|
44
- run_matching_files("#{m[0].split('/').last.split('.').first}")
47
+
48
+ %w[rb erb haml slim].each { |type|
49
+ watch("app/.*/(.*)\.#{type}") { |match|
50
+ run_matching_files(match[1])
45
51
  }
46
52
  }
47
53
 
data/Gemfile CHANGED
@@ -1,15 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'micro-optparse'
3
+ gemspec
4
4
 
5
5
  group :test do
6
- gem 'simplecov', require: false
7
- end
8
-
9
- group :test, :development do
10
- gem 'rake'
11
6
  gem 'observr'
12
- gem 'minitest'
7
+ gem 'rubocop', require: false
8
+ gem 'simplecov', require: false
13
9
  end
14
-
15
- gemspec
data/Gemfile.lock CHANGED
@@ -1,31 +1,56 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doit (0.3.0)
4
+ doit (1.0.2)
5
5
  micro-optparse (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- docile (1.1.5)
11
- json (1.8.3)
12
- micro-optparse (1.2.0)
13
- minitest (5.8.4)
10
+ ast (2.4.2)
11
+ docile (1.4.0)
12
+ micro-optparse (1.2.1)
13
+ minitest (5.14.4)
14
14
  observr (1.0.5)
15
- rake (10.5.0)
16
- simplecov (0.11.1)
17
- docile (~> 1.1.0)
18
- json (~> 1.8)
19
- simplecov-html (~> 0.10.0)
20
- simplecov-html (0.10.0)
15
+ parallel (1.20.1)
16
+ parser (3.0.1.1)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.0.0)
19
+ rake (13.0.3)
20
+ regexp_parser (2.1.1)
21
+ rexml (3.2.5)
22
+ rubocop (1.17.0)
23
+ parallel (~> 1.10)
24
+ parser (>= 3.0.0.0)
25
+ rainbow (>= 2.2.2, < 4.0)
26
+ regexp_parser (>= 1.8, < 3.0)
27
+ rexml
28
+ rubocop-ast (>= 1.7.0, < 2.0)
29
+ ruby-progressbar (~> 1.7)
30
+ unicode-display_width (>= 1.4.0, < 3.0)
31
+ rubocop-ast (1.7.0)
32
+ parser (>= 3.0.1.1)
33
+ ruby-progressbar (1.11.0)
34
+ simplecov (0.21.2)
35
+ docile (~> 1.1)
36
+ simplecov-html (~> 0.11)
37
+ simplecov_json_formatter (~> 0.1)
38
+ simplecov-html (0.12.3)
39
+ simplecov_json_formatter (0.1.3)
40
+ unicode-display_width (2.0.0)
21
41
 
22
42
  PLATFORMS
23
- ruby
43
+ x86_64-linux
24
44
 
25
45
  DEPENDENCIES
46
+ bundler (~> 2)
26
47
  doit!
27
- micro-optparse
28
- minitest
48
+ micro-optparse (~> 1)
49
+ minitest (~> 5)
29
50
  observr
30
- rake
51
+ rake (~> 13)
52
+ rubocop
31
53
  simplecov
54
+
55
+ BUNDLED WITH
56
+ 2.2.17
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Dittmar Krall
1
+ Copyright (c) 2014-2020 Dittmar Krall
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -23,18 +23,20 @@ Options
23
23
  -------
24
24
  -l, --[no-]list Lists available scripts
25
25
  -r, --remote ["host"] remote host or comma separated hosts
26
+ -e, --[no-]each Lists each remote command (no execution)
26
27
  -s, --[no-]silent run silently; suppress output
27
28
  -v, --[no-]verbose Enable verbose output
28
29
  -n, --[no-]noop Suppress execution of commannds
29
30
  -h, --help Show this message
30
31
  -V, --version Print version
31
32
 
33
+
32
34
  File Structure
33
35
  --------------
34
36
  ~/.doit/deploy # chmod +x .doit/deploy
35
37
  ~/.doit/deploy.yml
36
38
  $PROJ/.doit/deploy.yml # overwrites $HOME(~/) script/configuration
37
- $PROJ/.doit/push # chmod +x .doit/deploy
39
+ $PROJ/.doit/push # chmod +x .doit/push
38
40
  $PROJ/.doit/push.yml
39
41
 
40
42
  $PROJ/.doit/push
@@ -73,4 +75,4 @@ $PROJ/.doit/push
73
75
  - bob@sample.com
74
76
  - alice@customer.com
75
77
 
76
- Copyright (c) 2014-2016 [Dittmar Krall], released under the MIT license
78
+ Copyright (c) 2014-2019 [Dittmar Krall], released under the MIT license.
data/bin/doit CHANGED
@@ -1,21 +1,24 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
 
3
- lib = File.expand_path('../../lib/', __FILE__)
4
- $:.unshift lib unless $:.include?(lib)
3
+ lib = File.expand_path('../lib/', __dir__)
4
+ # $:.unshift lib unless $:.include?(lib)
5
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
6
 
6
7
  require 'doit'
7
8
  require 'micro-optparse'
8
9
  require 'globals'
10
+ require 'what'
9
11
 
10
12
  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 :each, 'Lists each remote command (no execution)'
15
- p.option :remote, 'Remote host or comma separated hosts', default: '...', optional: true
16
- p.option :silent, 'Run silently; suppress output'
17
- p.option :verbose, 'Enable verbose output'
18
- p.option :noop, 'Suppress execution of commannds'
13
+ p.banner = 'Usage: doit script... [options] # execute locally or remotely'
14
+ p.version = "doit #{Globals::VERSION}"
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'
19
22
  end.process!
20
23
 
21
24
  Doit.start(options)
data/doit.gemspec CHANGED
@@ -1,22 +1,28 @@
1
- $:.push File.expand_path("../lib", __FILE__)
1
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
2
2
  require 'globals'
3
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)."
4
+ Gem::Specification.new do |s|
5
+ s.name = 'doit'
6
+ s.version = Globals::VERSION
7
+ s.summary = 'Simple local & remote script executor'
8
+ s.description = 'Run good old shell/bash scripts locally or remotely(ssh).'
9
9
 
10
- gem.authors = ['Dittmar Krall']
11
- gem.email = 'dittmar.krall@matique.de'
12
- gem.homepage = 'http://www.matique.de'
13
- gem.license = 'MIT'
10
+ s.authors = ['Dittmar Krall']
11
+ s.email = 'dittmar.krall@matique.de'
12
+ s.homepage = 'http://www.matique.de'
13
+ s.license = 'MIT'
14
14
 
15
- gem.add_dependency 'micro-optparse', '~> 1'
15
+ s.add_dependency 'micro-optparse', '~> 1'
16
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"]
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- test`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`
20
+ .split("\n").map { |f| File.basename(f) }
21
+ s.require_paths = ['lib']
21
22
 
23
+ s.add_development_dependency 'bundler', '~> 2'
24
+ s.add_development_dependency 'rake', '~> 13'
25
+
26
+ s.add_development_dependency 'micro-optparse', '~> 1'
27
+ s.add_development_dependency 'minitest', '~> 5'
22
28
  end
data/lib/doit.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # rubocop: disable all
2
+
1
3
  require 'my'
2
4
  require 'run'
3
5
  require 'import'
4
- require 'what'
5
6
 
6
7
  Doit = Object.new
7
8
  class << Doit
@@ -17,7 +18,8 @@ class << Doit
17
18
  end
18
19
 
19
20
  def options
20
- @options || {}
21
+ @options ||= {}
22
+ @options
21
23
  end
22
24
 
23
25
  def list
@@ -25,10 +27,12 @@ class << Doit
25
27
  hsh.sort.each { |abb, long|
26
28
  puts "#{abb}\t- #{long}"
27
29
  next unless options[:verbose]
30
+
28
31
  lines = `grep -i 'usage\\|summary' #{long} | grep '^#'`.split("\n")
29
32
  lines.each { |line|
30
33
  next unless line
31
34
  next if line.empty?
35
+
32
36
  puts "\t #{line}"
33
37
  }
34
38
  }
@@ -40,11 +44,9 @@ class << Doit
40
44
  puts "doit: script '#{name}' not found"
41
45
  return
42
46
  end
43
- What.init(Import.script, Import.config)
47
+ What.init(Import.config)
44
48
 
45
- What.where.each { |w|
46
- puts "doit #{name} -r #{w}"
47
- } if options[:each]
49
+ What.where.each { |w| puts "doit #{name} -r #{w}" } if options[:each]
48
50
 
49
51
  where_loop unless options[:each]
50
52
  end
@@ -56,18 +58,18 @@ class << Doit
56
58
  }
57
59
  end
58
60
 
59
- def matrix_loop(w)
61
+ def matrix_loop(where)
60
62
  What.matrix.each { |mm|
61
63
  prefix = mm.empty? ? '' : "#{What.to_env(mm)}\n"
62
64
 
63
65
  What.env.each { |en|
64
- prefix2 = en.empty? ? '' : "#{en}\n"
66
+ prefix2 = en.empty? ? '' : "#{en}\n"
65
67
 
66
- cmds = Import.script
67
- cmds = @argv + prefix + prefix2 + cmds
68
- Run.init cmds, w
69
- Run.info if options[:verbose]
70
- Run.run
68
+ cmds = Import.script
69
+ cmds = @argv + prefix + prefix2 + cmds
70
+ Run.init cmds, where
71
+ Run.info if options[:verbose]
72
+ Run.run
71
73
  }
72
74
  }
73
75
  end
data/lib/globals.rb CHANGED
@@ -1,3 +1,14 @@
1
+ # rubocop: disable all
2
+
1
3
  module Globals
2
- VERSION = '0.3.0'
4
+ VERSION = '1.0.2' # 2021-06-26
5
+ # VERSION = '1.0.1' # 2021-04-21
6
+ # VERSION = '1.0.0' # 2020-10-26
7
+ # VERSION = '0.3.9' # 2020-07-17
8
+ # VERSION = '0.3.8' # 2020-02-26
9
+ # VERSION = '0.3.7' # 2019-10-15
10
+ # VERSION = '0.3.6' # 2019-03-06
11
+ # VERSION = '0.3.5' # 2018-09-11
12
+ # VERSION = '0.3.4' # 2018-08-19
13
+ # VERSION = '0.3.3'
3
14
  end
data/lib/import.rb CHANGED
@@ -1,11 +1,20 @@
1
+ # rubocop: disable all
2
+
1
3
  require 'pathname'
2
4
  require 'erb'
3
5
 
4
6
  Import = Object.new
5
7
  class << Import
6
8
 
7
- def script; @script; end
8
- def config; @config; end
9
+ def script
10
+ @script ||= nil
11
+ @script
12
+ end
13
+
14
+ def config
15
+ @config ||= nil
16
+ @config
17
+ end
9
18
 
10
19
  def init(name)
11
20
  @script = read(name)
@@ -21,11 +30,10 @@ class << Import
21
30
  def info
22
31
  return unless Doit.options[:verbose]
23
32
 
24
- My.verbose "SCRIPT", @script
25
- My.verbose "CONFIG(yml)", @config
33
+ My.verbose 'SCRIPT', @script
34
+ My.verbose 'CONFIG(yml)', @config
26
35
  end
27
36
 
28
-
29
37
  private
30
38
  def list2
31
39
  res = {}
@@ -54,7 +62,7 @@ class << Import
54
62
  def try_ascend(filename)
55
63
  Pathname.pwd.ascend { |dir|
56
64
  str = dir + filename
57
- return File.read(str) if File.exists?(str)
65
+ return File.read(str) if File.exist?(str)
58
66
  }
59
67
  nil
60
68
  end
data/lib/my.rb CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  My = Object.new
2
- class << My
3
4
 
5
+ class << My
4
6
  def verbose(what, txt)
5
- marker = '*'*4
7
+ marker = '*' * 4
6
8
  arr = txt
7
- arr = txt ? txt.split("\n") : '' unless Array === txt
9
+ arr = txt ? txt.split("\n") : '' unless txt.is_a?(Array)
8
10
  if arr.length > 1
9
11
  puts "#{marker} #{what} #{marker}"
10
12
  puts txt
@@ -13,5 +15,4 @@ class << My
13
15
  puts "#{marker} #{what}: #{txt}"
14
16
  end
15
17
  end
16
-
17
18
  end
data/lib/run.rb CHANGED
@@ -1,10 +1,12 @@
1
+ # rubocop: disable all
2
+
1
3
  Run = Object.new
2
4
  class << Run
3
5
 
4
- def ssh; @ssh; end
6
+ attr_reader :ssh
5
7
 
6
8
  def init(cmds, where)
7
- aster = '*'*24
9
+ aster = '*' * 24
8
10
  puts "#{aster} #{where} #{aster}"
9
11
  @ssh = nil
10
12
  @cmds = cmds
@@ -18,7 +20,7 @@ class << Run
18
20
  dir = where
19
21
  end
20
22
 
21
- @cmds = "cd; cd #{dir}\n" + @cmds unless dir && dir.empty?
23
+ @cmds = "cd; cd #{dir}\n" + @cmds unless dir&.empty?
22
24
  @ssh = "ssh #{host}" if host
23
25
  end
24
26
 
@@ -33,10 +35,10 @@ class << Run
33
35
  cmd = "cat <<'#{here}\' | #{@ssh} bash -i -l #{silent} 2>&1"
34
36
  cmds = "#{cmd}\n#{@cmds}#{here}\n"
35
37
 
36
- unless Doit.options[:noop]
37
- IO.popen(cmds) { |p| p.each { |f| puts f } }
38
- else
38
+ if Doit.options[:noop]
39
39
  My.verbose('noop', cmds)
40
+ else
41
+ IO.popen(cmds) { |p| p.each { |f| puts f } }
40
42
  end
41
43
  end
42
44
 
data/lib/what.rb CHANGED
@@ -1,14 +1,16 @@
1
+ # rubocop: disable all
2
+
1
3
  require 'yaml'
2
4
  require 'doit'
3
5
 
4
6
  What = Object.new
5
7
  class << What
6
8
 
7
- def matrix; @matrix; end
8
- def where; @where; end
9
- def env; @env; end
9
+ attr_reader :matrix
10
+ attr_reader :where
11
+ attr_reader :env
10
12
 
11
- def init(script, config)
13
+ def init(config)
12
14
  @matrix = nil
13
15
  @yml = (config && YAML.load(config)) || {}
14
16
 
@@ -24,7 +26,7 @@ class << What
24
26
 
25
27
  build_matrix
26
28
  @matrix ||= []
27
- @matrix = [@matrix] unless Array === @matrix.first
29
+ @matrix = [@matrix] unless @matrix.first.is_a?(Array)
28
30
  @matrix.map! { |m| m.flatten.inject({}) { |hsh, h| hsh.merge(h) } }
29
31
  info
30
32
  end
@@ -37,24 +39,25 @@ class << What
37
39
  def info
38
40
  return unless Doit.options[:verbose]
39
41
 
40
- My.verbose "where", @where
41
- My.verbose "matrix", @matrix
42
- My.verbose "env", @env
42
+ My.verbose 'where', @where
43
+ My.verbose 'matrix', @matrix
44
+ My.verbose 'env', @env
43
45
  end
44
46
 
45
-
46
47
  private
47
48
  def build_matrix
48
- unless @yml.empty?
49
- key, value = @yml.first
50
- @yml.delete(key)
51
- add_to_matrix(key, value)
52
- build_matrix
53
- end
49
+ return if @yml.empty?
50
+
51
+ key, value = @yml.first
52
+ @yml.delete(key)
53
+ add_to_matrix(key, value)
54
+ build_matrix
54
55
  end
55
56
 
56
57
  def add_to_matrix(key, val)
57
- arr = Array === val ? val.collect {|v| [{key => v}] } : [{key => val}]
58
+ arr = val.is_a?(Array) ?
59
+ val.collect { |v| [{ key => v }] } :
60
+ [{ key => val }]
58
61
  @matrix = @matrix ? @matrix.product(arr) : arr
59
62
  end
60
63
 
data/test/doit_test.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'doit'
3
2
 
4
3
  describe Doit do
5
4
 
@@ -7,48 +6,48 @@ describe Doit do
7
6
  Doit.start({})
8
7
  end
9
8
 
10
- it "start" do
11
- out = noop { }
9
+ it 'start' do
10
+ out = noop {}
12
11
  assert_equal '', out
13
12
  end
14
13
 
15
- it "options" do
14
+ it 'options' do
16
15
  assert_equal({}, Doit.options)
17
16
  end
18
17
 
19
- it "list" do
18
+ it 'list' do
20
19
  out = noop {
21
20
  Doit.list
22
21
  }
23
- assert_match /\/\.doit/, out
22
+ assert_match(/\/\.doit/, out)
24
23
  end
25
24
 
26
- it "execute" do
27
- out, err = capture_io do
25
+ it 'execute' do
26
+ out, _err = capture_io do
28
27
  Doit.execute('hello')
29
28
  end
30
- assert_match /\nHello\n/, out
29
+ assert_match(/\nHello\n/, out)
31
30
  end
32
31
 
33
- it "execute with unknown script" do
34
- out, err = capture_io do
32
+ it 'execute with unknown script' do
33
+ out, _err = capture_io do
35
34
  Doit.execute('______unknown______')
36
35
  end
37
- assert_match /not found/, out
36
+ assert_match(/not found/, out)
38
37
  end
39
38
 
40
- it "tests option --each" do
41
- out = noop({each: true}) {
39
+ it 'tests option --each' do
40
+ out = noop(each: true) {
42
41
  Doit.execute('hello')
43
42
  }
44
- assert_match /doit hello -r/, out
43
+ assert_match(/doit hello -r/, out)
45
44
  end
46
45
 
47
- it "coverage: list; option -lv" do
48
- out = noop({verbose: true, list: true}) {
49
- Doit.start({verbose: true, list: true})
46
+ it 'coverage: list; option -lv' do
47
+ out = noop(verbose: true, list: true) {
48
+ Doit.start(verbose: true, list: true)
50
49
  }
51
- assert_match /just a test\n/, out
50
+ assert_match(/just a test\n/, out)
52
51
  end
53
52
 
54
53
  end
data/test/import_test.rb CHANGED
@@ -5,33 +5,33 @@ require 'my'
5
5
 
6
6
  describe Import do
7
7
 
8
- it "init fails with empty" do
8
+ it 'init fails with empty' do
9
9
  assert_raises(Errno::EISDIR) { Import.init('') }
10
10
  end
11
11
 
12
- it "init" do
12
+ it 'init' do
13
13
  Import.init('hello')
14
14
  end
15
15
 
16
- it "list" do
16
+ it 'list' do
17
17
  Import.init('hello')
18
- assert_match /\/\.doit\/hello$/, Import.list['hello']
18
+ assert_match(/\/\.doit\/hello$/, Import.list['hello'])
19
19
  end
20
20
 
21
- it "info" do
22
- out = noop({verbose: true}) {
21
+ it 'info' do
22
+ out = noop(verbose: true) {
23
23
  Import.init('hello')
24
24
  Import.info
25
25
  }
26
- assert_match /SCRIPT/, out
27
- assert_match /CONFIG/, out
26
+ assert_match(/SCRIPT/, out)
27
+ assert_match(/CONFIG/, out)
28
28
  end
29
29
 
30
- it "coverage: script" do
30
+ it 'coverage: script' do
31
31
  Import.script
32
32
  end
33
33
 
34
- it "coverage: config" do
34
+ it 'coverage: config' do
35
35
  Import.config
36
36
  end
37
37
 
data/test/my_test.rb CHANGED
@@ -3,20 +3,20 @@ require 'my'
3
3
 
4
4
  describe My do
5
5
 
6
- it "verbose" do
6
+ it 'verbose' do
7
7
  h = 'hello'
8
- out, err = capture_io do
8
+ out, _err = capture_io do
9
9
  My.verbose('a', h)
10
10
  end
11
- assert_match /#{h}/, out
11
+ assert_match(/#{h}/, out)
12
12
  end
13
13
 
14
- it "verbose text" do
14
+ it 'verbose text' do
15
15
  h = 'hello'
16
- out, err = capture_io do
16
+ out, _err = capture_io do
17
17
  My.verbose('a', "#{h}\nx\n")
18
18
  end
19
- assert_match /#{h}/, out
19
+ assert_match(/#{h}/, out)
20
20
  end
21
21
 
22
22
  end
data/test/run_test.rb CHANGED
@@ -5,54 +5,54 @@ require 'doit'
5
5
 
6
6
  describe Run do
7
7
 
8
- it "coverage #info" do
9
- out, err = capture_io do
8
+ it 'coverage #info' do
9
+ _out, _err = capture_io do
10
10
  Run.init('', '')
11
11
  Run.info
12
12
  end
13
13
  end
14
14
 
15
15
  it "where '' returns nil" do
16
- out, err = capture_io do
16
+ _out, _err = capture_io do
17
17
  Run.init('', '')
18
18
  assert_equal nil, Run.ssh
19
19
  end
20
20
  end
21
21
 
22
22
  it "where 'a' returns nil" do
23
- out, err = capture_io do
23
+ _out, _err = capture_io do
24
24
  Run.init('', 'a')
25
25
  assert_equal nil, Run.ssh
26
26
  end
27
27
  end
28
28
 
29
29
  it "where 'a@b' returns 'ssh a@b'" do
30
- out, err = capture_io do
30
+ _out, _err = capture_io do
31
31
  Run.init('', 'a@b')
32
32
  assert_equal 'ssh a@b', Run.ssh
33
33
  end
34
34
  end
35
35
 
36
36
  it "where 'a@b:c' returns 'ssh a@b'" do
37
- out, err = capture_io do
37
+ _out, _err = capture_io do
38
38
  Run.init('', 'a@b:c')
39
39
  assert_equal 'ssh a@b', Run.ssh
40
40
  end
41
41
  end
42
42
 
43
- it "coverage #run" do
44
- out, err = capture_io do
43
+ it 'coverage #run' do
44
+ _out, _err = capture_io do
45
45
  Run.init('', '')
46
46
  Run.run
47
47
  end
48
48
  end
49
49
 
50
- it "coverage #run noop" do
50
+ it 'coverage #run noop' do
51
51
  out = noop {
52
52
  Run.init('', '')
53
53
  Run.run
54
54
  }
55
- assert_match /EOS/, out
55
+ assert_match(/EOS/, out)
56
56
  end
57
57
 
58
58
  end
data/test/test_helper.rb CHANGED
@@ -1,18 +1,21 @@
1
- require 'simplecov'
2
- SimpleCov.start do
3
- add_filter 'test'
4
- command_name 'Minitest'
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter '/test/'
5
+ end
5
6
  end
6
7
 
8
+ require 'what'
9
+
7
10
  require 'minitest/autorun'
8
11
 
9
- def noop(options = {noop: true}, &block)
12
+ def noop(options = { noop: true }, &block)
10
13
  return 'noop: missing block' unless block
11
14
 
12
15
  out = '---'
13
16
  Doit.stub :options, options do
14
- out, err = capture_io do
15
- block.call
17
+ out, _err = capture_io do
18
+ yield
16
19
  end
17
20
  end
18
21
  out
data/test/what_test.rb CHANGED
@@ -1,11 +1,10 @@
1
1
  require 'test_helper'
2
- require 'what'
3
2
  require 'my'
4
3
 
5
4
  describe What do
6
5
 
7
- it "is robust against empty params" do
8
- What.init('', '')
6
+ it 'is robust against empty params' do
7
+ What.init('')
9
8
  assert_equal [Dir.pwd], What.where
10
9
  assert_equal [{}], What.matrix
11
10
  end
@@ -14,32 +13,32 @@ describe What do
14
13
  assert_equal '', What.to_env({})
15
14
  end
16
15
 
17
- it "to_env converts variable to uppercase" do
18
- assert_equal 'A=1', What.to_env({a: 1})
16
+ it 'to_env converts variable to uppercase' do
17
+ assert_equal 'A=1', What.to_env(a: 1)
19
18
  end
20
19
 
21
- it "coverage: #info" do
22
- Doit.stub :options, {verbose: true} do
23
- out, err = capture_io do
24
- What.init('', '')
25
- What.info
20
+ it 'coverage: #info' do
21
+ Doit.stub :options, verbose: true do
22
+ _out, _err = capture_io do
23
+ What.init('')
24
+ What.info
26
25
  end
27
26
  end
28
27
  end
29
28
 
30
- it "builds simple matrix" do
31
- What.init('', "a: 1\n")
32
- assert_equal [{"a"=>1}], What.matrix
29
+ it 'builds simple matrix' do
30
+ What.init("a: 1\n")
31
+ assert_equal [{ 'a' => 1 }], What.matrix
33
32
  end
34
33
 
35
- it "builds matrix" do
36
- What.init('', "a:\n - 1\n - 2\n")
37
- assert_equal [{"a"=>1}, {"a"=>2}], What.matrix
34
+ it 'builds matrix' do
35
+ What.init("a:\n - 1\n - 2\n")
36
+ assert_equal [{ 'a' => 1 }, { 'a' => 2 }], What.matrix
38
37
  end
39
38
 
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
39
+ it 'builds product matrix' do
40
+ What.init("a:\n - 1\nb:\n - 3\n - 4\n")
41
+ assert_equal [{ 'a' => 1, 'b' => 3 }, { 'a' => 1, 'b' => 4 }], What.matrix
43
42
  end
44
43
 
45
44
  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: 0.3.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dittmar Krall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2021-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: micro-optparse
@@ -24,6 +24,62 @@ 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
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: micro-optparse
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5'
27
83
  description: Run good old shell/bash scripts locally or remotely(ssh).
28
84
  email: dittmar.krall@matique.de
29
85
  executables:
@@ -33,6 +89,10 @@ extra_rdoc_files: []
33
89
  files:
34
90
  - ".doit/hello"
35
91
  - ".doit/hello.yml"
92
+ - ".github/workflows/rake.yml"
93
+ - ".gitignore"
94
+ - ".rubocop.yml"
95
+ - ".ruby-gemset"
36
96
  - ".ruby-version"
37
97
  - ".travis.yml"
38
98
  - ".watchr"
@@ -74,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
134
  - !ruby/object:Gem::Version
75
135
  version: '0'
76
136
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.5
137
+ rubygems_version: 3.2.6
79
138
  signing_key:
80
139
  specification_version: 4
81
140
  summary: Simple local & remote script executor