ruby-remote-config 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a44504aa1ec85d3f3b7634aba02f6ebfc13fc1609273515d7fd49b847a9a3fe
4
- data.tar.gz: 7de4cef1901e0a1039fea2ee1a3a9475f630f5513d034ec046c9184bd0521690
3
+ metadata.gz: e7a6c343c5f228ed34384490cdd3e34117d364ce9a4bbc614a475dce8a9565b1
4
+ data.tar.gz: 5cd91703f418554fe7785c62c7bad44585329f02c0baf9385d3b91b981862f3b
5
5
  SHA512:
6
- metadata.gz: 1324e9089fde6ad235c6f8f053f84da5d75da48bdedb3ba5928ec8d3fc9f949dd1871572a5b76ef553749aace09fc0ddfcb7802a620e6ed001f821e45cc083ae
7
- data.tar.gz: 2088236bacf28aeed925f08ae6ea36a4b597c49bb34d0564d03e3c638707d4c3b1d6ad9246ba21dfca7db8c90b1178103463f9ddbe1e5db22a299083386f41fb
6
+ metadata.gz: 7423c3e91cfb64d9b828c672113a41423ea6b59d1a04b3e410733a32522dbdf1dee9e33d236bd40f4b01468ef154ddc4bfe83e6a74ab3cab49cf4ee60b08ccee
7
+ data.tar.gz: 0b71be842a564ec939828feaced03cd12f10992798bc7ccdae290b89f4e782e38e2c0c72cda918209855514b4898a82394cb7bf4473aa9c23458ed0e961d1a37
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -4,11 +4,11 @@ require "yaml"
4
4
  require "logger"
5
5
  require "repository"
6
6
 
7
- module Source
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 Source::Repository
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 Source
9
+ module RubyRemoteConfig
10
10
  class GcpStorageRepository
11
- include Source::Repository
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Source
3
+ module RubyRemoteConfig
4
4
  module Repository
5
5
  attr_reader :name, :data, :lock
6
6
 
@@ -6,9 +6,9 @@ require 'yaml'
6
6
  require 'logger'
7
7
  require "repository"
8
8
 
9
- module Source
9
+ module RubyRemoteConfig
10
10
  class WebRepository
11
- include Source::Repository
11
+ include RubyRemoteConfig::Repository
12
12
  attr_reader :url
13
13
 
14
14
  def initialize(name:, url:)
@@ -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.1 ruby lib
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.1"
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 Source::FileRepository do
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 = Source::FileRepository.new(name: 'test', path: yaml_file.path)
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 = Source::FileRepository.new(name: 'test', path: yaml_file.path)
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 Source::GcpStorageRepository do
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 = Source::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
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 = Source::GcpStorageRepository.new(name: 'test', bucket_name: 'my-bucket', object_name: 'my-file')
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: Source::FileRepository.new(name: "test", path: "spec/test.yaml"),
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
@@ -4,7 +4,7 @@ require 'yaml'
4
4
  require 'logger'
5
5
  require 'web_repository'
6
6
 
7
- RSpec.describe Source::WebRepository do
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 = Source::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
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 = Source::WebRepository.new(name: 'test', url: "http://127.0.0.1:#{server_port}/config.yml")
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-remote-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - divakarmanoj