Parent

Bones::App::Command

Attributes

stdout[R]
stderr[R]
config[R]

Public Class Methods

inherited( other ) click to toggle source
     # File lib/bones/app/command.rb, line 202
202:   def self.inherited( other )
203:     other.extend ClassMethods
204:   end
new( opts = {} ) click to toggle source
    # File lib/bones/app/command.rb, line 12
12:   def initialize( opts = {} )
13:     @stdout = opts[:stdout] || $stdout
14:     @stderr = opts[:stderr] || $stderr
15: 
16:     @config = {
17:       :skeleton_dir => File.join(mrbones_dir, DEFAULT_SKELETON),
18:       :verbose => false,
19:       :name => nil,
20:       :output_dir => nil
21:     }
22:     @config[:skeleton_dir] = ::Bones.path(DEFAULT_SKELETON) unless test(dd, skeleton_dir)
23:   end
standard_options() click to toggle source
     # File lib/bones/app/command.rb, line 134
134:   def self.standard_options
135:     @standard_options ||= {
136:       :verbose => ['-v', '--verbose', 'Enable verbose output.',
137:           lambda { config[:verbose] = true }],
138: 
139:       :directory => ['-d', '--directory DIRECTORY', String,
140:           'Project directory to create.',  '(defaults to project_name)',
141:           lambda { |value| config[:output_dir] = value }],
142: 
143:       :skeleton => ['-s', '--skeleton NAME', String,
144:           'Project skeleton to use.',
145:           lambda { |value|
146:             path = File.join(mrbones_dir, value)
147:             if test(ee, value)
148:               config[:skeleton_dir] = value
149:             elsif test(ee, path)
150:               config[:skeleton_dir] = path
151:             else
152:               raise ArgumentError, "Unknown skeleton '#{value}'."
153:             end
154:           }],
155: 
156:       :repository => ['-r', '--repository URL', String,
157:           'svn or git repository path.',
158:           lambda { |value| config[:repository] = value }]
159:     }
160:   end

Public Instance Methods

in_directory( dir ) click to toggle source

Run a block of code in the given directory.

    # File lib/bones/app/command.rb, line 72
72:   def in_directory( dir )
73:     pwd = File.expand_path(FileUtils.pwd)
74:     FileUtils.cd dir
75:     yield
76:   ensure
77:     FileUtils.cd pwd
78:   end
mrbones_dir() click to toggle source

Returns the ’.mrbones’ resource directory in the user’s home directory.

    # File lib/bones/app/command.rb, line 63
63:   def mrbones_dir
64:     return @mrbones_dir if defined? @mrbones_dir
65: 
66:     path = File.join(::Bones::HOME, '.mrbones')
67:     @mrbones_dir = File.expand_path(path)
68:   end
name() click to toggle source

The project name from the command line.

    # File lib/bones/app/command.rb, line 43
43:   def name
44:     @config[:name]
45:   end
output_dir() click to toggle source

The output directory where files will be written.

    # File lib/bones/app/command.rb, line 31
31:   def output_dir
32:     @config[:output_dir]
33:   end
parse( args ) click to toggle source
     # File lib/bones/app/command.rb, line 88
 88:   def parse( args )
 89:     opts = OptionParser.new
 90: 
 91:     opts.banner = 'NAME'
 92:     opts.separator "  bones v#{::Bones.version}"
 93:     opts.separator ''
 94: 
 95:     if self.class.synopsis
 96:       opts.separator 'SYNOPSIS'
 97:       self.class.synopsis.split("\n").each { |line| opts.separator "  #{line.strip}" }
 98:       opts.separator ''
 99:     end
100: 
101:     if self.class.description
102:       opts.separator 'DESCRIPTION'
103:       self.class.description.split("\n").each { |line| opts.separator "  #{line.strip}" }
104:       opts.separator ''
105:     end
106: 
107:     if self.class.options and not self.class.options.empty?
108:       opts.separator 'PARAMETERS'
109:       self.class.options.each { |option|
110:         case option
111:         when Array
112:           option << method(option.pop) if option.last =~ /^__/
113:           opts.on(*option)
114:         when String
115:           opts.separator("  #{option.strip}")
116:         else opts.separator('') end
117:       }
118:       opts.separator ''
119:     end
120: 
121:     opts.separator '  Common Options:'
122:     opts.on_tail( '-h', '--help', 'show this message' ) {
123:       stdout.puts opts
124:       exit
125:     }
126:     opts.on_tail ''
127: 
128:     opts.parse! args
129:     return opts
130:   end
repository() click to toggle source

A git or svn repository URL from the command line.

    # File lib/bones/app/command.rb, line 49
49:   def repository
50:     return @config[:repository] if @config.has_key? :repository
51:     return IO.read(skeleton_dir).strip if skeleton_dir and test(ff, skeleton_dir)
52:     nil
53:   end
run( args ) click to toggle source
    # File lib/bones/app/command.rb, line 25
25:   def run( args )
26:     raise NotImplementedError
27:   end
skeleton_dir() click to toggle source

The directory where the project skeleton is located.

    # File lib/bones/app/command.rb, line 37
37:   def skeleton_dir
38:     @config[:skeleton_dir]
39:   end
standard_options() click to toggle source
    # File lib/bones/app/command.rb, line 82
82:   def standard_options
83:     Command.standard_options
84:   end
verbose?() click to toggle source

Returns true if the user has requested verbose messages.

    # File lib/bones/app/command.rb, line 57
57:   def verbose?
58:     @config[:verbose]
59:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.