Skip to content

Commit

Permalink
show plugin list if no arguments present closes #892
Browse files Browse the repository at this point in the history
  • Loading branch information
achiurizo committed Aug 7, 2012
1 parent dea27b6 commit 1aed4e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
24 changes: 15 additions & 9 deletions padrino-gen/lib/padrino-gen/generators/plugin.rb
Expand Up @@ -36,7 +36,21 @@ def self.banner; "padrino-gen plugin [plugin_identifier] [options]"; end
#
# @api private
def setup_plugin
if options[:list] # list method ran here
if options[:list] || plugin_file.nil? # list method ran here
list_plugins
else # executing the plugin instructions
if in_app_root?
self.behavior = :revoke if options[:destroy]
self.destination_root = options[:root]
execute_runner(:plugin, plugin_file)
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
end
end
end

no_tasks do
def list_plugins
plugins = {}
uri = URI.parse(PLUGIN_URL)
http = Net::HTTP.new(uri.host, uri.port)
Expand All @@ -49,14 +63,6 @@ def setup_plugin
end
say "Available plugins:", :green
say plugins.map { |plugin| " - #{plugin}" }.join("\n")
else # executing the plugin instructions
if in_app_root?
self.behavior = :revoke if options[:destroy]
self.destination_root = options[:root]
execute_runner(:plugin, plugin_file)
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
end
end
end
end # Plugins
Expand Down
14 changes: 14 additions & 0 deletions padrino-gen/test/test_plugin_generator.rb
Expand Up @@ -82,6 +82,20 @@ def teardown
end
end

context "with list option" do
should "return a list of available plugins with no parameter" do
plugin_gen = Padrino::Generators::Plugin.new([], [],{})
plugin_gen.expects(:list_plugins).returns(true).once
capture_io { plugin_gen.invoke_all }
end

should "return a list of available plugins with list option" do
plugin_gen = Padrino::Generators::Plugin.new(['some_plugin'], ["-l", "-r=#{@apptmp}/sample_project"],{})
plugin_gen.expects(:list_plugins).returns(true).once
capture_io { plugin_gen.invoke_all }
end
end

context "with git commands" do
should "generate a repository correctly" do
skip 'Change stubs here'
Expand Down

0 comments on commit 1aed4e4

Please sign in to comment.