rails_configurations 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 chaunce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ rails_configurations
2
+ ===========
3
+
4
+ Parse and store YAML configuration files in Rails.configuration
5
+
6
+ Usage
7
+ --------
8
+
9
+ add `rails_configurations` to your Gemfile
10
+
11
+ gem 'rails_configurations'
12
+
13
+ load a YAML configuration file in an initializer
14
+
15
+ sidekiq_yml = Rails.root.join('config', 'sidekiq.yml')
16
+ Rails.configuration.parse(sidekiq_yml)
17
+
18
+ access your configuration data
19
+
20
+ Rails.configuration.sidekiq_configuration
@@ -0,0 +1,36 @@
1
+ require "yaml"
2
+ require "erb"
3
+
4
+ module Rails
5
+ class Application
6
+
7
+ # based on Rails::Application::Configuration#database_configuration
8
+ # in rails/railties/lib/rails/application/configuration.rb
9
+ module ConfigurationExtension
10
+ extend ActiveSupport::Concern
11
+
12
+ def parse(path)
13
+ yaml = Pathname.new(path) if path
14
+
15
+ config = if yaml && yaml.exist?
16
+ YAML.load(ERB.new(yaml.read).result) || {}
17
+ else
18
+ raise "No such file - #{path}"
19
+ end
20
+
21
+ configuration_attr = :"#{path.to_s.split('/').last.split('.').first.underscore}_configuration"
22
+ Rails::Application::Configuration.send(:attr_accessor, configuration_attr)
23
+
24
+ Rails.configuration.send("#{configuration_attr}=", config.with_indifferent_access)
25
+ rescue Psych::SyntaxError => e
26
+ raise "YAML syntax error occurred while parsing #{path}. " \
27
+ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
28
+ "Error: #{e.message}"
29
+ rescue => e
30
+ raise e, "Cannot load #{path.to_s.split('/').last.split('.').first.humanize.downcase} configuration:\n#{e.message}", e.backtrace
31
+ end
32
+ end
33
+
34
+ Configuration.send(:include, ConfigurationExtension)
35
+ end
36
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module RailsConfigurations
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_configurations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - chaunce
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.0.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.0.0
46
+ description: Parse and store YAML configuration files in Railspec.configuration
47
+ email: chaunce.slc@gmail.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - LICENSE
53
+ - README.md
54
+ - lib/rails_configurations.rb
55
+ - lib/version.rb
56
+ homepage: https://github.com/chaunce/rails_configurations
57
+ licenses:
58
+ - MIT
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.25
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: RailsConfigurations
81
+ test_files: []