hotwire_native_rails 0.3.1 → 0.3.2

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: db9feb69df016d6781d12df5d095422b9984afe20e0128add4ec5db096bc9232
4
- data.tar.gz: ae82da4ac986d04d552d47207b7c93dc75fea6cde2e38944f8b9926997d89b3e
3
+ metadata.gz: b7c5dccf379ea2df338bbcb79be305de69d6bddf6d18b90aa385b3b5cfa02c0a
4
+ data.tar.gz: 735bb16d4b1edea360e76be697e2b2205fed6bb3cc600a1d701f62d2bfcf50b9
5
5
  SHA512:
6
- metadata.gz: 18302cf1e8af968d95a23685db7d7020375060bc7a22b628b146d3596791fcdd18409f818d04456594b030d2ab40bc98f90b4d6c1d08fd3108448929155c16f8
7
- data.tar.gz: 1385c781224c90744b7eeea4b7fa5690524768cd5fc21db85085ac1725b42ae0f901bc433a80082771ba88e1ca04f1a1c8918dbbcf692e87f82d015cc48a9bfb
6
+ metadata.gz: f85af13e81abf134367debe8dd96ba2159dd291daf517c142c97784515df219cf8f4e8388ac56e9fbbacbbf455a00edd44f5124e08400a3ea45f5261f51bd1f3
7
+ data.tar.gz: 4f17e15e2067bdef0aa9db0c9295410f19315ba7159e761d5e323f5e29d32154f2ed788f03bd9186d265495158a44cfce5c7694bd1a7d22903642f4b42e3e0cc
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.end_with?('.gem') }
23
23
  end
24
24
  end
@@ -9,11 +9,13 @@ class HotwireNativeGenerator < Rails::Generators::Base
9
9
  # helpers
10
10
  copy_file "helpers/hotwire_native_helper.rb", "app/helpers/hotwire_native_helper.rb"
11
11
  copy_file "test_unit/hotwire_native_helper_test.rb", "test/helpers/hotwire_native_helper_test.rb"
12
+ copy_file "test_unit/hotwire_native_controller_test.rb", "test/controllers/hotwire_native_controller_test.rb"
12
13
 
13
14
  # routes
14
15
  copy_file "routes/hotwire_native.rb", "config/routes/hotwire_native.rb"
15
- copy_file "controllers/hotwire_native/v1/android/path_configuration_controller.rb", "app/controllers/hotwire_native/v1/android/path_configuration_controller.rb"
16
- copy_file "controllers/hotwire_native/v1/ios/path_configuration_controller.rb", "app/controllers/hotwire_native/v1/ios/path_configuration_controller.rb"
16
+ copy_file "controllers/hotwire_native/v1/android/path_configurations_controller.rb", "app/controllers/hotwire_native/v1/android/path_configurations_controller.rb"
17
+ copy_file "controllers/hotwire_native/v1/ios/path_configurations_controller.rb", "app/controllers/hotwire_native/v1/ios/path_configurations_controller.rb"
18
+ copy_file "test_unit/path_configurations_controller_test.rb", "test/controllers/path_configurations_controller_test.rb"
17
19
 
18
20
  # :native request variant
19
21
  copy_file "controllers/concerns/device_format.rb", "app/controllers/concerns/device_format.rb"
@@ -8,6 +8,6 @@ module DeviceFormat
8
8
  private
9
9
 
10
10
  def set_variant
11
- return request.variant = :mobile if turbo_native_app? || browser.device.mobile?
11
+ request.variant = :mobile if turbo_native_app? || browser.device.mobile?
12
12
  end
13
13
  end
@@ -37,37 +37,37 @@ module HotwireNativeHelper
37
37
  end
38
38
 
39
39
  # override link_to to not open internal links in in-app browser on native app
40
- def link_to(name = nil, options = nil, html_options = {}, &block)
40
+ def link_to(name = nil, options = nil, html_options = {}, &)
41
41
  html_options[:target] = '' if turbo_native_app? && internal_url?(url_for(options))
42
- super(name, options, html_options, &block)
42
+ super
43
43
  end
44
44
 
45
45
  # https://github.com/joemasilotti/daily-log/blob/main/rails/app/helpers/form_helper.rb
46
46
  class BridgeFormBuilder < ActionView::Helpers::FormBuilder
47
47
  def submit(value = nil, options = {})
48
48
  options[:data] ||= {}
49
- options["data-bridge--form-target"] = "submit"
50
- options[:class] = [options[:class], "turbo-native:hidden"].compact
51
- super(value, options)
49
+ options['data-bridge--form-target'] = 'submit'
50
+ options[:class] = [options[:class], 'turbo-native:hidden'].compact
51
+ super
52
52
  end
53
53
  end
54
54
 
55
- def bridge_form_with(*, **options, &block)
55
+ def bridge_form_with(*, **options, &)
56
56
  options[:html] ||= {}
57
57
  options[:html][:data] ||= {}
58
58
  options[:html][:data] = options[:html][:data].merge(bridge_form_data)
59
59
 
60
60
  options[:builder] = BridgeFormBuilder
61
61
 
62
- form_with(*, **options, &block)
62
+ form_with(*, **options, &)
63
63
  end
64
64
 
65
65
  private
66
66
 
67
67
  def bridge_form_data
68
68
  {
69
- controller: "bridge--form",
70
- action: "turbo:submit-start->bridge--form#submitStart turbo:submit-end->bridge--form#submitEnd"
69
+ controller: 'bridge--form',
70
+ action: 'turbo:submit-start->bridge--form#submitStart turbo:submit-end->bridge--form#submitEnd'
71
71
  }
72
72
  end
73
73
 
