ruby_native 0.1.3 → 0.1.5

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: aa4462855e62841b90cda69ebd6fd10e6286d61d6432f1bf4faf601a6a691daf
4
+ data.tar.gz: 3420d0c6584aa8da8e71c96918576cfbf9a298cbb7de9b3e666114674eba5137
5
5
  SHA512:
6
- metadata.gz: 8566892b7a575d4b60fcda366827f663ac9b8ca66b2b80e4133f432434687f2b73b1276140e1b7fe3134f77bbab3daf60e136d8b3c6b4c28acb6cfc8079ca1a3
7
- data.tar.gz: 48733345d9bf04179752359e7c3fd20ed9f72b1cbd5ed94983b0f5b1f6a74e5fc585bc4edda37b51425759ef793e4e39aeb2cd3112acc34b6fa3a3ccccf315f6
6
+ metadata.gz: 2388cb1e1a48d7980cefa1e5d59647c655c04b17d957fc3d47bd2c6d80a79c63d012290e2649d7f3c7e738caaa7755391b2d6ad9c7303051544e566e25609d04
7
+ data.tar.gz: d63ea8c05fb937ea8b2f28d874467824a68609006bca637ab7a05ebb7e72a5cb2130e98613972cf3af330ae8947ba7c14d08687a47172f90ced7c06fa006beef
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.5"
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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Masilotti