ruby_native 0.9.2 → 0.9.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: 9b2ce922165f55b3cb27cdac92845dff657ed2ef0b404c85634dc41e151fe116
4
- data.tar.gz: 47cf4144895b3049c2f73f2c59a3d250c09190e7571dbab98a431256dfdae3b4
3
+ metadata.gz: 56ba510fa3e0b1a2584a3aeaf4aede167043a3772c31ff8c08ab968dfac94ab5
4
+ data.tar.gz: ab47c472e8537a3204388ddd610d1a0d93417507e450c353a89ce9a6b5ee5af1
5
5
  SHA512:
6
- metadata.gz: 616e74c90c38fda0fc9f51503369ae44f66e2659ffbc02f9279c7591817f40f57ca435ba554e8c53d099a9f0fe9db5edf7769965683bb60d0028500af9699284
7
- data.tar.gz: 52bbeccb5a2b802796f11a6b259d5f24ab76380467b850ec3e8dbd68a462dd076f7eb94f3bea45d2660b6b1556051b37a36433e4167585f46329397e060f242b
6
+ metadata.gz: 39844845a2983578185ce85e2c0213092467801f9135b5681515b9ee495770a875ccac8ba2c1bf2ae39c8b8952ec5cf3118fe36661ff6a602a450f0aa97a2430
7
+ data.tar.gz: f0bf80917cae40af6f92ca71c644dd20839aa899fedcb0c9455c01a7b3549963bc78490594a4532fc67d951bfc49217938a5275eb289122965b59b174c89b7dc
@@ -89,6 +89,7 @@ Use these in your layouts and views:
89
89
  - `native_tabs_tag` renders a signal element that tells the app to show the tab bar. Only include it on pages where tabs should appear.
90
90
  - `native_form_tag` marks the page as a form. The app uses this to skip form pages when navigating back.
91
91
  - `native_push_tag` requests push notification permission from the user.
92
+ - `native_review_tag` asks the app to show the App Store rating prompt when the page loads. The system throttles how often the prompt appears (and shows nothing in TestFlight builds), so it is safe to render on any page where a review would be welcome. It is automatically suppressed during App Store screenshot runs.
92
93
 
93
94
  Signal elements are hidden `<div>` tags. Place them in the `<body>`, not the `<head>`.
94
95
 
@@ -13,36 +13,44 @@ module RubyNative
13
13
  PUBLIC_NAMESERVERS = ["1.1.1.1", "8.8.8.8"].freeze
14
14
 
15
15
  def initialize(argv)
16
+ @url = parse_option(argv, "--url")
16
17
  @port = parse_port(argv)
18
+ @upstream = @url || "http://localhost:#{@port}"
17
19
  end
18
20
 
19
21
  def run
20
22
  check_cloudflared!
21
- check_local_server!
23
+ check_upstream!
22
24
  start_tunnel
23
25
  end
24
26
 
25
27
  private
26
28
 
27
- def check_local_server!
28
- uri = URI("http://localhost:#{@port}#{CONFIG_PATH}")
29
+ def check_upstream!
30
+ uri = URI("#{@upstream}#{CONFIG_PATH}")
29
31
  response = fetch_config_response(uri)
30
32
 
31
33
  return if response.is_a?(Net::HTTPSuccess)
32
34
 
33
- puts "Rails server is running on port #{@port}, but #{CONFIG_PATH} returned #{response.code}."
35
+ puts "Rails server is reachable at #{@upstream}, but #{CONFIG_PATH} returned #{response.code}."
34
36
  puts ""
35
37
  puts "Make sure the ruby_native gem is installed and mounted:"
36
38
  puts " https://rubynative.com/docs/install"
37
39
  exit 1
38
40
  rescue Errno::ECONNREFUSED
39
- puts "Nothing is running on port #{@port}."
40
- puts ""
41
- puts "Start your Rails server in another terminal:"
42
- puts " bin/rails server -p #{@port}"
41
+ if @url
42
+ puts "Could not connect to #{@url}."
43
+ puts ""
44
+ puts "Make sure your Rails server is reachable at that URL."
45
+ else
46
+ puts "Nothing is running on port #{@port}."
47
+ puts ""
48
+ puts "Start your Rails server in another terminal:"
49
+ puts " bin/rails server -p #{@port}"
50
+ end
43
51
  exit 1
44
52
  rescue => e
45
- puts "Could not reach http://localhost:#{@port}#{CONFIG_PATH}: #{e.message}"
53
+ puts "Could not reach #{@upstream}#{CONFIG_PATH}: #{e.message}"
46
54
  exit 1
47
55
  end
48
56
 
@@ -100,12 +108,13 @@ module RubyNative
100
108
  end
101
109
 
102
110
  def parse_port(argv)
103
- index = argv.index("--port")
104
- if index
105
- argv[index + 1]&.to_i || 3000
106
- else
107
- 3000
108
- end
111
+ value = parse_option(argv, "--port")
112
+ value ? value.to_i : 3000
113
+ end
114
+
115
+ def parse_option(argv, flag)
116
+ index = argv.index(flag)
117
+ index ? argv[index + 1] : nil
109
118
  end
110
119
 
111
120
  def check_cloudflared!
@@ -121,12 +130,16 @@ module RubyNative
121
130
  end
122
131
 
123
132
  def start_tunnel
124
- puts "Starting tunnel to http://localhost:#{@port}..."
125
- puts "Make sure your Rails server is running on port #{@port} in another terminal."
133
+ puts "Starting tunnel to #{@upstream}..."
134
+ if @url
135
+ puts "Make sure your Rails server is reachable at #{@url}."
136
+ else
137
+ puts "Make sure your Rails server is running on port #{@port} in another terminal."
138
+ end
126
139
  puts ""
127
140
 
128
141
  stdin, stdout_err, wait_thread = Open3.popen2e(
129
- "cloudflared", "tunnel", "--url", "http://localhost:#{@port}"
142
+ "cloudflared", "tunnel", "--url", @upstream
130
143
  )
131
144
  stdin.close
132
145
 
@@ -175,7 +188,11 @@ module RubyNative
175
188
  puts url
176
189
  puts ""
177
190
  puts "Scan the QR code or paste the URL into the Ruby Native Preview app."
178
- puts "Keep this running and your Rails server on port #{@port} in another terminal."
191
+ if @url
192
+ puts "Keep this running and your Rails server reachable at #{@url}."
193
+ else
194
+ puts "Keep this running and your Rails server on port #{@port} in another terminal."
195
+ end
179
196
  puts "Press Ctrl+C to stop."
180
197
  end
181
198
 
@@ -73,6 +73,18 @@ module RubyNative
73
73
  data
74
74
  end
75
75
 
76
+ # Renders a signal element that asks the app to request an App Store
77
+ # rating from the user. The system decides whether to actually show the
78
+ # prompt (Apple throttles it to a few times per year), so it is safe to
79
+ # render this on any page where a review would be welcome, like a
80
+ # confirmation screen after the user finishes something worthwhile.
81
+ #
82
+ # See Apple's docs on requesting App Store reviews:
83
+ # https://developer.apple.com/documentation/storekit/requesting-app-store-reviews
84
+ def native_review_tag
85
+ tag.div(data: { native_review: true }, hidden: true)
86
+ end
87
+
76
88
  # Picks the right icon name for the current native platform. Accepts the
77
89
  # single `icon:` form (applied to every platform) and/or the `icons:` hash
78
90
  # form (`{ ios: "...", android: "..." }`). When both are given, a matching
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.4"
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.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti