ruby_native 0.11.0 → 0.11.1

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: 354cc245f5601b5e39b3cbba720da1fe06edf675eb373e22eb1028b2c27056ce
4
- data.tar.gz: 38080a8029fbffa2c920cd734196a88377f6b20967b83f9f947eab37835f46c6
3
+ metadata.gz: c596379ed0170d7784e8273e1ac3c10023ebc6115a7d8a7d1edb2633f7325449
4
+ data.tar.gz: b966e8aeb40899fa32ff8f34f85dffc031b073f0637cf1917083f43ce504e06a
5
5
  SHA512:
6
- metadata.gz: 92f68b9731f743efd5aece5debb221c4963a93b373f9c76997dc688eba4f6da85b3eb3832efa457ebca0a0ed93d36a2b8417d0af5efa2fb23e8ce64734ac7002
7
- data.tar.gz: 3142eea082eab9acc7f279173ca731452cd3e21f58a1d491470b61433204bed26a35f81f71ca6fad60ac7271fb776931872215867d6fbc574682605ee7b8286f
6
+ metadata.gz: fbddcd87a18dc14cd8eacdf1b4456c6cacc41c2f26c76e3dc0d6d2383b8c40a76de274901d3456d2ee40a79f56edd3b17d0a9510918e7a67adc9d6fa675f57d3
7
+ data.tar.gz: 1d9bbb26a648e42952fd11de6d63cb65286d8247e5c847fbd2007760de213ed371f5ff6a61372f582a9cfe75b26fb10f8b11f6c5187187f415af4c511021a748
@@ -131,14 +131,43 @@ module RubyNative
131
131
  # form (`{ ios: "...", android: "..." }`). When both are given, a matching
132
132
  # `icons[platform]` wins; otherwise falls back to `icon`. Returns nil when
133
133
  # nothing resolves.
134
+ #
135
+ # A non-Hash `icons:` raises rather than falling through. `icons: [ios:
136
+ # "...", android: "..."]` is an easy slip in ERB and yields an Array holding
137
+ # one Hash, which used to skip the lookup and fall back to `icon` — usually
138
+ # nil, so the button rendered with no icon on either platform and nothing
139
+ # said why. That reads as "per-platform icons are broken" rather than "wrong
140
+ # bracket," and it is invisible on whichever platform you aren't testing.
134
141
  def self.resolve_icon(icon: nil, icons: nil, platform: nil)
142
+ if !icons.nil? && !icons.is_a?(Hash)
143
+ raise ArgumentError,
144
+ "icons: must be a Hash like { ios: \"square.and.arrow.up\", android: \"share\" }, " \
145
+ "got #{icons.class}. Check for square brackets instead of curly braces."
146
+ end
147
+
135
148
  if icons.is_a?(Hash) && platform
136
149
  key = platform.to_sym
137
150
  per_platform = icons[key] || icons[key.to_s]
138
151
  return per_platform if per_platform
139
152
  end
140
- icon
153
+
154
+ # Nothing matched, which is every web render: `native_platform` is nil in
155
+ # a browser. Fall back to `icon:`, then to any name in `icons:`, the same
156
+ # order `RubyNative.backfill_tab_icons` uses for the YAML config.
157
+ #
158
+ # Returning nil here instead would make `icons:` alone unusable, because
159
+ # `native_fab_tag` raises on a nil icon and would 500 a page that renders
160
+ # fine inside the app. The signal element is hidden and only read by the
161
+ # native app, so which name survives on the web doesn't matter.
162
+ icon || fallback_icon(icons)
163
+ end
164
+
165
+ def self.fallback_icon(icons)
166
+ return nil unless icons.is_a?(Hash)
167
+
168
+ icons[:ios] || icons["ios"] || icons[:android] || icons["android"]
141
169
  end
170
+ private_class_method :fallback_icon
142
171
 
143
172
  class NavbarBuilder
144
173
  def initialize(context)
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti