pushr-core 1.0.4 → 1.0.5

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: d796496da363829ca4ccbdf77044b7b091392a54717871d6cec168c0413dbce4
4
- data.tar.gz: abc0435d73c288f343f9d34bc86edf59ebed7ed19fcd88057c0e05daee1df7fb
3
+ metadata.gz: b863ca933317f600b397b26c3e1ba6075f0882cbf9790687f1556288e2819e65
4
+ data.tar.gz: b6d46fb71f809753fd66f0fa1639bb2f0afe1b04d021874aff4f9112e1304882
5
5
  SHA512:
6
- metadata.gz: 7cace2417bb7dcfa77c3496f4b97018b77003735b999e01679c9a9d9825e82209023c533baa0efb23a89fc7899bd3b2e8d7501395af3c1b51978c4ef107726ff
7
- data.tar.gz: bf37754b174865ba67a77635df9780709559f379567adc7b58729156df57a807fbcd80a817d4fd00d05f3a7c65ca44ac97c9e30fccebd227a5819cc76e3473a1
6
+ metadata.gz: f3358210249ae43ea51905979fcd0f3b10f560a67ca203dbd13b6f32124d3ebb91f9d3b5558f4997f849de1ab549a567f9a608b5f9a5a32ccd5e7b072a10a033
7
+ data.tar.gz: cecd4649f0078410f928c91608a40d5d8ba12484b49af38e74acf3764ae87e5014b5c5a8f7eda5219d2bd47dd9c673ce8c1faa79a15e74e5efe8ba09f93f5b79
@@ -69,13 +69,13 @@ module Pushr
69
69
  def self.read_from_yaml_file
70
70
  filename = Pushr::Core.configuration_file
71
71
  configs = File.open(filename) { |fd| YAML.load(fd) }
72
- configs.map { |hsh| instantiate(hsh) }
72
+ configs.map { |hsh| instantiate(hsh) }.compact
73
73
  end
74
74
 
75
75
  def self.read_from_redis
76
76
  configurations = Pushr::Core.redis { |conn| conn.hgetall('pushr:configurations') }
77
77
  configurations.each { |key, config| configurations[key] = instantiate_json(config, key) }
78
- configurations.values
78
+ configurations.values.compact
79
79
  end
80
80
 
81
81
  def self.instantiate_json(config, id)
@@ -83,7 +83,12 @@ module Pushr
83
83
  end
84
84
 
85
85
  def self.instantiate(hsh)
86
- klass = hsh['type'].split('::').reduce(Object) { |a, e| a.const_get e }
86
+ klass = hsh['type'].split('::').reduce(Object) do |a, e|
87
+ if Object.const_defined?(hsh['type'])
88
+ a.const_get e
89
+ end
90
+ end
91
+ return nil if klass == nil
87
92
  klass.new(hsh)
88
93
  end
89
94
  end
@@ -17,7 +17,7 @@ module Pushr
17
17
  end
18
18
 
19
19
  def self.build_client(url, namespace, driver)
20
- client = Redis.connect(url: url, driver: driver)
20
+ client = Redis.new(url: url, driver: driver)
21
21
  if namespace
22
22
  Redis::Namespace.new(namespace, redis: client)
23
23
  else
@@ -1,3 +1,3 @@
1
1
  module Pushr
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
@@ -12,6 +12,12 @@ describe Pushr::Configuration do
12
12
  it 'returns all configurations' do
13
13
  expect(Pushr::Configuration.all).to eql([])
14
14
  end
15
+
16
+ it 'should not load missing configuration constant' do
17
+ Pushr::ConfigurationDummy2.new(app: 'app_name', connections: 2, enabled: true).save
18
+ Pushr.send(:remove_const, :ConfigurationDummy2)
19
+ expect(Pushr::Configuration.all).to eql([])
20
+ end
15
21
  end
16
22
 
17
23
  describe 'create' do
@@ -0,0 +1,13 @@
1
+ module Pushr
2
+ class ConfigurationDummy2 < Pushr::Configuration
3
+ attr_accessor :test_attr
4
+
5
+ def name
6
+ :dummy
7
+ end
8
+
9
+ def to_hash(_ = nil)
10
+ { id: [@app, name].join(':'), type: self.class.to_s, app: app, enabled: enabled, connections: connections, test_attr: test_attr }
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushr-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Pesman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '4.0'
20
20
  type: :runtime
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: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis-namespace
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -235,6 +235,7 @@ files:
235
235
  - spec/spec_helper.rb
236
236
  - spec/support/logger.rb
237
237
  - spec/support/pushr_configuration_dummy.rb
238
+ - spec/support/pushr_configuration_dummy2.rb
238
239
  - spec/support/pushr_connection_dummy.rb
239
240
  - spec/support/pushr_dummy.rb
240
241
  - spec/support/pushr_feedback_dummy.rb
@@ -260,8 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
261
  - !ruby/object:Gem::Version
261
262
  version: '0'
262
263
  requirements: []
263
- rubyforge_project:
264
- rubygems_version: 2.7.6
264
+ rubygems_version: 3.0.6
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: Core of the pushr daemon.
@@ -280,6 +280,7 @@ test_files:
280
280
  - spec/spec_helper.rb
281
281
  - spec/support/logger.rb
282
282
  - spec/support/pushr_configuration_dummy.rb
283
+ - spec/support/pushr_configuration_dummy2.rb
283
284
  - spec/support/pushr_connection_dummy.rb
284
285
  - spec/support/pushr_dummy.rb
285
286
  - spec/support/pushr_feedback_dummy.rb