ruby_native 0.7.0 → 0.8.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: 8cbf9c1f97b07ee4e4f6bb1f48b529f55928b19ceedc11cd6910ad85da451d36
4
- data.tar.gz: 6911ed4b628413e7ae1234068bdd6efd3ba682ca1f6e93a15565866c6f19dfea
3
+ metadata.gz: 14d5f9a36897b60216aa1be47dff449c2df67714bb2e5126a328c338880c08ca
4
+ data.tar.gz: f34ad47417b280405eeaed9ece9a76fca2d3205968040d5064513fa04ec801ea
5
5
  SHA512:
6
- metadata.gz: 8936caf8661fc97745fe2282b55650c66a903e2880544247fc16c3668b5ddf0723bc369089cbf89d7ffc88151a7c4464649f33af14d6dca1853833fab1a0803d
7
- data.tar.gz: a3c94710c642b99f3d5bb48929dad93f5d865dfc815aa4cb2da8337ef22defd140e3367c0159376cb7110f8ffaf1f9b14a0480149e99376f68e972c2933a0d2d
6
+ metadata.gz: ce0bbd95aef443ed74c8b7990d988ff8afe2d78b8bf02b3284f7bc0ad7989629b1f31cc1f1ae5750efcbf7c6f4c8afe67aa8249694682b0760f0486406e7b12f
7
+ data.tar.gz: 5430d11acfdf0e8ff79b7b4e3f72af61dea68a881650bea745058335fa891349c30b64662650578c689d4cc15c43ff6b3b77de2ccf4ff83df724705ae745f16c
@@ -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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.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.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti