roda-project 0.1.8 → 0.1.9

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: 6e2e4f0e1a643cc30ca1efff43c571e29acf2ef47385c8fb6b5b1b1553641d6b
4
- data.tar.gz: 0f81e9706caee934a023ba77243fc21447a39279719713e610c237136ae66a01
3
+ metadata.gz: bca56b06faeb347730f67dce564950b0f3fb9a2e0271820551f96752678121e1
4
+ data.tar.gz: 1233a11fa1418c2492e956e79ea8d2f74db2689ce902e3fad04159245fc8a451
5
5
  SHA512:
6
- metadata.gz: 4f27ffba5ba456ec2d937f69f1781f58193fc27567bf0ac3d7ea83edad23e948f3d127b3f608ca354cec3746bad1dcba85203bcd529a64c156734a38ded7a9d2
7
- data.tar.gz: 104494e4ff9bb346b440ac9b0be67d430653861079cdea90e99e813a7aad8236d63609bfbd0fb8bf2bb3043718e3fb6e8001cd5ccae59ee384a22eb4ba9123b8
6
+ metadata.gz: 0f42c3f7152377f79986fbba0fb2c2cfa7cb6c583c68ca05c9f78463c44e8445ad9c76a87e506302718f8d07c1ea97b195359878b21357b89b005e329de45e35
7
+ data.tar.gz: 23ce0cb9af858542d5a213e5e934a97619ea3b4be93b3379b06a04b63dabaa2019d18cc5e4fcf847581bad81a1c9de4eed81efa660367827b6627cbee57a6158
@@ -13,6 +13,7 @@ class Roda
13
13
  generate_routes
14
14
  generate_views
15
15
  generate_tests
16
+ print_nested_branch_reminder
16
17
  end
17
18
 
18
19
  private
@@ -25,9 +26,19 @@ class Roda
25
26
  " r.#{method} \"#{name}\" do#{view_line}\n end"
26
27
  end.join("\n\n")
27
28
 
29
+ hash_branch_header = if branch_name.include?("/")
30
+ parts = branch_name.split("/")
31
+ sub_path = parts[0..-2].join("/")
32
+ namespace = sub_path.include?("/") ? ":\"#{sub_path}\"" : ":#{sub_path}"
33
+ branch_segment = parts.last
34
+ "hash_branch #{namespace}, \"#{branch_segment}\" do |r|"
35
+ else
36
+ "hash_branch \"#{branch_name}\" do |r|"
37
+ end
38
+
28
39
  content = <<~RUBY
29
40
  class #{@context.const_project_name}
30
- hash_branch "#{branch_name}" do |r|
41
+ #{hash_branch_header}
31
42
  #{route_definitions}
32
43
  end
33
44
  end
@@ -99,6 +110,20 @@ class Roda
99
110
  def branch_name
100
111
  @branch_name ||= @args[0]
101
112
  end
113
+
114
+ def print_nested_branch_reminder
115
+ return unless branch_name.include?("/")
116
+
117
+ parts = branch_name.split("/")
118
+ sub_path = parts[0..-2].join("/")
119
+ namespace = sub_path.include?("/") ? ":\"#{sub_path}\"" : ":#{sub_path}"
120
+
121
+ puts "\ndont forget to add:\n\n" \
122
+ "autoload_hash_branch_dir(#{namespace}, \"./app/routes/#{sub_path}\")\n\n" \
123
+ "route do |r|\n" \
124
+ " r.on(\"#{sub_path}\") { r.hash_branches(#{namespace}) }\n" \
125
+ "end\n"
126
+ end
102
127
  end
103
128
  end
104
129
  end
@@ -1,6 +1,6 @@
1
1
  class <%= context.const_project_name %> < Roda
2
2
  # Routing<% if context.fullstack? %>
3
- plugin :hash_branch_view_subdir<% end %>
3
+ plugin :hash_branch_view_namespace<% end %>
4
4
  plugin :autoload_hash_branches
5
5
  autoload_hash_branch_dir("./app/routes")
6
6
  plugin :all_verbs
@@ -23,6 +23,7 @@ gem "puma"
23
23
 
24
24
  # Views
25
25
  gem 'roda-assets_manifest'
26
+ gem 'roda-hash_branch_view_namespace'
26
27
  <% end %>
27
28
  # Performance
28
29
  gem "oj"
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Roda
4
4
  module Project
5
- VERSION = "0.1.8"
5
+ VERSION = "0.1.9"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-project
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique F. Teixeira