diff options
author | Dickson S. Guedes | 2011-05-12 03:48:06 +0000 |
---|---|---|
committer | Dickson S. Guedes | 2011-05-12 03:48:06 +0000 |
commit | c90859f8785884130fbe8c921dbe25a16df08d1c (patch) | |
tree | 0382a8d807586b0ca990c50917f469a49d3846e6 | |
parent | bc8c46378f88ee3a5cb232251127835b49f5e795 (diff) |
refactoring options names
now options follow the respective names in META based on SPEC.
-rw-r--r-- | lib/pgxn_utils/cli.rb | 29 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/%extension_name%.control.tt | 2 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/META.json.tt | 18 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt | 4 | ||||
-rw-r--r-- | lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt | 2 | ||||
-rw-r--r-- | spec/cli_spec.rb | 12 |
6 files changed, 37 insertions, 30 deletions
diff --git a/lib/pgxn_utils/cli.rb b/lib/pgxn_utils/cli.rb index c6e53f4..944c4dd 100644 --- a/lib/pgxn_utils/cli.rb +++ b/lib/pgxn_utils/cli.rb @@ -1,17 +1,26 @@ module PgxnUtils class CLI < Thor - attr_accessor :extension_name, :target, :author_name, :author_mail - attr_accessor :short_description, :long_description, :tags + attr_accessor :extension_name, :target, :maintainer, :maintainer_mail + attr_accessor :abstract, :description, :tags include Thor::Actions desc "skeleton extension_name", "Creates an extension skeleton in current directory." + method_option :target, :aliases => "-p", :default => "." - method_option :author_name, :aliases => "-n", :type => :string, :default => "Your Name Here" - method_option :author_mail, :aliases => "-m", :type => :string, :default => "[email protected]" + + # META required fields + method_option :maintainer, :aliases => "-m", :type => :string, :default => "The maintainer's name" + method_option :maintainer_mail, :aliases => "-e", :type => :string, :default => "[email protected]" + method_option :abstract, :aliases => "-a", :type => :string, :default => "A short description" + method_option :license, :aliases => "-l", :type => :string, :default => "postgresql" + method_option :version, :aliases => "-v", :type => :string, :default => "0.0.1" + + # META optional fields + method_option :description, :aliases => "-d", :type => :string, :default => "A long description" + method_option :generated_by, :aliases => "-b", :type => :string, :default => "Generator's name" method_option :tags, :aliases => "-t", :type => :array - method_option :short_description, :aliases => "-s", :type => :string, :default => "A short description" - method_option :long_description, :aliases => "-l", :type => :string , :default => "A long description" + method_option :release_status, :aliases => "-r", :type => :string, :default => "unstable" def skeleton(extension_name) self.set_accessors extension_name @@ -24,11 +33,11 @@ module PgxnUtils self.extension_name = extension_name self.target = options[:target] - self.author_name = options[:author_name] - self.author_mail = options[:author_mail] + self.maintainer = options[:maintainer] + self.maintainer_mail = options[:maintainer_mail] self.tags = options[:tags] - self.short_description = options[:short_description] - self.long_description = options[:long_description] + self.abstract = options[:abstract] + self.description = options[:description] self.destination_root = target end diff --git a/lib/pgxn_utils/templates/root/%extension_name%.control.tt b/lib/pgxn_utils/templates/root/%extension_name%.control.tt index 3430846..395dc27 100644 --- a/lib/pgxn_utils/templates/root/%extension_name%.control.tt +++ b/lib/pgxn_utils/templates/root/%extension_name%.control.tt @@ -1,5 +1,5 @@ # <%= extension_name %> extension -comment = '<%= short_description %>' +comment = '<%= abstract %>' default_version = '1.0.0' module_pathname = '/<%= extension_name %>' relocatable = true diff --git a/lib/pgxn_utils/templates/root/META.json.tt b/lib/pgxn_utils/templates/root/META.json.tt index dad6da4..cc21246 100644 --- a/lib/pgxn_utils/templates/root/META.json.tt +++ b/lib/pgxn_utils/templates/root/META.json.tt @@ -1,26 +1,24 @@ { "name": "<%= extension_name %>", - "abstract": "<%= short_description %>", - "description": "<%= long_description %>", + "abstract": "<%= abstract %>", + "description": "<%= description %>", "version": "1.0.0", - "maintainer": [ - "<%= author_name %> <<%= author_mail %>>" - ], + "maintainer": "<%= maintainer %> <<%= maintainer_mail %>>", "license": "postgresql", "provides": { "<%= extension_name %>": { - "abstract": "<%= short_description %>", + "abstract": "<%= abstract %>", "file": "sql/<%= extension_name %>.sql", "docfile": "doc/<%= extension_name %>.md", "version": "1.0.0" } }, - "generated_by": "<%= author_name %>", + "generated_by": "<%= maintainer %>", + <% if tags %> + "tags": [ <%= tags.collect { |t| %Q|"#{t}"| }.join(",") %> ], + <% end %> "meta-spec": { "version": "1.0.0", "url": "http://pgxn.org/meta/spec.txt" } - <% unless tags.nil? || tags.empty? %> - , "tags": [ <%= tags.collect { |t| %Q|"#{t}"| }.join(",") %> ] - <% end %> } diff --git a/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt b/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt index 559137e..aaef9a4 100644 --- a/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt +++ b/lib/pgxn_utils/templates/root/doc/%extension_name%.md.tt @@ -1,4 +1,4 @@ <%= extension_name %> -<%= extension_name.gsub(/./,"-") %> +<%= extension_name.gsub(/./,"=") %> -<%= long_description %> +<%= description %> diff --git a/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt b/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt index 9e2c72a..b2ebdaf 100644 --- a/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt +++ b/lib/pgxn_utils/templates/root/sql/%extension_name%.sql.tt @@ -1,5 +1,5 @@ /* - * Author: <%= author_name %> <<%= author_mail %>> + * Author: <%= maintainer %> <<%= maintainer_mail %>> * Created at: <%= Time.now %> * */ diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 1d727e6..a77de03 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -28,21 +28,21 @@ describe PgxnUtils::CLI do expected_extension = next_extension expected_name = "Guedes" expected_mail = "[email protected]" - expected_short_description = "Short description" - expected_long_description = "Very Long description for my cool extension" + expected_abstract = "Short description" + expected_description = "Very Long description for my cool extension" expected_tags = "one two tree" - skeleton expected_extension, "-p /tmp -n #{expected_name} -m #{expected_mail} -t #{expected_tags} -s '#{expected_short_description}' -l '#{expected_long_description}'" + skeleton expected_extension, "-p /tmp -m #{expected_name} -e #{expected_mail} -t #{expected_tags} -a '#{expected_abstract}' -d '#{expected_description}'" meta = File.read("/tmp/#{expected_extension}/META.json") meta.should match(/"name": "#{expected_extension}"/) - meta.should match(/"abstract": "#{expected_short_description}"/) - meta.should match(/"description": "#{expected_long_description}"/) + meta.should match(/"abstract": "#{expected_abstract}"/) + meta.should match(/"description": "#{expected_description}"/) meta.should match(/"#{expected_name} <#{expected_mail}>"/) meta.should match(/"file": "sql\/#{expected_extension}.sql"/) meta.should match(/"docfile": "doc\/#{expected_extension}.md"/) meta.should match(/"generated_by": "#{expected_name}"/) - meta.should match(/, "tags": \[ "one","two","tree" \]/) + meta.should match(/"tags": \[ "one","two","tree" \],/) makefile = File.read("/tmp/#{expected_extension}/Makefile") makefile.should match(/EXTENSION = #{expected_extension}/) |