Sha256: e60c8cddd557596d251e55ae9f737fc63486741b21907235c9bb7af6e3b0c6a3

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Scrapbook
  # A generator to create a new scrapbook with  either the default (scrapbook) or specified
  # name. (Using the default options for the URL path and folder root.)
  class RoutesGenerator < Rails::Generators::Base
    argument :name, optional: true, default: 'scrapbook'

    def routes
      # TODO: Investigate using a Rubocop rule to determine using single or double auotes.

      inject_into_file('config/routes.rb', after: "Rails.application.routes.draw do\n") do
        "  extend Scrapbook::Routing\n"
      end

      inject_into_file('config/routes.rb', after: "extend Scrapbook::Routing\n") do
        "\n  scrapbook('#{name}') if Rails.env.development?\n"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scrapbook-0.3.2 lib/generators/scrapbook/routes_generator.rb
scrapbook-0.3.1 lib/generators/scrapbook/routes_generator.rb
scrapbook-0.3.0 lib/generators/scrapbook/routes_generator.rb
scrapbook-0.2.2 lib/generators/scrapbook/routes_generator.rb