envvy 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/envvy.rb +1 -13
- data/lib/envvy/engine.rb +59 -3
- data/lib/envvy/js.rb +1 -1
- data/lib/envvy/version.rb +1 -1
- data/test/dummy_app/config/environments/development.rb +0 -3
- metadata +2 -4
- data/envvy-1.0.3.gem +0 -0
- data/lib/envvy/railtie.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3fa08ec3c434f18e06a89d6c8a9d59d53170f6b
|
4
|
+
data.tar.gz: a30f7891b0b24938d6969af9f33e5b8c076b9f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4647ef7630bae61bb21709317f24611e0215c36b63adc5f46d817764dd6d49697cf9c467e03d2d6c5bd31c83d93349107354df7b4a5fb9cfe1e75bb6b953ba84
|
7
|
+
data.tar.gz: d6b7ed27ae08359dc4ce33a15fbc5e6af38d15883ccdaef949901628c28a0b8e004216d440c3b11f2da7572af79f81cc994e55c42d12965b75ee367cdd7d177b
|
data/.gitignore
CHANGED
data/lib/envvy.rb
CHANGED
@@ -1,19 +1,7 @@
|
|
1
1
|
require "envvy/version"
|
2
|
-
require "envvy/railtie"
|
3
2
|
require "envvy/js"
|
3
|
+
require "envvy/engine"
|
4
4
|
|
5
5
|
module Envvy
|
6
|
-
class << self
|
7
6
|
|
8
|
-
def register_engine
|
9
|
-
require "envvy/engine"
|
10
|
-
end
|
11
|
-
|
12
|
-
def get arg
|
13
|
-
Railtie.get arg
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
Envvy.register_engine
|
19
7
|
end
|
data/lib/envvy/engine.rb
CHANGED
@@ -1,10 +1,66 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Envvy
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
attr_accessor :env
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :config_path
|
2
9
|
|
3
|
-
|
4
|
-
|
10
|
+
def config_path
|
11
|
+
@config_path || File.join(Rails.root, "config", "env_vars.yml")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
initializer "env-loader.precompile" do |app|
|
5
16
|
app.config.assets.paths << root.join('assets', 'javascripts').to_s
|
6
17
|
end
|
7
|
-
end
|
8
18
|
|
19
|
+
initializer "envvy.register_preprocessor", :after => "sprockets.environment" do
|
20
|
+
Rails.application.assets.register_preprocessor "application/javascript", :"js_env" do |context, source|
|
21
|
+
if context.logical_path == "js_env" && File.exist?(self.class.config_path)
|
22
|
+
context.depend_on(File.expand_path(self.class.config_path))
|
23
|
+
end
|
24
|
+
source
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
config.before_initialize do
|
29
|
+
self.get("config") do |config|
|
30
|
+
config.each do |k, v|
|
31
|
+
ENV[k.to_s.upcase] ||= v
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
config.before_configuration do
|
9
37
|
|
38
|
+
set_env self.config_path
|
39
|
+
|
40
|
+
if Rails.env.development?
|
41
|
+
require 'filewatch/watch'
|
42
|
+
conf_watcher = FileWatch::Watch.new
|
43
|
+
conf_watcher.watch(self.config_path)
|
44
|
+
|
45
|
+
Thread.new do
|
46
|
+
conf_watcher.subscribe(1,5) do |_status, path|
|
47
|
+
set_env path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_env file
|
54
|
+
self.env = {"js_config" => {}, "config" => {}}
|
55
|
+
self.env.merge! YAML.load(File.read(file)) if File.exist?(file)
|
56
|
+
end
|
57
|
+
|
58
|
+
def get(key, &block)
|
59
|
+
if block_given?
|
60
|
+
yield self.env[key]
|
61
|
+
else
|
62
|
+
return self.env[key]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
10
66
|
end
|
data/lib/envvy/js.rb
CHANGED
data/lib/envvy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: envvy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Balaine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -139,12 +139,10 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- app/assets/javascripts/js_env.js.erb
|
142
|
-
- envvy-1.0.3.gem
|
143
142
|
- envvy.gemspec
|
144
143
|
- lib/envvy.rb
|
145
144
|
- lib/envvy/engine.rb
|
146
145
|
- lib/envvy/js.rb
|
147
|
-
- lib/envvy/railtie.rb
|
148
146
|
- lib/envvy/version.rb
|
149
147
|
- test/compilation/js_test.rb
|
150
148
|
- test/dummy_app/Rakefile
|
data/envvy-1.0.3.gem
DELETED
Binary file
|
data/lib/envvy/railtie.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Envvy
|
4
|
-
class Railtie < Rails::Railtie
|
5
|
-
attr_accessor :env
|
6
|
-
|
7
|
-
class << self
|
8
|
-
attr_accessor :config_path
|
9
|
-
|
10
|
-
def config_path
|
11
|
-
@config_path || File.join(Rails.root, "config", "env_vars.yml")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
config.before_initialize do
|
16
|
-
self.get("config") do |config|
|
17
|
-
config.each do |k, v|
|
18
|
-
ENV[k.to_s.upcase] = v
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
config.before_configuration do
|
24
|
-
|
25
|
-
set_env self.config_path
|
26
|
-
|
27
|
-
if Rails.env.development?
|
28
|
-
require 'filewatch/watch'
|
29
|
-
conf_watcher = FileWatch::Watch.new
|
30
|
-
conf_watcher.watch(self.config_path)
|
31
|
-
|
32
|
-
Thread.new do
|
33
|
-
conf_watcher.subscribe(1,5) do |status, path|
|
34
|
-
set_env path
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_env file
|
41
|
-
self.env = if File.exist?(file) then YAML.load(File.read(file)) else {"js_config" => {}, "config" => {}} end
|
42
|
-
end
|
43
|
-
|
44
|
-
def get(key, &block)
|
45
|
-
if block_given?
|
46
|
-
yield self.env[key]
|
47
|
-
else
|
48
|
-
return self.env[key]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|