rails_configurator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/rails_configurator.rb +46 -0
- data/lib/rails_configurator/version.rb +3 -0
- data/rails_configurator.gemspec +22 -0
- metadata +72 -0
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require 'bundler/gem_tasks'
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require "rails_configurator/version"
         | 
| 2 | 
            +
            require "ostruct"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
             | 
| 5 | 
            +
            module RailsConfigurator
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              def RailsConfigurator.extend(config, property, options={}, &block)
         | 
| 10 | 
            +
                config.class.class_eval do
         | 
| 11 | 
            +
                  
         | 
| 12 | 
            +
                  define_method(property) do
         | 
| 13 | 
            +
                    ivar = "@#{property}"
         | 
| 14 | 
            +
                    instance_variable_get(ivar) || instance_variable_set(ivar, (begin
         | 
| 15 | 
            +
                      
         | 
| 16 | 
            +
                      defaults = options[:defaults] || {}
         | 
| 17 | 
            +
                      settings_path = options[:path] || Rails.root.join("config", "#{property}.yml")
         | 
| 18 | 
            +
                      settings = YAML.load_file(settings_path)[Rails.env.to_s]
         | 
| 19 | 
            +
                      settings.reverse_merge!(defaults)
         | 
| 20 | 
            +
                      
         | 
| 21 | 
            +
                      o = OpenStruct.new(settings)
         | 
| 22 | 
            +
                      o.class_eval(&block) if block_given?
         | 
| 23 | 
            +
                      o
         | 
| 24 | 
            +
                    end))
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                  
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
              
         | 
| 30 | 
            +
              
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
              module InstanceMethods
         | 
| 33 | 
            +
                
         | 
| 34 | 
            +
                def extend(property, options={}, &block)
         | 
| 35 | 
            +
                  RailsConfigurator.extend(self, property, options, &block)
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
                
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
              
         | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
            Rails::Application::Configuration.send(:include, RailsConfigurator::InstanceMethods)
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "rails_configurator/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "rails_configurator"
         | 
| 7 | 
            +
              s.version     = RailsConfigurator::VERSION
         | 
| 8 | 
            +
              s.authors     = ["Robert Lail"]
         | 
| 9 | 
            +
              s.email       = ["robert.lail@cph.org"]
         | 
| 10 | 
            +
              s.homepage    = ""
         | 
| 11 | 
            +
              s.summary     = %q{extend Rails::Configuration}
         | 
| 12 | 
            +
              s.description = %q{extend Rails::Configuration}
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              s.rubyforge_project = "rails_configurator"
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              s.add_dependency "rails"
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 19 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 20 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 21 | 
            +
              s.require_paths = ["lib"]
         | 
| 22 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,72 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: rails_configurator
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              prerelease: 
         | 
| 5 | 
            +
              version: 0.0.1
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors: 
         | 
| 8 | 
            +
            - Robert Lail
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            date: 2011-08-19 00:00:00 -05:00
         | 
| 14 | 
            +
            default_executable: 
         | 
| 15 | 
            +
            dependencies: 
         | 
| 16 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 17 | 
            +
              name: rails
         | 
| 18 | 
            +
              prerelease: false
         | 
| 19 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 20 | 
            +
                none: false
         | 
| 21 | 
            +
                requirements: 
         | 
| 22 | 
            +
                - - ">="
         | 
| 23 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 24 | 
            +
                    version: "0"
         | 
| 25 | 
            +
              type: :runtime
         | 
| 26 | 
            +
              version_requirements: *id001
         | 
| 27 | 
            +
            description: extend Rails::Configuration
         | 
| 28 | 
            +
            email: 
         | 
| 29 | 
            +
            - robert.lail@cph.org
         | 
| 30 | 
            +
            executables: []
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            extensions: []
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            extra_rdoc_files: []
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            files: 
         | 
| 37 | 
            +
            - .gitignore
         | 
| 38 | 
            +
            - Gemfile
         | 
| 39 | 
            +
            - Rakefile
         | 
| 40 | 
            +
            - lib/rails_configurator.rb
         | 
| 41 | 
            +
            - lib/rails_configurator/version.rb
         | 
| 42 | 
            +
            - rails_configurator.gemspec
         | 
| 43 | 
            +
            has_rdoc: true
         | 
| 44 | 
            +
            homepage: ""
         | 
| 45 | 
            +
            licenses: []
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            post_install_message: 
         | 
| 48 | 
            +
            rdoc_options: []
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            require_paths: 
         | 
| 51 | 
            +
            - lib
         | 
| 52 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 53 | 
            +
              none: false
         | 
| 54 | 
            +
              requirements: 
         | 
| 55 | 
            +
              - - ">="
         | 
| 56 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 57 | 
            +
                  version: "0"
         | 
| 58 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 59 | 
            +
              none: false
         | 
| 60 | 
            +
              requirements: 
         | 
| 61 | 
            +
              - - ">="
         | 
| 62 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 63 | 
            +
                  version: "0"
         | 
| 64 | 
            +
            requirements: []
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            rubyforge_project: rails_configurator
         | 
| 67 | 
            +
            rubygems_version: 1.6.2
         | 
| 68 | 
            +
            signing_key: 
         | 
| 69 | 
            +
            specification_version: 3
         | 
| 70 | 
            +
            summary: extend Rails::Configuration
         | 
| 71 | 
            +
            test_files: []
         | 
| 72 | 
            +
             |