Module: EverydayThorUtil::Builder
- Includes:
- Common
- Defined in:
- lib/everyday_thor_util/builder.rb
Instance Method Summary collapse
- #build! ⇒ Object
- #command(options = {}, &block) ⇒ Object
- #create_cmd_class_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) ⇒ Object
- #create_cmd_method_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) ⇒ Object
- #flag(opts = {}) ⇒ Object
- #global ⇒ Object
- #root_command ⇒ Object
Methods included from Common
Instance Method Details
#build! ⇒ Object
194 195 196 197 198 |
# File 'lib/everyday_thor_util/builder.rb', line 194 def build! rc = Class.new(Thor) build_recurse(self.root_command, rc) rc end |
#command(options = {}, &block) ⇒ Object
190 191 192 |
# File 'lib/everyday_thor_util/builder.rb', line 190 def command( = {}, &block) EverydayThorUtil::BuilderBuildItems::BuilderCommand.new(nil, , &block) end |
#create_cmd_class_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) ⇒ Object
237 238 239 240 241 |
# File 'lib/everyday_thor_util/builder.rb', line 237 def create_cmd_class_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) create_command_class(c, pc, cn, desc, long_desc, short_desc) aliases.each { |an| create_command_class(c, pc, an, desc, long_desc, short_desc.gsub(/^\S+(?=\s|$)/, an.gsub(/_/, '-'))) } if aliases && !aliases.empty? true end |
#create_cmd_method_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) ⇒ Object
243 244 245 246 247 248 249 250 251 |
# File 'lib/everyday_thor_util/builder.rb', line 243 def create_cmd_method_and_aliases(c, pc, cn, aliases, desc, long_desc, short_desc) setup_command(c, pc, desc, long_desc, short_desc) pc.create_method(cn.to_sym, &c.body) aliases.each { |an| setup_command(c, pc, desc, long_desc, short_desc.gsub(/^\S+(?=\s|$)/, an.gsub(/_/, '-'))) pc.dup_method an.to_sym, cn.to_sym } if aliases true end |
#flag(opts = {}) ⇒ Object
186 187 188 |
# File 'lib/everyday_thor_util/builder.rb', line 186 def flag(opts = {}) opts end |
#global ⇒ Object
178 179 180 |
# File 'lib/everyday_thor_util/builder.rb', line 178 def global @global ||= EverydayThorUtil::BuilderBuildItems::BuilderGlobal.new end |
#root_command ⇒ Object
182 183 184 |
# File 'lib/everyday_thor_util/builder.rb', line 182 def root_command @root_command ||= EverydayThorUtil::BuilderBuildItems::BuilderCommand.new end |