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 +4 -4
- data/README.md +1 -0
- data/lib/ruby_native/helper.rb +0 -4
- data/lib/ruby_native/native_detection.rb +9 -0
- data/lib/ruby_native/version.rb +1 -1
- data/lib/ruby_native.rb +1 -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: b546f190679f4ae4dde09215caab504a0a1d08066a21550b0489c2b85918f04b
|
|
4
|
+
data.tar.gz: a13166af16459ef7d46bfa04b4527d378975928f5d69125d17060f3f66641cd0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -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
|
data/lib/ruby_native/version.rb
CHANGED
data/lib/ruby_native.rb
CHANGED