Permalink
Browse files

added --template to skeleton, #18

  • Loading branch information...
1 parent 91ae5ef commit e1d2ae7a3eacfb8c3dfb7a240698fc90d30bdb0a @guedes guedes committed Oct 14, 2011
Showing with 8 additions and 3 deletions.
  1. +2 −1 lib/pgxn_utils/cli.rb
  2. +6 −2 spec/cli_spec.rb
View
@@ -24,6 +24,7 @@ class CLI < Thor
method_option :tags, :aliases => "-t", :type => :array, :desc => "Defines extension's tags"
method_option :release_status, :aliases => "-r", :type => :string, :desc => "Initial extension's release status"
method_option :git, :type => :boolean, :default => false, :desc => "Initialize a git repository after create the extension"
+ method_option :template, :type => :string, :default => "sql", :desc => "The template that will be used to create the extension. Expected values are: sql, c, fdw"
def skeleton(extension_name,target=nil)
self.target = options[:target] || target || "."
@@ -36,7 +37,7 @@ def skeleton(extension_name,target=nil)
say "Can't create an extension overwriting an existing directory.", :red
else
self.set_accessors extension_name
- directory "root", extension_name
+ directory options[:template], extension_name
init_repository("#{self.target}/#{extension_name}") if options[:git]
end
View
@@ -63,12 +63,13 @@
control.should match(/default_version = '#{expected_version}'/)
end
- it "should generates a skeleton" do
+ it "should generates a default skeleton" do
extension = next_extension
skeleton extension
- Dir["#{extension}/**/{*,.gitignore}"].sort.should == [
+ Dir["#{extension}/**/{*,.gitignore,.template}"].sort.should == [
"#{extension}/.gitignore",
+ "#{extension}/.template",
"#{extension}/META.json",
"#{extension}/Makefile",
"#{extension}/README.md",
@@ -84,6 +85,9 @@
"#{extension}/test/sql/base.sql",
"#{extension}/#{extension}.control"
].sort
+
+ template = File.read("#{extension}/.template").chomp
+ template.should == "sql"
end
it "should generates a git repo with --git" do

0 comments on commit e1d2ae7

Please sign in to comment.