guard-exec 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +120 -0
- data/.travis.yml +5 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +98 -0
- data/Guardfile +21 -0
- data/README.md +89 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/guard-exec.gemspec +30 -0
- data/lib/guard/exec.rb +102 -0
- data/lib/guard/exec/options.rb +31 -0
- data/lib/guard/exec/runner.rb +44 -0
- data/lib/guard/exec/templates/Guardfile +30 -0
- data/lib/guard/exec/version.rb +3 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbc0afaa0fc9ab724706df3dd7c6b8ab379827f0d1414920eca5986f98ae2e15
|
4
|
+
data.tar.gz: f69c71d79ce5ea4e5eb6f7aa477b0c603243f4f888a0f04004bb365cf00d23d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75badba1936cb27dda0eaf4e970855ee6fb4df885d509c8a6c8ff268542c5bdd05b631436b2a703c40c3649c39c2946743e699d495b7075718c04369e6781762
|
7
|
+
data.tar.gz: fe9caeef58d147c36588f7c9c32be270079ea122e2d3fc14cc2d6f41311ff1726133a2770e1f227469a7df98b4930c7e96fdf5d7e5388842ddd70314e90f45dc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-12-06 21:38:44 -0300 using RuboCop version 0.61.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
12
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Exclude:
|
15
|
+
- 'Gemfile'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/LeadingBlankLines:
|
20
|
+
Exclude:
|
21
|
+
- 'guard-exec.gemspec'
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
26
|
+
# SupportedStyles: space, no_space
|
27
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
28
|
+
Layout/SpaceInsideBlockBraces:
|
29
|
+
Exclude:
|
30
|
+
- 'Gemfile'
|
31
|
+
|
32
|
+
# Offense count: 2
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
# Configuration parameters: EnforcedStyle.
|
35
|
+
# SupportedStyles: final_newline, final_blank_line
|
36
|
+
Layout/TrailingBlankLines:
|
37
|
+
Exclude:
|
38
|
+
- 'lib/guard/exec.rb'
|
39
|
+
- 'lib/guard/exec/templates/Guardfile'
|
40
|
+
|
41
|
+
# Offense count: 1
|
42
|
+
Style/Documentation:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Offense count: 5
|
46
|
+
# Cop supports --auto-correct.
|
47
|
+
# Configuration parameters: EnforcedStyle.
|
48
|
+
# SupportedStyles: compact, expanded
|
49
|
+
Style/EmptyMethod:
|
50
|
+
Exclude:
|
51
|
+
- 'lib/guard/exec.rb'
|
52
|
+
|
53
|
+
# Offense count: 2
|
54
|
+
# Cop supports --auto-correct.
|
55
|
+
Style/ExpandPathArguments:
|
56
|
+
Exclude:
|
57
|
+
- 'guard-exec.gemspec'
|
58
|
+
|
59
|
+
# Offense count: 1
|
60
|
+
# Cop supports --auto-correct.
|
61
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
62
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
63
|
+
Style/HashSyntax:
|
64
|
+
Exclude:
|
65
|
+
- 'Rakefile'
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
# Cop supports --auto-correct.
|
69
|
+
Style/MutableConstant:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/guard/exec/version.rb'
|
72
|
+
|
73
|
+
# Offense count: 2
|
74
|
+
# Cop supports --auto-correct.
|
75
|
+
# Configuration parameters: PreferredDelimiters.
|
76
|
+
Style/PercentLiteralDelimiters:
|
77
|
+
Exclude:
|
78
|
+
- 'Guardfile'
|
79
|
+
- 'guard-exec.gemspec'
|
80
|
+
|
81
|
+
# Offense count: 1
|
82
|
+
# Cop supports --auto-correct.
|
83
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
84
|
+
# SupportedStyles: slashes, percent_r, mixed
|
85
|
+
Style/RegexpLiteral:
|
86
|
+
Exclude:
|
87
|
+
- 'Guardfile'
|
88
|
+
|
89
|
+
# Offense count: 29
|
90
|
+
# Cop supports --auto-correct.
|
91
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
92
|
+
# SupportedStyles: single_quotes, double_quotes
|
93
|
+
Style/StringLiterals:
|
94
|
+
Exclude:
|
95
|
+
- 'Gemfile'
|
96
|
+
- 'Guardfile'
|
97
|
+
- 'Rakefile'
|
98
|
+
- 'bin/console'
|
99
|
+
- 'guard-exec.gemspec'
|
100
|
+
- 'spec/guard/exec_spec.rb'
|
101
|
+
- 'spec/spec_helper.rb'
|
102
|
+
|
103
|
+
# Offense count: 1
|
104
|
+
# Cop supports --auto-correct.
|
105
|
+
Style/UnneededPercentQ:
|
106
|
+
Exclude:
|
107
|
+
- 'guard-exec.gemspec'
|
108
|
+
|
109
|
+
# Offense count: 10
|
110
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
111
|
+
# URISchemes: http, https
|
112
|
+
Metrics/LineLength:
|
113
|
+
Max: 114
|
114
|
+
|
115
|
+
Metrics/MethodLength:
|
116
|
+
Max: 13
|
117
|
+
|
118
|
+
Metrics/BlockLength:
|
119
|
+
Exclude:
|
120
|
+
- 'spec/**/*.rb'
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in guard-exec.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'rubocop', require: false
|
10
|
+
gem 'guard-rubocop', require: false
|
11
|
+
gem 'guard-rspec', require: false
|
12
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
guard-exec (0.1.0)
|
5
|
+
colorize
|
6
|
+
guard (~> 2.1)
|
7
|
+
guard-compat (~> 1.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.0)
|
13
|
+
coderay (1.1.2)
|
14
|
+
colorize (0.8.1)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
ffi (1.9.25)
|
17
|
+
formatador (0.2.5)
|
18
|
+
guard (2.15.0)
|
19
|
+
formatador (>= 0.2.4)
|
20
|
+
listen (>= 2.7, < 4.0)
|
21
|
+
lumberjack (>= 1.0.12, < 2.0)
|
22
|
+
nenv (~> 0.1)
|
23
|
+
notiffany (~> 0.0)
|
24
|
+
pry (>= 0.9.12)
|
25
|
+
shellany (~> 0.0)
|
26
|
+
thor (>= 0.18.1)
|
27
|
+
guard-compat (1.2.1)
|
28
|
+
guard-rspec (4.7.3)
|
29
|
+
guard (~> 2.1)
|
30
|
+
guard-compat (~> 1.1)
|
31
|
+
rspec (>= 2.99.0, < 4.0)
|
32
|
+
guard-rubocop (1.3.0)
|
33
|
+
guard (~> 2.0)
|
34
|
+
rubocop (~> 0.20)
|
35
|
+
jaro_winkler (1.5.1)
|
36
|
+
listen (3.1.5)
|
37
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
38
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
39
|
+
ruby_dep (~> 1.2)
|
40
|
+
lumberjack (1.0.13)
|
41
|
+
method_source (0.9.2)
|
42
|
+
nenv (0.3.0)
|
43
|
+
notiffany (0.1.1)
|
44
|
+
nenv (~> 0.1)
|
45
|
+
shellany (~> 0.0)
|
46
|
+
parallel (1.12.1)
|
47
|
+
parser (2.5.3.0)
|
48
|
+
ast (~> 2.4.0)
|
49
|
+
powerpack (0.1.2)
|
50
|
+
pry (0.12.2)
|
51
|
+
coderay (~> 1.1.0)
|
52
|
+
method_source (~> 0.9.0)
|
53
|
+
rainbow (3.0.0)
|
54
|
+
rake (10.5.0)
|
55
|
+
rb-fsevent (0.10.3)
|
56
|
+
rb-inotify (0.9.10)
|
57
|
+
ffi (>= 0.5.0, < 2)
|
58
|
+
rspec (3.8.0)
|
59
|
+
rspec-core (~> 3.8.0)
|
60
|
+
rspec-expectations (~> 3.8.0)
|
61
|
+
rspec-mocks (~> 3.8.0)
|
62
|
+
rspec-core (3.8.0)
|
63
|
+
rspec-support (~> 3.8.0)
|
64
|
+
rspec-expectations (3.8.2)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-mocks (3.8.0)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-support (3.8.0)
|
71
|
+
rubocop (0.61.1)
|
72
|
+
jaro_winkler (~> 1.5.1)
|
73
|
+
parallel (~> 1.10)
|
74
|
+
parser (>= 2.5, != 2.5.1.1)
|
75
|
+
powerpack (~> 0.1)
|
76
|
+
rainbow (>= 2.2.2, < 4.0)
|
77
|
+
ruby-progressbar (~> 1.7)
|
78
|
+
unicode-display_width (~> 1.4.0)
|
79
|
+
ruby-progressbar (1.10.0)
|
80
|
+
ruby_dep (1.5.0)
|
81
|
+
shellany (0.0.1)
|
82
|
+
thor (0.20.3)
|
83
|
+
unicode-display_width (1.4.0)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
ruby
|
87
|
+
|
88
|
+
DEPENDENCIES
|
89
|
+
bundler (~> 1.16)
|
90
|
+
guard-exec!
|
91
|
+
guard-rspec
|
92
|
+
guard-rubocop
|
93
|
+
rake (~> 10.0)
|
94
|
+
rspec (~> 3.0)
|
95
|
+
rubocop
|
96
|
+
|
97
|
+
BUNDLED WITH
|
98
|
+
1.16.2
|
data/Guardfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
clearing :on
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
4
|
+
require "guard/rspec/dsl"
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
6
|
+
|
7
|
+
# Ruby files
|
8
|
+
ruby = dsl.ruby
|
9
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
10
|
+
|
11
|
+
# RSpec files
|
12
|
+
rspec = dsl.rspec
|
13
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_files)
|
16
|
+
end
|
17
|
+
|
18
|
+
guard :rubocop do
|
19
|
+
watch(%r{.+\.rb$})
|
20
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
21
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Guard::Exec
|
2
|
+
![gem_version](https://img.shields.io/badge/gem__version-0.1.0-green.svg)
|
3
|
+
|
4
|
+
## Install
|
5
|
+
|
6
|
+
Add the gem to your Gemfile (inside development group):
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
gem 'guard-exec', require: false
|
10
|
+
```
|
11
|
+
|
12
|
+
Add guard definition to your Guardfile by running this command:
|
13
|
+
|
14
|
+
```
|
15
|
+
$ bundle exec guard init rspec
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Please read [Guard usage doc](https://github.com/guard/guard#readme).
|
21
|
+
|
22
|
+
## Guardfile
|
23
|
+
|
24
|
+
Guard::Exec can be adapted to all kinds of projects.
|
25
|
+
|
26
|
+
### Options
|
27
|
+
|
28
|
+
```
|
29
|
+
# [command] [command_options] paths [commands_arguments]
|
30
|
+
# for crystal minitest:
|
31
|
+
$ crystal spec -d spec/router.cr -- --chaos
|
32
|
+
```
|
33
|
+
|
34
|
+
The following options are available:
|
35
|
+
|
36
|
+
- name
|
37
|
+
The display name of your process in Guard, this is shown when Guard::Exec is starting
|
38
|
+
- color
|
39
|
+
The display color of yout proccess, Please read
|
40
|
+
[Colorize usage](https://github.com/fazibear/colorize).
|
41
|
+
- command
|
42
|
+
The command to run as you would run it from the command line `crystal spec`
|
43
|
+
- command_options
|
44
|
+
The command options or switches ` -d`
|
45
|
+
- commands_arguments
|
46
|
+
The command arguments ` -- --chaos`
|
47
|
+
|
48
|
+
## Examples
|
49
|
+
|
50
|
+
### Crystal minitest
|
51
|
+
|
52
|
+
``` ruby
|
53
|
+
# crystal spec -- --chaos
|
54
|
+
guard :exec, name: 'Minitest', command: 'crystal spec', comand_arguments: '-- --chaos' do
|
55
|
+
watch(%r{^spec/(.*)_spec\.cr})
|
56
|
+
watch(%r{^src/[^/+]+/(.+)\.cr$}) { |m| "spec/#{m[1]}_spec.cr" }
|
57
|
+
end
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
### Elixir Test
|
62
|
+
``` ruby
|
63
|
+
# mix test
|
64
|
+
guard :exec, name: 'Test', command: 'mix test' do
|
65
|
+
watch(%r{^test/(.*)_test\.exs})
|
66
|
+
watch(%r{^lib/(.+)\.ex$}) { |m| "test/#{m[1]}_test.exs" }
|
67
|
+
watch(%r{^test/test_helper.exs$}) { "test" }
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
### Elixir Credo
|
72
|
+
``` ruby
|
73
|
+
# mix credo --strict --format=oneline
|
74
|
+
credo = {
|
75
|
+
name: 'Credo',
|
76
|
+
command: 'mix credo',
|
77
|
+
command_options: '--strict --format=oneline',
|
78
|
+
color: :yellow
|
79
|
+
}
|
80
|
+
|
81
|
+
guard :exec, credo do
|
82
|
+
watch(%r{\.(erl|ex|exs|eex|xrl|yrl)$})
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/clouw/guard-exec.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "guard/exec"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/guard-exec.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "guard/exec/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "guard-exec"
|
8
|
+
spec.version = Guard::EXEC_VERSION
|
9
|
+
spec.authors = ["Ramón Soto"]
|
10
|
+
spec.email = ["ddsstr@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{execute command on guard}
|
13
|
+
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'colorize'
|
24
|
+
spec.add_dependency "guard", "~> 2.1"
|
25
|
+
spec.add_dependency "guard-compat", "~> 1.1"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
end
|
data/lib/guard/exec.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'guard/compat/plugin'
|
3
|
+
require 'guard/exec/version'
|
4
|
+
require 'guard/exec/options'
|
5
|
+
require 'guard/exec/runner'
|
6
|
+
|
7
|
+
module Guard
|
8
|
+
class Exec < Plugin
|
9
|
+
attr_accessor :options, :runner
|
10
|
+
# Initializes a Guard plugin.
|
11
|
+
# Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!
|
12
|
+
#
|
13
|
+
# @param [Hash] options the custom Guard plugin options
|
14
|
+
# @option options [Array<Guard::Watcher>] watchers the Guard plugin file watchers
|
15
|
+
# @option options [Symbol] group the group this Guard plugin belongs to
|
16
|
+
# @option options [Boolean] any_return allow any object to be returned from a watcher
|
17
|
+
#
|
18
|
+
def initialize(options = {})
|
19
|
+
raise MissingCommandOption unless options[:command]
|
20
|
+
|
21
|
+
super
|
22
|
+
|
23
|
+
@options = Options.with_defaults(options)
|
24
|
+
@runner = Runner.new(@options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Called once when Guard starts. Please override initialize method to init stuff.
|
28
|
+
#
|
29
|
+
# @raise [:task_has_failed] when start has failed
|
30
|
+
# @return [Object] the task result
|
31
|
+
#
|
32
|
+
def start
|
33
|
+
end
|
34
|
+
|
35
|
+
# Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
|
36
|
+
#
|
37
|
+
# @raise [:task_has_failed] when stop has failed
|
38
|
+
# @return [Object] the task result
|
39
|
+
#
|
40
|
+
def stop
|
41
|
+
end
|
42
|
+
|
43
|
+
# Called when `reload|r|z + enter` is pressed.
|
44
|
+
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
|
45
|
+
#
|
46
|
+
# @raise [:task_has_failed] when reload has failed
|
47
|
+
# @return [Object] the task result
|
48
|
+
#
|
49
|
+
def reload
|
50
|
+
end
|
51
|
+
|
52
|
+
# Called when just `enter` is pressed
|
53
|
+
# This method should be principally used for long action like running all specs/tests/...
|
54
|
+
#
|
55
|
+
# @raise [:task_has_failed] when run_all has failed
|
56
|
+
# @return [Object] the task result
|
57
|
+
#
|
58
|
+
def run_all
|
59
|
+
Compat::UI.info ['Running all', options[:name]].compact.join ' '
|
60
|
+
|
61
|
+
runner.run
|
62
|
+
end
|
63
|
+
|
64
|
+
# Called on file(s) additions that the Guard plugin watches.
|
65
|
+
#
|
66
|
+
# @param [Array<String>] paths the changes files or paths
|
67
|
+
# @raise [:task_has_failed] when run_on_additions has failed
|
68
|
+
# @return [Object] the task result
|
69
|
+
#
|
70
|
+
def run_on_additions(paths)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Called on file(s) modifications that the Guard plugin watches.
|
74
|
+
#
|
75
|
+
# @param [Array<String>] paths the changes files or paths
|
76
|
+
# @raise [:task_has_failed] when run_on_modifications has failed
|
77
|
+
# @return [Object] the task result
|
78
|
+
#
|
79
|
+
def run_on_modifications(paths)
|
80
|
+
return if paths.empty?
|
81
|
+
|
82
|
+
Compat::UI.info("Running: [#{paths.join(', ')}]", reset: true)
|
83
|
+
|
84
|
+
runner.run(paths)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Called on file(s) removals that the Guard plugin watches.
|
88
|
+
#
|
89
|
+
# @param [Array<String>] paths the changes files or paths
|
90
|
+
# @raise [:task_has_failed] when run_on_removals has failed
|
91
|
+
# @return [Object] the task result
|
92
|
+
#
|
93
|
+
def run_on_removals(paths)
|
94
|
+
end
|
95
|
+
|
96
|
+
class MissingCommandOption < StandardError
|
97
|
+
def message
|
98
|
+
'missing required option :command'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Guard
|
2
|
+
class Exec < Plugin
|
3
|
+
module Options
|
4
|
+
DEFAULTS = {
|
5
|
+
command: nil,
|
6
|
+
command_options: nil,
|
7
|
+
command_arguments: nil,
|
8
|
+
name: nil,
|
9
|
+
color: :light_green
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def with_defaults(options = {})
|
14
|
+
_deep_merge(DEFAULTS, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def _deep_merge(hash1, hash2)
|
20
|
+
hash1.merge(hash2) do |_key, oldval, newval|
|
21
|
+
if oldval.instance_of?(Hash) && newval.instance_of?(Hash)
|
22
|
+
_deep_merge(oldval, newval)
|
23
|
+
else
|
24
|
+
newval
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Guard
|
2
|
+
class Exec < Plugin
|
3
|
+
class Runner
|
4
|
+
DEFAULT_NAME = 'command'.freeze
|
5
|
+
|
6
|
+
attr_accessor :options
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(paths = [])
|
13
|
+
command = build_command(paths)
|
14
|
+
show_command(command)
|
15
|
+
system(command)
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@title ||= "❱ #{name.capitalize}".colorize(options[:color])
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def name
|
25
|
+
options[:name] || DEFAULT_NAME
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_command(paths)
|
29
|
+
command = [
|
30
|
+
options[:command],
|
31
|
+
options[:command_options],
|
32
|
+
paths,
|
33
|
+
options[:command_arguments]
|
34
|
+
]
|
35
|
+
|
36
|
+
command.reject { |el| el.nil? || el.empty? }.join(' ')
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_command(command)
|
40
|
+
Compat::UI.info "\n#{title} [exec] : - #{command}\n\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# directories %w(lib test)
|
2
|
+
# clearing :on
|
3
|
+
|
4
|
+
# # Crystal minitest
|
5
|
+
# # crystal spec -- --chaos
|
6
|
+
# guard :exec, name: 'Minitest', command: 'crystal spec', comand_arguments: '-- --chaos' do
|
7
|
+
# watch(%r{^spec/(.*)_spec\.cr})
|
8
|
+
# watch(%r{^src/[^/+]+/(.+)\.cr$}) { |m| "spec/#{m[1]}_spec.cr" }
|
9
|
+
# end
|
10
|
+
|
11
|
+
# # Elixir Test
|
12
|
+
# # mix test
|
13
|
+
# guard :exec, name: 'Test', command: 'mix test' do
|
14
|
+
# watch(%r{^test/(.*)_test\.exs})
|
15
|
+
# watch(%r{^lib/(.+)\.ex$}) { |m| "test/#{m[1]}_test.exs" }
|
16
|
+
# watch(%r{^test/test_helper.exs$}) { "test" }
|
17
|
+
# end
|
18
|
+
|
19
|
+
# # Elixir Credo
|
20
|
+
# # mix credo --strict --format=oneline
|
21
|
+
# credo = {
|
22
|
+
# name: 'Credo',
|
23
|
+
# command: 'mix credo',
|
24
|
+
# command_options: '--strict --format=oneline',
|
25
|
+
# color: :yellow
|
26
|
+
# }
|
27
|
+
|
28
|
+
# guard :exec, credo do
|
29
|
+
# watch(%r{\.(erl|ex|exs|eex|xrl|yrl)$})
|
30
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-exec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ramón Soto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-compat
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- ddsstr@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".rubocop.yml"
|
107
|
+
- ".rubocop_todo.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- Guardfile
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- guard-exec.gemspec
|
117
|
+
- lib/guard/exec.rb
|
118
|
+
- lib/guard/exec/options.rb
|
119
|
+
- lib/guard/exec/runner.rb
|
120
|
+
- lib/guard/exec/templates/Guardfile
|
121
|
+
- lib/guard/exec/version.rb
|
122
|
+
homepage:
|
123
|
+
licenses: []
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.7.7
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: execute command on guard
|
145
|
+
test_files: []
|