ruby_native 0.21.0 → 0.21.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/README.md +14 -0
- data/app/controllers/ruby_native/push/devices_controller.rb +6 -2
- data/config/routes.rb +13 -9
- data/config/signals.yml +3 -0
- data/lib/generators/ruby_native/iap_generator.rb +12 -0
- data/lib/ruby_native/engine.rb +6 -0
- data/lib/ruby_native/helper.rb +10 -2
- data/lib/ruby_native/oauth_middleware.rb +2 -0
- data/lib/ruby_native/version.rb +1 -1
- data/lib/ruby_native.rb +5 -0
- 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: 214a6d7b02be3c7c90c308071419aae2ea57f13257450199eab2eab0ef9f7e6b
|
|
4
|
+
data.tar.gz: c2791d0963affa9ad1fa1bd3774ebef1ffa102605814c4085180adfb354d9218
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b94380d87da65e5f8ac6b8a0cabf310c692325a3394ad8ac581ac8d86eadd95828d28fded7157e93a11ad57df580d7695c71e5edf672c2faff83f63e418cc22
|
|
7
|
+
data.tar.gz: 974292315e6f1d86746295a56a71f1dfef557d78d7db371112f3060577c6ae96a189c72188262559c2cde8198d0f672f104a5e81389b736c65a96ebdcecdb75f
|
data/README.md
CHANGED
|
@@ -66,6 +66,20 @@ tabs:
|
|
|
66
66
|
|
|
67
67
|
Changes are picked up without restarting the server in development. See [rubynative.com/docs](https://rubynative.com/docs) for the full schema: appearance and dark mode, navbar branding, Advanced Mode, OAuth, and linked domains.
|
|
68
68
|
|
|
69
|
+
### In-app purchase and push routes
|
|
70
|
+
|
|
71
|
+
In-app purchase routes are off by default. `bin/rails g ruby_native:iap` turns them on, or add this to `config/initializers/ruby_native.rb`:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
RubyNative.configure { |config| config.iap_enabled = true }
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This adds the purchase, completion, restore, and Apple subscription webhook routes.
|
|
78
|
+
|
|
79
|
+
The push device route, `POST /native/push/devices`, is on by default. Set `config.push_enabled = false` to handle it yourself with your own `post "/native/push/devices"` route, since the app always sends tokens to that path.
|
|
80
|
+
|
|
81
|
+
Restart the server after changing the initializer.
|
|
82
|
+
|
|
69
83
|
## Preview
|
|
70
84
|
|
|
71
85
|
Preview your app on a real device without deploying:
|
|
@@ -4,8 +4,12 @@ module RubyNative
|
|
|
4
4
|
skip_forgery_protection
|
|
5
5
|
|
|
6
6
|
def create
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
token = params[:token]
|
|
8
|
+
return head :bad_request unless token.is_a?(String) && token.present?
|
|
9
|
+
|
|
10
|
+
device = ruby_native_user.push_devices.find_or_initialize_by(token: token)
|
|
11
|
+
return head :unprocessable_entity unless device.update(platform: params[:platform], name: params[:name])
|
|
12
|
+
|
|
9
13
|
head :ok
|
|
10
14
|
end
|
|
11
15
|
|
data/config/routes.rb
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
RubyNative::Engine.routes.draw do
|
|
2
2
|
resource :config, only: :show, controller: "config"
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
if RubyNative.push_enabled
|
|
4
|
+
namespace :push do
|
|
5
|
+
resources :devices, only: :create
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
8
|
namespace :auth do
|
|
7
9
|
get "start/:provider", to: "start#show", as: :start
|
|
8
10
|
resource :session, only: :show
|
|
9
11
|
end
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if RubyNative.iap_enabled
|
|
13
|
+
namespace :webhooks do
|
|
14
|
+
resource :apple, only: :create, controller: "apple"
|
|
15
|
+
end
|
|
16
|
+
namespace :iap do
|
|
17
|
+
resources :purchases, only: :create
|
|
18
|
+
post "completions/:uuid", to: "completions#create", as: :completion
|
|
19
|
+
resource :restore, only: :create
|
|
20
|
+
end
|
|
17
21
|
end
|
|
18
22
|
namespace :screenshots do
|
|
19
23
|
resource :session, only: :show, controller: "sessions"
|
data/config/signals.yml
CHANGED
|
@@ -110,6 +110,9 @@ signals:
|
|
|
110
110
|
data-native-navbar-logo:
|
|
111
111
|
since: "0.21.0"
|
|
112
112
|
helper: native_navbar_tag
|
|
113
|
+
data-native-navbar-title:
|
|
114
|
+
since: "0.21.1"
|
|
115
|
+
helper: native_navbar_tag
|
|
113
116
|
data-native-overscroll-bottom:
|
|
114
117
|
since: "0.5.0"
|
|
115
118
|
helper: native_overscroll_tag
|
|
@@ -32,6 +32,18 @@ module RubyNative
|
|
|
32
32
|
"db/migrate/add_restored_transaction_id_to_ruby_native_purchase_intents.rb"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def enable_iap_routes
|
|
36
|
+
path = "config/initializers/ruby_native.rb"
|
|
37
|
+
line = "RubyNative.configure { |config| config.iap_enabled = true }\n"
|
|
38
|
+
full_path = File.join(destination_root, path)
|
|
39
|
+
|
|
40
|
+
if !File.exist?(full_path)
|
|
41
|
+
create_file path, line
|
|
42
|
+
elsif !File.read(full_path).include?("iap_enabled")
|
|
43
|
+
append_to_file path, "\n#{line}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
35
47
|
def print_next_steps
|
|
36
48
|
say ""
|
|
37
49
|
say "Ruby Native IAP installed!", :green
|
data/lib/ruby_native/engine.rb
CHANGED
|
@@ -42,6 +42,12 @@ module RubyNative
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
config.after_initialize do
|
|
46
|
+
if RubyNative.subscription_callbacks.any? && !RubyNative.iap_enabled
|
|
47
|
+
Rails.logger.warn("[RubyNative] on_subscription_change is set but in-app purchase routes are off. Add `config.iap_enabled = true` to RubyNative.configure.")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
initializer "ruby_native.routes" do |app|
|
|
46
52
|
app.routes.prepend do
|
|
47
53
|
get "/.well-known/apple-app-site-association", to: "ruby_native/aasa#show"
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -223,9 +223,15 @@ module RubyNative
|
|
|
223
223
|
tag.div(data: data, hidden: true)
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
+
NAVBAR_TITLE_OMITTED = Object.new.freeze
|
|
227
|
+
private_constant :NAVBAR_TITLE_OMITTED
|
|
228
|
+
|
|
229
|
+
# With no title the bar shows the page's `<title>`. An explicit blank title
|
|
230
|
+
# (`""`, `nil`, or `false`) leaves the bar without any title text.
|
|
231
|
+
#
|
|
226
232
|
# `logo: false` hides `appearance.navbar.logo` on this page and shows the
|
|
227
233
|
# title instead. The logo shows everywhere else, as it does without the option.
|
|
228
|
-
def native_navbar_tag(title =
|
|
234
|
+
def native_navbar_tag(title = NAVBAR_TITLE_OMITTED, pull_to_refresh: true, logo: nil, &block)
|
|
229
235
|
unless [ nil, true, false ].include?(logo)
|
|
230
236
|
raise ArgumentError, "native_navbar_tag logo: must be true or false, got #{logo.inspect}"
|
|
231
237
|
end
|
|
@@ -233,7 +239,9 @@ module RubyNative
|
|
|
233
239
|
builder = NavbarBuilder.new(self)
|
|
234
240
|
capture(builder, &block) if block
|
|
235
241
|
|
|
236
|
-
|
|
242
|
+
omitted = title.equal?(NAVBAR_TITLE_OMITTED)
|
|
243
|
+
data = { native_navbar: omitted || title.blank? ? "" : title.to_s }
|
|
244
|
+
data[:native_navbar_title] = "false" if !omitted && title.blank?
|
|
237
245
|
data[:native_pull_to_refresh] = "false" unless pull_to_refresh
|
|
238
246
|
data[:native_navbar_logo] = logo.to_s unless logo.nil?
|
|
239
247
|
tag.div(data: data, hidden: true) { builder.to_html }
|
|
@@ -70,6 +70,8 @@ module RubyNative
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def self.read_token(token)
|
|
73
|
+
return nil unless token.is_a?(String) && token.present?
|
|
74
|
+
|
|
73
75
|
data = encryptor.decrypt_and_verify(token, purpose: "ruby_native_oauth")
|
|
74
76
|
data&.symbolize_keys
|
|
75
77
|
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
data/lib/ruby_native/version.rb
CHANGED
data/lib/ruby_native.rb
CHANGED
|
@@ -19,6 +19,11 @@ require "ruby_native/engine"
|
|
|
19
19
|
module RubyNative
|
|
20
20
|
mattr_accessor :subscription_callbacks, default: []
|
|
21
21
|
|
|
22
|
+
# Read when routes are drawn, so set them in an initializer. The IAP
|
|
23
|
+
# generator turns on `iap_enabled`; set `push_enabled` false to use your own endpoint.
|
|
24
|
+
mattr_accessor :iap_enabled, default: false
|
|
25
|
+
mattr_accessor :push_enabled, default: true
|
|
26
|
+
|
|
22
27
|
# Screenshot configuration. Set via `RubyNative.configure` in an initializer.
|
|
23
28
|
mattr_accessor :screenshot_key
|
|
24
29
|
mattr_accessor :screenshot_sign_in
|