blueprint_config 1.0.0 → 1.1.0

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: be61b7fe3cee8680edfeddde8bbd290aa4463fd68ea2b2582651f740afe4685b
4
- data.tar.gz: 9e6f745b5acc18080066a2ffb482eee0d69f704010ef923b8cab0f960c10ba48
3
+ metadata.gz: cec591307b09bd72ebe07601ae537938479fa70561e82127a468b7e0028e4df8
4
+ data.tar.gz: 4ac393929bbf592a95e4196cbb195cd7d463e80f4ba6df4fce8c99b74967e330
5
5
  SHA512:
6
- metadata.gz: e2849e6eb9237668d42fa9d7c10fe3075798e2cbc296a4a21d76429dcd921252d012a0c96672b69debc18f919d650dc8a2f1897f3401b664c6b6b688326c6719
7
- data.tar.gz: c76bd8289d7075f53358f9d7035b9d8e3479c4dc081c40c2c826e1cb3f561803bbe2380f66b741b6dea13636b2337c7cef4587dd29d241cb59a04790f236c97e
6
+ metadata.gz: 17467c0fd7172bf30880be1a40c1564c7f4271df3f388537f31986682f950766cea2ef3969061d5e7e2f68b1935dcddc930bff9151815be09be6ffcc1cca6bc8
7
+ data.tar.gz: 890305e747d5314fcd1d9fc13e0eeaec4d931930483ef39898f44df9105f17f5e4e191b5a1f76eb907bc00647668ceb42b2ded7dc6051c476e43fc37d458b200
@@ -11,7 +11,7 @@ module BlueprintConfig
11
11
  =======================================================================
12
12
  Settings table not found. Please add the configuration table by running:
13
13
 
14
- rails generate blue_config:migration
14
+ rails generate blueprint_config:install
15
15
  rake db:migrate
16
16
  =======================================================================
17
17
  WARNING
@@ -20,16 +20,27 @@ module BlueprintConfig
20
20
  @options = options
21
21
  @updated_at = nil
22
22
  @last_checked_at = nil
23
- @mutex = Mutex.new
23
+ @configured = true
24
+ @mutex = Thread::Mutex.new
24
25
  end
25
26
 
26
27
  def load_keys
28
+ @configured = true
27
29
  update_timestamp
28
30
 
29
31
  data = Setting.all.map { |s| { s.key => s.parsed_value } }.reduce(:merge) || {}
30
32
  return data.transform_keys(&:to_sym) unless @options[:nest]
31
33
 
32
34
  nest_hash(data, @options[:nest_separator] || '.')
35
+ rescue ::ActiveRecord::NoDatabaseError => e
36
+ # database is not created yet
37
+ @configured = false
38
+ {}
39
+ rescue ::ActiveRecord::StatementInvalid => e
40
+ @configured = false
41
+ Rails.logger.warn(e.message)
42
+ Rails.logger.warn(MISSING_TABLE_WARNING)
43
+ {}
33
44
  end
34
45
 
35
46
  def update_timestamp
@@ -39,6 +50,8 @@ module BlueprintConfig
39
50
  end
40
51
 
41
52
  def fresh?
53
+ # if database is not create/configured yet - don't try to refresh settings from it
54
+ return true if !@configured
42
55
  return true if @last_checked_at.present? && @last_checked_at > 1.second.ago
43
56
 
44
57
  @mutex.synchronize do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueprintConfig
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprint_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Elchinov