Sha256: d58e41c197a721969e6eb188663c84e782f90fcbc92839c4312767b2325b6458
Contents?: true
Size: 1.66 KB
Versions: 14
Compression:
Stored size: 1.66 KB
Contents
# -*- encoding : utf-8 -*- class DaoGenerator < Rails::Generators::NamedBase source_root(File.expand_path('../templates', __FILE__)) def copy_files ARGV.shift if ARGV.first == name case name when /conducer/ generate_conducer! when /system/ generate_system! when /helper/ generate_helper! when /api/ generate_system! when /assets/ generate_system! else raise "dunno how to generate #{ name.inspect }" end end protected def generate_conducer! @conducer_name = ARGV.shift.sub(/_?conducer$/i, '') + '_conducer' template "conducer.rb", "app/conducers/#{ @conducer_name.underscore }.rb" end def generate_helper! copy_file("dao_helper.rb", "app/helpers/dao_helper.rb") end def generate_system! FileUtils.mkdir_p(File.join(Rails.root, 'app/conducers')) copy_file("api.rb", "lib/api.rb") copy_file("api_controller.rb", "app/controllers/api_controller.rb") copy_file("dao_helper.rb", "app/helpers/dao_helper.rb") copy_file("dao.js", "app/assets/javascripts/dao.js") copy_file("dao.css", "app/assets/stylesheets/dao.css") route("match 'api(/*path)' => 'api#index', :as => 'api'") application( <<-__ config.after_initialize do require File.join(Rails.root, 'lib/api.rb') end ### config.action_view.javascript_expansions[:defaults] ||= [] ### config.action_view.javascript_expansions[:defaults] += %( dao ) ### config.action_view.stylesheet_expansions[:defaults] ||= [] ### config.action_view.stylesheet_expansions[:defaults] += %( dao ) __ ) end end
Version data entries
14 entries across 14 versions & 1 rubygems