chorizo 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 +7 -0
- data/bin/chorizo +36 -0
- data/lib/chorizo.rb +60 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8eb4c89b6ba351bda5b63a3ae008412252c7b0ca
|
4
|
+
data.tar.gz: f90ae9235b1f66a627cf5f18c75dad3706b412fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d846874c589fd2e70a92086bcb7121e1d349b1ee39c41a0ee162eedaf1541a790946abb5f2b6c49b8cbd76e7707ab780816900dd380d4b5a45a564bbb0b758e
|
7
|
+
data.tar.gz: 00535e0aba34d357008f36698c9ddc12119fd742e7e9811182a116d72b058661e319fd771569f8027c11c587d96bbcf2b5c084bbaccc9f308875ebfc5c96d3f9
|
data/bin/chorizo
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'chorizo'
|
4
|
+
require 'slop'
|
5
|
+
require 'colorize'
|
6
|
+
|
7
|
+
opts = Slop.parse(help: true) do
|
8
|
+
banner 'Usage: chorizo [options]'
|
9
|
+
|
10
|
+
on :t, :target, 'target host. one of "cloud66" or "heroku"', argument: true
|
11
|
+
on :e, :environment, 'environment. e.x. "staging"', argument: true
|
12
|
+
on :a, :app, 'app. (for heroku only)', argument: :optional
|
13
|
+
end
|
14
|
+
|
15
|
+
unless opts[:environment]
|
16
|
+
STDERR.puts "please specify an environment".red
|
17
|
+
puts opts
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
if opts[:target] == 'heroku' && !opts[:app]
|
22
|
+
STDERR.puts "please specify an app for heroku".red
|
23
|
+
puts opts
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
|
27
|
+
case opts[:target]
|
28
|
+
when 'cloud66'
|
29
|
+
Chorizo.new.cloud66 opts[:environment]
|
30
|
+
when 'heroku'
|
31
|
+
Chorizo.new.heroku(opts[:environment], opts[:app])
|
32
|
+
else
|
33
|
+
STDERR.puts "please specify a valid target".red
|
34
|
+
puts opts
|
35
|
+
exit 1
|
36
|
+
end
|
data/lib/chorizo.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Chorizo
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@host_names = %w(cloud66 heroku)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_config
|
10
|
+
yml = YAML.load_file('./config/application.yml')
|
11
|
+
hashes, base = yml.partition { |k,v| v.is_a?(Hash) }
|
12
|
+
hashes = hashes.to_h
|
13
|
+
base = base.to_h
|
14
|
+
hosts = {}
|
15
|
+
@host_names.each do |host|
|
16
|
+
hosts[host] = hashes.delete(host) if hashes[host]
|
17
|
+
end
|
18
|
+
{ base: base, hosts: hosts, envs: hashes }
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_output(env, host)
|
22
|
+
configs = load_config
|
23
|
+
output = configs[:base]
|
24
|
+
|
25
|
+
# load environment config
|
26
|
+
if configs[:envs][env]
|
27
|
+
output.merge! configs[:envs][env]
|
28
|
+
else
|
29
|
+
STDERR.puts "WARNING: #{env} specific configuration not found".red
|
30
|
+
end
|
31
|
+
|
32
|
+
# load host config
|
33
|
+
if configs[:hosts][host]
|
34
|
+
hc = configs[:hosts][host]
|
35
|
+
# load embedded env config in host config, if present
|
36
|
+
hc_envs, hc_base = hc.partition { |k,v| v.is_a?(Hash) }
|
37
|
+
hc_env = hc_envs.to_h[env]
|
38
|
+
hc_output = hc_base.to_h
|
39
|
+
hc_output.merge! hc_env if hc_env
|
40
|
+
|
41
|
+
output.merge! hc_output
|
42
|
+
else
|
43
|
+
STDERR.puts "WARNING: #{host} specific configuration not found".red
|
44
|
+
end
|
45
|
+
|
46
|
+
output
|
47
|
+
end
|
48
|
+
|
49
|
+
def cloud66(env)
|
50
|
+
output = build_output(env, 'cloud66')
|
51
|
+
output.each { |k,v| puts "#{k.upcase}=#{v}" }
|
52
|
+
end
|
53
|
+
|
54
|
+
def heroku(env, app)
|
55
|
+
output = build_output(env, 'heroku')
|
56
|
+
cmd_output = output.map { |k,v| "#{k}='#{v}'" }.join(' ')
|
57
|
+
system "heroku config:set #{cmd_output} -a #{app}"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chorizo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Arnold
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.6'
|
41
|
+
description: Parse and set environment variables on hosting providers
|
42
|
+
email: dan@cacheventures.com
|
43
|
+
executables:
|
44
|
+
- chorizo
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bin/chorizo
|
49
|
+
- lib/chorizo.rb
|
50
|
+
homepage: http://rubygems.org/gems/chorizo
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.4.8
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Parse and set environment variables on hosting providers
|
74
|
+
test_files: []
|