ruby_native 0.12.0 → 0.12.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 +4 -4
- data/lib/ruby_native/cli/preview.rb +16 -2
- data/lib/ruby_native/helper.rb +42 -0
- data/lib/ruby_native/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: b7e336fc49236887320d23ecfc7718229370029d7a2b7981df2e888fd427e853
|
|
4
|
+
data.tar.gz: 16ca5ee3894370636c36193591a135c3829c3a9bb1449065994e04fc09be6b47
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8039052ae6fe99f9a429564c534b9b78b1df59c5cfa9a4b0157dd3b606244d609666b360242ff25b2a9931511262bb933f0e1b668c6570ade89413dd4c058009
|
|
7
|
+
data.tar.gz: 5b3b966610654c7f0625b2ffdb4aa42f4cb0ecccf773f06a2795faea962b6e54db0324d246959a3436083c907e1cc6b8f208275718fb598ceef74f4d42e04afd
|
|
@@ -34,8 +34,22 @@ module RubyNative
|
|
|
34
34
|
|
|
35
35
|
puts "Rails server is reachable at #{@upstream}, but #{CONFIG_PATH} returned #{response.code}."
|
|
36
36
|
puts ""
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
# 404 is what an unmounted engine returns; any other code means the app
|
|
39
|
+
# answered, so the mount is not the thing to go re-verify.
|
|
40
|
+
case response
|
|
41
|
+
when Net::HTTPNotFound
|
|
42
|
+
puts "Make sure the ruby_native gem is installed and mounted:"
|
|
43
|
+
puts " https://rubynative.com/docs/setup"
|
|
44
|
+
when Net::HTTPRedirection
|
|
45
|
+
puts "Something redirected the request to #{response["location"]}."
|
|
46
|
+
puts "Look for a force_ssl setting or a before_action that catches this path."
|
|
47
|
+
else
|
|
48
|
+
puts "Your Rails app returned an error. Open #{@upstream} in a browser and fix"
|
|
49
|
+
puts "what it reports, then try again. Pending migrations are a common cause:"
|
|
50
|
+
puts ""
|
|
51
|
+
puts " bin/rails db:migrate"
|
|
52
|
+
end
|
|
39
53
|
exit 1
|
|
40
54
|
rescue Errno::ECONNREFUSED
|
|
41
55
|
if @url
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -221,6 +221,48 @@ module RubyNative
|
|
|
221
221
|
tag.div(data: { native_review: true }, hidden: true)
|
|
222
222
|
end
|
|
223
223
|
|
|
224
|
+
TOAST_APPEARANCES = %w[inverted system].freeze
|
|
225
|
+
|
|
226
|
+
# Shows a transient native toast above all app chrome, including the nav
|
|
227
|
+
# bar. The signal is consumed the moment it fires, so a cached page
|
|
228
|
+
# restored by back navigation cannot re-toast. Renders nothing visible on
|
|
229
|
+
# the web; keep your web-styled flash for browsers.
|
|
230
|
+
#
|
|
231
|
+
# <%= native_toast_tag flash[:notice] %>
|
|
232
|
+
#
|
|
233
|
+
# A blank message renders nothing, so the flash one-liner needs no guard.
|
|
234
|
+
# Icons follow the same `icon:`/`icons:` rules as the navbar; the default
|
|
235
|
+
# is a per-platform checkmark and `icon: false` hides it. `appearance:` is
|
|
236
|
+
# :inverted (flips the theme so the toast always pops) or :system (matches
|
|
237
|
+
# it).
|
|
238
|
+
def native_toast_tag(message, icon: nil, icons: nil, duration: 4, appearance: :inverted)
|
|
239
|
+
return "".html_safe if message.blank?
|
|
240
|
+
|
|
241
|
+
appearance = appearance.to_s
|
|
242
|
+
unless TOAST_APPEARANCES.include?(appearance)
|
|
243
|
+
raise ArgumentError,
|
|
244
|
+
"appearance must be #{TOAST_APPEARANCES.map { |a| ":#{a}" }.join(" or ")}, " \
|
|
245
|
+
"got #{appearance.inspect}"
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# An absent icon attribute means "use the default" to the shell (the JS
|
|
249
|
+
# API omits it), so `icon: false` emits an empty value to mean "none".
|
|
250
|
+
platform = try(:native_platform)
|
|
251
|
+
resolved = if icon == false
|
|
252
|
+
""
|
|
253
|
+
else
|
|
254
|
+
RubyNative::Helper.resolve_icon(icon: icon, icons: icons, platform: platform) ||
|
|
255
|
+
(platform == "android" ? "check_circle" : "checkmark.circle.fill")
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
data = { native_toast: "", native_toast_message: message }
|
|
259
|
+
data[:native_toast_icon] = resolved
|
|
260
|
+
data[:native_toast_duration] = duration
|
|
261
|
+
data[:native_toast_appearance] = appearance
|
|
262
|
+
|
|
263
|
+
tag.div(data: data, hidden: true)
|
|
264
|
+
end
|
|
265
|
+
|
|
224
266
|
# Picks the right icon name for the current native platform. Accepts the
|
|
225
267
|
# single `icon:` form (applied to every platform) and/or the `icons:` hash
|
|
226
268
|
# form (`{ ios: "...", android: "..." }`). When both are given, a matching
|
data/lib/ruby_native/version.rb
CHANGED