Sha256: 76b7bc016ebd9f51a808f4a8e3e665a15a00a110d335b00b7b02b10a71cfa420
Contents?: true
Size: 1.74 KB
Versions: 10
Compression:
Stored size: 1.74 KB
Contents
require 'erubis' require 'mixlib/cli' module Liquid class Generator def run self.__send__(ARGV.shift, *ARGV) end def project(name) if File.exist?(name) puts "!!! #{name} already exists" exit(1) end puts ">>> Generating new project #{name}" constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/ constant_array = constant_name.split('::') config = opts config.merge!({ name: name, constant_name: constant_name, constant_array: constant_array, }) { "Gemfile" => "Gemfile", "Rakefile" => "Rakefile", "LICENSE.txt" => "LICENSE.txt", "README.md" => "README.md", ".gitignore" => "gitignore", "#{name}.gemspec" => "gemspec", "bin/#{name}" => "binwrapper", "config.yml" => "config.yml", "#{name}/server.rb" => "server.rb", }.each do |dest, source| puts " * #{dest}" source = File.join(ROOT, 'lib/liquid/templates', "#{source}.tt") dest = File.join(name, dest) FileUtils.mkdir_p(File.dirname(dest)) input = File.read(source) eruby = Erubis::Eruby.new(input) output = File.open(dest, "w") output.write(eruby.result(binding())) output.close end Dir.chdir(name) do puts ">>> Installing dependencies" system("bundle install") system("chmod +x bin/*") end end end end
Version data entries
10 entries across 10 versions & 1 rubygems