hotwire_native_version_gate 0.2.0 → 0.3.0

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: b384ce481e578f198a0f503b3b3f7230b16f590687f2d8b82338884c51497205
4
- data.tar.gz: c775c3b942f4e91b9fead131b59f2f1794482ef7b8d747925509cff84786e98d
3
+ metadata.gz: 76b2d43b870dbf0099ed5a0c6e465a1853cc2ae96b2ab16f06570aa6397d71af
4
+ data.tar.gz: '08393f721a6e48fc5193c5a34c6b4c76936a1aa923c1b04c209c0666a66e7ad7'
5
5
  SHA512:
6
- metadata.gz: 712bb5741e30bad54c4f5b909c129113a305223e07a0d950330614059b0d5e0942fb818a84ed66566fbfa39cffe2fcd206fd299a694e6c9936464ca3928b09fb
7
- data.tar.gz: c5ef5a8af322f641e755e5e718995ed0b811b16afc25dd03e6ad5f161d4ac7a60fd2d3c83f2c91570a4dd43cbe499a942e318c1986da4f007f42db9a0793db82
6
+ metadata.gz: ea6c7456e14d5cdc4336c9ea872741087b203b01dd00b45ae36961182b589c83c260195d05b131445ba873c89b2423d31b79ff327ba2ce56ec535802734688e0
7
+ data.tar.gz: a4345f8b1044668538d643242c8fc8fb67aa43291365794cf60c041ef7f1371570de93f25c4d23fb812011d477414cfefe7d119ccde86183396fb11ef5990ac7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -20,18 +20,23 @@ module HotwireNativeVersionGate
20
20
 
21
21
  included do
22
22
  if respond_to?(:helper_method)
23
- helper_method :native_feature_enabled?
23
+ helper_method :native_feature_enabled?, :hotwire_native_ios?, :hotwire_native_android?
24
24
  end
25
25
  end
26
26
 
27
27
  def native_feature_enabled?(feature)
28
- user_agent = if respond_to?(:request) && request.respond_to?(:user_agent)
29
- request.user_agent
30
- else
31
- nil
32
- end
33
-
28
+ user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil
34
29
  VersionGate.feature_enabled?(feature, user_agent, context: self)
35
30
  end
31
+
32
+ def hotwire_native_ios?
33
+ user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil
34
+ VersionGate.ios?(user_agent)
35
+ end
36
+
37
+ def hotwire_native_android?
38
+ user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil
39
+ VersionGate.android?(user_agent)
40
+ end
36
41
  end
37
42
  end
@@ -36,6 +36,16 @@ module HotwireNativeVersionGate
36
36
  handle_feature(feature_config, user_agent, context: context)
37
37
  end
38
38
 
39
+ def ios?(user_agent)
40
+ platform = match_platform(user_agent)
41
+ platform&.downcase == 'ios'
42
+ end
43
+
44
+ def android?(user_agent)
45
+ platform = match_platform(user_agent)
46
+ platform&.downcase == 'android'
47
+ end
48
+
39
49
  private
40
50
 
41
51
  def validate_regexes(regexes)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_native_version_gate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Yamartino