global 0.2.2 → 2.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 +5 -5
- data/.github/workflows/tests.yml +24 -0
- data/.rubocop.yml +110 -0
- data/.ruby-version +1 -1
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -6
- data/README.md +275 -66
- data/Rakefile +10 -2
- data/bin/console +15 -0
- data/global.gemspec +20 -22
- data/lib/global/backend/aws_parameter_store.rb +110 -0
- data/lib/global/backend/filesystem.rb +91 -0
- data/lib/global/backend/gcp_secret_manager.rb +137 -0
- data/lib/global/base.rb +40 -60
- data/lib/global/configuration.rb +25 -18
- data/lib/global/version.rb +4 -2
- data/lib/global.rb +5 -2
- data/spec/files/aws.test.yml +3 -0
- data/spec/files/aws.yml +6 -0
- data/spec/global/backend/aws_parameter_store_spec.rb +48 -0
- data/spec/global/backend/gcp_secret_manager_spec.rb +39 -0
- data/spec/global/configuration_spec.rb +88 -74
- data/spec/global_spec.rb +53 -70
- data/spec/merge_backends_spec.rb +23 -0
- data/spec/spec_helper.rb +9 -6
- metadata +68 -30
- data/.travis.yml +0 -30
- data/app/assets/javascripts/global-js.js.erb +0 -2
- data/lib/global/engine.rb +0 -78
- data/spec/global/global_js_spec.rb +0 -114
- data/spec/support/javascript_helper.rb +0 -24
metadata
CHANGED
@@ -1,71 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Railsware LLC
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: aws-sdk-ssm
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: google-cloud-secret_manager
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.81.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.81.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.16.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.16.1
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: activesupport
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,41 +108,49 @@ dependencies:
|
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '2.0'
|
83
|
-
description: Simple way to load your configs from yaml
|
111
|
+
description: Simple way to load your configs from yaml/aws/gcp
|
84
112
|
email: contact@railsware.com
|
85
|
-
executables:
|
113
|
+
executables:
|
114
|
+
- console
|
86
115
|
extensions: []
|
87
116
|
extra_rdoc_files: []
|
88
117
|
files:
|
118
|
+
- ".github/workflows/tests.yml"
|
89
119
|
- ".gitignore"
|
90
120
|
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
91
122
|
- ".ruby-version"
|
92
|
-
-
|
123
|
+
- CODE_OF_CONDUCT.md
|
93
124
|
- Gemfile
|
94
125
|
- LICENSE.txt
|
95
126
|
- README.md
|
96
127
|
- Rakefile
|
97
|
-
-
|
128
|
+
- bin/console
|
98
129
|
- global.gemspec
|
99
130
|
- lib/global.rb
|
131
|
+
- lib/global/backend/aws_parameter_store.rb
|
132
|
+
- lib/global/backend/filesystem.rb
|
133
|
+
- lib/global/backend/gcp_secret_manager.rb
|
100
134
|
- lib/global/base.rb
|
101
135
|
- lib/global/configuration.rb
|
102
|
-
- lib/global/engine.rb
|
103
136
|
- lib/global/version.rb
|
137
|
+
- spec/files/aws.test.yml
|
138
|
+
- spec/files/aws.yml
|
104
139
|
- spec/files/bool_config.yml
|
105
140
|
- spec/files/nested_config.yml
|
106
141
|
- spec/files/rspec/config.yml
|
107
142
|
- spec/files/rspec_config.yml
|
143
|
+
- spec/global/backend/aws_parameter_store_spec.rb
|
144
|
+
- spec/global/backend/gcp_secret_manager_spec.rb
|
108
145
|
- spec/global/configuration_spec.rb
|
109
|
-
- spec/global/global_js_spec.rb
|
110
146
|
- spec/global_spec.rb
|
147
|
+
- spec/merge_backends_spec.rb
|
111
148
|
- spec/spec_helper.rb
|
112
|
-
- spec/support/javascript_helper.rb
|
113
149
|
homepage: https://github.com/railsware/global
|
114
150
|
licenses:
|
115
151
|
- MIT
|
116
152
|
metadata: {}
|
117
|
-
post_install_message:
|
153
|
+
post_install_message:
|
118
154
|
rdoc_options: []
|
119
155
|
require_paths:
|
120
156
|
- lib
|
@@ -129,18 +165,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
165
|
- !ruby/object:Gem::Version
|
130
166
|
version: '0'
|
131
167
|
requirements: []
|
132
|
-
|
133
|
-
|
134
|
-
signing_key:
|
168
|
+
rubygems_version: 3.0.3
|
169
|
+
signing_key:
|
135
170
|
specification_version: 4
|
136
|
-
summary: Simple way to load your configs from yaml
|
171
|
+
summary: Simple way to load your configs from yaml/aws/gcp
|
137
172
|
test_files:
|
173
|
+
- spec/files/aws.test.yml
|
174
|
+
- spec/files/aws.yml
|
138
175
|
- spec/files/bool_config.yml
|
139
176
|
- spec/files/nested_config.yml
|
140
177
|
- spec/files/rspec/config.yml
|
141
178
|
- spec/files/rspec_config.yml
|
179
|
+
- spec/global/backend/aws_parameter_store_spec.rb
|
180
|
+
- spec/global/backend/gcp_secret_manager_spec.rb
|
142
181
|
- spec/global/configuration_spec.rb
|
143
|
-
- spec/global/global_js_spec.rb
|
144
182
|
- spec/global_spec.rb
|
183
|
+
- spec/merge_backends_spec.rb
|
145
184
|
- spec/spec_helper.rb
|
146
|
-
- spec/support/javascript_helper.rb
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
cache:
|
4
|
-
bundler: true
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.0
|
8
|
-
- 2.1
|
9
|
-
- 2.2
|
10
|
-
- 2.3.3
|
11
|
-
- 2.4.2
|
12
|
-
- 2.5.0
|
13
|
-
- jruby-19mode
|
14
|
-
- ruby-head
|
15
|
-
- jruby-head
|
16
|
-
|
17
|
-
notifications:
|
18
|
-
email: false
|
19
|
-
|
20
|
-
sudo: false
|
21
|
-
|
22
|
-
branches:
|
23
|
-
only:
|
24
|
-
- master
|
25
|
-
- development
|
26
|
-
|
27
|
-
matrix:
|
28
|
-
allow_failures:
|
29
|
-
- rvm: ruby-head
|
30
|
-
- rvm: jruby-head
|
data/lib/global/engine.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Global
|
3
|
-
class SprocketsExtension
|
4
|
-
GLOBAL_JS_ASSET = 'global-js'
|
5
|
-
|
6
|
-
def initialize(filename, &block)
|
7
|
-
@filename = filename
|
8
|
-
@source = block.call
|
9
|
-
end
|
10
|
-
|
11
|
-
def render(context, empty_hash_wtf)
|
12
|
-
self.class.run(@filename, @source, context)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.run(filename, source, context)
|
16
|
-
if GLOBAL_JS_ASSET == context.logical_path
|
17
|
-
configs = Dir.glob("#{Global.config_directory}#{File::SEPARATOR}*.yml")
|
18
|
-
configs.map{ |config| context.depend_on(config) }
|
19
|
-
end
|
20
|
-
source
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.call(input)
|
24
|
-
filename = input[:filename]
|
25
|
-
source = input[:data]
|
26
|
-
context = input[:environment].context_class.new(input)
|
27
|
-
|
28
|
-
result = run(filename, source, context)
|
29
|
-
context.metadata.merge(data: result)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
class Engine < ::Rails::Engine
|
35
|
-
require 'sprockets/version'
|
36
|
-
v2 = Gem::Dependency.new('', ' ~> 2')
|
37
|
-
vgte3 = Gem::Dependency.new('', ' >= 3')
|
38
|
-
sprockets_version = Gem::Version.new(::Sprockets::VERSION).release
|
39
|
-
initializer_args = case sprockets_version
|
40
|
-
when -> (v) { v2.match?('', v) }
|
41
|
-
{ after: "sprockets.environment" }
|
42
|
-
when -> (v) { vgte3.match?('', v) }
|
43
|
-
{ after: :engines_blank_point, before: :finisher_hook }
|
44
|
-
else
|
45
|
-
raise StandardError, "Sprockets version #{sprockets_version} is not supported"
|
46
|
-
end
|
47
|
-
|
48
|
-
is_running_rails = defined?(Rails) && Rails.respond_to?(:version)
|
49
|
-
is_running_rails_32 = is_running_rails && Rails.version.match(/3\.2/)
|
50
|
-
|
51
|
-
initializer 'global-js.dependent_on_configs', initializer_args do
|
52
|
-
case sprockets_version
|
53
|
-
when -> (v) { v2.match?('', v) },
|
54
|
-
-> (v) { vgte3.match?('', v) }
|
55
|
-
|
56
|
-
# It seems rails 3.2 is not working if
|
57
|
-
# `Rails.application.config.assets.configure` is used for
|
58
|
-
# registering preprocessor
|
59
|
-
if is_running_rails_32
|
60
|
-
Rails.application.assets.register_preprocessor(
|
61
|
-
"application/javascript",
|
62
|
-
SprocketsExtension
|
63
|
-
)
|
64
|
-
elsif Rails.application.config.respond_to?(:assets)
|
65
|
-
# Other rails version, assumed newer
|
66
|
-
Rails.application.config.assets.configure do |config|
|
67
|
-
config.register_preprocessor(
|
68
|
-
"application/javascript",
|
69
|
-
SprocketsExtension
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
else
|
74
|
-
raise StandardError, "Sprockets version #{sprockets_version} is not supported"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Global, "generate js in Rails" do
|
4
|
-
before do
|
5
|
-
evaljs("var window = this;", true)
|
6
|
-
jscontext[:log] = lambda {|context, value| puts value.inspect}
|
7
|
-
|
8
|
-
described_class.configure do |config|
|
9
|
-
config.environment = "test"
|
10
|
-
config.config_directory = File.join(Dir.pwd, "spec/files")
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'simple generate' do
|
16
|
-
before do
|
17
|
-
described_class.configure do |config|
|
18
|
-
config.namespace = 'Global'
|
19
|
-
config.except = :all
|
20
|
-
config.only = :all
|
21
|
-
end
|
22
|
-
evaljs(described_class.generate_js)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should generate valid global config" do
|
26
|
-
expect(evaljs("Global.rspec_config.default_value")).to eq('default value')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should generate valid global config for array" do
|
30
|
-
expect(evaljs("Global.nested_config.some_array_value.length")).to eq(3)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should generate valid global config for array, first element" do
|
34
|
-
expect(evaljs("Global.nested_config.some_array_value[0]")).to eq("First")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should generate valid global config for array, last element" do
|
38
|
-
expect(evaljs("Global.nested_config.some_array_value[2]")).to eq("Third")
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'custom namespace' do
|
44
|
-
before do
|
45
|
-
described_class.configure do |config|
|
46
|
-
config.namespace = 'CustomGlobal'
|
47
|
-
config.except = :all
|
48
|
-
config.only = :all
|
49
|
-
end
|
50
|
-
evaljs(described_class.generate_js)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should generate valid global config" do
|
54
|
-
expect(evaljs("CustomGlobal.rspec_config.default_value")).to eq('default value')
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'custom namespace from function' do
|
60
|
-
before do
|
61
|
-
evaljs(described_class.generate_js(namespace: 'CustomGlobalNamespace', only: :all))
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should generate valid global config" do
|
65
|
-
expect(evaljs("CustomGlobalNamespace.rspec_config.default_value")).to eq('default value')
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'only select' do
|
71
|
-
before do
|
72
|
-
described_class.configure do |config|
|
73
|
-
config.namespace = 'Global'
|
74
|
-
config.except = :all
|
75
|
-
config.only = [:bool_config]
|
76
|
-
end
|
77
|
-
|
78
|
-
evaljs(described_class.generate_js)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should generate visible global config" do
|
82
|
-
expect(evaljs("Global.bool_config.works")).to eq(true)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should have not some keys in js" do
|
86
|
-
expect(evaljs("Global.nested_config")).to be_nil
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'except select' do
|
92
|
-
before do
|
93
|
-
described_class.configure do |config|
|
94
|
-
config.namespace = 'Global'
|
95
|
-
config.except = [:nested_config]
|
96
|
-
config.only = []
|
97
|
-
end
|
98
|
-
evaljs(described_class.generate_js)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should generate visible global config with bool_config" do
|
102
|
-
expect(evaljs("Global.bool_config.works")).to eq(true)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should generate visible global config with rspec_config" do
|
106
|
-
expect(evaljs("Global.rspec_config.default_value")).to eq('default value')
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should have not some keys in js" do
|
110
|
-
expect(evaljs("Global.nested_config")).to be_nil
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
if defined?(JRUBY_VERSION)
|
2
|
-
require 'rhino'
|
3
|
-
JS_LIB_CLASS = Rhino
|
4
|
-
else
|
5
|
-
require 'v8'
|
6
|
-
JS_LIB_CLASS = V8
|
7
|
-
end
|
8
|
-
|
9
|
-
module JavascriptHelper
|
10
|
-
def evaljs(string, force = false)
|
11
|
-
jscontext(force).eval(string)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def jscontext(force = false)
|
17
|
-
if force
|
18
|
-
@jscontext = JS_LIB_CLASS::Context.new
|
19
|
-
else
|
20
|
-
@jscontext ||= JS_LIB_CLASS::Context.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|