sail 3.2.2 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/sail/application.scss +9 -0
- data/app/models/sail/profile.rb +16 -0
- data/app/models/sail/setting.rb +13 -6
- data/app/views/sail/profiles/_profile.html.erb +6 -0
- data/config/locales/en.yml +4 -0
- data/lib/sail/instrumenter.rb +26 -6
- data/lib/sail/version.rb +1 -1
- metadata +42 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f081b9724cf8e7ee4e932c22f1d8dcfc1d7f32156d826f18180377523d243225
|
4
|
+
data.tar.gz: ccbe270becea33e68416423060f3e21c147534fb79bb996d7545f73e06187c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 {
|
data/app/models/sail/profile.rb
CHANGED
@@ -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
|
data/app/models/sail/setting.rb
CHANGED
@@ -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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
Rails.cache.
|
69
|
-
|
70
|
-
|
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>
|
data/config/locales/en.yml
CHANGED
@@ -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
|
data/lib/sail/instrumenter.rb
CHANGED
@@ -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
|
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
|
|
data/lib/sail/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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:
|
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.
|
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.
|
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:
|
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:
|
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.
|
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.
|
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
|