constantizer 1.0.0
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.
- checksums.yaml +7 -0
- data/lib/constantizer/integration/sinatra.rb +16 -0
- data/lib/constantizer/rack/reloader.rb +15 -0
- data/lib/constantizer/version.rb +3 -0
- data/lib/constantizer.rb +14 -0
- metadata +78 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 3536fb1f6c5d346acc03f943b92c63b346120f20
         | 
| 4 | 
            +
              data.tar.gz: 6b4c09125ad8176a5307fb3c94133e54125dbf74
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: ea4c1b5c58da055e06312f7f3bf8644af65adf86379e2dd14c453aded959882c788ffb2717d2055f76be1a4ddf58d74b831d42e32e2dce8b9fa5fc602f9c86c5
         | 
| 7 | 
            +
              data.tar.gz: e68af67c774036db313d4355635d77cff123c9565fd6b0635aaf464fe615771ae3f6f9a26b73dfd5853a12bbe77eb615f2d48fd9d969acaebd306bd30ad7509a
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module Constantizer
         | 
| 2 | 
            +
              # provide helper to register within your Sinatra app
         | 
| 3 | 
            +
              #
         | 
| 4 | 
            +
              # set :root, File.dirname(__FILE__)
         | 
| 5 | 
            +
              # register Constantizer
         | 
| 6 | 
            +
              #
         | 
| 7 | 
            +
              module Sinatra
         | 
| 8 | 
            +
                def self.registered(app)
         | 
| 9 | 
            +
                  app.configure do |inner_app|
         | 
| 10 | 
            +
                    Constantizer.load!(File.join(inner_app.root, 'constants'))
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    inner_app.use(Constantizer::Rack::Reloader) if inner_app.development?
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module Constantizer
         | 
| 2 | 
            +
              module Rack
         | 
| 3 | 
            +
                # Rack middleware the reloads RailsConfig on every request (only use in dev mode)
         | 
| 4 | 
            +
                class Reloader
         | 
| 5 | 
            +
                  def initialize(app)
         | 
| 6 | 
            +
                    @app = app
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def call(env)
         | 
| 10 | 
            +
                    Constantizer.reload!
         | 
| 11 | 
            +
                    @app.call(env)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        data/lib/constantizer.rb
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            require "constantizer/version"
         | 
| 2 | 
            +
            require "constantizer/integration/sinatra"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Constantizer
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def self.load!(path)
         | 
| 7 | 
            +
                @path = path
         | 
| 8 | 
            +
                Dir.glob(File.join(path,'/*.yml')).each { |file| YAML.load_file(file).each { |k, v| Object.const_set k, v } }
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def self.reload!
         | 
| 12 | 
            +
                load! @path
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: constantizer
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Baraa Al-Bourghli
         | 
| 8 | 
            +
            - Essam Arab
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2014-11-23 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: bundler
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                requirements:
         | 
| 18 | 
            +
                - - ~>
         | 
| 19 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 20 | 
            +
                    version: '1.6'
         | 
| 21 | 
            +
              type: :development
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 | 
            +
                requirements:
         | 
| 25 | 
            +
                - - ~>
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 27 | 
            +
                    version: '1.6'
         | 
| 28 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 29 | 
            +
              name: rake
         | 
| 30 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 31 | 
            +
                requirements:
         | 
| 32 | 
            +
                - - '>='
         | 
| 33 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            +
                    version: '0'
         | 
| 35 | 
            +
              type: :development
         | 
| 36 | 
            +
              prerelease: false
         | 
| 37 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 | 
            +
                requirements:
         | 
| 39 | 
            +
                - - '>='
         | 
| 40 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            +
                    version: '0'
         | 
| 42 | 
            +
            description: 
         | 
| 43 | 
            +
            email:
         | 
| 44 | 
            +
            - essam.a0@gmail.com
         | 
| 45 | 
            +
            - baraa.bourghli@gmail.com
         | 
| 46 | 
            +
            executables: []
         | 
| 47 | 
            +
            extensions: []
         | 
| 48 | 
            +
            extra_rdoc_files: []
         | 
| 49 | 
            +
            files:
         | 
| 50 | 
            +
            - lib/constantizer.rb
         | 
| 51 | 
            +
            - lib/constantizer/integration/sinatra.rb
         | 
| 52 | 
            +
            - lib/constantizer/rack/reloader.rb
         | 
| 53 | 
            +
            - lib/constantizer/version.rb
         | 
| 54 | 
            +
            homepage: https://github.com/baraabourghli/constantizer
         | 
| 55 | 
            +
            licenses:
         | 
| 56 | 
            +
            - MIT
         | 
| 57 | 
            +
            metadata: {}
         | 
| 58 | 
            +
            post_install_message: 
         | 
| 59 | 
            +
            rdoc_options: []
         | 
| 60 | 
            +
            require_paths:
         | 
| 61 | 
            +
            - lib
         | 
| 62 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 63 | 
            +
              requirements:
         | 
| 64 | 
            +
              - - '>='
         | 
| 65 | 
            +
                - !ruby/object:Gem::Version
         | 
| 66 | 
            +
                  version: '0'
         | 
| 67 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 68 | 
            +
              requirements:
         | 
| 69 | 
            +
              - - '>='
         | 
| 70 | 
            +
                - !ruby/object:Gem::Version
         | 
| 71 | 
            +
                  version: '0'
         | 
| 72 | 
            +
            requirements: []
         | 
| 73 | 
            +
            rubyforge_project: 
         | 
| 74 | 
            +
            rubygems_version: 2.2.2
         | 
| 75 | 
            +
            signing_key: 
         | 
| 76 | 
            +
            specification_version: 4
         | 
| 77 | 
            +
            summary: constantizer is a gem for bulding constants in the app using YAML files
         | 
| 78 | 
            +
            test_files: []
         |