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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16d86a78b8a3cd4859836c03556ed78d98957bdba6e320402768a5c68c2856da
4
- data.tar.gz: b325524f806120e6ab5aa682dd7f8d537c4421f36a4b1b48bd33e52f2621a909
3
+ metadata.gz: 2ce51b7283b6d2b8fdbcc0186ecbf52ded0d45e5dc0eb52728bed6be9ca616c5
4
+ data.tar.gz: a417404eb455ab6c5af6d9f651b4e83325193c878dda9462764feae569d1511d
5
5
  SHA512:
6
- metadata.gz: d06145423f6eed536b7ac02ad7f4790c01f1220d2245ccb94f2c626b0dcc72409e1a2e965fd3673ecce7e37fda9050e5e400735c6c95dc1e21a1d6e6d9b2b24e
7
- data.tar.gz: 55aa307a620b36d3c1ec8bd0dd1f7b780ecfb976f28addcd3dfd6a43c5cb6449b08df766a1e7b3bb3c187e18be03952fb1249098263842bba96c3a22b87311f2
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, DEFAULT_SHOW_STATUSES.dup.merge(statuses[:show] || {})
56
- const_set :FATCOW_ICON_FORM_STATUSES, DEFAULT_FORM_STATUSES.dup.merge(statuses[:form] || {})
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
@@ -1,5 +1,5 @@
1
1
  module Fatcow
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
 
4
4
  ASSET_ROOT = File.expand_path("assets", __dir__)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fatcow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gray