jumper_cable 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a6112e1031f8116804382223287d083df7eeaeb5d18139b7502beb82f305784b
4
+ data.tar.gz: e1c442b0a56876a8a0915980f090f37c58856d1e12064d56ccd8444c2bd284ec
5
+ SHA512:
6
+ metadata.gz: d93af9140f7181fb867dc0770feb39f113f1459214bd2ba7ebb232cb7dc18327a7731dd7660740e743939cf8863aed993f3fdce8dbb0733159a7aa1d191ac9f8
7
+ data.tar.gz: 85f51888453cecf935740adcea517345227206b261fb1b59d7598d0de0aebcf12e67143fa4f876fea1ca88b788dccd49fc51a2b5e8affbd9c604553e86388e79
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-05-08
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "jumper_cable" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["info.spencer.burke@gmail.com"](mailto:"info.spencer.burke@gmail.com").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Spencer Burke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # JumperCable
2
+
3
+ Hotwire and MVC is a powerful combination for building maintainable, accessible Rails applications.
4
+ But as your app grows, the presentation layer gets scattered across different controllers:
5
+ - login form in `sessions#new`
6
+ - signup in `registrations#new`
7
+ - profiles in `users#show`
8
+
9
+ Finding which controller renders which page becomes ambiguous.
10
+
11
+ JumperCable solves this by codifying a "page controller" pattern.
12
+ Every page in your app gets a single canonical home, making your application's structure immediately navigable.
13
+
14
+ Think of your resource controllers as an **engine**... it handles the business logic and data.
15
+ Pages are the presentation layer, and turbo frames are the **jumper cables**... wires that connect your engine to presentation of your app.
16
+
17
+ ## Installation
18
+
19
+ Add to your Gemfile:
20
+
21
+ ```bash
22
+ bundle add jumper_cable
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Routing DSL
28
+
29
+ ```ruby
30
+ # config/routes.rb
31
+ Rails.application.routes.draw do
32
+ page :login # GET /login -> pages/login_page#page
33
+ page :profile, params: [:id] # GET /profile/:id -> pages/profile_page#page
34
+
35
+ namespace :about do
36
+ page :team # GET /about/team -> pages/about/team_page#page
37
+ end
38
+ end
39
+ ```
40
+
41
+ ### Generator
42
+
43
+ ```bash
44
+ rails generate jumper_cable:page Login
45
+ # creates app/controllers/pages/login_page_controller.rb
46
+ # creates app/views/pages/login_page/page.html.erb
47
+
48
+ rails generate jumper_cable:page About::Team
49
+ # creates app/controllers/pages/about/team_page_controller.rb
50
+ # creates app/views/pages/about/team_page/page.html.erb
51
+ ```
52
+
53
+ ### Page Controllers
54
+
55
+ Page controllers inherit from `JumperCable::PageController` and define a single `page` action:
56
+
57
+ ```ruby
58
+ class Pages::LoginPageController < JumperCable::PageController
59
+ def page
60
+ # optionally fetch data for the page
61
+ end
62
+ end
63
+ ```
64
+
65
+ ### Page Views
66
+
67
+ Pages are shells for Turbo Frames. Resource controllers power the frames — pages just wire them together:
68
+
69
+ ```erb
70
+ <%# app/views/pages/login_page/page.html.erb %>
71
+ <%= turbo_frame_tag "login-form" %>
72
+ <%= turbo_frame_tag "login-errors" %>
73
+ ```
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/spencer-burke/jumper_cable.
78
+
79
+ ## License
80
+
81
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,21 @@
1
+ module JumperCable
2
+ module Generators
3
+ class PageGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ def create_controller
7
+ template "controller.rb.tt", "app/controllers/pages/#{namespaced_path}_page_controller.rb"
8
+ end
9
+
10
+ def create_view
11
+ template "view.html.erb.tt", "app/views/pages/#{namespaced_path}_page/page.html.erb"
12
+ end
13
+
14
+ private
15
+
16
+ def namespaced_path
17
+ (class_path + [file_name]).join("/")
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ class Pages::<%= class_name %>PageController < JumperCable::PageController
2
+ def page
3
+ end
4
+ end
@@ -0,0 +1 @@
1
+ <h1><%= class_name %> Page</h1>
@@ -0,0 +1,6 @@
1
+ module JumperCable
2
+ class PageController < ActionController::Base
3
+ def page
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module JumperCable
2
+ class Railtie < Rails::Railtie
3
+ initializer "jumper_cable.routing" do
4
+ ActionDispatch::Routing::Mapper.include(JumperCable::Routing)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ module JumperCable
2
+ module Routing
3
+ def page(name, params: [], &block)
4
+ controller = resolve_controller(name)
5
+ path = resolve_path(name, params)
6
+
7
+ get path, to: "#{controller}#page"
8
+ end
9
+
10
+ def namespace(name, &block)
11
+ scope "/#{name}" do
12
+ with_namespace(name) { yield }
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def with_namespace(name, &block)
19
+ @_jc_namespace = name
20
+
21
+ yield
22
+
23
+ @_jc_namespace = nil
24
+ end
25
+
26
+ def resolve_controller(name)
27
+ if @_jc_namespace
28
+ return "pages/#{@_jc_namespace}/#{name}_page"
29
+ end
30
+
31
+ return "pages/#{name}_page"
32
+ end
33
+
34
+ def resolve_path(name, params)
35
+ segments = [name.to_s] + params.map {|p| ":#{p}"}
36
+
37
+ return("/#{segments.join("/")}")
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JumperCable
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jumper_cable/version"
4
+ require_relative "jumper_cable/routing"
5
+ require_relative "jumper_cable/railtie" if defined?(Rails)
6
+ require_relative "jumper_cable/page_controller" if defined?(Rails)
7
+
8
+ module JumperCable
9
+ class Error < StandardError; end
10
+ end
@@ -0,0 +1,4 @@
1
+ module JumperCable
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jumper_cable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - spencer burke
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: railties
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '7.0'
26
+ description: Extends the routing dsl, and adds a generator to automatically "page
27
+ controllers"
28
+ email:
29
+ - info.spencer.burke@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - CODE_OF_CONDUCT.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/generators/jumper_cable/page/page_generator.rb
40
+ - lib/generators/jumper_cable/page/templates/controller.rb.tt
41
+ - lib/generators/jumper_cable/page/templates/view.html.erb.tt
42
+ - lib/jumper_cable.rb
43
+ - lib/jumper_cable/page_controller.rb
44
+ - lib/jumper_cable/railtie.rb
45
+ - lib/jumper_cable/routing.rb
46
+ - lib/jumper_cable/version.rb
47
+ - sig/jumper_cable.rbs
48
+ homepage: https://github.com/spencer-burke/jumper_cable
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ allowed_push_host: https://rubygems.org
53
+ homepage_uri: https://github.com/spencer-burke/jumper_cable
54
+ source_code_uri: https://github.com/spencer-burke/jumper_cable/tree/main
55
+ changelog_uri: https://github.com/spencer-burke/jumper_cable/blob/main/CHANGELOG.md
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 3.2.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 4.0.3
71
+ specification_version: 4
72
+ summary: Organizes hotwire apps by creating pages
73
+ test_files: []