Sha256: eae57480adaf83b31fcbcb78d3fb614c4f98dde1b9d898e0efefb9574d6d170d

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require "inflecto"
require "dry/web/roda/generate"

module Dry
  module Web
    module Roda
      module Generators
        class SubApp
          attr_reader :generate

          def initialize
            @generate = Dry::Web::Roda::Generate.new("sub_app")
          end

          def call(target_dir, options = {})
            umbrella_name = options.fetch(:umbrella)
            generate_to = options.fetch(:to) { File.join("apps", target_dir) }

            generate.(generate_to, prepare_scope(target_dir, umbrella_name))
          end

          private

          def prepare_scope(target_dir, umbrella_name)
            {
              underscored_app_name: Inflecto.underscore(target_dir),
              camel_cased_app_name: Inflecto.camelize(target_dir),
              underscored_umbrella_name: Inflecto.underscore(umbrella_name),
              camel_cased_umbrella_name: Inflecto.camelize(umbrella_name),
            }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-web-roda-0.6.1 lib/dry/web/roda/generators/sub_app.rb