envyous 1.0.0.alpha.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 +15 -0
- data/lib/envyous.rb +2 -0
- data/lib/envyous/core.rb +95 -0
- data/lib/envyous/rake.rb +1 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWRjZDYzYTk5ZjUyNWUxZDI4OTliMjc0OTFjOTVlNGU5MTQ4OTk0ZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTg3MmQ1MDRhM2ZiMmQ0MzcxOTQ4OGYzZjM2N2Y2ZTdlNDcxZGRlMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTQyYzZkZjY5NDBiYmE0ZmIzNDVmMGY1NDY4OTdhMTNiYTA4OTQ5NjkyZDE3
|
10
|
+
N2M1YmZlYzIxM2JlMjkyNzQ2YzIwMzc2MTA5MzZiMWRlZmJkYmRkY2JhYzQ4
|
11
|
+
MGQ1MDc5M2YyYTEwYzNmYmQwNTNhMGFmNGUxYjk3ZmM3M2RhMWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjgyZjMwMGY5ZTdmMjVhNTdmM2VlYTFkNTc3YTc4NmQ3NjMwZjI5YzhiYmJh
|
14
|
+
NTY1NDRlOTMxNDFiYTEzZDAyNGVkMTk1YzgxNGZjZjNhNmNlMjQyMTcwNTgy
|
15
|
+
ODM1YTFlOWNjZGYwYjVkOGZhZGJmOTBlZTFhZTBiNWY3YTU4MTU=
|
data/lib/envyous.rb
ADDED
data/lib/envyous/core.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
require 'confickle'
|
3
|
+
|
4
|
+
module Envyous
|
5
|
+
class EnvironmentNotSpecified < Exception
|
6
|
+
end
|
7
|
+
|
8
|
+
class EnvironmentNameIsEmpty < Exception
|
9
|
+
end
|
10
|
+
|
11
|
+
class EnvironmentRootDoesNotExist < Exception
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.config(options)
|
15
|
+
c = Context.new(options)
|
16
|
+
|
17
|
+
retval = c.confickle
|
18
|
+
|
19
|
+
unless File.exists?(retval.root)
|
20
|
+
raise EnvironmentRootDoesNotExist.new(retval.root)
|
21
|
+
end
|
22
|
+
|
23
|
+
retval
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
class Context
|
28
|
+
|
29
|
+
# The root config folder. Contains the
|
30
|
+
# config folders for all environments.
|
31
|
+
attr_reader :root
|
32
|
+
|
33
|
+
# Name of the environment variable that will
|
34
|
+
# be used as the environment switch.
|
35
|
+
#
|
36
|
+
# Default value: 'ENV'
|
37
|
+
#
|
38
|
+
attr_reader :env_var
|
39
|
+
|
40
|
+
|
41
|
+
# Options that will be passed to confickle.
|
42
|
+
# Note: Envyous will override the :root option.
|
43
|
+
attr_reader :confickle_opts
|
44
|
+
|
45
|
+
def initialize(options)
|
46
|
+
if options.is_a? String
|
47
|
+
options = {root: options}
|
48
|
+
end
|
49
|
+
|
50
|
+
@root = options.fetch(:root)
|
51
|
+
@env_var = options.fetch(:env_var, 'ENV').to_s
|
52
|
+
@confickle_opts = options.fetch(:confickle_opts, {})
|
53
|
+
end
|
54
|
+
|
55
|
+
def envyous_opts
|
56
|
+
@envyous_opts ||= begin
|
57
|
+
File.open(File.join(root, "envyous.json")) do |fin|
|
58
|
+
JSON.parse(fin.read, symbolize_names: true)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
def env_name
|
66
|
+
@env_name ||= begin
|
67
|
+
name = ENV.fetch(env_var) do
|
68
|
+
envyous_opts.fetch(:env) do
|
69
|
+
raise EnvironmentNotSpecified
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if name.empty?
|
74
|
+
raise EnvironmentNameIsEmpty
|
75
|
+
end
|
76
|
+
|
77
|
+
name
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def confickle_root
|
83
|
+
@confickle_root ||= File.join(root, "environments", env_name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def confickle
|
87
|
+
opts = confickle_opts.merge(
|
88
|
+
root: confickle_root
|
89
|
+
)
|
90
|
+
|
91
|
+
Confickle.new(opts)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/lib/envyous/rake.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: envyous
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lauber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: confickle
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Environmentally-friendly config!
|
42
|
+
email: constructible.truth@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/envyous/core.rb
|
48
|
+
- lib/envyous/rake.rb
|
49
|
+
- lib/envyous.rb
|
50
|
+
homepage:
|
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: 1.3.1
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.1.11
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Environmentally-friendly config!
|
74
|
+
test_files: []
|