sail 3.2.2 → 3.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f50a3ffd08ce3319b7c12965a4ada7954e9be63c98904480cb82fc9ca94876e
4
- data.tar.gz: caf14276d020f847b8b7fd3d5959e028d300289cd7e996622cd4c00505dc820e
3
+ metadata.gz: f081b9724cf8e7ee4e932c22f1d8dcfc1d7f32156d826f18180377523d243225
4
+ data.tar.gz: ccbe270becea33e68416423060f3e21c147534fb79bb996d7545f73e06187c22
5
5
  SHA512:
6
- metadata.gz: 34a45a3c9879a9317d60f43df33ad48f1391b7a44861eabefbe187cb221d9029c5bf98d4ce6bd8770059a8c535a9023fe0627b9dc458d5b2d82df67d4730667d
7
- data.tar.gz: 034f78ae3a617031c3861b0777dc165dbf48ca3b5325e23758ac1d97cb53e684f06f8dfee05756a6eeb0dea0c04b6239fd75f0a29762839ad64c530578fee960
6
+ metadata.gz: 1bd0d3def56886d0d240ee4ee1e0d21490af030144f4fc0e724b13a6d11e479ab7ee8bb0bce74c1baefd7fa6b4b6476ea41bf42a691d246be5531f3e30a2f70e
7
+ data.tar.gz: a79930a890281251ae8919e8fd44b2d282642463d8bea0f991b11375484dc16e2f54a56266dc21dbd530ff845eba7797c7f4fa45847a1cfc8dffad5864d0c0be
@@ -228,6 +228,15 @@ html, body {
228
228
  color: $light_green;
229
229
  }
230
230
  }
231
+
232
+ .errors-indicator {
233
+ float: left;
234
+ position: relative;
235
+ top: 9px;
236
+ left: 15px;
237
+ font-style: italic;
238
+ color: darken($aluminium, 30%);
239
+ }
231
240
  }
232
241
 
233
242
  #new-profile-input {
@@ -11,6 +11,7 @@ module Sail
11
11
  has_many :entries, dependent: :destroy
12
12
  has_many :settings, through: :entries
13
13
  validates :name, presence: true, uniqueness: { case_sensitive: false }
14
+ validate :only_one_active_profile
14
15
 
15
16
  # create_or_update_self
16
17
  #
@@ -55,6 +56,13 @@ module Sail
55
56
  end
56
57
  # rubocop:enable Rails/SkipsModelValidations
57
58
 
59
+ # current
60
+ #
61
+ # Returns the currently activated profile
62
+ def self.current
63
+ find_by(active: true)
64
+ end
65
+
58
66
  private_class_method :handle_profile_activation
59
67
 
60
68
  # dirty?
@@ -65,5 +73,13 @@ module Sail
65
73
  def dirty?
66
74
  @dirty ||= entries.any?(&:dirty?)
67
75
  end
76
+
77
+ private
78
+
79
+ def only_one_active_profile
80
+ if active? && Profile.where(active: true).where.not(id: id).count.positive?
81
+ errors.add(:single_active_profile, "Cannot have two active profiles at once")
82
+ end
83
+ end
68
84
  end
69
85
  end
@@ -59,16 +59,23 @@ module Sail
59
59
 
60
60
  def self.get(name)
61
61
  Sail.instrumenter.increment_usage_of(name)
62
+
63
+ cached_setting = Rails.cache.read("setting_get_#{name}")
64
+ return cached_setting unless cached_setting.nil?
65
+
62
66
  setting = Setting.for_value_by_name(name).first
63
67
  return if setting.nil?
64
68
 
65
- if setting.should_not_cache?
66
- setting.safe_cast
67
- else
68
- Rails.cache.fetch("setting_get_#{name}", expires_in: Sail.configuration.cache_life_span) do
69
- setting.safe_cast
70
- end
69
+ setting_value = setting.safe_cast
70
+
71
+ unless setting.should_not_cache?
72
+ Rails.cache.write(
73
+ "setting_get_#{name}", setting_value,
74
+ expires_in: Sail.configuration.cache_life_span
75
+ )
71
76
  end
77
+
78
+ setting_value
72
79
  end
73
80
 
74
81
  def self.set(name, value)
@@ -4,6 +4,12 @@
4
4
  title="<%= profile.dirty? ? I18n.t("sail.dirty_profile_tooltip") : I18n.t("sail.clean_profile_tooltip") %>">
5
5
 
6
6
  </span>
7
+
8
+ <% unless Sail.instrumenter.profile(profile.name).zero? %>
9
+ <span class="errors-indicator" title="<%= I18n.t("sail.profile_error_tooltip") %>">
10
+ <%= I18n.t("sail.profile_errors", count: Sail.instrumenter.profile(profile.name)) %>
11
+ </span>
12
+ <% end %>
7
13
  <% end %>
8
14
 
9
15
  <span class="entry-name"><%= profile.name.titleize %></span>
@@ -46,3 +46,7 @@ en:
46
46
  how_to_profiles: How to organize your settings in profiles
47
47
  how_to_relevancy_score: What is the relevancy score and how to use it
