ruby_native 0.7.0 → 0.8.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59fd793a678f35fc19666a9e5a182a3d33fceab98957ec486f4fb02983c8050c
|
|
4
|
+
data.tar.gz: 045fd16fede9352d7a2c86502b633b5f06f432a16a9cf2bcce8dae520601b522
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4eae6af16060395f8a75d58fcd883b4cd69dc2ff69465d7da8be31cf1074d5c558733072ef68db069f721291a5734ad1f0c448c9b10f5576fd1c07223236680
|
|
7
|
+
data.tar.gz: be5da276be7b009b947090396f96dfd7db7e53b9d182ab3c94e1c837d8fbe46774196de0510266f0c4ee85c778d1bd77f833f204e2f94bd9609fff64b77e2331
|
|
@@ -21,9 +21,12 @@ rails generate ruby_native:install
|
|
|
21
21
|
4. Add to your layout `<head>`:
|
|
22
22
|
|
|
23
23
|
```erb
|
|
24
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
24
25
|
<%= stylesheet_link_tag :ruby_native %>
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
The `viewport-fit=cover` attribute is required so CSS `env(safe-area-inset-*)` variables return real values. If you already have a viewport meta tag, add `viewport-fit=cover` to its `content` attribute.
|
|
29
|
+
|
|
27
30
|
5. Add to your layout `<body>`:
|
|
28
31
|
|
|
29
32
|
```erb
|
|
@@ -126,6 +129,35 @@ The gem auto-mounts at `/native`. No route configuration needed.
|
|
|
126
129
|
- `GET /native/config` returns the YAML config as JSON
|
|
127
130
|
- `POST /native/push/devices` registers a push notification device token
|
|
128
131
|
|
|
132
|
+
## CLI
|
|
133
|
+
|
|
134
|
+
### Deploy from CI
|
|
135
|
+
|
|
136
|
+
Use `--if-needed` to auto-deploy only when the gem version changes:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
bundle exec ruby_native deploy --if-needed
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Set `RUBY_NATIVE_TOKEN` as an environment variable for CI (no interactive login needed):
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
# GitHub Actions
|
|
146
|
+
- run: bundle exec ruby_native deploy --if-needed
|
|
147
|
+
env:
|
|
148
|
+
RUBY_NATIVE_TOKEN: ${{ secrets.RUBY_NATIVE_TOKEN }}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Other commands
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
bundle exec ruby_native login # authenticate (opens browser)
|
|
155
|
+
bundle exec ruby_native deploy # trigger a build
|
|
156
|
+
bundle exec ruby_native preview # start a tunnel and display a QR code
|
|
157
|
+
bundle exec ruby_native screenshots # capture App Store screenshots
|
|
158
|
+
bundle exec ruby_native logout # remove stored credentials
|
|
159
|
+
```
|
|
160
|
+
|
|
129
161
|
## Common tasks
|
|
130
162
|
|
|
131
163
|
### Hide web navigation in the native app
|
|
@@ -7,6 +7,10 @@ module RubyNative
|
|
|
7
7
|
PATH = File.join(Dir.home, ".ruby_native", "credentials")
|
|
8
8
|
|
|
9
9
|
def self.token
|
|
10
|
+
ENV["RUBY_NATIVE_TOKEN"] || file_token
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.file_token
|
|
10
14
|
return unless File.exist?(PATH)
|
|
11
15
|
JSON.parse(File.read(PATH))["token"]
|
|
12
16
|
rescue JSON::ParserError
|
|
@@ -2,6 +2,7 @@ require "json"
|
|
|
2
2
|
require "net/http"
|
|
3
3
|
require "uri"
|
|
4
4
|
require "ruby_native/cli/credentials"
|
|
5
|
+
require "ruby_native/version"
|
|
5
6
|
|
|
6
7
|
module RubyNative
|
|
7
8
|
class CLI
|
|
@@ -14,13 +15,22 @@ module RubyNative
|
|
|
14
15
|
TokenExpiredError = Class.new(StandardError)
|
|
15
16
|
|
|
16
17
|
def initialize(argv)
|
|
18
|
+
@if_needed = argv.include?("--if-needed")
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def run
|
|
20
22
|
load_config!
|
|
21
23
|
ensure_authenticated!
|
|
22
24
|
app_id = resolve_app_id!
|
|
25
|
+
|
|
26
|
+
if @if_needed && skip_build?(app_id)
|
|
27
|
+
puts "Ruby Native v#{RubyNative::VERSION} already built. Skipping deploy."
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
23
31
|
build = trigger_build(app_id)
|
|
32
|
+
return if @if_needed
|
|
33
|
+
|
|
24
34
|
poll_build_status(app_id, build)
|
|
25
35
|
end
|
|
26
36
|
|
|
@@ -53,6 +63,39 @@ module RubyNative
|
|
|
53
63
|
app_id
|
|
54
64
|
end
|
|
55
65
|
|
|
66
|
+
# --- Version check ---
|
|
67
|
+
|
|
68
|
+
def skip_build?(app_id)
|
|
69
|
+
latest = fetch_latest_build(app_id)
|
|
70
|
+
return false unless latest
|
|
71
|
+
|
|
72
|
+
latest_gem_version = latest["gem_version"]
|
|
73
|
+
return false unless latest_gem_version
|
|
74
|
+
|
|
75
|
+
Gem::Version.new(latest_gem_version) >= Gem::Version.new(RubyNative::VERSION)
|
|
76
|
+
rescue ArgumentError
|
|
77
|
+
false
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def fetch_latest_build(app_id)
|
|
81
|
+
uri = URI("#{HOST}/api/v1/apps/#{app_id}/builds/latest")
|
|
82
|
+
req = Net::HTTP::Get.new(uri)
|
|
83
|
+
req["Authorization"] = "Token #{Credentials.token}"
|
|
84
|
+
|
|
85
|
+
response = make_request(uri, req)
|
|
86
|
+
|
|
87
|
+
case response
|
|
88
|
+
when Net::HTTPSuccess
|
|
89
|
+
JSON.parse(response.body)
|
|
90
|
+
when Net::HTTPNoContent
|
|
91
|
+
nil
|
|
92
|
+
when Net::HTTPUnauthorized
|
|
93
|
+
raise TokenExpiredError
|
|
94
|
+
else
|
|
95
|
+
nil
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
56
99
|
# --- Build ---
|
|
57
100
|
|
|
58
101
|
def trigger_build(app_id)
|
|
@@ -62,6 +105,7 @@ module RubyNative
|
|
|
62
105
|
req = Net::HTTP::Post.new(uri)
|
|
63
106
|
req["Authorization"] = "Token #{Credentials.token}"
|
|
64
107
|
req["Content-Type"] = "application/json"
|
|
108
|
+
req.body = JSON.generate(gem_version: RubyNative::VERSION)
|
|
65
109
|
|
|
66
110
|
response = make_request(uri, req)
|
|
67
111
|
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -40,6 +40,13 @@ module RubyNative
|
|
|
40
40
|
tag.div(data: { native_navbar: title.to_s }, hidden: true) { builder.to_html }
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
def native_fab_tag(icon:, href: nil, click: nil)
|
|
44
|
+
data = { native_fab: true, native_icon: icon }
|
|
45
|
+
data[:native_href] = href if href
|
|
46
|
+
data[:native_click] = click if click
|
|
47
|
+
tag.div(data: data, hidden: true)
|
|
48
|
+
end
|
|
49
|
+
|
|
43
50
|
def native_overscroll_tag(top:, bottom: nil)
|
|
44
51
|
tag.div(data: { native_overscroll_top: top, native_overscroll_bottom: bottom || top }, hidden: true)
|
|
45
52
|
end
|
data/lib/ruby_native/version.rb
CHANGED