ruby-remote-config 0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.idea/.gitignore +8 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/ruby-remote-config.iml +146 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +182 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +50 -0
- data/lib/file_repository.rb +34 -0
- data/lib/gcp_storage_repository.rb +42 -0
- data/lib/repository.rb +29 -0
- data/lib/ruby_remote_config.rb +44 -0
- data/lib/web_repository.rb +37 -0
- data/spec/file_repository_spec.rb +42 -0
- data/spec/gcp_storage_repository_spec.rb +47 -0
- data/spec/ruby_remote_config_spec.rb +14 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/test.yaml +2 -0
- data/spec/web_repository_spec.rb +75 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 218bc6b45534d1be0e739ef91be83cb07c8d9e3719400e257b79a35e6ea9054a
|
4
|
+
data.tar.gz: c12fe18ef627610dd86355bba639b69fea33b5f31015523fee9b040149167688
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac119e509c4c704a4bcb01ea7720e150a55805450b90c745924c4aa05a3c60fa960845f7115102b4462aab9d268a5f4503f9c4c671d508744a8c0e8df23b761f
|
7
|
+
data.tar.gz: 297a2cc4f7cb01fa4d67f65577a06af3ee16d7754bb203a3e3430c4a035784f4e04650299f4d4cb44d615d79c684531dbf613db9a0ce0877eed587fcadcf3d55
|
data/.document
ADDED
data/.idea/.gitignore
ADDED
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/ruby-remote-config.iml" filepath="$PROJECT_DIR$/.idea/ruby-remote-config.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
@@ -0,0 +1,146 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="jdk" jdkName="RVM: ruby-3.0.4" jdkType="RUBY_SDK" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.33, RVM: ruby-3.0.4) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.2.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="declarative (v0.0.20, RVM: ruby-3.0.4) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="descendants_tracker (v0.0.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="digest-crc (v0.6.5, RVM: ruby-3.0.4) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday (v1.10.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-em_http (v1.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-em_synchrony (v1.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-excon (v1.1.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-httpclient (v1.0.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-multipart (v1.0.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-net_http (v1.0.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-net_http_persistent (v1.2.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-patron (v1.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-rack (v1.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="faraday-retry (v1.0.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="git (v1.18.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="github_api (v0.19.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="google-apis-core (v0.11.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="google-apis-iamcredentials_v1 (v0.17.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="google-apis-storage_v1 (v0.19.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="google-cloud-core (v1.6.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="google-cloud-env (v1.6.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="google-cloud-errors (v1.3.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="google-cloud-storage (v1.44.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="googleauth (v1.7.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="hashie (v3.6.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="highline (v2.1.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="httpclient (v2.8.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="juwelier (v2.1.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="jwt (v2.7.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
52
|
+
<orderEntry type="library" scope="PROVIDED" name="memoist (v0.16.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.1.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.19.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.15.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
57
|
+
<orderEntry type="library" scope="PROVIDED" name="multipart-post (v2.3.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
58
|
+
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.15.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
59
|
+
<orderEntry type="library" scope="PROVIDED" name="oauth2 (v1.4.11, RVM: ruby-3.0.4) [gem]" level="application" />
|
60
|
+
<orderEntry type="library" scope="PROVIDED" name="os (v1.1.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
61
|
+
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
62
|
+
<orderEntry type="library" scope="PROVIDED" name="racc (v1.7.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
63
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v3.0.8, RVM: ruby-3.0.4) [gem]" level="application" />
|
64
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
65
|
+
<orderEntry type="library" scope="PROVIDED" name="rchardet (v1.8.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
66
|
+
<orderEntry type="library" scope="PROVIDED" name="rdoc (v3.12.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
67
|
+
<orderEntry type="library" scope="PROVIDED" name="representable (v3.2.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
68
|
+
<orderEntry type="library" scope="PROVIDED" name="retriable (v3.1.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
69
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
70
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
71
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
72
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
73
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
74
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
75
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby2_keywords (v0.0.5, RVM: ruby-3.0.4) [gem]" level="application" />
|
76
|
+
<orderEntry type="library" scope="PROVIDED" name="semver (v1.0.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
77
|
+
<orderEntry type="library" scope="PROVIDED" name="shoulda (v4.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
78
|
+
<orderEntry type="library" scope="PROVIDED" name="shoulda-context (v2.0.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
79
|
+
<orderEntry type="library" scope="PROVIDED" name="shoulda-matchers (v4.5.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
80
|
+
<orderEntry type="library" scope="PROVIDED" name="signet (v0.17.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
81
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.22.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
82
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-3.0.4) [gem]" level="application" />
|
83
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-3.0.4) [gem]" level="application" />
|
84
|
+
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
85
|
+
<orderEntry type="library" scope="PROVIDED" name="trailblazer-option (v0.1.2, RVM: ruby-3.0.4) [gem]" level="application" />
|
86
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, RVM: ruby-3.0.4) [gem]" level="application" />
|
87
|
+
<orderEntry type="library" scope="PROVIDED" name="uber (v0.1.0, RVM: ruby-3.0.4) [gem]" level="application" />
|
88
|
+
<orderEntry type="library" scope="PROVIDED" name="webrick (v1.8.1, RVM: ruby-3.0.4) [gem]" level="application" />
|
89
|
+
</component>
|
90
|
+
<component name="RakeTasksCache">
|
91
|
+
<option name="myRootTask">
|
92
|
+
<RakeTaskImpl id="rake">
|
93
|
+
<subtasks>
|
94
|
+
<RakeTaskImpl description="Build gem into pkg/" fullCommand="build" id="build" />
|
95
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
96
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
97
|
+
<RakeTaskImpl description="Remove RDoc HTML files" fullCommand="clobber_rdoc" id="clobber_rdoc" />
|
98
|
+
<RakeTaskImpl description="Start IRB with all runtime dependencies loaded" fullCommand="console[script]" id="console[script]" />
|
99
|
+
<RakeTaskImpl id="gemcutter">
|
100
|
+
<subtasks>
|
101
|
+
<RakeTaskImpl description="Release gem to Gemcutter" fullCommand="gemcutter:release" id="release" />
|
102
|
+
</subtasks>
|
103
|
+
</RakeTaskImpl>
|
104
|
+
<RakeTaskImpl description="Generate and validate gemspec" fullCommand="gemspec" id="gemspec" />
|
105
|
+
<RakeTaskImpl id="gemspec">
|
106
|
+
<subtasks>
|
107
|
+
<RakeTaskImpl description="Display the gemspec for debugging purposes, as juwelier knows it (not from the filesystem)" fullCommand="gemspec:debug" id="debug" />
|
108
|
+
<RakeTaskImpl description="Regenerate the gemspec on the filesystem" fullCommand="gemspec:generate" id="generate" />
|
109
|
+
<RakeTaskImpl description="Regenerate and validate gemspec, and then commits and pushes to git" fullCommand="gemspec:release" id="release" />
|
110
|
+
<RakeTaskImpl description="Validates the gemspec on the filesystem" fullCommand="gemspec:validate" id="validate" />
|
111
|
+
</subtasks>
|
112
|
+
</RakeTaskImpl>
|
113
|
+
<RakeTaskImpl id="git">
|
114
|
+
<subtasks>
|
115
|
+
<RakeTaskImpl description="Tag and push release to git" fullCommand="git:release" id="release" />
|
116
|
+
</subtasks>
|
117
|
+
</RakeTaskImpl>
|
118
|
+
<RakeTaskImpl description="Build and install gem using `gem install`" fullCommand="install" id="install" />
|
119
|
+
<RakeTaskImpl description="Build RDoc HTML files" fullCommand="rdoc" id="rdoc" />
|
120
|
+
<RakeTaskImpl description="Release gem" fullCommand="release" id="release" />
|
121
|
+
<RakeTaskImpl description="Rebuild RDoc HTML files" fullCommand="rerdoc" id="rerdoc" />
|
122
|
+
<RakeTaskImpl description="Code coverage detail" fullCommand="simplecov" id="simplecov" />
|
123
|
+
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
124
|
+
<RakeTaskImpl description="Displays the current version" fullCommand="version" id="version" />
|
125
|
+
<RakeTaskImpl id="version">
|
126
|
+
<subtasks>
|
127
|
+
<RakeTaskImpl id="bump">
|
128
|
+
<subtasks>
|
129
|
+
<RakeTaskImpl description="Bump the major version by 1" fullCommand="version:bump:major" id="major" />
|
130
|
+
<RakeTaskImpl description="Bump the a minor version by 1" fullCommand="version:bump:minor" id="minor" />
|
131
|
+
<RakeTaskImpl description="Bump the patch version by 1" fullCommand="version:bump:patch" id="patch" />
|
132
|
+
</subtasks>
|
133
|
+
</RakeTaskImpl>
|
134
|
+
<RakeTaskImpl description="Writes out an explicit version" fullCommand="version:write" id="write" />
|
135
|
+
</subtasks>
|
136
|
+
</RakeTaskImpl>
|
137
|
+
<RakeTaskImpl description="" fullCommand="console" id="console" />
|
138
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
139
|
+
<RakeTaskImpl description="" fullCommand="gemspec_required" id="gemspec_required" />
|
140
|
+
<RakeTaskImpl description="" fullCommand="rdoc/index.html" id="rdoc/index.html" />
|
141
|
+
<RakeTaskImpl description="" fullCommand="version_required" id="version_required" />
|
142
|
+
</subtasks>
|
143
|
+
</RakeTaskImpl>
|
144
|
+
</option>
|
145
|
+
</component>
|
146
|
+
</module>
|
data/.idea/vcs.xml
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 2.2"
|
11
|
+
gem "juwelier", "~> 2.1.0"
|
12
|
+
gem "simplecov", ">= 0"
|
13
|
+
gem "rspec"
|
14
|
+
end
|
15
|
+
|
16
|
+
gem 'google-cloud-storage', '~> 1.44'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (7.0.6)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
addressable (2.8.4)
|
10
|
+
public_suffix (>= 2.0.2, < 6.0)
|
11
|
+
builder (3.2.4)
|
12
|
+
concurrent-ruby (1.2.2)
|
13
|
+
declarative (0.0.20)
|
14
|
+
descendants_tracker (0.0.4)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
16
|
+
diff-lcs (1.5.0)
|
17
|
+
digest-crc (0.6.5)
|
18
|
+
rake (>= 12.0.0, < 14.0.0)
|
19
|
+
docile (1.4.0)
|
20
|
+
faraday (1.10.3)
|
21
|
+
faraday-em_http (~> 1.0)
|
22
|
+
faraday-em_synchrony (~> 1.0)
|
23
|
+
faraday-excon (~> 1.1)
|
24
|
+
faraday-httpclient (~> 1.0)
|
25
|
+
faraday-multipart (~> 1.0)
|
26
|
+
faraday-net_http (~> 1.0)
|
27
|
+
faraday-net_http_persistent (~> 1.0)
|
28
|
+
faraday-patron (~> 1.0)
|
29
|
+
faraday-rack (~> 1.0)
|
30
|
+
faraday-retry (~> 1.0)
|
31
|
+
ruby2_keywords (>= 0.0.4)
|
32
|
+
faraday-em_http (1.0.0)
|
33
|
+
faraday-em_synchrony (1.0.0)
|
34
|
+
faraday-excon (1.1.0)
|
35
|
+
faraday-httpclient (1.0.1)
|
36
|
+
faraday-multipart (1.0.4)
|
37
|
+
multipart-post (~> 2)
|
38
|
+
faraday-net_http (1.0.1)
|
39
|
+
faraday-net_http_persistent (1.2.0)
|
40
|
+
faraday-patron (1.0.0)
|
41
|
+
faraday-rack (1.0.0)
|
42
|
+
faraday-retry (1.0.3)
|
43
|
+
git (1.18.0)
|
44
|
+
addressable (~> 2.8)
|
45
|
+
rchardet (~> 1.8)
|
46
|
+
github_api (0.19.0)
|
47
|
+
addressable (~> 2.4)
|
48
|
+
descendants_tracker (~> 0.0.4)
|
49
|
+
faraday (>= 0.8, < 2)
|
50
|
+
hashie (~> 3.5, >= 3.5.2)
|
51
|
+
oauth2 (~> 1.0)
|
52
|
+
google-apis-core (0.11.1)
|
53
|
+
addressable (~> 2.5, >= 2.5.1)
|
54
|
+
googleauth (>= 0.16.2, < 2.a)
|
55
|
+
httpclient (>= 2.8.1, < 3.a)
|
56
|
+
mini_mime (~> 1.0)
|
57
|
+
representable (~> 3.0)
|
58
|
+
retriable (>= 2.0, < 4.a)
|
59
|
+
rexml
|
60
|
+
webrick
|
61
|
+
google-apis-iamcredentials_v1 (0.17.0)
|
62
|
+
google-apis-core (>= 0.11.0, < 2.a)
|
63
|
+
google-apis-storage_v1 (0.19.0)
|
64
|
+
google-apis-core (>= 0.9.0, < 2.a)
|
65
|
+
google-cloud-core (1.6.0)
|
66
|
+
google-cloud-env (~> 1.0)
|
67
|
+
google-cloud-errors (~> 1.0)
|
68
|
+
google-cloud-env (1.6.0)
|
69
|
+
faraday (>= 0.17.3, < 3.0)
|
70
|
+
google-cloud-errors (1.3.1)
|
71
|
+
google-cloud-storage (1.44.0)
|
72
|
+
addressable (~> 2.8)
|
73
|
+
digest-crc (~> 0.4)
|
74
|
+
google-apis-iamcredentials_v1 (~> 0.1)
|
75
|
+
google-apis-storage_v1 (~> 0.19.0)
|
76
|
+
google-cloud-core (~> 1.6)
|
77
|
+
googleauth (>= 0.16.2, < 2.a)
|
78
|
+
mini_mime (~> 1.0)
|
79
|
+
googleauth (1.7.0)
|
80
|
+
faraday (>= 0.17.3, < 3.a)
|
81
|
+
jwt (>= 1.4, < 3.0)
|
82
|
+
memoist (~> 0.16)
|
83
|
+
multi_json (~> 1.11)
|
84
|
+
os (>= 0.9, < 2.0)
|
85
|
+
signet (>= 0.16, < 2.a)
|
86
|
+
hashie (3.6.0)
|
87
|
+
highline (2.1.0)
|
88
|
+
httpclient (2.8.3)
|
89
|
+
i18n (1.14.1)
|
90
|
+
concurrent-ruby (~> 1.0)
|
91
|
+
json (1.8.6)
|
92
|
+
juwelier (2.1.3)
|
93
|
+
builder
|
94
|
+
bundler (>= 1.13)
|
95
|
+
git (>= 1.2.5)
|
96
|
+
github_api
|
97
|
+
highline (>= 1.6.15)
|
98
|
+
nokogiri (>= 1.5.10)
|
99
|
+
rake
|
100
|
+
rdoc
|
101
|
+
semver
|
102
|
+
jwt (2.7.1)
|
103
|
+
memoist (0.16.2)
|
104
|
+
mini_mime (1.1.2)
|
105
|
+
minitest (5.19.0)
|
106
|
+
multi_json (1.15.0)
|
107
|
+
multi_xml (0.6.0)
|
108
|
+
multipart-post (2.3.0)
|
109
|
+
nokogiri (1.15.3-arm64-darwin)
|
110
|
+
racc (~> 1.4)
|
111
|
+
oauth2 (1.4.11)
|
112
|
+
faraday (>= 0.17.3, < 3.0)
|
113
|
+
jwt (>= 1.0, < 3.0)
|
114
|
+
multi_json (~> 1.3)
|
115
|
+
multi_xml (~> 0.5)
|
116
|
+
rack (>= 1.2, < 4)
|
117
|
+
os (1.1.4)
|
118
|
+
public_suffix (5.0.3)
|
119
|
+
racc (1.7.1)
|
120
|
+
rack (3.0.8)
|
121
|
+
rake (13.0.6)
|
122
|
+
rchardet (1.8.0)
|
123
|
+
rdoc (3.12.2)
|
124
|
+
json (~> 1.4)
|
125
|
+
representable (3.2.0)
|
126
|
+
declarative (< 0.1.0)
|
127
|
+
trailblazer-option (>= 0.1.1, < 0.2.0)
|
128
|
+
uber (< 0.2.0)
|
129
|
+
retriable (3.1.2)
|
130
|
+
rexml (3.2.6)
|
131
|
+
rspec (3.12.0)
|
132
|
+
rspec-core (~> 3.12.0)
|
133
|
+
rspec-expectations (~> 3.12.0)
|
134
|
+
rspec-mocks (~> 3.12.0)
|
135
|
+
rspec-core (3.12.2)
|
136
|
+
rspec-support (~> 3.12.0)
|
137
|
+
rspec-expectations (3.12.3)
|
138
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
139
|
+
rspec-support (~> 3.12.0)
|
140
|
+
rspec-mocks (3.12.6)
|
141
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
142
|
+
rspec-support (~> 3.12.0)
|
143
|
+
rspec-support (3.12.1)
|
144
|
+
ruby2_keywords (0.0.5)
|
145
|
+
semver (1.0.1)
|
146
|
+
shoulda (4.0.0)
|
147
|
+
shoulda-context (~> 2.0)
|
148
|
+
shoulda-matchers (~> 4.0)
|
149
|
+
shoulda-context (2.0.0)
|
150
|
+
shoulda-matchers (4.5.1)
|
151
|
+
activesupport (>= 4.2.0)
|
152
|
+
signet (0.17.0)
|
153
|
+
addressable (~> 2.8)
|
154
|
+
faraday (>= 0.17.5, < 3.a)
|
155
|
+
jwt (>= 1.5, < 3.0)
|
156
|
+
multi_json (~> 1.10)
|
157
|
+
simplecov (0.22.0)
|
158
|
+
docile (~> 1.1)
|
159
|
+
simplecov-html (~> 0.11)
|
160
|
+
simplecov_json_formatter (~> 0.1)
|
161
|
+
simplecov-html (0.12.3)
|
162
|
+
simplecov_json_formatter (0.1.4)
|
163
|
+
thread_safe (0.3.6)
|
164
|
+
trailblazer-option (0.1.2)
|
165
|
+
tzinfo (2.0.6)
|
166
|
+
concurrent-ruby (~> 1.0)
|
167
|
+
uber (0.1.0)
|
168
|
+
webrick (1.8.1)
|
169
|
+
|
170
|
+
PLATFORMS
|
171
|
+
arm64-darwin-21
|
172
|
+
|
173
|
+
DEPENDENCIES
|
174
|
+
bundler (~> 2.2)
|
175
|
+
google-cloud-storage (~> 1.44)
|
176
|
+
juwelier (~> 2.1.0)
|
177
|
+
rspec
|
178
|
+
shoulda
|
179
|
+
simplecov
|
180
|
+
|
181
|
+
BUNDLED WITH
|
182
|
+
2.2.33
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2023 manoj
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= ruby-remote-config
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to ruby-remote-config
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2023 manoj. See LICENSE.txt for
|
18
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
require 'juwelier'
|
14
|
+
Juwelier::Tasks.new do |gem|
|
15
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
16
|
+
gem.name = "ruby-remote-config"
|
17
|
+
gem.homepage = "http://github.com/divakarmanoj/ruby-remote-config"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = "this is a simple gem that implements a remote config"
|
20
|
+
gem.description = "this is a simple gem that implements a remote config. It can accept different types of remote source and can be used to fetch config from them."
|
21
|
+
gem.email = "manoj.prithvee@gmail.com"
|
22
|
+
gem.authors = ["divakarmanoj"]
|
23
|
+
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['test'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "ruby-remote-config #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "logger"
|
5
|
+
require "repository"
|
6
|
+
|
7
|
+
module Source
|
8
|
+
# FileRepository is a struct that implements the Repository interface for
|
9
|
+
# handling configuration data stored in a YAML file.
|
10
|
+
class FileRepository
|
11
|
+
include Source::Repository
|
12
|
+
attr_reader :path
|
13
|
+
|
14
|
+
def initialize(name:, path:)
|
15
|
+
super(name: name)
|
16
|
+
@path = path
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
# Refresh reads the YAML file, unmarshal it into the data map.
|
22
|
+
def refresh
|
23
|
+
@lock.synchronize do
|
24
|
+
# Read the YAML file
|
25
|
+
data = File.read(@path)
|
26
|
+
# Unmarshal the YAML data into the data map
|
27
|
+
@data = YAML.safe_load(data)
|
28
|
+
|
29
|
+
# Store the raw data of the YAML file
|
30
|
+
@raw_data = data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "google/cloud/storage"
|
4
|
+
require "yaml"
|
5
|
+
require "repository"
|
6
|
+
|
7
|
+
# GcpStorageRepository is a class that implements the Repository interface for
|
8
|
+
# handling configuration data stored in a YAML file within a GCS bucket.
|
9
|
+
module Source
|
10
|
+
class GcpStorageRepository
|
11
|
+
include Source::Repository
|
12
|
+
attr_reader :bucket_name, :object_name, :client
|
13
|
+
|
14
|
+
def initialize(name:, bucket_name:, object_name:)
|
15
|
+
super(name: name)
|
16
|
+
@bucket_name = bucket_name
|
17
|
+
@object_name = object_name
|
18
|
+
@client = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
# Refresh reads the YAML file from the GCS bucket, unmarshal it into the data map.
|
22
|
+
def refresh
|
23
|
+
@lock.synchronize do
|
24
|
+
# If the GCS client does not exist, create it.
|
25
|
+
if @client.nil?
|
26
|
+
@client = Google::Cloud::Storage.new()
|
27
|
+
end
|
28
|
+
|
29
|
+
# Open the YAML file from the GCS bucket.
|
30
|
+
bucket = @client.bucket(@bucket_name)
|
31
|
+
file = bucket.file(@object_name)
|
32
|
+
file_content = file.download
|
33
|
+
|
34
|
+
# Unmarshal the YAML data into the data map.
|
35
|
+
@data = YAML.safe_load(file_content)
|
36
|
+
@raw_data = file_content
|
37
|
+
end
|
38
|
+
rescue StandardError => e
|
39
|
+
raise "Error refreshing configuration data: #{e.message}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/repository.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Source
|
4
|
+
module Repository
|
5
|
+
attr_reader :name, :data, :lock
|
6
|
+
|
7
|
+
def initialize(name:)
|
8
|
+
@name = name
|
9
|
+
@data = {}
|
10
|
+
@lock = Mutex.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_name
|
14
|
+
@name
|
15
|
+
end
|
16
|
+
|
17
|
+
# GetData returns the configuration data as a map of configuration names to their respective models.
|
18
|
+
def get_data(config_name)
|
19
|
+
@lock.synchronize do
|
20
|
+
config = @data[config_name]
|
21
|
+
return config
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def refresh
|
26
|
+
raise NotImplementedError, 'Method not implemented'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'concurrent'
|
3
|
+
require 'file_repository'
|
4
|
+
require 'gcp_storage_repository'
|
5
|
+
require 'web_repository'
|
6
|
+
require 'repository'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
module RubyRemoteConfig
|
11
|
+
class Client
|
12
|
+
attr_reader :repository, :refresh_interval, :cancel
|
13
|
+
def initialize(repository: Repository, refresh_interval: Integer)
|
14
|
+
# Create the Client instance with the provided repository and refresh interval.
|
15
|
+
@repository = repository
|
16
|
+
@refresh_interval = refresh_interval
|
17
|
+
|
18
|
+
@cancel = Concurrent::MutexAtomicBoolean.new(false)
|
19
|
+
|
20
|
+
# Refresh the configuration data for the first time to ensure the
|
21
|
+
# Client is initialized with the latest data before it is used.
|
22
|
+
@repository.refresh
|
23
|
+
|
24
|
+
# Start the background refresh goroutine by calling the refresh function
|
25
|
+
# with the newly created context and the client as arguments.
|
26
|
+
Thread.new { refresh() }
|
27
|
+
|
28
|
+
# Return the created Client instance, which is now ready to use.
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
def refresh
|
33
|
+
loop do
|
34
|
+
sleep(refresh_interval)
|
35
|
+
@repository.refresh()
|
36
|
+
break if @cancel
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def stop
|
41
|
+
@cancel.make_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'yaml'
|
6
|
+
require 'logger'
|
7
|
+
require "repository"
|
8
|
+
|
9
|
+
module Source
|
10
|
+
class WebRepository
|
11
|
+
include Source::Repository
|
12
|
+
attr_reader :url
|
13
|
+
|
14
|
+
def initialize(name:, url:)
|
15
|
+
super(name: name)
|
16
|
+
@url = URI.parse(url)
|
17
|
+
end
|
18
|
+
|
19
|
+
def refresh
|
20
|
+
@lock.synchronize do
|
21
|
+
http = Net::HTTP.new(@url.host, @url.port)
|
22
|
+
http.use_ssl = @url.scheme == 'https'
|
23
|
+
|
24
|
+
request = Net::HTTP::Get.new(@url)
|
25
|
+
response = http.request(request)
|
26
|
+
|
27
|
+
if response.code == '200'
|
28
|
+
@raw_data = response.body
|
29
|
+
@data = YAML.safe_load(@raw_data)
|
30
|
+
else
|
31
|
+
raise "Failed to fetch data from #{@url}: #{response}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'logger'
|
3
|
+
require 'file_repository'
|
4
|
+
|
5
|
+
RSpec.describe Source::FileRepository do
|
6
|
+
describe '#refresh' do
|
7
|
+
it 'reads the YAML file and unmarshals it into the data map' do
|
8
|
+
# Create a temporary YAML file
|
9
|
+
yaml_data = { 'config_name' => { 'key' => 'value' } }.to_yaml
|
10
|
+
yaml_file = Tempfile.new('config.yml')
|
11
|
+
yaml_file.write(yaml_data)
|
12
|
+
yaml_file.close
|
13
|
+
|
14
|
+
# Create a new FileRepository object
|
15
|
+
repo = Source::FileRepository.new(name: 'test', path: yaml_file.path)
|
16
|
+
|
17
|
+
# Call the refresh method
|
18
|
+
repo.refresh
|
19
|
+
|
20
|
+
# Check that the data map is set correctly
|
21
|
+
expect(repo.get_data('config_name')).to eq({ 'key' => 'value' })
|
22
|
+
|
23
|
+
# Delete the temporary YAML file
|
24
|
+
yaml_file.unlink
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raises an error if there is an error unmarshalling the YAML data' do
|
28
|
+
# Create a temporary YAML file with invalid data
|
29
|
+
yaml_data = "invalid_yaml_data"
|
30
|
+
yaml_file = Tempfile.new('invalid_yaml_data.yml')
|
31
|
+
yaml_file.write(yaml_data)
|
32
|
+
yaml_file.close
|
33
|
+
# Create a new FileRepository object
|
34
|
+
repo = Source::FileRepository.new(name: 'test', path: yaml_file.path)
|
35
|
+
# Call the refresh method and check that it raises an error
|
36
|
+
repo.refresh
|
37
|
+
|
38
|
+
# Delete the temporary YAML file
|
39
|
+
yaml_file.unlink
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'google/cloud/storage'
|
2
|
+
require 'yaml'
|
3
|
+
require 'rspec/mocks'
|
4
|
+
require 'gcp_storage_repository'
|
5
|
+
|
6
|
+
RSpec.describe Source::GcpStorageRepository do
|
7
|
+
describe '#refresh' do
|
8
|
+
it 'reads the YAML file from the GCS bucket and unmarshals it into the data map' do
|
9
|
+
# Create a mock storage object
|
10
|
+
storage_mock = instance_double(Google::Cloud::Storage::Project)
|
11
|
+
|
12
|
+
# Create a mock bucket object
|
13
|
+
bucket_mock = instance_double(Google::Cloud::Storage::Bucket)
|
14
|
+
|
15
|
+
# Create a mock file object
|
16
|
+
file_mock = instance_double(Google::Cloud::Storage::File)
|
17
|
+
|
18
|
+
# Set up the expectations for the mock objects
|
19
|
+
allow(Google::Cloud::Storage).to receive(:new).and_return(storage_mock)
|
20
|
+
allow(storage_mock).to receive(:bucket).with('my-bucket').and_return(bucket_mock)
|
21
|
+
allow(bucket_mock).to receive(:file).with('my-file').and_return(file_mock)
|
22
|
+
allow(file_mock).to receive(:download).and_return('config_name: { key: value }')
|
23
|
+
|
24
|
+
# Create a new GcpStorageRepository object
|
25
|
+
repo = Source::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
|
26
|
+
|
27
|
+
# Call the refresh method
|
28
|
+
repo.refresh
|
29
|
+
|
30
|
+
# Check that the data map is set correctly
|
31
|
+
expect(repo.get_data('config_name')).to eq({ 'key' => 'value' })
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'raises an error if there is an error refreshing the configuration data' do
|
35
|
+
# Create a mock storage object that raises an error when creating a bucket
|
36
|
+
storage_mock = instance_double(Google::Cloud::Storage::Project)
|
37
|
+
allow(Google::Cloud::Storage).to receive(:new).and_return(storage_mock)
|
38
|
+
allow(storage_mock).to receive(:bucket).and_raise(StandardError.new('Error creating bucket'))
|
39
|
+
|
40
|
+
# Create a new GcpStorageRepository object
|
41
|
+
repo = Source::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
|
42
|
+
|
43
|
+
# Call the refresh method and check that it raises an error
|
44
|
+
expect { repo.refresh }.to raise_error('Error refreshing configuration data: Error creating bucket')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "ruby_remote_config"
|
2
|
+
|
3
|
+
describe RubyRemoteConfig do
|
4
|
+
context "Testing File Repository" do
|
5
|
+
it "should return the correct data" do
|
6
|
+
print(Dir.getwd)
|
7
|
+
client = RubyRemoteConfig::Client.new(
|
8
|
+
repository: Source::FileRepository.new(name: "test", path: "spec/test.yaml"),
|
9
|
+
refresh_interval: 1)
|
10
|
+
expect(client.repository.get_data("test")).to eq("test")
|
11
|
+
client.stop
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
|
65
|
+
config.disable_monkey_patching!
|
66
|
+
|
67
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
68
|
+
# be too noisy due to issues in dependencies.
|
69
|
+
config.warnings = true
|
70
|
+
|
71
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
72
|
+
# file, and it's useful to allow more verbose output when running an
|
73
|
+
# individual spec file.
|
74
|
+
if config.files_to_run.one?
|
75
|
+
# Use the documentation formatter for detailed output,
|
76
|
+
# unless a formatter has already been configured
|
77
|
+
# (e.g. via a command-line flag).
|
78
|
+
config.default_formatter = "doc"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Print the 10 slowest examples and example groups at the
|
82
|
+
# end of the spec run, to help surface which specs are running
|
83
|
+
# particularly slow.
|
84
|
+
config.profile_examples = 10
|
85
|
+
|
86
|
+
# Run specs in random order to surface order dependencies. If you find an
|
87
|
+
# order dependency and want to debug it, you can fix the order by providing
|
88
|
+
# the seed, which is printed after each run.
|
89
|
+
# --seed 1234
|
90
|
+
config.order = :random
|
91
|
+
|
92
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
93
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
94
|
+
# test failures related to randomization by passing the same `--seed` value
|
95
|
+
# as the one that triggered the failure.
|
96
|
+
Kernel.srand config.seed
|
97
|
+
=end
|
98
|
+
end
|
data/spec/test.yaml
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'yaml'
|
4
|
+
require 'logger'
|
5
|
+
require 'web_repository'
|
6
|
+
|
7
|
+
RSpec.describe Source::WebRepository do
|
8
|
+
describe '#refresh' do
|
9
|
+
it 'fetches the YAML data from the specified URL and unmarshals it into the data map' do
|
10
|
+
# Create a temporary YAML file
|
11
|
+
yaml_data = { 'config_name' => { 'key' => 'value' } }.to_yaml
|
12
|
+
yaml_file = Tempfile.new('config.yml')
|
13
|
+
yaml_file.write(yaml_data)
|
14
|
+
yaml_file.close
|
15
|
+
|
16
|
+
# Start a local HTTP server to serve the YAML file
|
17
|
+
server = TCPServer.new('127.0.0.1', 0)
|
18
|
+
server_port = server.addr[1]
|
19
|
+
thread = Thread.new do
|
20
|
+
loop do
|
21
|
+
begin
|
22
|
+
client = server.accept
|
23
|
+
request = client.gets
|
24
|
+
if request.start_with?('GET')
|
25
|
+
client.puts "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n#{yaml_data}"
|
26
|
+
else
|
27
|
+
client.puts "HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\nNot found"
|
28
|
+
end
|
29
|
+
client.close
|
30
|
+
rescue
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a new WebRepository object
|
36
|
+
repo = Source::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
|
37
|
+
|
38
|
+
# Call the refresh method
|
39
|
+
repo.refresh
|
40
|
+
|
41
|
+
# Check that the data map is set correctly
|
42
|
+
expect(repo.get_data('config_name')).to eq({ 'key' => 'value' })
|
43
|
+
|
44
|
+
# Stop the local HTTP server
|
45
|
+
server.close
|
46
|
+
thread.kill
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'raises an error if the HTTP response code is not 200' do
|
50
|
+
# Start a local HTTP server that always returns a 404 response
|
51
|
+
server = TCPServer.new('127.0.0.1', 0)
|
52
|
+
server_port = server.addr[1]
|
53
|
+
thread = Thread.new do
|
54
|
+
loop do
|
55
|
+
begin
|
56
|
+
client = server.accept
|
57
|
+
client.puts "HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\nNot found"
|
58
|
+
client.close
|
59
|
+
rescue
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Create a new WebRepository object
|
65
|
+
repo = Source::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
|
66
|
+
|
67
|
+
# Call the refresh method and check that it raises an error
|
68
|
+
expect { repo.refresh }.to raise_error(StandardError)
|
69
|
+
|
70
|
+
# Stop the local HTTP server
|
71
|
+
server.close
|
72
|
+
thread.kill
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-remote-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- divakarmanoj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-cloud-storage
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.44'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.44'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shoulda
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: juwelier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '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'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: this is a simple gem that implements a remote config. It can accept different
|
98
|
+
types of remote source and can be used to fetch config from them.
|
99
|
+
email: manoj.prithvee@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files:
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.rdoc
|
105
|
+
files:
|
106
|
+
- ".document"
|
107
|
+
- ".idea/.gitignore"
|
108
|
+
- ".idea/misc.xml"
|
109
|
+
- ".idea/modules.xml"
|
110
|
+
- ".idea/ruby-remote-config.iml"
|
111
|
+
- ".idea/vcs.xml"
|
112
|
+
- ".rspec"
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.rdoc
|
117
|
+
- Rakefile
|
118
|
+
- lib/file_repository.rb
|
119
|
+
- lib/gcp_storage_repository.rb
|
120
|
+
- lib/repository.rb
|
121
|
+
- lib/ruby_remote_config.rb
|
122
|
+
- lib/web_repository.rb
|
123
|
+
- spec/file_repository_spec.rb
|
124
|
+
- spec/gcp_storage_repository_spec.rb
|
125
|
+
- spec/ruby_remote_config_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/test.yaml
|
128
|
+
- spec/web_repository_spec.rb
|
129
|
+
homepage: http://github.com/divakarmanoj/ruby-remote-config
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.2.33
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: this is a simple gem that implements a remote config
|
152
|
+
test_files: []
|