Sha256: 60728ad874f65ff7dddb1ff44bd18792add4e004e6c93a768570cf8f2aa60ba7

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

module MarkMapper
  module Generators
    class ConfigGenerator < Rails::Generators::Base
      desc 'creates the MarkMapper configuration at config/marklogic.yml'

      argument :database_name, :type => :string, :optional => true

      def self.source_root
        @source_root ||= File.expand_path('../templates', __FILE__)
      end

      def create_config_file
        template 'marklogic.yml', File.join('config', 'marklogic.yml')
        template 'markmapper.rb', File.join('config', 'initializers/markmapper.rb')
      end

      protected

        def app_name
          @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root)
        end

        def defined_app_name
          defined_app_const_base.underscore
        end

        def defined_app_const_base
          Rails.respond_to?(:application) && defined?(Rails::Application) &&
            Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, '')
        end

        alias :defined_app_const_base? :defined_app_const_base

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mark_mapper-0.0.6 lib/rails/generators/mark_mapper/config/config_generator.rb
mark_mapper-0.0.5 lib/rails/generators/mark_mapper/config/config_generator.rb
mark_mapper-0.0.4 lib/rails/generators/mark_mapper/config/config_generator.rb
mark_mapper-0.0.3 lib/rails/generators/mark_mapper/config/config_generator.rb
mark_mapper-0.0.2 lib/rails/generators/mark_mapper/config/config_generator.rb