ruby_native 0.1.3 → 0.1.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: 20d760214b3f22f2ad779114c93fea5123415f54eae344bd4b8615704a5abc06
4
- data.tar.gz: a840dcc62eb743a8319646fbc31429b62ec3bcd42c5927cbecf51bb1e72c114c
3
+ metadata.gz: b546f190679f4ae4dde09215caab504a0a1d08066a21550b0489c2b85918f04b
4
+ data.tar.gz: a13166af16459ef7d46bfa04b4527d378975928f5d69125d17060f3f66641cd0
5
5
  SHA512:
6
- metadata.gz: 8566892b7a575d4b60fcda366827f663ac9b8ca66b2b80e4133f432434687f2b73b1276140e1b7fe3134f77bbab3daf60e136d8b3c6b4c28acb6cfc8079ca1a3
7
- data.tar.gz: 48733345d9bf04179752359e7c3fd20ed9f72b1cbd5ed94983b0f5b1f6a74e5fc585bc4edda37b51425759ef793e4e39aeb2cd3112acc34b6fa3a3ccccf315f6
6
+ metadata.gz: 945389ac999ee2fc61577ca83483169e3bc0366db35817b8f730d8e405070e657a63b0c59f08ae24b59995651eafb3cff2a3662dc571767f172ee4261781b2bb
7
+ data.tar.gz: db4a34d192c1166ee9a64ed5983a940038bd43e5e7ee19b8def64666f00e29c61ed9415d8bf405fd28abc6c761bf58be29dc175ffcc4525727c324e7cfebf2be
data/README.md CHANGED
@@ -91,6 +91,7 @@ Place helpers in the `<body>`, not the `<head>`.
91
91
  ### Any mode
92
92
 
93
93
  - `native_app?` - true when the request comes from a Ruby Native app (checks user agent)
94
+ - `native_version` - returns the app version as a `RubyNative::NativeVersion`. Defaults to `"0"` when the version is unknown. Supports string comparisons: `native_version >= "1.4"`.
94
95
  - `native_tabs_tag(enabled: true)` - shows the native tab bar.
95
96
  - `native_push_tag` - requests push notification permission.
96
97
  - `native_back_button_tag(text = nil, **options)` - renders a back button for Normal Mode. Hidden by default, shown when the native app sets `body.can-go-back`. Not needed in [Advanced Mode](https://rubynative.com/docs/advanced-mode) where the system provides a native back button.
@@ -1,9 +1,5 @@
1
1
  module RubyNative
2
2
  module Helper
3
- def native_app?
4
- request.user_agent.to_s.include?("Ruby Native")
5
- end
6
-
7
3
  def native_tabs_tag(enabled: true)
8
4
  safe_join([
9
5
  (tag.div(data: { native_tabs: true }, hidden: true) if enabled),
@@ -2,8 +2,17 @@ module RubyNative
2
2
  module NativeDetection
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ included do
6
+ helper_method :native_app?, :native_version if respond_to?(:helper_method)
7
+ end
8
+
5
9
  def native_app?
6
10
  request.user_agent.to_s.include?("Ruby Native")
7
11
  end
12
+
13
+ def native_version
14
+ match = request.user_agent.to_s.match(/Ruby Native.*?\/([\d.]+)/)
15
+ NativeVersion.new(match ? match[1] : "0")
16
+ end
8
17
  end
9
18
  end
@@ -1,3 +1,3 @@
1
1
  module RubyNative
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/ruby_native.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "ruby_native/version"
2
2
  require "ruby_native/helper"
3
+ require "ruby_native/native_version"
3
4
  require "ruby_native/native_detection"
4
5
  require "ruby_native/oauth_middleware"
5
6
  require "ruby_native/engine"
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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti