Sha256: ace17bf853e712058e003f720679a5561070b1948ea13dcdf507f23fe77cd0c0

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

require 'generators/transponder'

module Transponder
  module Generators
    class PresenterGenerator < Base
      class_option :module_name, type: :string, aliases: '-m', default: 'application'

      def add_presenter
        presenter_path = File.join(javascripts_path, options[:module_name], "presenters/#{file_name.downcase}_presenter.coffee")
        template "_presenter.coffee", presenter_path
      end

      def presenter_class_name
        "#{options[:module_name].camelize}.Presenters.#{file_name.camelize}Presenter"
      end

      def add_presenter_to_boot
        boot_file = File.join(javascripts_path, options[:module_name], 'initializers/boot.coffee')
        insert_into_file boot_file, 
                         "new #{presenter_class_name}()\n",
                         after: "# presenters\n"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
transponder-2.0.0 lib/generators/transponder/presenter/presenter_generator.rb
transponder-1.0.0 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.10.4 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.10.2 lib/generators/transponder/presenter/presenter_generator.rb
transponder-0.10.1 lib/generators/transponder/presenter/presenter_generator.rb