rivet_cms 0.1.0.pre → 0.1.1.pre

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: 80cc85ed4a64302837525fa46d4c3dfa9513929ca29318db4cf6136dcb3db358
4
- data.tar.gz: ca6ee6f525a26a5a480d46bfc014dce6fac1636d6da125d8ad59d010d168759a
3
+ metadata.gz: f4ab85871fd2fb7a01b149fb1d70b99e7683c87d22e028c337c3029257162dfa
4
+ data.tar.gz: 7854daa20f72debd1f2efc10bb9f0593b7d4912629dad6ae0accb8ee04e32b88
5
5
  SHA512:
6
- metadata.gz: 89e6857b0d727e9c83601f68186fe08344a17b73395372b30ed40b552252ecfecb5cc56e8a39cd0c332373ec4e8466fdb0cd46ee692851d516d8c3a23f91a2c2
7
- data.tar.gz: 7412c588bac4bacf3841f220d55d1c1b5664c19b985f2a86ffe12fb8f7155ec409aa80097b18deeb8d3d4a4b234a2c77058053c675b090427873a6dd83f6a742
6
+ metadata.gz: 73eedb4dbfb8dd8e456ac72c43cf7040965a0a2ce4418a4220ff54f60b6f054c203eeb3b5ffdd098812e836f707138006a47c349c30b36101a76f8646fad382e
7
+ data.tar.gz: 818fe99cd5bcc199bbcc53763bceb1c4f460dce246dedf0aad1636fd3add63c3627abd3ccc57f37722448bef7f1f17a156b5dc37d677b2470bb335ce63d0920e
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
- RivetCms::Engine.register_routes do
2
- get '/', to: "dashboard#index", as: :dashboard
1
+ RivetCms::Routes.add_routes do
2
+ get '/', to: "dashboard#index"
3
3
 
4
4
  # Content Type Management
5
5
  resources :content_types, path: 'content-types' do
@@ -53,4 +53,6 @@ RivetCms::Engine.register_routes do
53
53
  end
54
54
  end
55
55
 
56
- RivetCms::Engine.draw_routes
56
+ RivetCms::Engine.routes.draw do
57
+ RivetCms::Routes.draw_routes
58
+ end
@@ -4,6 +4,7 @@ require "prefixed_ids"
4
4
  require "kaminari"
5
5
  require "turbo-rails"
6
6
  require "stimulus-rails"
7
+ require "rivet_cms/routes"
7
8
 
8
9
  module RivetCms
9
10
  class Engine < ::Rails::Engine
@@ -21,35 +22,16 @@ module RivetCms
21
22
  g.factory_bot dir: 'spec/factories'
22
23
  end
23
24
 
24
- class << self
25
- # Accessor for the routes storage
26
- def routes_storage
27
- # Use a class-level instance variable with a default empty array
28
- @routes_storage ||= []
29
- end
30
-
31
- # Register route definitions to be drawn later
32
- # @param block [Proc] A block containing route definitions
33
- def register_routes(&block)
34
- routes_storage << block # Add the block to the storage
35
- end
36
-
37
- # Draw all registered routes into the engine's RouteSet
38
- def draw_routes
39
- # Capture the routes in a local variable before entering the block
40
- stored_routes = routes_storage
25
+ def self.add_routes(&block)
26
+ RivetCms::Routes.add_routes(&block)
27
+ end
41
28
 
42
- # Use the engine's routes.draw method to provide the proper routing context
43
- routes.draw do
44
- # Iterate over the captured routes
45
- stored_routes.each do |route_block|
46
- instance_eval(&route_block)
47
- end
48
- end
29
+ def self.append_routes(&block)
30
+ RivetCms::Routes.append_routes(&block)
31
+ end
49
32
 
50
- # Clear the routes to prevent re-drawing if called again
51
- routes_storage.clear
52
- end
33
+ def self.draw_routes(&block)
34
+ RivetCms::Routes.draw_routes(&block)
53
35
  end
54
36
  end
55
37
  end
@@ -0,0 +1,39 @@
1
+ module RivetCms
2
+ module Routes
3
+ def self.draw_routes(&block)
4
+ @rivet_routes ||= []
5
+ @append_routes ||= []
6
+
7
+ # Evaluate the passed block first if given
8
+ eval_block(block) if block_given?
9
+
10
+ # Draw main routes
11
+ @rivet_routes.each { |r| eval_block(&r) }
12
+
13
+ # Draw appended routes
14
+ @append_routes.each { |r| eval_block(&r) }
15
+
16
+ # Clear routes to prevent drawing twice
17
+ @rivet_routes = []
18
+ @append_routes = []
19
+ end
20
+
21
+ def self.add_routes(&block)
22
+ @rivet_routes ||= []
23
+ # Store the block unless it's already been added
24
+ @rivet_routes << block unless @rivet_routes.include?(block)
25
+ end
26
+
27
+ def self.append_routes(&block)
28
+ @append_routes ||= []
29
+ # Store the block unless it's already been added
30
+ @append_routes << block unless @append_routes.include?(block)
31
+ end
32
+
33
+ private
34
+
35
+ def self.eval_block(&block)
36
+ RivetCms::Engine.routes.send(:eval_block, block)
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module RivetCms
2
- VERSION = "0.1.0.pre"
2
+ VERSION = "0.1.1.pre"
3
3
  end
data/lib/rivet_cms.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require "rivet_cms/version"
2
+ require "rivet_cms/routes"
2
3
  require "rivet_cms/engine"
3
4
 
4
5
  module RivetCms
6
+ class Error < StandardError; end
7
+
5
8
  class << self
6
9
  def configuration
7
10
  @configuration ||= Configuration.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rivet_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.1.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-28 00:00:00.000000000 Z
11
+ date: 2025-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -199,6 +199,7 @@ files:
199
199
  - db/migrate/20250317194359_create_core_tables.rb
200
200
  - lib/rivet_cms.rb
201
201
  - lib/rivet_cms/engine.rb
202
+ - lib/rivet_cms/routes.rb
202
203
  - lib/rivet_cms/version.rb
203
204
  - lib/tasks/rivet_cms_tasks.rake
204
205
  homepage: https://github.com/narch/rivet_cms