quandl-config 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 36b55fd81a33c3118fdd834c7039dbdbc329188c
4
+ data.tar.gz: 989c8386206043b99dfb8d071818fcc12181b149
5
+ SHA512:
6
+ metadata.gz: c953ae47a416c6fd2a8851b26d397877f0e7d8295ca0a21f1961060cc2f12e0c7abe74147333d9e0ce8a07f15456d8e599ce33160790546734df9da5c41b27a8
7
+ data.tar.gz: 9cf64d6da20a947364eb18ba6808d643d72bf781842318f5587155d1e4701a70d8649050722dcdd1de7fdcf4f8448224e96e75b27c587f9ad8493e77f4222811
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ LineLength:
2
+ Max: 150
3
+ Documentation:
4
+ Enabled: false
5
+ FileName:
6
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quandl-config.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Najwa Azer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Quandl::Config
2
+
3
+ This gem allows you to quickly convert YML files into a `Config` object where the attributes can be accessed using dot, hash symbol or hash string notation.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'quandl-config'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install quandl-config
18
+
19
+ ## Usage
20
+
21
+ 1. Create a `yml` file with the same file name as your class. For example:
22
+ ```
23
+ class: A::B::C
24
+ file name: config/a/b/c.yml
25
+ ```
26
+
27
+ 2. Extend the Quandl::Configurable class. This adds a configuration class method.
28
+ ```ruby
29
+ class A::B::C
30
+ extend Quandl::Configurable
31
+ end
32
+ ```
33
+
34
+ ```ruby
35
+ pry
36
+ pry> A::B::C.configuration
37
+ => #<Quandl::Config language="spanish", hello="hola">
38
+ ```
39
+
40
+ ### What if my yml file name doesn't match the class name?
41
+
42
+ ```ruby
43
+ class A::B::Special
44
+ extend Quandl::Configurable
45
+ def self.file_name
46
+ 'database_zip_uploader'
47
+ end
48
+ end
49
+ ```
50
+
51
+ ### What if I want configuration to be an instance method?
52
+
53
+ ```ruby
54
+ class A::B::C
55
+ include Quandl::Configurable
56
+ end
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/[my-github-username]/quandl-config/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'documentation']
8
+ end
9
+
10
+ task default: :spec
@@ -0,0 +1,24 @@
1
+ require 'ostruct'
2
+ require 'yaml'
3
+
4
+ module Quandl
5
+ class Config < ::OpenStruct
6
+ VERSION = '0.0.1'
7
+
8
+ def initialize(file_name)
9
+ raw_config = File.read(::Rails.root.join('config', "#{file_name}.yml"))
10
+ erb_config = ERB.new(raw_config).result
11
+ config = YAML.load(erb_config)[Rails.env]
12
+
13
+ super(config)
14
+ end
15
+
16
+ def configurable_attributes
17
+ setters_and_getters = methods - self.class.instance_methods
18
+ getters = setters_and_getters.reject { |method| method =~ /=$/ }
19
+ getters
20
+ end
21
+ end
22
+ end
23
+
24
+ require 'quandl/configurable'
@@ -0,0 +1,15 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Quandl
4
+ module Configurable
5
+ def configuration
6
+ @configuration ||= Config.new(file_name)
7
+ end
8
+
9
+ private
10
+
11
+ def file_name
12
+ defined?(name) ? name.underscore : self.class.name.underscore
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'quandl/config'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'quandl-config'
8
+ spec.version = Quandl::Config::VERSION
9
+ spec.authors = ['Najwa Azer']
10
+ spec.email = ['najwa.azer@gmail.com']
11
+ spec.summary = 'Openstruct-based per-class configuration.'
12
+ spec.description = 'Openstruct-based per-class configuration.'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'rspec-nc'
25
+ spec.add_development_dependency 'guard'
26
+ spec.add_development_dependency 'guard-rspec'
27
+ spec.add_development_dependency 'pry'
28
+ spec.add_development_dependency 'pry-remote'
29
+ spec.add_development_dependency 'pry-nav'
30
+ spec.add_runtime_dependency 'activesupport'
31
+ end
@@ -0,0 +1,41 @@
1
+ defaults: &defaults
2
+ webhook_url: https://hooks.slack.com/services/fake/fake/fake
3
+ notifiers: &default_subclasses
4
+ asset_management:
5
+ channel: '#releases'
6
+ username: Next Asset Deployer
7
+ icon_emoji: airplane
8
+ stripe:
9
+ channel: '#stripe-testing'
10
+ username: stripe
11
+ ci:
12
+ channel: <%= ENV.fetch('SLACK_CHANNEL', "'#development'") %>
13
+
14
+ development:
15
+ <<: *defaults
16
+
17
+ staging:
18
+ <<: *defaults
19
+
20
+ test:
21
+ <<: *defaults
22
+
23
+ jenkins:
24
+ <<: *defaults
25
+
26
+ vagrant:
27
+ <<: *defaults
28
+
29
+ vagrant_test:
30
+ <<: *defaults
31
+
32
+ vagrant_staging:
33
+ <<: *defaults
34
+
35
+ production:
36
+ <<: *defaults
37
+ subclasses:
38
+ <<: *default_subclasses
39
+ stripe:
40
+ channel: '#stripe-events'
41
+ username: stripe
@@ -0,0 +1,11 @@
1
+ Rails = Class.new do
2
+ require "#{File.dirname(__FILE__)}/dummy_app/fake"
3
+
4
+ def self.root
5
+ Pathname.new(File.dirname(__FILE__))
6
+ end
7
+
8
+ def self.env
9
+ 'development'
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ class Fake
2
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Quandl::Config do
4
+ describe '.initialize' do
5
+ it 'generates a Config class, evaluating ERB' do
6
+ configuration = Quandl::Config.new('fake')
7
+
8
+ expect(configuration['notifiers']['ci']['channel']).to eq('#development')
9
+ end
10
+ end
11
+
12
+ describe '#configurable_attributes' do
13
+ it 'provides a list of configurable attributes' do
14
+ configuration = Quandl::Config.new('fake')
15
+
16
+ expect(configuration.configurable_attributes).to eq([:webhook_url, :notifiers])
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Quandl::Configurable do
4
+ context 'when extending' do
5
+ it 'adds a configuration class method' do
6
+ Fake.extend(Quandl::Configurable)
7
+ expect(Fake.configuration).to be_kind_of(Quandl::Config)
8
+ end
9
+ end
10
+
11
+ context 'when including' do
12
+ it 'adds a configuration instance method' do
13
+ Fake.include(Quandl::Configurable)
14
+ expect(Fake.new.configuration).to be_kind_of(Quandl::Config)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ require 'pry'
2
+ require 'quandl/config'
3
+ require 'fixtures/dummy_app'
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quandl-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Najwa Azer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-nc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-remote
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-nav
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activesupport
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Openstruct-based per-class configuration.
154
+ email:
155
+ - najwa.azer@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rubocop.yml"
162
+ - Gemfile
163
+ - Guardfile
164
+ - LICENSE.txt
165
+ - README.md
166
+ - Rakefile
167
+ - lib/quandl/config.rb
168
+ - lib/quandl/configurable.rb
169
+ - quandl-config.gemspec
170
+ - spec/fixtures/config/fake.yml
171
+ - spec/fixtures/dummy_app.rb
172
+ - spec/fixtures/dummy_app/fake.rb
173
+ - spec/quandl/quandl-config_spec.rb
174
+ - spec/quandl/quandl-configurable_spec.rb
175
+ - spec/spec_helper.rb
176
+ homepage: ''
177
+ licenses:
178
+ - MIT
179
+ metadata: {}
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.2.2
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: Openstruct-based per-class configuration.
200
+ test_files:
201
+ - spec/fixtures/config/fake.yml
202
+ - spec/fixtures/dummy_app.rb
203
+ - spec/fixtures/dummy_app/fake.rb
204
+ - spec/quandl/quandl-config_spec.rb
205
+ - spec/quandl/quandl-configurable_spec.rb
206
+ - spec/spec_helper.rb