delano-drydock 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES.txt CHANGED
@@ -5,6 +5,20 @@ DRYDOCK, CHANGES
5
5
  * Support putting descriptions into resource file (or __END__)
6
6
 
7
7
 
8
+ #### 0.6.3 (2009-05-10) #############################
9
+
10
+ * ADDED: show-commands now displays a note about which command is the default
11
+ * CHANGE: Moved mixins to lib/drydock/mixins (so other projects can require 'drydock/mixins')
12
+ * FIXED: Support for inline command aliases when specifying a class:
13
+ command [:name, :alias1, :alias2] => SomeClass
14
+
15
+
16
+ #### 0.6.2 (2009-05-07) #############################
17
+
18
+ * ADDED: drydock/console.rb to start a new wing in the drydock
19
+ * ADDED: mixins for String and Object (for Console)
20
+
21
+
8
22
  #### 0.6.1 (2009-05-03) #############################
9
23
 
10
24
  * FIXED: @@trawler raises an error in Ruby 1.8 if it's a Symbol
data/bin/example CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/ruby
2
2
 
3
3
  # Seafaring Drydock Examples
4
4
  #
@@ -102,7 +102,7 @@ module Example
102
102
  end
103
103
 
104
104
  about "My way of saying hello!"
105
- command :ahoy! => JohnWestSmokedOysters
105
+ command [:ahoy!, :hello!] => JohnWestSmokedOysters
106
106
  # If you don't provide a block, Drydock will call JohnWestSmokedOysters#ahoy!
107
107
 
108
108
 
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.6.2"
3
+ s.version = "0.6.3"
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
 
@@ -12,16 +12,17 @@
12
12
  # = MANIFEST =
13
13
  # git ls-files
14
14
  s.files = %w(
15
- CHANGES.txt
16
- LICENSE.txt
17
- README.rdoc
18
- Rakefile
19
- bin/example
20
- drydock.gemspec
21
- lib/drydock.rb
22
- lib/drydock/console.rb
23
- lib/mixins/object.rb
24
- lib/mixins/string.rb
15
+ CHANGES.txt
16
+ LICENSE.txt
17
+ README.rdoc
18
+ Rakefile
19
+ bin/example
20
+ drydock.gemspec
21
+ lib/drydock.rb
22
+ lib/drydock/console.rb
23
+ lib/drydock/mixins.rb
24
+ lib/drydock/mixins/object.rb
25
+ lib/drydock/mixins/string.rb
25
26
  )
26
27
 
27
28
  # s.add_dependency ''
File without changes
@@ -1,3 +1,4 @@
1
+
1
2
  class String
2
3
  @@print_with_attributes = true
3
4
  def String.disable_colour; @@print_with_attributes = false; end
@@ -63,4 +64,3 @@ class String
63
64
  alias :noansi :noatt
64
65
 
65
66
  end
66
-
@@ -0,0 +1,4 @@
1
+
2
+
3
+ require 'drydock/mixins/object'
4
+ require 'drydock/mixins/string'
data/lib/drydock.rb CHANGED
@@ -3,8 +3,7 @@ require 'ostruct'
3
3
  require 'stringio'
4
4
 
5
5
  require 'drydock/console'
6
- require 'mixins/string'
7
- require 'mixins/object'
6
+ require 'drydock/mixins'
8
7
 
9
8
  module Drydock
10
9
  class FancyArray < Array #:nodoc:
@@ -292,7 +291,8 @@ module Drydock
292
291
  if @global.verbose > 0
293
292
  puts # empty line
294
293
  cmd_names_sorted.each do |cmd|
295
- puts "%s %s" % [@executable, cmds[cmd][:pretty]]
294
+ puts "$ %s" % [@executable] if Drydock.default?(cmd)
295
+ puts "$ %s %s" % [@executable, cmds[cmd][:pretty]]
296
296
  puts "%10s: %s" % ["About", cmds[cmd][:desc]] if cmds[cmd][:desc]
297
297
  if cmds[cmd][:aliases]
298
298
  cmds[cmd][:aliases].sort!{ |a,b| a.size <=> b.size }
@@ -306,7 +306,8 @@ module Drydock
306
306
  aliases = cmds[cmd][:aliases] || []
307
307
  aliases.sort!{ |a,b| a.size <=> b.size }
308
308
  aliases = aliases.empty? ? '' : "(aliases: #{aliases.join(', ')})"
309
- puts " %-16s %s" % [cmds[cmd][:pretty], aliases]
309
+ pattern = Drydock.default?(cmd) ? "* %-16s %s" : " %-16s %s"
310
+ puts pattern % [cmds[cmd][:pretty], aliases]
310
311
  end
311
312
  end
312
313
  end
@@ -460,6 +461,12 @@ module Drydock
460
461
  @@default_command = (b) ? command(cmd || :default, &b).cmd : canonize(cmd)
461
462
  end
462
463
 
464
+ # Is +cmd+ the default command?
465
+ def default?(cmd)
466
+ return false if @@default_command.nil?
467
+ (@@default_command == canonize(cmd))
468
+ end
469
+
463
470
  # Define a block for processing STDIN before the command is called.
464
471
  # The command block receives the return value of this block as obj.stdin:
465
472
  #
@@ -588,11 +595,15 @@ module Drydock
588
595
  cmd = cmds.shift # Should we accept aliases here?
589
596
 
590
597
  if cmd.is_a? Hash
591
- raise "#{cmd.values.first} is not a subclass of Drydock::Command" unless cmd.values.first.ancestors.member?(Drydock::Command)
592
- c = cmd.values.first.new(cmd.keys.first, &b) # A custom class was specified
593
- # TODO: handle command [:task, :alias] => Class
594
- #elsif cmd.is_a? Array
595
- # p cmd
598
+ klass = cmd.values.first
599
+ names = cmd.keys.first
600
+ if names.is_a? Array
601
+ cmd, cmds = names.shift, [names].flatten.compact
602
+ else
603
+ cmd = names
604
+ end
605
+ raise "#{klass} is not a subclass of Drydock::Command" unless klass.ancestors.member?(Drydock::Command)
606
+ c = klass.new(cmd, &b) # A custom class was specified
596
607
  else
597
608
  c = Drydock::Command.new(cmd, &b)
598
609
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delano-drydock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -32,8 +32,9 @@ files:
32
32
  - drydock.gemspec
33
33
  - lib/drydock.rb
34
34
  - lib/drydock/console.rb
35
- - lib/mixins/object.rb
36
- - lib/mixins/string.rb
35
+ - lib/drydock/mixins.rb
36
+ - lib/drydock/mixins/object.rb
37
+ - lib/drydock/mixins/string.rb
37
38
  has_rdoc: true
38
39
  homepage: http://github.com/delano/drydock
39
40
  post_install_message: