Class: Coherent::Commands::Plugin
- Inherits:
-
Object
- Object
- Coherent::Commands::Plugin
- Defined in:
- lib/plugin/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.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
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.
7 8 9 10 11 12 |
# File 'lib/plugin/commands/plugin.rb', line 7 def initialize @environment = Coherent::Environment.default @root = Coherent::Environment.default.root @script_name = File.basename($0) @sources = [] end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
6 7 8 |
# File 'lib/plugin/commands/plugin.rb', line 6 def environment @environment end |
#script_name ⇒ Object (readonly)
Returns the value of attribute script_name.
6 7 8 |
# File 'lib/plugin/commands/plugin.rb', line 6 def script_name @script_name end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
6 7 8 |
# File 'lib/plugin/commands/plugin.rb', line 6 def sources @sources end |
Class Method Details
Instance Method Details
#options ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/plugin/commands/plugin.rb', line 19 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "Usage: #{@script_name} [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: #{@root}") { |root| @root = root; self.environment = Coherent::Environment.new(@root) } o.on("-s", "--source=URL1,URL2", Array, "Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources} 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 " discover Discover plugin repositories." o.separator " list List available plugins." o.separator " install Install plugin(s) from known repositories or URLs." o.separator " update Update installed plugins." o.separator " remove Uninstall plugins." o.separator " source Add a plugin source repository." o.separator " unsource Remove a plugin repository." o.separator " sources List currently configured plugin repositories." o.separator "" o.separator "EXAMPLES" o.separator " Install a plugin:" o.separator " #{@script_name} install continuous_builder\n" o.separator " Install a plugin from a subversion URL:" o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n" o.separator " Install a plugin from a git URL:" o.separator " #{@script_name} 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} install -x continuous_builder\n" o.separator " List all available plugins:" o.separator " #{@script_name} list\n" o.separator " List plugins in the specified repository:" o.separator " #{@script_name} list --source=http://dev.rubyonrails.com/svn/rails/plugins/\n" o.separator " Discover and prompt to add new repositories:" o.separator " #{@script_name} discover\n" o.separator " Discover new repositories but just list them, don't add anything:" o.separator " #{@script_name} discover -l\n" o.separator " Add a new repository to the source list:" o.separator " #{@script_name} source http://dev.rubyonrails.com/svn/rails/plugins/\n" o.separator " Remove a repository from the source list:" o.separator " #{@script_name} unsource http://dev.rubyonrails.com/svn/rails/plugins/\n" o.separator " Show currently configured repositories:" o.separator " #{@script_name} sources\n" end end |
#parse!(args = ARGV) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/plugin/commands/plugin.rb', line 76 def parse!(args=ARGV) general, sub = split_args(args) .parse!(general) command = general.shift if command =~ /^(list|discover|install|source|unsource|sources|remove|update|info)$/ command = Commands.const_get(command.capitalize).new(self) command.parse!(sub) else puts "Unknown command: #{command}" puts exit 1 end end |
#split_args(args) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/plugin/commands/plugin.rb', line 91 def split_args(args) left = [] left << args.shift while args[0] and args[0] =~ /^-/ left << args.shift if args[0] return [left, args] end |