herokuconf 0.0.1 → 0.0.6
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 +4 -4
- data/herokuconf.gemspec +1 -1
- data/lib/herokuconf.rb +40 -6
- metadata +1 -2
- data/lib/herokuconf/app.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 898c4fd09b882a3e199aa0b05eb8d3ecaf42e385
|
4
|
+
data.tar.gz: 867acce0a8ca10a653e8a6e28024ef03c232c803
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ad6fa33a8535b5b2e4c18cc747b623c2199b319e3d37732fa2455d16a0ad5f6ea9be5509ec7689b30fefb6e6d4d5ee7d688cde96ffa35c798d575957a6a4e6c
|
7
|
+
data.tar.gz: 982da23a89c50aa2df008fd27b9b1f938279d09182a973ff48427f962259e624eb28b33e73d1c209e139a2ae2f4f0976bf9bcac5b078b81640cba43edd7ec0b3
|
data/herokuconf.gemspec
CHANGED
data/lib/herokuconf.rb
CHANGED
@@ -1,13 +1,47 @@
|
|
1
|
+
require 'heroku-api'
|
2
|
+
require 'netrc'
|
3
|
+
|
1
4
|
##
|
2
5
|
# Base module for HerokuConf
|
3
6
|
module HerokuConf
|
4
7
|
class << self
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
DEFAULT_OPTIONS = {
|
9
|
+
app: nil,
|
10
|
+
keys: nil
|
11
|
+
}
|
12
|
+
|
13
|
+
def configure!(params = {})
|
14
|
+
return if ENV['DYNO']
|
15
|
+
app, keys = DEFAULT_OPTIONS.dup.merge!(params).values_at(:app, :keys)
|
16
|
+
pairs = config_vars(app)
|
17
|
+
pairs.select! { |k, _| keys.include? k } if keys
|
18
|
+
pairs.each { |k, v| ENV[k] = v }
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def config_vars(app = nil)
|
24
|
+
app ||= parse_app
|
25
|
+
client.get_config_vars(app).body
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_app
|
29
|
+
remotes.first[1].split('/').last.split('.').first
|
30
|
+
end
|
31
|
+
|
32
|
+
def remotes
|
33
|
+
remotes = `git remote -v`.split("\n").map(&:split)
|
34
|
+
remotes.select! { |x| x.first == 'heroku' && x.last == '(push)' }
|
35
|
+
fail('No app found') unless remotes.size == 1
|
36
|
+
remotes
|
37
|
+
end
|
38
|
+
|
39
|
+
def client
|
40
|
+
@client ||= Heroku::API.new(api_key: api_key)
|
41
|
+
end
|
42
|
+
|
43
|
+
def api_key
|
44
|
+
@api_key ||= Netrc.read['api.heroku.com'].password
|
9
45
|
end
|
10
46
|
end
|
11
47
|
end
|
12
|
-
|
13
|
-
require 'herokuconf/app'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herokuconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
@@ -124,7 +124,6 @@ files:
|
|
124
124
|
- Rakefile
|
125
125
|
- herokuconf.gemspec
|
126
126
|
- lib/herokuconf.rb
|
127
|
-
- lib/herokuconf/app.rb
|
128
127
|
- spec/herokuconf_spec.rb
|
129
128
|
- spec/spec_helper.rb
|
130
129
|
homepage: https://github.com/akerl/herokuconf
|
data/lib/herokuconf/app.rb
DELETED
@@ -1,51 +0,0 @@
|
|
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
|