Class: Rails::Commands::Plugin
- Defined in:
- railties/lib/rails/commands/plugin.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#script_name ⇒ Object
readonly
Returns the value of attribute script_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Plugin
constructor
A new instance of Plugin.
- #options ⇒ Object
- #parse!(args = ARGV) ⇒ Object
- #split_args(args) ⇒ Object
Constructor Details
#initialize ⇒ Plugin
Returns a new instance of Plugin.
281 282 283 284 285 |
# File 'railties/lib/rails/commands/plugin.rb', line 281 def initialize @environment = RailsEnvironment.default @rails_root = RailsEnvironment.default.root @script_name = File.basename($0) end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment
280 281 282 |
# File 'railties/lib/rails/commands/plugin.rb', line 280 def environment @environment end |
#script_name ⇒ Object (readonly)
Returns the value of attribute script_name
280 281 282 |
# File 'railties/lib/rails/commands/plugin.rb', line 280 def script_name @script_name end |
Class Method Details
Instance Method Details
#options ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'railties/lib/rails/commands/plugin.rb', line 292 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "Usage: plugin [OPTIONS] command" o.define_head "Rails plugin manager." o.separator "" o.separator "GENERAL OPTIONS" o.on("-r", "--root=DIR", String, "Set an explicit rails app directory.", "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) } o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose } o.on("-h", "--help", "Show this help message.") { puts o; exit } o.separator "" o.separator "COMMANDS" o.separator " install Install plugin(s) from known repositories or URLs." o.separator " remove Uninstall plugins." o.separator "" o.separator "EXAMPLES" o.separator " Install a plugin from a subversion URL:" o.separator " #{@script_name} plugin install http://example.com/my_svn_plugin\n" o.separator " Install a plugin from a git URL:" o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n" o.separator " Install a plugin and add a svn:externals entry to vendor/plugins" o.separator " #{@script_name} plugin install -x my_svn_plugin\n" end end |
#parse!(args = ARGV) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'railties/lib/rails/commands/plugin.rb', line 325 def parse!(args=ARGV) general, sub = split_args(args) .parse!(general) command = general.shift if command =~ /^(install|remove)$/ command = Commands.const_get(command.capitalize).new(self) command.parse!(sub) else puts "Unknown command: #{command}" unless command.blank? puts exit 1 end end |
#split_args(args) ⇒ Object
340 341 342 343 344 345 |
# File 'railties/lib/rails/commands/plugin.rb', line 340 def split_args(args) left = [] left << args.shift while args[0] and args[0] =~ /^-/ left << args.shift if args[0] [left, args] end |