Sha256: c2ada23daf28689970b26b52946ae1bc09c83b31dc18a017adfce59fbc971a80

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. app_slice])
require File.join(File.dirname(__FILE__), %w[rails initializer])
require File.join(File.dirname(__FILE__), %w[rails file])

module AppSlice
  module Rails
    class << self
      def init!
        ::Rails.public_path = public_path
        ::ActionController::Routing::Routes.add_configuration_file File.join(config_path, 'routes.rb')
        # Update frameworks with view_paths
        [::ActionController, ::ActionMailer].each do |framework|
          framework::Base.send(:view_paths).unshift(view_path)
        end
        @initialized = true
      end
      
      def root
        if AppSlice.exists?
          File.join(RAILS_ROOT, 'app_slices', AppSlice.app)
        else
          RAILS_ROOT
        end
      end
      
      def environment_path
        File.join(config_path, 'environments', "#{RAILS_ENV}.rb")
      end
      
      def public_path
        File.join(root, 'public')
      end
      
      def root_environment_path
        File.join(config_path, 'environment.rb')
      end
      
      def config_path
        File.join(root, 'config')
      end
      
      def view_path
        File.join(root, %w[app views])
      end
      
      def configure(configuration = ::Rails::Configuration.new)
        # Create our new configuration block here
        configuration.database_configuration_file = database_configuration_file
        return configuration
      end
      
      def initialized?
        @initialized
      end
      
    protected
      def routes_configuration_file
        File.join(config_path, 'routes.rb')
      end
      
      def database_configuration_file
        File.join(config_path, 'database.yml')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bradgessler-app-slice-0.2.4 lib/app_slice/rails.rb