Using 'say' instead raising and fixing some code issue_9
authorDickson S. Guedes <[email protected]>
Fri, 24 Jun 2011 22:01:46 +0000 (19:01 -0300)
committerDickson S. Guedes <[email protected]>
Fri, 24 Jun 2011 22:01:46 +0000 (19:01 -0300)
README.md
Rakefile
lib/pgxn_utils/cli.rb

index 3f0c4014e6b22f0827a0acb33b51d005227a8db9..bfb2f33c28a5675a065fac676a590c960e77a22d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -109,14 +109,16 @@ For all switches that you can use with *change*, type:
 
 Well, since you finished your work you can bundle it to send to [PGXN](http://pgxn.org).
 
-Just type:
+Bundle it:
 
     $ pgxn_utils bundle my_cool_extension
     Extension generated at: /home/guedes/extensions/my_cool_extension-0.0.1.zip
 
-    $ ../pgxn-utils/bin/pgxn_utils release overpaid-0.0.6b3.zip 
+and release it:
+
+    $ pgxn_utils release my_cool_extension-0.0.1.zip
     Enter your PGXN username: guedes
-    Enter your PGXN password: **************
+    Enter your PGXN password: ******
     Trying to release my_cool_extension-0.0.1.zip ... released successfully!
     Visit: http://manager.pgxn.org/distributions/my_cool_extension/0.0.1
 
index 39881c0b96b635fa485199fa11ba514eb8d2ab3c..31d0bccaf3d2c477541eb4fa3266e3d7e8682178 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,16 +1,14 @@
 require 'bundler'
-include Rake::DSL
+#include Rake::DSL
 Bundler::GemHelper.install_tasks
 require 'rspec/core/rake_task'
 
 desc "Run RSpec"
 RSpec::Core::RakeTask.new do |t|
   t.verbose = false
-  #t.rspec_opts = %w(-fs --color)
   t.rspec_opts = %w(--color)
-  #dont show warnings here yet
-  #t.ruby_opts  = %w(-w)
 end
+
 desc "CTag Files"
 task :ctag do
   #system("ctags -R --exclude=.git --exclude=log * ~/.rvm/gems/")
index 7ab8b3e34029dcaf62a0ac5557f6c91129576b49..58061d4524dcf003d0b38b9d016c87c3b7dcd5e3 100644 (file)
@@ -14,7 +14,6 @@ module PgxnUtils
 
     # META required fields
     method_option :maintainer,        :aliases => "-m", :type => :string, :desc => "Maintainer's name <maintainer@email>"
-    #method_option :maintainer_mail,   :aliases => "-e", :type => :string, :desc => "Maintainer's mail"
     method_option :abstract,          :aliases => "-a", :type => :string, :desc => "Defines a short description to abstract"
     method_option :license,           :aliases => "-l", :type => :string, :desc => "The extension license."
     method_option :version,           :aliases => "-v", :type => :string, :desc => "Initial version"
@@ -29,11 +28,11 @@ module PgxnUtils
       self.target = options[:target] || target || "."
 
       if is_extension?("#{self.target}/#{extension_name}")
-        raise ArgumentError, "'#{extension_name}' already exists. Please, use 'change' instead 'skeleton'."
+        say "'#{extension_name}' already exists. Please, use 'change' instead 'skeleton'.", :red
       elsif is_extension?(".")
-        raise ArgumentError, "You are inside a extension directory, already. Consider use 'change' instead."
+        say "You are inside a extension directory, already. Consider use 'change' instead.", :red
       elsif is_dir?("#{self.target}/#{extension_name}")
-        raise ArgumentError, "Can't create an extension overwriting an existing directory."
+        say "Can't create an extension overwriting an existing directory.", :red
       else
         self.set_accessors extension_name
 
@@ -47,7 +46,6 @@ module PgxnUtils
 
     # META required fields
     method_option :maintainer,        :aliases => "-m", :type => :string, :desc => "Maintainer's name <maintainer@email>"
-    #method_option :maintainer_mail,   :aliases => "-e", :type => :string, :desc => "Maintainer's mail"
     method_option :abstract,          :aliases => "-a", :type => :string, :desc => "Defines a short description to abstract"
     method_option :license,           :aliases => "-l", :type => :string, :desc => "The extension license."
     method_option :version,           :aliases => "-v", :type => :string, :desc => "Initial version"
@@ -70,7 +68,7 @@ module PgxnUtils
         template "root/META.json.tt", "#{extension_path}/META.json"
         template "root/%extension_name%.control.tt", "#{extension_path}/%extension_name%.control"
       else
-        raise ArgumentError, "'#{extension_name}' doesn't appears to be an extension. Please, supply the extension's name"
+        say "'#{extension_name}' doesn't appears to be an extension. Please, supply the extension's name", :red
       end
     end
 
@@ -78,7 +76,7 @@ module PgxnUtils
 
     def bundle(extension_name=".")
       unless is_extension?(extension_name)
-        raise ArgumentError, "'#{extension_name}' doesn't appears to be an extension. Please, supply the extension's name"
+        say "'#{extension_name}' doesn't appears to be an extension. Please, supply the extension's name", :red
       else
         path = File.expand_path(extension_name)
         extension_name = File.basename(path)
@@ -102,6 +100,7 @@ module PgxnUtils
     end
 
     desc "release filename", "Release a extension"
+
     def release(filename)
       send_file_to_pgxn(filename)
     end
@@ -120,7 +119,7 @@ module PgxnUtils
 
       def check_response(response)
         case response
-        when Net::HTTPUnauthorized then 
+        when Net::HTTPUnauthorized then
           say "oops!", :red
           say "It seems that you entered a wrong username or password.", :red
         when Net::HTTPConflict then
@@ -217,7 +216,6 @@ module PgxnUtils
         self.extension_name = extension_name
 
         self.maintainer      = options[:maintainer]      || config_options["maintainer"]      || "The maintainer's name"
-        #self.maintainer_mail = options[:maintainer_mail] || config_options["maintainer_mail"] || "[email protected]"
         self.abstract        = options[:abstract]        || config_options["abstract"]        || "A short description"
         self.license         = options[:license]         || config_options["license"]         || "postgresql"
         self.version         = options[:version]         || config_options["version"]         || "0.0.1"