Sha256: acfdaf3e2d655d4845f089944c5119c368d9089a47235111359fbc535fe74361
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
require_relative "../base" module Hexx module Generators # Scaffolds rails controller action and a corresponding route spec. class Controller < Base argument :route argument :usecase def self.source_root super __FILE__ end def create_routing_spec template( "routing_spec.erb", "spec/routing/#{ api_path }/#{ file_name }_routing_spec.rb", skip: true ) end def add_route_spec inject_template_into_file( "routing_action_spec.erb", "spec/routing/#{ api_path }/#{ file_name }_routing_spec.rb", before: " end\nend" ) end def create_controller_spec template( "controller_spec.erb", "spec/controllers/#{ api_path }/#{ file_name }_controller_spec.rb", skip: true ) end def add_controller_action_spec inject_template_into_file( "controller_action_spec.erb", "spec/controllers/#{ api_path }/#{ file_name }_controller_spec.rb", after: "describe \"action\" do" ) end def create_controller template( "controller.erb", "app/controllers/#{ api_path }/#{ file_name }_controller.rb", skip: true ) end def add_controller_action inject_template_into_file( "controller_action.erb", "app/controllers/#{ api_path }/#{ file_name }_controller.rb", after: " < ActionController" ) end private def action_type @action_type ||= super route end def action_name @action_name ||= super route end def use_case @use_case ||= usecase.camel_case end def use_case_file @use_case_file ||= usecase.snake_case end def api_path "#{ gem_name }/api/v1" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hexx-0.0.1 | lib/generators/controller/controller.rb |