Sha256: 6c1e9b5f95639e45f53f95dcadeec7a4f9319b0be85be2d42b672c56f7cc07c7

Contents?: true

Size: 747 Bytes

Versions: 7

Compression:

Stored size: 747 Bytes

Contents

require 'rails/generators'
module Hyper
  class Router < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    argument :component, type: :string
    class_option :path, type: :string, default: '/(*other)'
    def create_component_file
      component_array = component.split('::')
      @modules = component_array[0..-2]
      @file_name = component_array.last
      @indent = 0
      template 'router_template.rb',
               File.join('app/hyperloop/components',
                         @modules.map(&:downcase).join('/'),
                         "#{@file_name.underscore}.rb")
    end

    def add_route
      route "get '#{options['path']}', to: 'hyperloop##{@file_name.underscore}'"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyperloop-0.99.6 lib/generators/hyper/router_generator.rb
hyperloop-0.99.5 lib/generators/hyper/router_generator.rb
hyperloop-0.99.4 lib/generators/hyper/router_generator.rb
hyperloop-0.99.3 lib/generators/hyper/router_generator.rb
hyperloop-0.99.2 lib/generators/hyper/router_generator.rb
hyperloop-0.99.1 lib/generators/hyper/router_generator.rb
hyperloop-0.99.0 lib/generators/hyper/router_generator.rb