ruby-remote-config 1.0.1 → 1.0.2
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 +4 -4
- data/VERSION +1 -1
- data/lib/file_repository.rb +2 -4
- data/lib/gcp_storage_repository.rb +2 -2
- data/lib/repository.rb +1 -1
- data/lib/web_repository.rb +2 -2
- data/ruby-remote-config.gemspec +2 -2
- data/spec/file_repository_spec.rb +3 -3
- data/spec/gcp_storage_repository_spec.rb +3 -3
- data/spec/ruby_remote_config_spec.rb +3 -1
- data/spec/test.yaml +1 -2
- data/spec/web_repository_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a6c343c5f228ed34384490cdd3e34117d364ce9a4bbc614a475dce8a9565b1
|
4
|
+
data.tar.gz: 5cd91703f418554fe7785c62c7bad44585329f02c0baf9385d3b91b981862f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7423c3e91cfb64d9b828c672113a41423ea6b59d1a04b3e410733a32522dbdf1dee9e33d236bd40f4b01468ef154ddc4bfe83e6a74ab3cab49cf4ee60b08ccee
|
7
|
+
data.tar.gz: 0b71be842a564ec939828feaced03cd12f10992798bc7ccdae290b89f4e782e38e2c0c72cda918209855514b4898a82394cb7bf4473aa9c23458ed0e961d1a37
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/file_repository.rb
CHANGED
@@ -4,11 +4,11 @@ require "yaml"
|
|
4
4
|
require "logger"
|
5
5
|
require "repository"
|
6
6
|
|
7
|
-
module
|
7
|
+
module RubyRemoteConfig
|
8
8
|
# FileRepository is a struct that implements the Repository interface for
|
9
9
|
# handling configuration data stored in a YAML file.
|
10
10
|
class FileRepository
|
11
|
-
include
|
11
|
+
include RubyRemoteConfig::Repository
|
12
12
|
attr_reader :path
|
13
13
|
|
14
14
|
def initialize(name:, path:)
|
@@ -16,8 +16,6 @@ module Source
|
|
16
16
|
@path = path
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
19
|
# Refresh reads the YAML file, unmarshal it into the data map.
|
22
20
|
def refresh
|
23
21
|
@lock.synchronize do
|
@@ -6,9 +6,9 @@ require "repository"
|
|
6
6
|
|
7
7
|
# GcpStorageRepository is a class that implements the Repository interface for
|
8
8
|
# handling configuration data stored in a YAML file within a GCS bucket.
|
9
|
-
module
|
9
|
+
module RubyRemoteConfig
|
10
10
|
class GcpStorageRepository
|
11
|
-
include
|
11
|
+
include RubyRemoteConfig::Repository
|
12
12
|
attr_reader :bucket_name, :object_name, :client
|
13
13
|
|
14
14
|
def initialize(name:, bucket_name:, object_name:)
|
data/lib/repository.rb
CHANGED
data/lib/web_repository.rb
CHANGED
data/ruby-remote-config.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ruby-remote-config 1.0.
|
5
|
+
# stub: ruby-remote-config 1.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-remote-config".freeze
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
@@ -2,7 +2,7 @@ require 'yaml'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'file_repository'
|
4
4
|
|
5
|
-
RSpec.describe
|
5
|
+
RSpec.describe RubyRemoteConfig::FileRepository do
|
6
6
|
describe '#refresh' do
|
7
7
|
it 'reads the YAML file and unmarshals it into the data map' do
|
8
8
|
# Create a temporary YAML file
|
@@ -12,7 +12,7 @@ RSpec.describe Source::FileRepository do
|
|
12
12
|
yaml_file.close
|
13
13
|
|
14
14
|
# Create a new FileRepository object
|
15
|
-
repo =
|
15
|
+
repo = RubyRemoteConfig::FileRepository.new(name: 'test', path: yaml_file.path)
|
16
16
|
|
17
17
|
# Call the refresh method
|
18
18
|
repo.refresh
|
@@ -31,7 +31,7 @@ RSpec.describe Source::FileRepository do
|
|
31
31
|
yaml_file.write(yaml_data)
|
32
32
|
yaml_file.close
|
33
33
|
# Create a new FileRepository object
|
34
|
-
repo =
|
34
|
+
repo = RubyRemoteConfig::FileRepository.new(name: 'test', path: yaml_file.path)
|
35
35
|
# Call the refresh method and check that it raises an error
|
36
36
|
repo.refresh
|
37
37
|
|
@@ -3,7 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'rspec/mocks'
|
4
4
|
require 'gcp_storage_repository'
|
5
5
|
|
6
|
-
RSpec.describe
|
6
|
+
RSpec.describe RubyRemoteConfig::GcpStorageRepository do
|
7
7
|
describe '#refresh' do
|
8
8
|
it 'reads the YAML file from the GCS bucket and unmarshals it into the data map' do
|
9
9
|
# Create a mock storage object
|
@@ -22,7 +22,7 @@ RSpec.describe Source::GcpStorageRepository do
|
|
22
22
|
allow(file_mock).to receive(:download).and_return('config_name: { key: value }')
|
23
23
|
|
24
24
|
# Create a new GcpStorageRepository object
|
25
|
-
repo =
|
25
|
+
repo = RubyRemoteConfig::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
|
26
26
|
|
27
27
|
# Call the refresh method
|
28
28
|
repo.refresh
|
@@ -38,7 +38,7 @@ RSpec.describe Source::GcpStorageRepository do
|
|
38
38
|
allow(storage_mock).to receive(:bucket).and_raise(StandardError.new('Error creating bucket'))
|
39
39
|
|
40
40
|
# Create a new GcpStorageRepository object
|
41
|
-
repo =
|
41
|
+
repo = RubyRemoteConfig::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
|
42
42
|
|
43
43
|
# Call the refresh method and check that it raises an error
|
44
44
|
expect { repo.refresh }.to raise_error('Error refreshing configuration data: Error creating bucket')
|
@@ -11,11 +11,13 @@ describe RubyRemoteConfig do
|
|
11
11
|
client.stop
|
12
12
|
end
|
13
13
|
it "Change the data in the file and check if the data is updated" do
|
14
|
+
File.open("spec/test.yaml", "w") { |file| file.write("test: test") }
|
14
15
|
client = RubyRemoteConfig::Client.new(
|
15
|
-
repository:
|
16
|
+
repository: RubyRemoteConfig::FileRepository.new(name: "test", path: "spec/test.yaml"),
|
16
17
|
refresh_interval: 1)
|
17
18
|
expect(client.repository.get_data("test")).to eq("test")
|
18
19
|
File.open("spec/test.yaml", "w") { |file| file.write("test: test1") }
|
20
|
+
sleep(2)
|
19
21
|
expect(client.repository.get_data("test")).to eq("test1")
|
20
22
|
client.stop
|
21
23
|
end
|
data/spec/test.yaml
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
test: test
|
1
|
+
test: test1
|
data/spec/web_repository_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'yaml'
|
|
4
4
|
require 'logger'
|
5
5
|
require 'web_repository'
|
6
6
|
|
7
|
-
RSpec.describe
|
7
|
+
RSpec.describe RubyRemoteConfig::WebRepository do
|
8
8
|
describe '#refresh' do
|
9
9
|
it 'fetches the YAML data from the specified URL and unmarshals it into the data map' do
|
10
10
|
# Create a temporary YAML file
|
@@ -33,7 +33,7 @@ RSpec.describe Source::WebRepository do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# Create a new WebRepository object
|
36
|
-
repo =
|
36
|
+
repo = RubyRemoteConfig::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
|
37
37
|
|
38
38
|
# Call the refresh method
|
39
39
|
repo.refresh
|
@@ -62,7 +62,7 @@ RSpec.describe Source::WebRepository do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Create a new WebRepository object
|
65
|
-
repo =
|
65
|
+
repo = RubyRemoteConfig::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
|
66
66
|
|
67
67
|
# Call the refresh method and check that it raises an error
|
68
68
|
expect { repo.refresh }.to raise_error(StandardError)
|