idxprb 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7bb418a1efa6c60e9e89b1356282c33d408df8ef
4
+ data.tar.gz: 7cd1b6f433fb5c115d7665eb2c6fe97055d3f7f2
5
+ SHA512:
6
+ metadata.gz: 678fe3c5ef29117d2d481cc9c31adfb3c32ccb1e06dfd1a5548196cbf06ee76494d6864d2b9ca7a382235aecffa9335e091c39d2ddea18f7fd55db1626f8d5b1
7
+ data.tar.gz: 48998ae9f2ea77d59d9483a8c3f15833a0be202f3b095b19df1602310086bb16d7b85ed79d80b4ca8829752249143af5d3b0749c78e061ab61abfde151404624
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ Documentation:
2
+ Enabled: false
3
+ Metrics/AbcSize:
4
+ Max: 20
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in idxprb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Denis Lins
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,31 @@
1
+ # Idxprb
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'idxprb'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install idxprb
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/idxprb/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/idxprb.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'idxprb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'idxprb'
8
+ spec.version = Idxprb::VERSION
9
+ spec.authors = ['Denis Lins', 'Artur Rodrigues']
10
+ spec.email = ['dlins@idxpanalytics.com', 'artur@idxpanalytics.com']
11
+ spec.summary = 'IDXP\'s ruby helpers'
12
+ spec.description = 'IDXP\'s ruby helpers'
13
+ spec.homepage = 'https://github.com/idxp/idxprb'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
+
26
+ spec.add_dependency 'diplomat'
27
+ end
data/lib/idxprb.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'idxprb/version'
2
+ require 'idxprb/configurator'
@@ -0,0 +1,23 @@
1
+ require 'diplomat'
2
+
3
+ module Idxprb
4
+ class Configurator
5
+ def initialize(key)
6
+ @key = key
7
+ end
8
+
9
+ def configs
10
+ @configs ||= JSON.parse(load_configs)
11
+ end
12
+
13
+ private
14
+
15
+ def load_configs
16
+ if ENV['PRODUCTION']
17
+ Diplomat::Kv.get(@key)
18
+ else
19
+ File.read('config.json')
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Idxprb
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Idxprb::Configurator do
4
+ subject { Idxprb::Configurator.new('config_key') }
5
+
6
+ context 'when running in production' do
7
+ before do
8
+ ENV['PRODUCTION'] = 'true'
9
+ expect_any_instance_of(Diplomat::Kv)
10
+ .to receive(:get)
11
+ .with('config_key')
12
+ .and_return('{"config_from":"consul"}')
13
+ end
14
+
15
+ it 'loads the config from consul' do
16
+ expect(subject.configs).to eq('config_from' => 'consul')
17
+ end
18
+ end
19
+
20
+ context 'when running other environment than production' do
21
+ before do
22
+ ENV['PRODUCTION'] = nil
23
+ expect(File)
24
+ .to receive(:read)
25
+ .with('config.json')
26
+ .and_return('{"config_from":"file"}')
27
+ end
28
+
29
+ it 'loads the config from config file' do
30
+ expect(subject.configs).to eq('config_from' => 'file')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'idxprb'
2
+ require 'codeclimate-test-reporter'
3
+ require 'simplecov'
4
+
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ CodeClimate::TestReporter::Formatter
8
+ ]
9
+
10
+ SimpleCov.start(CodeClimate::TestReporter.configuration.profile)
11
+ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
12
+
13
+ RSpec.configure do |config|
14
+ config.expect_with :rspec do |expectations|
15
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16
+ end
17
+
18
+ config.mock_with :rspec do |mocks|
19
+ mocks.verify_partial_doubles = true
20
+ end
21
+
22
+ config.filter_run :focus
23
+ config.run_all_when_everything_filtered = true
24
+ config.disable_monkey_patching!
25
+ config.default_formatter = 'doc' if config.files_to_run.one?
26
+
27
+ config.order = :random
28
+ Kernel.srand config.seed
29
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idxprb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Denis Lins
8
+ - Artur Rodrigues
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-06-19 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.7'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: codeclimate-test-reporter
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: diplomat
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: IDXP's ruby helpers
85
+ email:
86
+ - dlins@idxpanalytics.com
87
+ - artur@idxpanalytics.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - ".ruby-version"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - idxprb.gemspec
101
+ - lib/idxprb.rb
102
+ - lib/idxprb/configurator.rb
103
+ - lib/idxprb/version.rb
104
+ - spec/idxprb/configurator_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/idxp/idxprb
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: IDXP's ruby helpers
130
+ test_files:
131
+ - spec/idxprb/configurator_spec.rb
132
+ - spec/spec_helper.rb