Sha256: 189fb3d5e52d3d5b3ca816d73b2c2f4174cc0429c5b8102684e6de2a80415556

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Scrapbook
  # A generator to create a new scrapbook at either the default (scrapbook) or specified
  # path from the Rails application root.
  class RoutesGenerator < Rails::Generators::Base
    argument :path, optional: true, default: '/scrapbook'

    def routes
      # TODO: Investigate using a Rubocop rule to determine using single or double auotes.
      url_path = path.start_with?('/') ? path : "/#{path}"
      route <<~ROUTES
        if Rails.env.development?
          mount Scrapbook::Engine => '#{url_path}'
        end
      ROUTES
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scrapbook-0.2.1 lib/generators/scrapbook/routes_generator.rb
scrapbook-0.2.0 lib/generators/scrapbook/routes_generator.rb