48
48
  how_to_groups_and_types: List of available groups and types
49
+ profile_errors:
50
+ one: 1 error
51
+ other: "%{count} errors"
52
+ profile_error_tooltip: This is the number of unexpected errors raised for all settings while this profile was active
@@ -14,16 +14,32 @@ module Sail
14
14
  # Declare basic hash containing setting
15
15
  # statistics
16
16
  def initialize
17
- @statistics = {}.with_indifferent_access
17
+ @statistics = { settings: {}, profiles: {} }.with_indifferent_access
18
18
  end
19
19
 
20
20
  # []
21
21
  #
22
- # Accessor method for the statistics to guarantee
22
+ # Accessor method for setting statistics to guarantee
23
23
  # proper initialization of hashes.
24
24
  def [](name)
25
- @statistics[name] = { usages: 0, failures: 0 }.with_indifferent_access if @statistics[name].blank?
26
- @statistics[name]
25
+ @statistics[:settings][name] = { usages: 0, failures: 0 }.with_indifferent_access if @statistics[:settings][name].blank?
26
+ @statistics[:settings][name]
27
+ end
28
+
29
+ # increment_profile_failure_of
30
+ #
31
+ # Increments the number of failures
32
+ # for settings while a profile is active
33
+ def increment_profile_failure_of(name)
34
+ @statistics[:profiles][name] ||= 0
35
+ @statistics[:profiles][name] += 1
36
+ end
37
+
38
+ # profile
39
+ #
40
+ # Profile statistics accessor
41
+ def profile(name)
42
+ @statistics[:profiles][name] ||= 0
27
43
  end
28
44
 
29
45
  # increment_usage
@@ -41,9 +57,9 @@ module Sail
41
57
  # a setting compared to all others
42
58
  # in percentage
43
59
  def relative_usage_of(setting_name)
44
- return 0.0 if @statistics.empty?
60
+ return 0.0 if @statistics[:settings].empty?
45
61
 
46
- (100.0 * self[setting_name][:usages]) / @statistics.map { |_, entry| entry[:usages] }.reduce(:+)
62
+ (100.0 * self[setting_name][:usages]) / @statistics[:settings].map { |_, entry| entry[:usages] }.reduce(:+)
47
63
  end
48
64
 
49
65
  # increment_failure_of
@@ -53,6 +69,10 @@ module Sail
53
69
  # exceeds the amount configured, resets the setting value
54
70
  def increment_failure_of(setting_name)
55
71
  self[setting_name][:failures] += 1
72
+
73
+ current_profile = Profile.current
74
+ increment_profile_failure_of(current_profile.name) if current_profile
75
+
56
76
  Sail.reset(setting_name) if self[setting_name][:failures] > Sail.configuration.failures_until_reset
57
77
  end
58
78
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sail
4
- VERSION = "3.2.2"
4
+ VERSION = "3.2.3"
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sail
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinicius Stock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-03 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: fugit
14
+ name: sassc-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: jquery-rails
28
+ name: fugit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: jquery-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sass-rails
56
+ name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: rspec-retry
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: rubocop
225
239
  requirement: !ruby/object:Gem::Requirement
@@ -268,28 +282,42 @@ dependencies:
268
282
  requirements:
269
283
  - - "~>"
270
284
  - !ruby/object:Gem::Version
271
- version: 0.16.1
285
+ version: 0.17.0
272
286
  type: :development
273
287
  prerelease: false
274
288
  version_requirements: !ruby/object:Gem::Requirement
275
289
  requirements:
276
290
  - - "~>"
277
291
  - !ruby/object:Gem::Version
278
- version: 0.16.1
292
+ version: 0.17.0
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: sqlite3
281
295
  requirement: !ruby/object:Gem::Requirement
282
296
  requirements:
283
- - - "<"
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: webdrivers
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
284
312
  - !ruby/object:Gem::Version
285
- version: 1.4.0
313
+ version: '0'
286
314
  type: :development
287
315
  prerelease: false
288
316
  version_requirements: !ruby/object:Gem::Requirement
289
317
  requirements:
290
- - - "<"
318
+ - - ">="
291
319
  - !ruby/object:Gem::Version
292
- version: 1.4.0
320
+ version: '0'
293
321
  description: Sail is a lightweight Rails engine that brings an admin panel for managing
294
322
  configuration settings on a live Rails app.
295
323
  email:
@@ -373,7 +401,7 @@ licenses:
373
401
  metadata: {}
374
402
  post_install_message: |
375
403
  **************************************************************************
376
- Sail 3.2.2!
404
+ Sail 3.2.3!
377
405
 
378
406
  For major version upgrades, check the CHANGELOG and run the updater to
379
407
  create necessary migrations.
@@ -395,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
395
423
  - !ruby/object:Gem::Version
396
424
  version: '0'
397
425
  requirements: []
398
- rubygems_version: 3.0.4
426
+ rubygems_version: 3.0.6
399
427
  signing_key:
400
428
  specification_version: 4
401
429
  summary: Sail is a lightweight Rails engine that brings an admin panel for managing