@@ -0,0 +1,15 @@
1
+ require "test_helper"
2
+
3
+ class HotwireNativeTest < ActionDispatch::IntegrationTest
4
+ test 'zoom is disabled for native' do
5
+ get root_path, headers: { HTTP_USER_AGENT: 'Hotwire Native' }
6
+ assert_response :success
7
+ assert_match(/user-scalable=0/, response.body)
8
+ end
9
+
10
+ test 'zoom is enabled for web' do
11
+ get root_path
12
+ assert_response :success
13
+ assert_no_match(/user-scalable=0/, response.body)
14
+ end
15
+ end
@@ -1,54 +1,53 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class HotwireNativeHelperTest < ActionView::TestCase
4
- # add more tests
5
4
  setup do
6
5
  def root_url
7
- "http://test.host/"
8
- end
6
+ 'http://test.host/'
7
+ end
9
8
  end
10
9
 
11
- test "link_to removes target for internal links in turbo native app" do
10
+ test 'link_to removes target for internal links in turbo native app' do
12
11
  def turbo_native_app?
13
12
  true
14
13
  end
15
14
 
16
- result = link_to("Home", "/foo/bar", target: "_blank")
17
- assert_no_match /target="_blank"/, result
15
+ result = link_to('Home', '/foo/bar', target: '_blank', rel: 'noopener')
16
+ assert_no_match(/target="_blank"/, result)
18
17
  end
19
18
 
20
- test "link_to keeps target for external links in turbo native app" do
19
+ test 'link_to keeps target for external links in turbo native app' do
21
20
  def turbo_native_app?
22
21
  true
23
22
  end
24
-
25
- result = link_to("External", "http://external.com", target: "_blank")
26
- assert_match /target="_blank"/, result
23
+
24
+ result = link_to('External', 'http://external.com', target: '_blank', rel: 'noopener')
25
+ assert_match(/target="_blank"/, result)
27
26
  end
28
27
 
29
- test "link_to keeps target for internal links when not in turbo native app" do
28
+ test 'link_to keeps target for internal links when not in turbo native app' do
30
29
  def turbo_native_app?
31
30
  false
32
31
  end
33
-
34
- result = link_to("Home", root_url, target: "_blank")
35
- assert_match /target="_blank"/, result
32
+
33
+ result = link_to('Home', root_url, target: '_blank', rel: 'noopener')
34
+ assert_match(/target="_blank"/, result)
36
35
  end
37
36
 
38
- test "link_to keeps target for external links when not in turbo native app" do
37
+ test 'link_to keeps target for external links when not in turbo native app' do
39
38
  def turbo_native_app?
40
39
  false
41
40
  end
42
41
 
43
- result = link_to("External", "http://external.com", target: "_blank")
44
- assert_match /target="_blank"/, result
42
+ result = link_to('External', 'http://external.com', target: '_blank', rel: 'noopener')
43
+ assert_match(/target="_blank"/, result)
45
44
  end
46
45
 
47
- test "internal_url? returns true for internal links" do
48
- assert internal_url?("http://test.host/some_path")
46
+ test 'internal_url? returns true for internal links' do
47
+ assert internal_url?('http://test.host/some_path')
49
48
  end
50
49
 
51
- test "internal_url? returns false for external links" do
52
- assert_not internal_url?("http://external.com")
50
+ test 'internal_url? returns false for external links' do
51
+ assert_not internal_url?('http://external.com')
53
52
  end
54
- end
53
+ end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class PathConfigurationsControllerTest < ActionDispatch::IntegrationTest
4
+ test 'android' do
5
+ get '/hotwire_native/v1/android/path_configuration'
6
+ assert_response :success
7
+ end
8
+
9
+ test 'ios' do
10
+ get '/hotwire_native/v1/ios/path_configuration'
11
+ assert_response :success
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HotwireNativeRails
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_native_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaro Shm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-30 00:00:00.000000000 Z
11
+ date: 2024-12-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -29,8 +29,8 @@ files:
29
29
  - hotwire_native_rails.gemspec
30
30
  - lib/generators/hotwire_native/hotwire_native_generator.rb
31
31
  - lib/generators/hotwire_native/templates/controllers/concerns/device_format.rb
32
- - lib/generators/hotwire_native/templates/controllers/hotwire_native/v1/android/path_configuration_controller.rb
33
- - lib/generators/hotwire_native/templates/controllers/hotwire_native/v1/ios/path_configuration_controller.rb
32
+ - lib/generators/hotwire_native/templates/controllers/hotwire_native/v1/android/path_configurations_controller.rb
33
+ - lib/generators/hotwire_native/templates/controllers/hotwire_native/v1/ios/path_configurations_controller.rb
34
34
  - lib/generators/hotwire_native/templates/helpers/hotwire_native_helper.rb
35
35
  - lib/generators/hotwire_native/templates/javascript/controllers/bridge/button_controller.js
36
36
  - lib/generators/hotwire_native/templates/javascript/controllers/bridge/form_controller.js
@@ -39,7 +39,9 @@ files:
39
39
  - lib/generators/hotwire_native/templates/javascript/controllers/bridge/overflow_menu_controller.js
40
40
  - lib/generators/hotwire_native/templates/javascript/controllers/bridge/review_prompt_controller.js
41
41
  - lib/generators/hotwire_native/templates/routes/hotwire_native.rb
42
+ - lib/generators/hotwire_native/templates/test_unit/hotwire_native_controller_test.rb
42
43
  - lib/generators/hotwire_native/templates/test_unit/hotwire_native_helper_test.rb
44
+ - lib/generators/hotwire_native/templates/test_unit/path_configurations_controller_test.rb
43
45
  - lib/hotwire_native_rails.rb
44
46
  - lib/hotwire_native_rails/version.rb
45
47
  homepage: https://github.com/yshmarov/hotwire_native_rails