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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308d144022ae260825f489654d98d381884a854c7c254e63dee358fb07b5cb6a
4
- data.tar.gz: a97d9f02879fd5102fd1587d7c1acd3a98785f77d61cd644462432dcfaaea811
3
+ metadata.gz: 214a6d7b02be3c7c90c308071419aae2ea57f13257450199eab2eab0ef9f7e6b
4
+ data.tar.gz: c2791d0963affa9ad1fa1bd3774ebef1ffa102605814c4085180adfb354d9218
5
5
  SHA512:
6
- metadata.gz: c94e639470044f93aece21cbcc4196a293971df9d44c4d7852f1ce9f42c4c374202b3efd6f5133712f0cf19020feb3f80214e9c13788bccf76c7146fdd5a3fcf
7
- data.tar.gz: 03a7240dd07185e77f36378d3f00b7b6c4046890645cc382334bead2d4d108052b729f35a9a069be9df1a4a5a2aa14a39007333dff92d97cc0f41787b92baea5
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
- device = ruby_native_user.push_devices.find_or_initialize_by(token: params[:token])
8
- device.update!(platform: params[:platform], name: params[:name])
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
- namespace :push do
4
- resources :devices, only: :create
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
- namespace :webhooks do
11
- resource :apple, only: :create, controller: "apple"
12
- end
13
- namespace :iap do
14
- resources :purchases, only: :create
15
- post "completions/:uuid", to: "completions#create", as: :completion
16
- resource :restore, only: :create
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
@@ -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"
@@ -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 = nil, pull_to_refresh: true, logo: nil, &block)
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
- data = { native_navbar: title.to_s }
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
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.21.0"
2
+ VERSION = "0.21.1"
3
3
  end
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
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.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti