ing 0.2.2 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/examples/publish_ssh.rb +106 -0
- data/examples/rake_pipeline.rb +5 -4
- data/examples/rspec_convert.rb +5 -1
- data/ing.rb +7 -2
- data/lib/ing.rb +3 -1
- data/lib/ing/commands/help.rb +29 -7
- data/lib/ing/commands/list.rb +13 -10
- data/lib/ing/commands/setup.rb +43 -0
- data/lib/ing/default_command.rb +68 -0
- data/lib/ing/generator.rb +1 -0
- data/lib/ing/task.rb +7 -5
- data/lib/ing/version.rb +1 -1
- data/test/acceptance/ing_help_tests.rb +80 -0
- data/test/acceptance/ing_list_tests.rb +141 -0
- data/test/fixtures/help.ing.rb +23 -0
- data/test/fixtures/list.ing.rb +73 -0
- data/test/test_helper.rb +2 -0
- data/todo.yml +2 -2
- metadata +17 -6
data/README.md
CHANGED
@@ -24,6 +24,11 @@ Option parsing courtesy of the venerable and excellent
|
|
24
24
|
|
25
25
|
gem install ing
|
26
26
|
|
27
|
+
To generate a default `ing.rb` file that loads from a `tasks` directory:
|
28
|
+
|
29
|
+
ing setup
|
30
|
+
|
31
|
+
|
27
32
|
## A quick tour
|
28
33
|
|
29
34
|
### The command line
|
@@ -58,7 +63,7 @@ defined or loaded from there, the command can be simply
|
|
58
63
|
### Built-in commands
|
59
64
|
|
60
65
|
Ing has some built-in commands. These are still being implemented, but
|
61
|
-
you can see what they are so far with `ing list`.
|
66
|
+
you can see what they are so far with `ing list -n ing:commands`.
|
62
67
|
|
63
68
|
The most significant subcommand is `generate` or `g`, which
|
64
69
|
simplifies a common and familiar use-case (at the expense of some file-
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# This is a translation of Rake SSH publisher classes,
|
2
|
+
# with some improvements.
|
3
|
+
# cf. https://github.com/jimweirich/rake/blob/master/lib/rake/contrib/sshpublisher.rb
|
4
|
+
#
|
5
|
+
# It's an example of using class inheritance with Ing::Task classes
|
6
|
+
#
|
7
|
+
module Publish
|
8
|
+
|
9
|
+
module Ssh
|
10
|
+
|
11
|
+
extend Ing::DefaultCommand
|
12
|
+
default_command :Dir
|
13
|
+
|
14
|
+
# Base class and options for all SSH publisher classes
|
15
|
+
# Publisher classes should at minimum define +shell_commands+ (array of shell
|
16
|
+
# commands to be executed)
|
17
|
+
#
|
18
|
+
class Base < Ing::Task
|
19
|
+
|
20
|
+
desc "(internal)"
|
21
|
+
opt :host, "Remote user@host", :type => :string
|
22
|
+
opt :remote_dir, "Remote path", :type => :string
|
23
|
+
opt :local_dir, "Local path", :type => :string, :default => Dir.pwd
|
24
|
+
opt :pretend, "Do not publish"
|
25
|
+
opt :debug, "Write shell commands to stderr"
|
26
|
+
|
27
|
+
# Note prompts for +host+ and +remote_dir+ if not given
|
28
|
+
def before
|
29
|
+
ask_unless_given!(:host, :remote_dir)
|
30
|
+
validate_option_exists :host
|
31
|
+
validate_option_exists :remote_dir
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
upload
|
36
|
+
end
|
37
|
+
|
38
|
+
def upload
|
39
|
+
before
|
40
|
+
Array(shell_commands).each do |cmd|
|
41
|
+
$stderr.puts cmd if debug?
|
42
|
+
sh cmd unless pretend?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def shell_commands
|
47
|
+
[]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def host; options[:host]; end
|
53
|
+
def remote_dir; options[:remote_dir]; end
|
54
|
+
def local_dir; options[:local_dir]; end
|
55
|
+
def debug?; !!options[:debug]; end
|
56
|
+
def pretend?; !!options[:pretend]; end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# +ing publish:ssh:dir+
|
61
|
+
class Dir < Base
|
62
|
+
desc "Publish an entire directory to an existing remote directory using SSH."
|
63
|
+
def shell_commands
|
64
|
+
%Q{scp -rq #{local_dir}/* #{host}:#{remote_dir}}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# +ing publish:ssh:fresh_dir+
|
69
|
+
class FreshDir < Dir
|
70
|
+
desc "Publish an entire directory to a fresh remote directory using SSH."
|
71
|
+
|
72
|
+
# note send multiple cmds to single ssh session via here-doc
|
73
|
+
def shell_commands
|
74
|
+
cmds = ["rm -rf #{remote_dir}", "mkdir #{remote_dir}"]
|
75
|
+
[
|
76
|
+
%Q{ssh #{host} << EOF\n #{cmds.join("\n ")}\nEOF },
|
77
|
+
] + Array(super)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# +ing publish:ssh:files+
|
82
|
+
class Files < Base
|
83
|
+
desc "Publish a list of files to an existing remote directory."
|
84
|
+
opt :files, "Files (or file globs) to copy", :type => :string, :multi => true
|
85
|
+
|
86
|
+
# to allow pre-expanded file globs like
|
87
|
+
# ing publish:ssh:files ./*` # instead of
|
88
|
+
# ing publish:ssh:files -f './*'
|
89
|
+
#
|
90
|
+
def call(*args)
|
91
|
+
options[:files] += args
|
92
|
+
super()
|
93
|
+
end
|
94
|
+
|
95
|
+
def shell_commands
|
96
|
+
files.map { |fn|
|
97
|
+
%Q{scp -q #{local_dir}/#{fn} #{host}:#{remote_dir}}
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def files; options[:files] || []; end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
data/examples/rake_pipeline.rb
CHANGED
@@ -13,13 +13,14 @@
|
|
13
13
|
# ing pipeline
|
14
14
|
#
|
15
15
|
# to start the preview server (equivalent to +rakep+)
|
16
|
-
#
|
16
|
+
#
|
17
|
+
# It's an example of using mixin inheritance with Ing::Task classes.
|
18
|
+
#
|
17
19
|
module Pipeline
|
18
20
|
|
19
21
|
# default == server
|
20
|
-
|
21
|
-
|
22
|
-
end
|
22
|
+
extend Ing::DefaultCommand
|
23
|
+
default_command :Server
|
23
24
|
|
24
25
|
module Helpers
|
25
26
|
|
data/examples/rspec_convert.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# A task to convert rspec 'should/not' matchers to minitest 'assert/refute'.
|
2
|
+
#
|
3
|
+
# Usage:
|
2
4
|
# ing rspec:convert which is equivalent to
|
3
5
|
# ing rspec:convert files './{test,spec}/**/*.rb' --convert-dir 'converted'
|
4
6
|
#
|
7
|
+
# It's an example of a plain ruby class implementation of a task.
|
8
|
+
#
|
5
9
|
module Rspec
|
6
10
|
|
7
11
|
class Convert
|
data/ing.rb
CHANGED
@@ -1,2 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Ing tasks
|
2
|
+
# Store your tasks in ./tasks and they will be available to `ing`.
|
3
|
+
# Or simply overwrite this file.
|
4
|
+
|
5
|
+
Dir[File.expand_path("examples/**/*.rb", File.dirname(__FILE__))].each do |rb|
|
6
|
+
load rb
|
7
|
+
end
|
data/lib/ing.rb
CHANGED
@@ -8,12 +8,14 @@
|
|
8
8
|
'ing/files',
|
9
9
|
'ing/task',
|
10
10
|
'ing/generator',
|
11
|
+
'ing/default_command',
|
11
12
|
'ing/command',
|
12
13
|
'ing/commands/boot',
|
13
14
|
'ing/commands/implicit',
|
14
15
|
'ing/commands/generate',
|
15
16
|
'ing/commands/list',
|
16
|
-
'ing/commands/help'
|
17
|
+
'ing/commands/help',
|
18
|
+
'ing/commands/setup'
|
17
19
|
].each do |f|
|
18
20
|
require_relative f
|
19
21
|
end
|
data/lib/ing/commands/help.rb
CHANGED
@@ -11,8 +11,10 @@
|
|
11
11
|
def self.specify_options(parser)
|
12
12
|
parser.text "Display help on specified command"
|
13
13
|
parser.text "\nUsage:"
|
14
|
-
parser.text " ing help generate # help on built-in command generate"
|
15
|
-
parser.text " ing help --namespace test
|
14
|
+
parser.text " ing help generate # help on built-in command 'generate'"
|
15
|
+
parser.text " ing help unit --namespace test # help on command 'unit' within namespace 'test'"
|
16
|
+
parser.text " ing help --namespace test:unit # another syntax"
|
17
|
+
parser.text " ing help test:unit # yet another syntax"
|
16
18
|
parser.text " ing help # display this message"
|
17
19
|
end
|
18
20
|
|
@@ -36,16 +38,36 @@
|
|
36
38
|
require_ing_file
|
37
39
|
end
|
38
40
|
|
39
|
-
def call(cmd=
|
41
|
+
def call(cmd=nil)
|
40
42
|
before
|
41
|
-
|
43
|
+
if options[:namespace_given]
|
44
|
+
if cmd
|
45
|
+
_do_help cmd, _namespace_class
|
46
|
+
else
|
47
|
+
_do_help _namespace_class
|
48
|
+
end
|
49
|
+
else
|
50
|
+
if cmd
|
51
|
+
if /:/ =~ cmd
|
52
|
+
_do_help cmd
|
53
|
+
else
|
54
|
+
_do_help cmd, _namespace_class
|
55
|
+
end
|
56
|
+
else
|
57
|
+
_do_help 'help', _namespace_class
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def _do_help(cmd, ns=::Object)
|
65
|
+
klass = Util.decode_class(cmd, ns)
|
42
66
|
help = Command.new(klass).help
|
43
67
|
shell.say help
|
44
68
|
end
|
45
69
|
|
46
|
-
|
47
|
-
def _namespace_class
|
48
|
-
return ::Object unless ns = options[:namespace]
|
70
|
+
def _namespace_class(ns=options[:namespace])
|
49
71
|
Util.decode_class(ns)
|
50
72
|
end
|
51
73
|
|
data/lib/ing/commands/list.rb
CHANGED
@@ -11,13 +11,16 @@
|
|
11
11
|
def self.specify_options(parser)
|
12
12
|
parser.banner "List all tasks by name or in specified namespace"
|
13
13
|
parser.text "\nUsage:"
|
14
|
-
parser.text " ing list # list all
|
14
|
+
parser.text " ing list # list all known commands that have a description"
|
15
15
|
parser.text " ing list -n rspec # list all commands in rspec namespace"
|
16
|
-
parser.text " ing list rspec #
|
17
|
-
parser.text " ing list rspec --all #
|
18
|
-
parser.text " ing list -n rspec conv #
|
16
|
+
parser.text " ing list rspec # list commands that match /.*rspec/ (in any namespace)"
|
17
|
+
parser.text " ing list rspec --all # list modules that don't have a description (not recommended!)"
|
18
|
+
parser.text " ing list -n rspec conv # list commands that match /.*conv/ in rspec namespace"
|
19
19
|
parser.text "\nOptions:"
|
20
|
-
parser.opt :all, "List all tasks including modules that don't have a description",
|
20
|
+
parser.opt :all, "List all tasks including modules that don't have a description",
|
21
|
+
:default => false
|
22
|
+
parser.opt :strict, "List only tasks that are strictly within specified namespace",
|
23
|
+
:default => false
|
21
24
|
end
|
22
25
|
|
23
26
|
include Ing::CommonOptions
|
@@ -42,19 +45,19 @@
|
|
42
45
|
|
43
46
|
def call(s=nil)
|
44
47
|
before
|
45
|
-
if
|
48
|
+
if !options[:namespace_given]
|
46
49
|
search_all s
|
47
50
|
else
|
48
51
|
search s
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
|
-
def search(s)
|
53
|
-
_do_search(_namespace_class, %r|.*#{s}|,
|
55
|
+
def search(s, recurse=!options[:strict])
|
56
|
+
_do_search(_namespace_class, %r|.*#{s}|, recurse)
|
54
57
|
end
|
55
58
|
|
56
|
-
def search_all(s)
|
57
|
-
_do_search(::Object, %r|.*#{s}|,
|
59
|
+
def search_all(s, recurse=!options[:strict])
|
60
|
+
_do_search(::Object, %r|.*#{s}|, recurse)
|
58
61
|
end
|
59
62
|
|
60
63
|
private
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Ing
|
2
|
+
module Commands
|
3
|
+
|
4
|
+
class Setup < Ing::Generator
|
5
|
+
|
6
|
+
desc "Set up a default ing.rb and tasks directory"
|
7
|
+
usage " ing setup"
|
8
|
+
|
9
|
+
def initial_options(given)
|
10
|
+
given[:dest] ||= Dir.pwd
|
11
|
+
given[:source] ||= File.dirname(__FILE__)
|
12
|
+
given
|
13
|
+
end
|
14
|
+
|
15
|
+
# note manual shell setup because `ing setup` is not routed through
|
16
|
+
# `ing implicit` (boot)
|
17
|
+
#
|
18
|
+
def call
|
19
|
+
setup_shell unless shell
|
20
|
+
in_root do
|
21
|
+
create_file 'ing.rb', <<_____
|
22
|
+
# Ing tasks
|
23
|
+
# Store your tasks in ./tasks and they will be available to `ing`.
|
24
|
+
# Or simply overwrite this file.
|
25
|
+
|
26
|
+
Dir[File.expand_path("tasks/**/*.rb", File.dirname(__FILE__))].each do |rb|
|
27
|
+
load rb
|
28
|
+
end
|
29
|
+
|
30
|
+
_____
|
31
|
+
empty_directory 'tasks'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def setup_shell
|
37
|
+
self.shell = Ing.shell_class.new
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Ing
|
2
|
+
|
3
|
+
# Use this module to define a default command to execute within a namespace.
|
4
|
+
# Convenience methods for a typical case.
|
5
|
+
#
|
6
|
+
# @Example:
|
7
|
+
#
|
8
|
+
# module Files
|
9
|
+
# extend Ing::DefaultCommand
|
10
|
+
# default_command :Export
|
11
|
+
#
|
12
|
+
# class Export
|
13
|
+
# ...
|
14
|
+
# end
|
15
|
+
# class Import
|
16
|
+
# ...
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# Then from the command line this:
|
22
|
+
#
|
23
|
+
# ing files [ARGS]
|
24
|
+
#
|
25
|
+
# is equivalent to
|
26
|
+
#
|
27
|
+
# ing files:export [ARGS]
|
28
|
+
#
|
29
|
+
# and
|
30
|
+
#
|
31
|
+
# ing list
|
32
|
+
#
|
33
|
+
# will display
|
34
|
+
#
|
35
|
+
# ing files # Default command: export
|
36
|
+
#
|
37
|
+
# PLEASE NOTE: extending your module with DefaultCommand will add state to
|
38
|
+
# your module: namely class instance variables @default_command and @shell,
|
39
|
+
# and also a default +specify_options+ method (which will be overriden by
|
40
|
+
# any you define on the underlying module).
|
41
|
+
#
|
42
|
+
module DefaultCommand
|
43
|
+
|
44
|
+
def default_command(name=nil)
|
45
|
+
@default_command = name if name
|
46
|
+
@default_command
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_accessor :shell
|
50
|
+
|
51
|
+
def specify_options(parser)
|
52
|
+
parser.text \
|
53
|
+
"Default command: #{Ing::Util.encode_class_names([default_command])}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def call(*args)
|
57
|
+
raise ArgumentError,
|
58
|
+
"No default command set for `#{self}`. Did you call `default_command :Default` ?" \
|
59
|
+
unless self.default_command
|
60
|
+
Ing.execute(self.const_get(default_command, false), *args) do |cmd|
|
61
|
+
cmd.shell = self.shell if cmd.respond_to?(:"shell=")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
data/lib/ing/generator.rb
CHANGED
data/lib/ing/task.rb
CHANGED
@@ -11,7 +11,8 @@ module Ing
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
|
14
|
-
|
14
|
+
attr_writer :inherited_options
|
15
|
+
def inherited_options; @inherited_options ||= {}; end
|
15
16
|
|
16
17
|
# On subclassing, deep copy the merge of current options into inherited
|
17
18
|
# options
|
@@ -112,8 +113,7 @@ module Ing
|
|
112
113
|
@options ||= {}
|
113
114
|
end
|
114
115
|
|
115
|
-
# Options merged into inherited options.
|
116
|
-
# +inherited+ hook (on subclassing), and should not be used otherwise.
|
116
|
+
# Options merged into inherited options.
|
117
117
|
def all_options
|
118
118
|
(inherited_options || {}).merge(options)
|
119
119
|
end
|
@@ -145,9 +145,11 @@ module Ing
|
|
145
145
|
#
|
146
146
|
def ask_unless_given(*opts)
|
147
147
|
opts.inject({}) do |memo, opt|
|
148
|
+
raise ArgumentError, "No option `#{opt}` for `#{self.class}`" \
|
149
|
+
unless self.class.all_options.has_key?(opt)
|
148
150
|
next memo if options[:"#{opt}_given"]
|
149
|
-
msg = self.class.
|
150
|
-
df = self.class.
|
151
|
+
msg = self.class.all_options[opt].desc + "?"
|
152
|
+
df = self.class.all_options[opt].default
|
151
153
|
memo[opt] = shell.ask(msg, :default => df)
|
152
154
|
memo
|
153
155
|
end
|
data/lib/ing/version.rb
CHANGED
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Ing::Commands::Help do
|
4
|
+
include TestHelpers
|
5
|
+
|
6
|
+
def capture_run(args)
|
7
|
+
capture(:stdout) { Ing.run args }
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset
|
11
|
+
Ing::Callstack.clear
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "no namespace, no args" do
|
15
|
+
|
16
|
+
subject { [ "help" ] }
|
17
|
+
before { reset }
|
18
|
+
|
19
|
+
it 'should display help on help' do
|
20
|
+
output = capture_run(subject)
|
21
|
+
assert_match(/Display help on specified command/i, output)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "no namespace, single arg with namespaced command" do
|
27
|
+
|
28
|
+
subject { [ "help", "helping:one" ] }
|
29
|
+
before { reset }
|
30
|
+
|
31
|
+
it 'should display help on task named in arg' do
|
32
|
+
output = capture_run(subject)
|
33
|
+
assert_match(/This is the help for helping:one/i, output)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "no namespace, single arg with non-namespaced command" do
|
38
|
+
|
39
|
+
subject { [ "help", "generate" ] }
|
40
|
+
before { reset }
|
41
|
+
|
42
|
+
it 'should display help on task named in arg within namespace ing:commands' do
|
43
|
+
output = capture_run(subject)
|
44
|
+
assert_match(/Run a generator task/i, output)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "namespace, no arg" do
|
49
|
+
|
50
|
+
subject { [ "help", "--namespace", "helping" ] }
|
51
|
+
before { reset }
|
52
|
+
|
53
|
+
it 'should display help on specified namespace' do
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "namespace, single arg with namespaced command" do
|
59
|
+
|
60
|
+
subject { [ "help", "--namespace", "helping", "sub:one" ] }
|
61
|
+
before { reset }
|
62
|
+
|
63
|
+
it 'should display help on task named in arg under specified namespace' do
|
64
|
+
output = capture_run(subject)
|
65
|
+
assert_match(/This is the help for helping:sub:one/i, output)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "namespace, single arg with non-namespaced command" do
|
70
|
+
|
71
|
+
subject { [ "help", "--namespace", "helping:sub", "one" ] }
|
72
|
+
before { reset }
|
73
|
+
|
74
|
+
it 'should display help on task named in arg under specified namespace' do
|
75
|
+
output = capture_run(subject)
|
76
|
+
assert_match(/This is the help for helping:sub:one/i, output)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Ing::Commands::List do
|
4
|
+
include TestHelpers
|
5
|
+
|
6
|
+
def capture_run(args)
|
7
|
+
capture(:stdout) { Ing.run args }
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset
|
11
|
+
Ing::Callstack.clear
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "namespace given, no args" do
|
15
|
+
|
16
|
+
subject { [ "list", "-n", "listing" ] }
|
17
|
+
before { reset }
|
18
|
+
|
19
|
+
it "should list all tasks that have a description within namespace" do
|
20
|
+
output = capture_run(subject)
|
21
|
+
assert_match(/ing listing:one\s/, output)
|
22
|
+
assert_match(/ing listing:two\s/, output)
|
23
|
+
assert_match(/ing listing:three\s/, output)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should list tasks within nested namespaces" do
|
27
|
+
output = capture_run(subject)
|
28
|
+
assert_match(/ing listing:sub\s/, output)
|
29
|
+
assert_match(/ing listing:sub:one\s/, output)
|
30
|
+
assert_match(/ing listing:sub:two\s/, output)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not list tasks that do not have a description" do
|
34
|
+
output = capture_run(subject)
|
35
|
+
refute_match(/ing listing:no_desc/, output)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "namespace given, no args, --all" do
|
41
|
+
|
42
|
+
subject { [ "list", "-n", "listing", "--all" ] }
|
43
|
+
before { reset }
|
44
|
+
|
45
|
+
it "should list tasks that do not have a description" do
|
46
|
+
output = capture_run(subject)
|
47
|
+
assert_match(/ing listing:no_desc:one\s/, output)
|
48
|
+
assert_match(/ing listing:no_desc:two\s/, output)
|
49
|
+
assert_match(/ing listing:no_desc:three\s/, output)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "namespace given, no args, --strict" do
|
55
|
+
|
56
|
+
subject { [ "list", "-n", "listing", "--strict" ] }
|
57
|
+
before { reset }
|
58
|
+
|
59
|
+
it "should list all tasks that have a description within namespace" do
|
60
|
+
output = capture_run(subject)
|
61
|
+
assert_match(/ing listing:one\s/, output)
|
62
|
+
assert_match(/ing listing:two\s/, output)
|
63
|
+
assert_match(/ing listing:three\s/, output)
|
64
|
+
assert_match(/ing listing:sub\s/, output)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should not list tasks within nested namespaces" do
|
68
|
+
output = capture_run(subject)
|
69
|
+
refute_match(/ing listing:sub:one\s/, output)
|
70
|
+
refute_match(/ing listing:sub:two\s/, output)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should not list tasks that do not have a description" do
|
74
|
+
output = capture_run(subject)
|
75
|
+
refute_match(/ing listing:no_desc/, output)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "namespace given with search arg" do
|
81
|
+
|
82
|
+
subject { [ "list", "-n", "listing", "one" ] }
|
83
|
+
before { reset }
|
84
|
+
|
85
|
+
it "should list all tasks within namespace that include search text and that have a description" do
|
86
|
+
output = capture_run(subject)
|
87
|
+
assert_match(/ing listing:one\s/, output)
|
88
|
+
assert_match(/ing listing:none\s/, output)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should list matching tasks in nested namespaces" do
|
92
|
+
output = capture_run(subject)
|
93
|
+
assert_match(/ing listing:sub:one\s/, output)
|
94
|
+
assert_match(/ing listing:sub:none\s/, output)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not list tasks that do not have a description" do
|
98
|
+
output = capture_run(subject)
|
99
|
+
refute_match(/ing listing:no_desc/, output)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "namespace given with search arg, --all" do
|
105
|
+
|
106
|
+
subject { [ "list", "-n", "listing", "--all", "one" ] }
|
107
|
+
before { reset }
|
108
|
+
|
109
|
+
it "should list tasks that do not have a description" do
|
110
|
+
output = capture_run(subject)
|
111
|
+
assert_match(/ing listing:no_desc:one\s/, output)
|
112
|
+
assert_match(/ing listing:no_desc:none\s/, output)
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "namespace given with search arg, --strict" do
|
118
|
+
|
119
|
+
subject { [ "list", "-n", "listing", "--strict", "one" ] }
|
120
|
+
before { reset }
|
121
|
+
|
122
|
+
it "should list all tasks that have a description within namespace" do
|
123
|
+
output = capture_run(subject)
|
124
|
+
assert_match(/ing listing:one\s/, output)
|
125
|
+
assert_match(/ing listing:none\s/, output)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should not list tasks within nested namespaces" do
|
129
|
+
output = capture_run(subject)
|
130
|
+
refute_match(/ing listing:sub:one\s/, output)
|
131
|
+
refute_match(/ing listing:sub:none\s/, output)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should not list tasks that do not have a description" do
|
135
|
+
output = capture_run(subject)
|
136
|
+
refute_match(/ing listing:no_desc/, output)
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Helping
|
2
|
+
|
3
|
+
def self.specify_options(p)
|
4
|
+
p.text "This is the help for helping"
|
5
|
+
end
|
6
|
+
|
7
|
+
class One
|
8
|
+
def self.specify_options(p)
|
9
|
+
p.text "This is the help for helping:one"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Sub
|
14
|
+
|
15
|
+
class One
|
16
|
+
def self.specify_options(p)
|
17
|
+
p.text "This is the help for helping:sub:one"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
|
2
|
+
module Listing
|
3
|
+
|
4
|
+
class One < Ing::Task
|
5
|
+
|
6
|
+
desc "A sample task implemented as Ing::Task"
|
7
|
+
|
8
|
+
def call(*args); end
|
9
|
+
end
|
10
|
+
|
11
|
+
class None < Ing::Task
|
12
|
+
desc "Sample task that should come up in searches for 'one'"
|
13
|
+
def call(*args); end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Two
|
17
|
+
|
18
|
+
def self.specify_options(p)
|
19
|
+
p.text "A sample task implemented as plain ruby"
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :shell
|
23
|
+
def initialize(options); end
|
24
|
+
def call(*args); end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
Three = Proc.new {|*args| }
|
29
|
+
def Three.specify_options(p)
|
30
|
+
p.text "A sample task implemented as a Proc"
|
31
|
+
end
|
32
|
+
|
33
|
+
module Sub
|
34
|
+
|
35
|
+
def self.specify_options(p)
|
36
|
+
p.text "A sample task implemented as a callable module"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.call(*args); end
|
40
|
+
|
41
|
+
class One < Ing::Task
|
42
|
+
desc "Task listing:sub:one"
|
43
|
+
def call(*args); end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Two < Ing::Task
|
47
|
+
desc "Task listing:sub:two"
|
48
|
+
def call(*args); end
|
49
|
+
end
|
50
|
+
|
51
|
+
class None < Ing::Task
|
52
|
+
desc "Task listing:sub:none should come up in searches for 'one'"
|
53
|
+
def call(*args); end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
module NoDesc
|
59
|
+
|
60
|
+
class One
|
61
|
+
end
|
62
|
+
|
63
|
+
module Two
|
64
|
+
end
|
65
|
+
|
66
|
+
Three = Proc.new {}
|
67
|
+
|
68
|
+
class None
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -11,6 +11,8 @@ ARGV.clear
|
|
11
11
|
load File.join(File.dirname(__FILE__), "fixtures", "task.ing.rb")
|
12
12
|
load File.join(File.dirname(__FILE__), "fixtures", "group.ing.rb")
|
13
13
|
load File.join(File.dirname(__FILE__), "fixtures", "invok.ing.rb")
|
14
|
+
load File.join(File.dirname(__FILE__), "fixtures", "list.ing.rb")
|
15
|
+
load File.join(File.dirname(__FILE__), "fixtures", "help.ing.rb")
|
14
16
|
|
15
17
|
module TestHelpers
|
16
18
|
|
data/todo.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Ing todo
|
2
2
|
---
|
3
|
-
- add
|
3
|
+
- add RCov to look for other corners that need tests
|
4
4
|
- add Shell::Color
|
5
5
|
- remove global Ing.shell_class, specify via color switch
|
6
6
|
- incorporate gsub_file patch, patches to Shell
|
7
7
|
- rewrite README centered on simplest usages and move the rest to MORE pages
|
8
|
-
- nicer error handling for bad input
|
8
|
+
- nicer error handling for bad input that shows Ing callstack as well as ruby callstack
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &6113820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *6113820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: fakeweb
|
27
|
-
requirement: &
|
27
|
+
requirement: &6113260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *6113260
|
36
36
|
description: ! "\nAn alternative to Rake and Thor, Ing has a command-line syntax similar
|
37
37
|
to \nThor's, and it incorporates Thor's (Rails') generator methods and shell \nconventions.
|
38
38
|
But unlike Thor or Rake, it does not define its own DSL. Your tasks\ncorrespond
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- README.md
|
53
53
|
- TASKS.md
|
54
54
|
- bin/ing
|
55
|
+
- examples/publish_ssh.rb
|
55
56
|
- examples/rake_pipeline.rb
|
56
57
|
- examples/rspec_convert.rb
|
57
58
|
- ing.gemspec
|
@@ -69,7 +70,9 @@ files:
|
|
69
70
|
- lib/ing/commands/help.rb
|
70
71
|
- lib/ing/commands/implicit.rb
|
71
72
|
- lib/ing/commands/list.rb
|
73
|
+
- lib/ing/commands/setup.rb
|
72
74
|
- lib/ing/common_options.rb
|
75
|
+
- lib/ing/default_command.rb
|
73
76
|
- lib/ing/files.rb
|
74
77
|
- lib/ing/generator.rb
|
75
78
|
- lib/ing/lib_trollop.rb
|
@@ -81,6 +84,8 @@ files:
|
|
81
84
|
- lib/ing/version.rb
|
82
85
|
- lib/thor/actions/file_manipulation.rb
|
83
86
|
- lib/thor/shell/basic.rb
|
87
|
+
- test/acceptance/ing_help_tests.rb
|
88
|
+
- test/acceptance/ing_list_tests.rb
|
84
89
|
- test/acceptance/ing_run_tests.rb
|
85
90
|
- test/acceptance/ing_task_tests.rb
|
86
91
|
- test/actions/create_file_spec.rb
|
@@ -101,7 +106,9 @@ files:
|
|
101
106
|
- test/fixtures/doc/config.rb
|
102
107
|
- test/fixtures/doc/config.yaml.tt
|
103
108
|
- test/fixtures/group.ing.rb
|
109
|
+
- test/fixtures/help.ing.rb
|
104
110
|
- test/fixtures/invok.ing.rb
|
111
|
+
- test/fixtures/list.ing.rb
|
105
112
|
- test/fixtures/namespace.ing.rb
|
106
113
|
- test/fixtures/require.ing.rb
|
107
114
|
- test/fixtures/task.ing.rb
|
@@ -138,6 +145,8 @@ signing_key:
|
|
138
145
|
specification_version: 3
|
139
146
|
summary: Vanilla ruby command-line scripting
|
140
147
|
test_files:
|
148
|
+
- test/acceptance/ing_help_tests.rb
|
149
|
+
- test/acceptance/ing_list_tests.rb
|
141
150
|
- test/acceptance/ing_run_tests.rb
|
142
151
|
- test/acceptance/ing_task_tests.rb
|
143
152
|
- test/actions/create_file_spec.rb
|
@@ -158,7 +167,9 @@ test_files:
|
|
158
167
|
- test/fixtures/doc/config.rb
|
159
168
|
- test/fixtures/doc/config.yaml.tt
|
160
169
|
- test/fixtures/group.ing.rb
|
170
|
+
- test/fixtures/help.ing.rb
|
161
171
|
- test/fixtures/invok.ing.rb
|
172
|
+
- test/fixtures/list.ing.rb
|
162
173
|
- test/fixtures/namespace.ing.rb
|
163
174
|
- test/fixtures/require.ing.rb
|
164
175
|
- test/fixtures/task.ing.rb
|