simple_config_loader 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5b47bf6315fdf8c0a3e6e481f82e8bc1f9cd39f
4
+ data.tar.gz: 9b74c16e23b6ff7963c5c635de3ee3663cfdc119
5
+ SHA512:
6
+ metadata.gz: 36948b4476144ab06598deabbe2958a9cdfc151f6d3093f25d3a1a6623f17c39c5d45dcdce80a0b830150f22fc69fdb383a6f9eb7c70d3fa44f0eac2ab1fc71e
7
+ data.tar.gz: 0bbf7ad7397dc2cdc943875146a7289957e17e138b68f940e3417de9d0e2629854d34f96f0c4da963d48b687e2ec61d187d44a2734bf7117bb2b56a021a3b16c
data/.codeclimate.yml ADDED
@@ -0,0 +1,20 @@
1
+ engines:
2
+ bundler-audit:
3
+ enabled: true
4
+
5
+ duplication:
6
+ enabled: true
7
+ config:
8
+ languages:
9
+ ruby:
10
+
11
+ fixme:
12
+ enabled: true
13
+
14
+ rubocop:
15
+ enabled: true
16
+
17
+ ratings:
18
+ paths:
19
+ - Gemfile.lock
20
+ - "**.rb"
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in config_loader.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :rspec, all_after_pass: false,
2
+ cmd: 'rspec' do
3
+ watch( 'spec/spec_helper.rb' ) { "spec" }
4
+ watch( %r{^lib/(.+)\.rb$} ) { |m| "spec/cases/#{m[1]}_spec.rb" }
5
+ watch( %r{^spec/cases/.+_spec\.rb$} )
6
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dean Brundage
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ [![Code Climate](https://codeclimate.com/github/brundage/config_loader/badges/gpa.svg)](https://codeclimate.com/github/brundage/config_loader)
2
+ [![Coverage Status](https://coveralls.io/repos/github/brundage/config_loader/badge.svg?branch=master)](https://coveralls.io/github/brundage/config_loader?branch=master)
3
+ [![Build Status](https://travis-ci.org/brundage/config_loader.svg?branch=master)](https://travis-ci.org/brundage/config_loader)
4
+ [![security](https://hakiri.io/github/brundage/config_loader/master.svg)](https://hakiri.io/github/brundage/config_loader/master)
5
+
6
+ # ConfigLoader
7
+
8
+ A gem to load configs
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'config_loader'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install config_loader
25
+
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/brundage/config_loader.
28
+
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
33
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "config_loader"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'config_loader/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simple_config_loader"
8
+ spec.version = ConfigLoader.version
9
+ spec.authors = ["Dean Brundage"]
10
+ spec.email = ["dean@deanandadie.net"]
11
+
12
+ spec.summary = %q{A loader for configs}
13
+ spec.description = %q{Utility class to load YAML config files}
14
+ spec.homepage = "https://github.com/brundage/config_loader"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency "coveralls"
28
+
29
+ end
@@ -0,0 +1,60 @@
1
+ require "config_loader/version"
2
+ require 'yaml'
3
+
4
+ class ConfigLoader
5
+
6
+ class NoConfigError < ArgumentError; end
7
+
8
+ def initialize(filename: nil, stream: nil, stream_loader: nil)
9
+ @filename = locate_config_file(filename)
10
+ @stream = stream
11
+ @stream_loader = stream_loader || YAML
12
+ end
13
+
14
+
15
+ def read
16
+ open_stream
17
+ if block_given?
18
+ yield handle
19
+ else
20
+ @stream_loader.load_stream(handle)[0]
21
+ end
22
+ close_stream
23
+ end
24
+
25
+
26
+ private
27
+
28
+ attr_reader :handle
29
+
30
+ def close_stream
31
+ return unless @handle
32
+ @handle.close
33
+ @handle = nil
34
+ end
35
+
36
+
37
+ def config_dir
38
+ File.expand_path( File.join( File.dirname(__FILE__), '..', '..', 'config' ) )
39
+ end
40
+
41
+
42
+ def locate_config_file(key)
43
+ return nil if key == nil
44
+ return key if File.absolute_path(key) == key
45
+ File.expand_path( File.join( config_dir, key ) )
46
+ end
47
+
48
+
49
+ def open_stream
50
+ !! @handle and return @handle
51
+ if @stream
52
+ @handle = @stream
53
+ else
54
+ @handle = File.open @filename if @filename
55
+ end
56
+ raise NoConfigError.new("Please suppply :filename or :stream to ConfigLoader") unless @handle
57
+ @handle
58
+ end
59
+
60
+ end
@@ -0,0 +1,4 @@
1
+ class ConfigLoader
2
+ VERSION = "0.1.0"
3
+ def self.version; VERSION; end
4
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_config_loader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dean Brundage
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-22 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-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: coveralls
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
+ description: Utility class to load YAML config files
70
+ email:
71
+ - dean@deanandadie.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".codeclimate.yml"
77
+ - ".coveralls.yml"
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - Guardfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - config_loader.gemspec
89
+ - lib/config_loader.rb
90
+ - lib/config_loader/version.rb
91
+ homepage: https://github.com/brundage/config_loader
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.5.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A loader for configs
115
+ test_files: []