delano-drydock 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +34 -29
- data/Rakefile +3 -6
- data/bin/example +17 -13
- data/drydock.gemspec +1 -1
- data/lib/drydock.rb +2 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -22,39 +22,44 @@ Or for GitHub fans:
|
|
22
22
|
|
23
23
|
See bin/example for more.
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
require 'drydock'
|
26
|
+
|
27
|
+
default :welcome
|
28
|
+
|
29
|
+
before do
|
30
|
+
# You can execute a block before the requests command is executed. Instance
|
31
|
+
# variables defined here will be available to all commands.
|
32
|
+
end
|
33
|
+
|
34
|
+
command :welcome do
|
35
|
+
# Example: ruby bin/example
|
36
|
+
|
37
|
+
puts "Welcome to Drydock. You have the following commands:"
|
38
|
+
|
39
|
+
# The commands method returns a hash of Drydock::Command objects
|
40
|
+
puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
|
41
|
+
end
|
42
|
+
|
43
|
+
usage "Example: #{$0} laugh [-f]"
|
44
|
+
option :f, :faster, "A boolean value. Go even faster!"
|
45
|
+
command :laugh do |obj|
|
46
|
+
# +obj+ is an instance of Drydock::Command. The options you define are available
|
47
|
+
# via accessors in this object.
|
34
48
|
|
35
|
-
|
36
|
-
# Example: ruby bin/example
|
49
|
+
answer = !obj.faster ? "Sort of" : "Yes! I'm literally laughing as fast as possible."
|
37
50
|
|
38
|
-
|
39
|
-
|
51
|
+
puts "Captain Stubing: Are you laughing?"
|
52
|
+
puts "Dr. Bricker: " << answer
|
53
|
+
end
|
40
54
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
option :f, :found, "A boolean value. Did you find the car?"
|
46
|
-
command :findcar do |options|
|
47
|
-
# +options+ is a hash containing the options defined above
|
48
|
-
# Example: ruby bin/example -f findcar
|
49
|
-
|
50
|
-
puts "Frylock: So, did they ever find your car?"
|
51
|
-
|
52
|
-
# The keys to the hash are the long string from the option definition.
|
53
|
-
# If only the short string is provided, those will be used instead (i.e. :f).
|
54
|
-
puts (!options[:found]) ? "Carl: No" :
|
55
|
-
"Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
|
56
|
-
end
|
55
|
+
class JohnWestSmokedOysters < Drydock::Command; end;
|
56
|
+
# You can write your own command classes by inheriting from Drydock::Command
|
57
|
+
# and referencing it in the command definition.
|
57
58
|
|
59
|
+
command :oysters => JohnWestSmokedOysters do |obj|
|
60
|
+
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
|
61
|
+
end
|
62
|
+
|
58
63
|
== More Information
|
59
64
|
|
60
65
|
http://www.youtube.com/watch?v=m_wFEB4Oxlo
|
data/Rakefile
CHANGED
@@ -16,13 +16,10 @@ end
|
|
16
16
|
|
17
17
|
# PACKAGE =============================================================
|
18
18
|
|
19
|
+
name = "drydock"
|
20
|
+
load "#{name}.gemspec"
|
19
21
|
|
20
|
-
|
21
|
-
load "drydock.gemspec"
|
22
|
-
|
23
|
-
version = Drydock::VERSION.to_s
|
24
|
-
|
25
|
-
Drydock.run = false
|
22
|
+
version = @spec.version
|
26
23
|
|
27
24
|
Rake::GemPackageTask.new(@spec) do |p|
|
28
25
|
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
data/bin/example
CHANGED
@@ -25,21 +25,17 @@ command :welcome do
|
|
25
25
|
puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
|
26
26
|
end
|
27
27
|
|
28
|
+
usage "Example: #{$0} laugh [-f]"
|
29
|
+
option :f, :faster, "A boolean value. Go even faster!"
|
30
|
+
command :laugh do |obj|
|
31
|
+
# +obj+ is an instance of Drydock::Command. The options you define are available
|
32
|
+
# via accessors in this object.
|
28
33
|
|
29
|
-
|
30
|
-
command :findcar do |obj|
|
31
|
-
# +obj+ is the Drylock::Command object instance. It contains accessors for all options.
|
32
|
-
# Example: ruby bin/example -f findcar
|
33
|
-
|
34
|
-
puts "Frylock: So, did they ever find your car?"
|
35
|
-
|
36
|
-
# The keys to the hash are the long string from the option definition.
|
37
|
-
# If only the short string is provided, those will be used instead (i.e. :f).
|
38
|
-
puts (!obj.found) ? "Carl: No" :
|
39
|
-
"Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
|
40
|
-
end
|
41
|
-
|
34
|
+
answer = !obj.faster ? "Sort of" : "Yes! I'm literally laughing as fast as possible."
|
42
35
|
|
36
|
+
puts "Captain Stubing: Are you laughing?"
|
37
|
+
puts "Dr. Bricker: " << answer
|
38
|
+
end
|
43
39
|
|
44
40
|
global_usage "USAGE: #{File.basename($0)} [global options] command [command options]"
|
45
41
|
global_option :s, :seconds, "Display values in seconds"
|
@@ -74,6 +70,14 @@ command :rogue do |obj, argv|
|
|
74
70
|
end
|
75
71
|
end
|
76
72
|
|
73
|
+
class JohnWestSmokedOysters < Drydock::Command; end;
|
74
|
+
# You can write your own command classes by inheriting from Drydock::Command
|
75
|
+
# and referencing it in the command definition.
|
76
|
+
|
77
|
+
command :oysters => JohnWestSmokedOysters do |obj|
|
78
|
+
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
|
79
|
+
end
|
80
|
+
|
77
81
|
option :c, :check, "Check response codes for each URI"
|
78
82
|
option :d, :delim, String, "Output delimiter"
|
79
83
|
option :t, :timeout, Float, "Timeout value for HTTP request" do |v|
|
data/drydock.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = %q{drydock}
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.2"
|
4
4
|
s.specification_version = 1 if s.respond_to? :specification_version=
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
|
data/lib/drydock.rb
CHANGED
@@ -113,6 +113,7 @@ module Drydock
|
|
113
113
|
@@debug = false
|
114
114
|
@@has_run = false
|
115
115
|
@@run = true
|
116
|
+
@@default_command = nil
|
116
117
|
|
117
118
|
public
|
118
119
|
# Enable or disable debug output.
|
@@ -305,7 +306,7 @@ module Drydock
|
|
305
306
|
def run!(argv=[], stdin=STDIN)
|
306
307
|
return if has_run?
|
307
308
|
@@has_run = true
|
308
|
-
raise NoCommandsDefined.new
|
309
|
+
raise NoCommandsDefined.new if commands.empty?
|
309
310
|
@@global_options, cmd_name, @@command_options, argv = process_arguments(argv)
|
310
311
|
|
311
312
|
cmd_name ||= default_command
|