lib/ggem/template.rb in ggem-1.9.5 vs lib/ggem/template.rb in ggem-1.10.0
- old
+ new
@@ -2,10 +2,11 @@
require "erb"
require "fileutils"
module GGem; end
+
class GGem::Template
def initialize(ggem)
@ggem = ggem
end
@@ -16,16 +17,19 @@
save_folder "test/system"
save_folder "test/unit"
save_folder "log"
save_folder "tmp"
+ save_file("l.yml.erb", ".l.yml")
+ save_file("t.yml.erb", ".t.yml")
+ save_file("rubocop.yml.erb", ".rubocop.yml")
save_file("ruby-version.erb", ".ruby-version")
- save_file("gitignore.erb", ".gitignore")
- save_file("Gemfile.erb", "Gemfile")
- save_file("gemspec.erb", "#{@ggem.name}.gemspec")
- save_file("README.md.erb", "README.md")
- save_file("LICENSE.erb", "LICENSE")
+ save_file("gitignore.erb", ".gitignore")
+ save_file("Gemfile.erb", "Gemfile")
+ save_file("gemspec.erb", "#{@ggem.name}.gemspec")
+ save_file("README.md.erb", "README.md")
+ save_file("LICENSE.erb", "LICENSE")
save_file("lib.rb.erb", "lib/#{@ggem.ruby_name}.rb")
save_file("lib_version.rb.erb", "lib/#{@ggem.ruby_name}/version.rb")
save_file("test_helper.rb.erb", "test/helper.rb")
@@ -37,11 +41,11 @@
save_empty_file("tmp/.keep")
end
private
- def save_folder(relative_path=nil)
+ def save_folder(relative_path = nil)
path = File.join([@ggem.path, relative_path].compact)
FileUtils.mkdir_p(path)
end
def save_empty_file(relative_path)
@@ -51,13 +55,13 @@
def save_file(source, output)
source_file = File.join(File.dirname(__FILE__), "template_file", source)
output_file = File.join(@ggem.root_path, @ggem.name, output)
- if File.exists?(source_file)
+ if File.exist?(source_file)
FileUtils.mkdir_p(File.dirname(output_file))
erb = ERB.new(File.read(source_file))
- File.open(output_file, "w") {|f| f << erb.result(binding) }
+ File.open(output_file, "w"){ |f| f << erb.result(binding) }
else
raise ArgumentError, "the source file `#{source_file}` does not exist"
end
end
end