Sha256: a8c96d3591d264e98e151bb1ae886dc77a5da9d0ff8c1850d3926dec91539125
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# rails generate repres:dosser:platform administration --version 2 class Repres::Dosser::PlatformGenerator < Rails::Generators::NamedBase # https://github.com/erikhuda/thor/blob/master/lib/thor/base.rb#L273 class_option :version, type: :numeric, required: false, default: 1, desc: 'a positive integer, the default value is 1' source_root File.expand_path('../templates', __FILE__) def produce @platform_name = file_name.downcase @version_number = options['version'].to_i bind_options generate_controller generate_route end def bind_options @platform_module_name = @platform_name.camelize @version_module_name = "V#{@version_number}" @version_name = "v#{@version_number}" end # controller # # app/controllers/platform/version/presentation_controller.rb # app/controllers/platform/version/portals_controller.rb # def generate_controller template 'controllers/portals_controller.rb', "app/controllers/#{@platform_name}/dosser/#{@version_name}/portals_controller.rb" template 'controllers/presentation_controller.rb', "app/controllers/#{@platform_name}/dosser/#{@version_name}/presentation_controller.rb" end # route # # config/routes.rb # def generate_route source = File.expand_path find_in_source_paths('routes.rb') content = ERB.new(File.binread(source).strip, nil, '-', "@output_buffer").result instance_eval('binding') route content end private :bind_options, :generate_controller, :generate_route end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
repres-dosser-1.6.2 | lib/generators/repres/dosser/platform/platform_generator.rb |