herokuconf 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: 2d11d494b1a7bdd768e47fa15f3eacb2302523c4
4
+ data.tar.gz: eb886dc7d75bec157080b7d0f149ccfe58f34c5d
5
+ SHA512:
6
+ metadata.gz: f3d5e0968225074bfd1bd0232f5646a25a66e9d7200898fe006be7e86616e15435e080fb8664b293536f7abbac775656cdfa6a005f940af33e5f18d82376f4b3
7
+ data.tar.gz: a5666680388f4b2705b8819cf53736e7c2d697e855aab01c948156d74e35a45f67b7624e4af10225a54dc7ddf1a00930103fe51d575d26ef846621c3466853b6
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ pkg/*.gem
2
+ coverage/
3
+ .coveralls.yml
4
+ .bundle
5
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Encoding:
2
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ notifications:
9
+ email: false
10
+ irc:
11
+ channels:
12
+ - ircs://irc.oftc.net#akerl,ysalamir
13
+ template:
14
+ - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Les Aker
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.
22
+
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ herokuconf
2
+ =========
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/herokuconf.svg)](https://rubygems.org/gems/herokuconf)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/akerl/herokuconf.svg)](https://gemnasium.com/akerl/herokuconf)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/akerl/herokuconf.svg)](https://codeclimate.com/github/akerl/herokuconf)
7
+ [![Coverage Status](https://img.shields.io/coveralls/akerl/herokuconf.svg)](https://coveralls.io/r/akerl/herokuconf)
8
+ [![Build Status](https://img.shields.io/travis/akerl/herokuconf.svg)](https://travis-ci.org/akerl/herokuconf)
9
+ [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
10
+
11
+ Configure local environment based on Heroku config variables
12
+
13
+ ## Usage
14
+
15
+ ## Installation
16
+
17
+ gem install herokuconf
18
+
19
+ ## License
20
+
21
+ herokuconf is released under the MIT License. See the bundled LICENSE file for details.
22
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ desc 'Run tests'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc 'Run Rubocop on the gem'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task default: [:spec, :rubocop, :build, :install]
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'herokuconf'
3
+ s.version = '0.0.1'
4
+ s.date = Time.now.strftime('%Y-%m-%d')
5
+
6
+ s.summary = 'Configure local environment based on Heroku config variables'
7
+ s.description = "Configure local environment based on Heroku config variables"
8
+ s.authors = ['Les Aker']
9
+ s.email = 'me@lesaker.org'
10
+ s.homepage = 'https://github.com/akerl/herokuconf'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files`.split
14
+ s.test_files = `git ls-files spec/*`.split
15
+
16
+ s.add_dependency 'netrc', '~> 0.10.2'
17
+ s.add_dependency 'heroku-api', '~> 0.3.22'
18
+
19
+ s.add_development_dependency 'rubocop', '~> 0.28.0'
20
+ s.add_development_dependency 'rake', '~> 10.4.0'
21
+ s.add_development_dependency 'coveralls', '~> 0.7.1'
22
+ s.add_development_dependency 'rspec', '~> 3.1.0'
23
+ s.add_development_dependency 'fuubar', '~> 2.0.0'
24
+ end
@@ -0,0 +1,51 @@
1
+ require 'netrc'
2
+ require 'heroku-api'
3
+
4
+ module HerokuConf
5
+ ##
6
+ # App object for parsing Heroku configs
7
+ class App
8
+ def initialize(params = {})
9
+ @app = params[:app]
10
+ end
11
+
12
+ def configure!(keys = nil)
13
+ pairs = config_vars
14
+ pairs.select! { |k, _| keys.include? k } if keys
15
+ pairs.each { |k, v| ENV[k] = v }
16
+ end
17
+
18
+ private
19
+
20
+ def config_vars
21
+ client.get_config_vars(app).body
22
+ end
23
+
24
+ def app
25
+ @app ||= parse_app
26
+ end
27
+
28
+ def parse_app
29
+ remotes.first[1].split('/').last.split('.').first
30
+ end
31
+
32
+ def remotes
33
+ @remote ||= parse_remotes
34
+ end
35
+
36
+ def parse_remotes
37
+ remotes = `git remote -v`.split("\n").map(&:split)
38
+ remotes.select! { |x| x.first == 'heroku' && x.last == '(push)' }
39
+ fail('No app found') unless remotes.size == 1
40
+ remotes
41
+ end
42
+
43
+ def client
44
+ @client ||= Heroku::API.new(api_key: api_key)
45
+ end
46
+
47
+ def api_key
48
+ @api_key ||= Netrc.read['api.heroku.com'].password
49
+ end
50
+ end
51
+ end
data/lib/herokuconf.rb ADDED
@@ -0,0 +1,13 @@
1
+ ##
2
+ # Base module for HerokuConf
3
+ module HerokuConf
4
+ class << self
5
+ ##
6
+ # Insert a helper .new() method for creating a new App object
7
+ def new(*args)
8
+ self::App.new(*args)
9
+ end
10
+ end
11
+ end
12
+
13
+ require 'herokuconf/app'
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ end
8
+
9
+ require 'rspec'
10
+ require 'herokuconf'
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: herokuconf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Les Aker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: netrc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: heroku-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.22
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.22
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.28.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.28.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 10.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 10.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: fuubar
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.0
111
+ description: Configure local environment based on Heroku config variables
112
+ email: me@lesaker.org
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - ".rubocop.yml"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - herokuconf.gemspec
126
+ - lib/herokuconf.rb
127
+ - lib/herokuconf/app.rb
128
+ - spec/herokuconf_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/akerl/herokuconf
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.5
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Configure local environment based on Heroku config variables
154
+ test_files:
155
+ - spec/herokuconf_spec.rb
156
+ - spec/spec_helper.rb