Sha256: 2c711084c687b9d0b2917b6162bd4ef0f9d44144e83d77576f3cb4e70b8971e7
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'active_support/core_ext' module NubisRailsBoilerplate class Templates def self.expand_skeleton(skeleton, basefile) skeleton_path = File.absolute_path(File.expand_path("../../skeletons/#{skeleton}", basefile)) `cp -r #{skeleton_path} #{get_app_name}` patch_module_name(skeleton, get_app_name) run_setup_tasks(get_app_name) puts "All done! Your app is ready to start customizing." end def self.patch_module_name(skeleton, app_name) puts "Patching #{skeleton} files for #{app_name}" %w(Rakefile config/application.rb config/environment.rb config/environments/development.rb config/environments/test.rb config/environments/production.rb config/initializers/secret_token.rb config/database.yml config/initializers/session_store.rb config/routes.rb config.ru).each do |filename| full_path = File.expand_path(filename, app_name) new_contents = File.read(full_path) .gsub(skeleton.camelize, app_name.camelize) .gsub(skeleton, app_name) File.write(full_path, new_contents) end end def self.run_setup_tasks(app_name) puts "Installing gems and configuring databases" Dir.chdir(app_name) do `bundle install; rake db:create; rake db:migrate; rake db:test:prepare` end end def self.get_app_name if ARGV.size != 1 puts "Call it like this: #{$0} app_name" exit 1 end unless ARGV[0] =~ /^[a-z_]*$/ puts "The app_name can only be lowercase letters and underscores" exit 1 end return ARGV[0] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nubis_rails_boilerplate-0.0.5 | lib/templates.rb |