fatcow 0.1.3 → 0.1.4
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 +4 -4
- data/lib/fatcow/model.rb +10 -6
- data/lib/fatcow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ce51b7283b6d2b8fdbcc0186ecbf52ded0d45e5dc0eb52728bed6be9ca616c5
|
|
4
|
+
data.tar.gz: a417404eb455ab6c5af6d9f651b4e83325193c878dda9462764feae569d1511d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7521fdb3002cfb91f5ed976d47876cd3f1c5cfe537d6bb0f95eaa32157792521c089b1697e0b8eedc1dbd1c1c66fa86e90d3f48207cd96decd73fd84ed62eed7
|
|
7
|
+
data.tar.gz: '0896205527bf40cc57a76b9211f37e18ba81df2f7800a6c63d0a232f9d0fce03b22ae5cf6c96a5c5863184f9e0873c7a7bd0f3899a1b42081927da0df84d0e9f'
|
data/lib/fatcow/model.rb
CHANGED
|
@@ -17,22 +17,25 @@ module Fatcow
|
|
|
17
17
|
|
|
18
18
|
included do
|
|
19
19
|
def show_icon(**options)
|
|
20
|
-
current_state = find_icon_status(:FATCOW_ICON_SHOW_STATUSES)
|
|
20
|
+
current_state = find_icon_status(:FATCOW_ICON_SHOW_STATUSES, :DEFAULT_SHOW_STATUSES)
|
|
21
21
|
|
|
22
22
|
return custom_icon(current_state, **options) if current_state
|
|
23
23
|
custom_icon(nil, **options) if current_state.nil?
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def form_icon(**options)
|
|
27
|
-
current_state = find_icon_status(:FATCOW_ICON_FORM_STATUSES)
|
|
27
|
+
current_state = find_icon_status(:FATCOW_ICON_FORM_STATUSES, :DEFAULT_FORM_STATUSES)
|
|
28
28
|
|
|
29
29
|
return custom_icon(current_state, **options) if current_state
|
|
30
30
|
custom_icon(nil, **options) if current_state.nil?
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def find_icon_status(statuses_const_key)
|
|
33
|
+
def find_icon_status(statuses_const_key, fallback_const_key)
|
|
34
34
|
statuses = self.class.const_get statuses_const_key
|
|
35
|
+
fallback = self.class.const_get fallback_const_key
|
|
36
|
+
|
|
35
37
|
current_status = statuses.find { |status, proc| instance_exec(&proc) }
|
|
38
|
+
current_status = fallback.find { |status, proc| instance_exec(&proc) } if current_status.nil?
|
|
36
39
|
|
|
37
40
|
return nil if current_status.nil?
|
|
38
41
|
current_status[0]
|
|
@@ -43,7 +46,8 @@ module Fatcow
|
|
|
43
46
|
|
|
44
47
|
icon.app = self if icon.app.nil?
|
|
45
48
|
icon.status = status if icon.status != status
|
|
46
|
-
icon.size = options[:size] if options[:size]
|
|
49
|
+
icon.size = options[:size] if options[:size] && icon.size != options[:size]
|
|
50
|
+
icon.size = :regular unless options[:size] && icon.size != :regular
|
|
47
51
|
|
|
48
52
|
icon
|
|
49
53
|
end
|
|
@@ -52,8 +56,8 @@ module Fatcow
|
|
|
52
56
|
class_methods do
|
|
53
57
|
def has_icon (icon_name, **statuses)
|
|
54
58
|
const_set :FATCOW_ICON, Fatcow::Icon.new(nil, icon_name)
|
|
55
|
-
const_set :FATCOW_ICON_SHOW_STATUSES,
|
|
56
|
-
const_set :FATCOW_ICON_FORM_STATUSES,
|
|
59
|
+
const_set :FATCOW_ICON_SHOW_STATUSES, statuses[:show] || {}
|
|
60
|
+
const_set :FATCOW_ICON_FORM_STATUSES, statuses[:form] || {}
|
|
57
61
|
end
|
|
58
62
|
end
|
|
59
63
|
end
|
data/lib/fatcow/version.rb
CHANGED