turbo_turbo 0.2.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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.claude/settings.local.json +14 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +96 -0
  5. data/CHANGELOG.md +50 -0
  6. data/LICENSE +21 -0
  7. data/README.md +498 -0
  8. data/Rakefile +12 -0
  9. data/app/assets/stylesheets/turbo_turbo/alerts.css +7 -0
  10. data/app/assets/stylesheets/turbo_turbo/base.css +4 -0
  11. data/app/assets/stylesheets/turbo_turbo/button.css +24 -0
  12. data/app/assets/stylesheets/turbo_turbo/modal.css +81 -0
  13. data/app/components/turbo_turbo/alerts/alert_component.html.erb +36 -0
  14. data/app/components/turbo_turbo/alerts/alert_component.rb +12 -0
  15. data/app/components/turbo_turbo/alerts/error_component.html.erb +36 -0
  16. data/app/components/turbo_turbo/alerts/error_component.rb +12 -0
  17. data/app/components/turbo_turbo/alerts/info_component.html.erb +36 -0
  18. data/app/components/turbo_turbo/alerts/info_component.rb +12 -0
  19. data/app/components/turbo_turbo/alerts/success_component.html.erb +47 -0
  20. data/app/components/turbo_turbo/alerts/success_component.rb +12 -0
  21. data/app/components/turbo_turbo/alerts/warning_component.html.erb +36 -0
  22. data/app/components/turbo_turbo/alerts/warning_component.rb +12 -0
  23. data/app/components/turbo_turbo/modal_component.html.erb +20 -0
  24. data/app/components/turbo_turbo/modal_component.rb +9 -0
  25. data/app/components/turbo_turbo/modal_footer_component.html.erb +6 -0
  26. data/app/components/turbo_turbo/modal_footer_component.rb +10 -0
  27. data/config/locales/en.yml +15 -0
  28. data/config/routes/turbo_turbo_routes.rb +20 -0
  29. data/lib/generators/turbo_turbo/install_generator.rb +351 -0
  30. data/lib/generators/turbo_turbo/layout_generator.rb +221 -0
  31. data/lib/generators/turbo_turbo/templates/config/routes/turbo_turbo_routes.rb +20 -0
  32. data/lib/generators/turbo_turbo/templates/turbo_turbo/_error_message.html.erb +15 -0
  33. data/lib/generators/turbo_turbo/templates/turbo_turbo/_flashes.html.erb +8 -0
  34. data/lib/generators/turbo_turbo/templates/turbo_turbo/_modal_background.html.erb +2 -0
  35. data/lib/generators/turbo_turbo/templates/turbo_turbo/flash_controller.js +28 -0
  36. data/lib/generators/turbo_turbo/templates/turbo_turbo/modal_controller.js +114 -0
  37. data/lib/generators/turbo_turbo/views_generator.rb +57 -0
  38. data/lib/turbo_turbo/controller_helpers.rb +157 -0
  39. data/lib/turbo_turbo/engine.rb +19 -0
  40. data/lib/turbo_turbo/form_helper.rb +135 -0
  41. data/lib/turbo_turbo/parameter_sanitizer.rb +69 -0
  42. data/lib/turbo_turbo/standard_actions.rb +96 -0
  43. data/lib/turbo_turbo/test_helpers.rb +64 -0
  44. data/lib/turbo_turbo/version.rb +5 -0
  45. data/lib/turbo_turbo.rb +15 -0
  46. data/sig/turbo_turbo.rbs +4 -0
  47. data/turbo_turbo.gemspec +42 -0
  48. metadata +136 -0
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurboTurbo
4
+ module TestHelpers
5
+ # Submit a TurboTurbo modal form
6
+ def submit_modal
7
+ button = find("button[data-action='turbo-turbo--modal#submitForm']")
8
+ button.click
9
+ end
10
+
11
+ # Click a new button for a given resource type
12
+ def click_new_button(singular_resource)
13
+ find("#new_#{singular_resource}").click
14
+ end
15
+
16
+ # Get the DOM ID selector for a table row
17
+ def table_row(resource)
18
+ "##{dom_id(resource)}"
19
+ end
20
+
21
+ # Click on a row action link (edit, delete, etc.)
22
+ def click_on_row_link(resource, action_type, confirm: false)
23
+ within table_row(resource) do
24
+ if confirm
25
+ accept_confirm { find("a.#{action_type}_button").click }
26
+ else
27
+ find("a.#{action_type}_button").click
28
+ end
29
+ end
30
+ end
31
+
32
+ # Close a TurboTurbo modal
33
+ def close_modal
34
+ # Try to find and click the close button, but don't fail if it's not there
35
+ close_button = "button[data-action='turbo-turbo--modal#closeModal']"
36
+
37
+ if page.has_css?(close_button, visible: true)
38
+ find(close_button, match: :first).click
39
+ else
40
+ # If no close button, try clicking the backdrop to close
41
+ backdrop = ".ModalBackdrop-turbo-turbo"
42
+ return true unless page.has_css?(backdrop, visible: true)
43
+
44
+ find(backdrop).click
45
+
46
+ # If still no modal elements, it might already be closed
47
+
48
+ end
49
+
50
+ # Wait for modal to close
51
+ expect(page).not_to have_css('[data-turbo-turbo--modal-target="modal"]', visible: true)
52
+ end
53
+
54
+ # Check if modal is open
55
+ def modal_open?
56
+ page.has_css?('[data-turbo-turbo--modal-target="modal"]', visible: true)
57
+ end
58
+
59
+ # Check if modal is closed
60
+ def modal_closed?
61
+ page.has_no_css?('[data-turbo-turbo--modal-target="modal"]', visible: true)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TurboTurbo
4
+ VERSION = "0.2.0"
5
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "turbo_turbo/version"
4
+ require "turbo_turbo/engine"
5
+ require "turbo_turbo/parameter_sanitizer"
6
+ require "turbo_turbo/standard_actions"
7
+ require "turbo_turbo/form_helper"
8
+ require "turbo_turbo/controller_helpers"
9
+
10
+ # Load test helpers if we're in a test environment
11
+ require "turbo_turbo/test_helpers" if defined?(RSpec) || (defined?(Rails) && Rails.env.test?)
12
+
13
+ module TurboTurbo
14
+ class Error < StandardError; end
15
+ end
@@ -0,0 +1,4 @@
1
+ module TurboTurbo
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/turbo_turbo/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "turbo_turbo"
7
+ spec.version = TurboTurbo::VERSION
8
+ spec.authors = ["Dan Brown"]
9
+ spec.email = ["dbrown@occameducation.com"]
10
+
11
+ spec.summary = "A library that aims to speed up using Turbo in common Rails controller actions."
12
+ spec.description = "A simplified DSL for responding in common ways to common controller actions " \
13
+ "so you can write as little code in CRUD routes as possible."
14
+ spec.homepage = "https://github.com/lordofthedanse/turbo_turbo"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 3.3.6"
17
+
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
21
+ spec.metadata["rubygems_mfa_required"] = "true"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (File.expand_path(f) == __FILE__) ||
28
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
29
+ end
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ # Dependencies
36
+ spec.add_dependency "rails", ">= 7.0"
37
+ spec.add_dependency "turbo-rails", ">= 1.0"
38
+ spec.add_dependency "view_component", ">= 2.0"
39
+
40
+ # For more information and examples about making a new gem, check out our
41
+ # guide at: https://bundler.io/guides/creating_gem.html
42
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turbo_turbo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Dan Brown
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: turbo-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: view_component
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ description: A simplified DSL for responding in common ways to common controller actions
56
+ so you can write as little code in CRUD routes as possible.
57
+ email:
58
+ - dbrown@occameducation.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".claude/settings.local.json"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - CHANGELOG.md
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - app/assets/stylesheets/turbo_turbo/alerts.css
71
+ - app/assets/stylesheets/turbo_turbo/base.css
72
+ - app/assets/stylesheets/turbo_turbo/button.css
73
+ - app/assets/stylesheets/turbo_turbo/modal.css
74
+ - app/components/turbo_turbo/alerts/alert_component.html.erb
75
+ - app/components/turbo_turbo/alerts/alert_component.rb
76
+ - app/components/turbo_turbo/alerts/error_component.html.erb
77
+ - app/components/turbo_turbo/alerts/error_component.rb
78
+ - app/components/turbo_turbo/alerts/info_component.html.erb
79
+ - app/components/turbo_turbo/alerts/info_component.rb
80
+ - app/components/turbo_turbo/alerts/success_component.html.erb
81
+ - app/components/turbo_turbo/alerts/success_component.rb
82
+ - app/components/turbo_turbo/alerts/warning_component.html.erb
83
+ - app/components/turbo_turbo/alerts/warning_component.rb
84
+ - app/components/turbo_turbo/modal_component.html.erb
85
+ - app/components/turbo_turbo/modal_component.rb
86
+ - app/components/turbo_turbo/modal_footer_component.html.erb
87
+ - app/components/turbo_turbo/modal_footer_component.rb
88
+ - config/locales/en.yml
89
+ - config/routes/turbo_turbo_routes.rb
90
+ - lib/generators/turbo_turbo/install_generator.rb
91
+ - lib/generators/turbo_turbo/layout_generator.rb
92
+ - lib/generators/turbo_turbo/templates/config/routes/turbo_turbo_routes.rb
93
+ - lib/generators/turbo_turbo/templates/turbo_turbo/_error_message.html.erb
94
+ - lib/generators/turbo_turbo/templates/turbo_turbo/_flashes.html.erb
95
+ - lib/generators/turbo_turbo/templates/turbo_turbo/_modal_background.html.erb
96
+ - lib/generators/turbo_turbo/templates/turbo_turbo/flash_controller.js
97
+ - lib/generators/turbo_turbo/templates/turbo_turbo/modal_controller.js
98
+ - lib/generators/turbo_turbo/views_generator.rb
99
+ - lib/turbo_turbo.rb
100
+ - lib/turbo_turbo/controller_helpers.rb
101
+ - lib/turbo_turbo/engine.rb
102
+ - lib/turbo_turbo/form_helper.rb
103
+ - lib/turbo_turbo/parameter_sanitizer.rb
104
+ - lib/turbo_turbo/standard_actions.rb
105
+ - lib/turbo_turbo/test_helpers.rb
106
+ - lib/turbo_turbo/version.rb
107
+ - sig/turbo_turbo.rbs
108
+ - turbo_turbo.gemspec
109
+ homepage: https://github.com/lordofthedanse/turbo_turbo
110
+ licenses:
111
+ - MIT
112
+ metadata:
113
+ allowed_push_host: https://rubygems.org
114
+ source_code_uri: https://github.com/lordofthedanse/turbo_turbo
115
+ changelog_uri: https://github.com/lordofthedanse/turbo_turbo/blob/main/CHANGELOG.md
116
+ rubygems_mfa_required: 'true'
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 3.3.6
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.5.22
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: A library that aims to speed up using Turbo in common Rails controller actions.
136
+ test_files: []