super 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/lib/super/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Super
4
- VERSION = "0.0.13"
4
+ VERSION = "0.0.14"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :super do
4
+ task :cheat do
5
+ require "super/cheat"
6
+ cheat = Super::Cheat.new
7
+ cheat.controls
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-17 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -287,6 +287,7 @@ files:
287
287
  - lib/super.rb
288
288
  - lib/super/action_inquirer.rb
289
289
  - lib/super/assets.rb
290
+ - lib/super/cheat.rb
290
291
  - lib/super/client_error.rb
291
292
  - lib/super/compatibility.rb
292
293
  - lib/super/configuration.rb
@@ -312,7 +313,8 @@ files:
312
313
  - lib/super/form/strong_params.rb
313
314
  - lib/super/layout.rb
314
315
  - lib/super/link.rb
315
- - lib/super/navigation/automatic.rb
316
+ - lib/super/link_builder.rb
317
+ - lib/super/navigation.rb
316
318
  - lib/super/pagination.rb
317
319
  - lib/super/panel.rb
318
320
  - lib/super/partial.rb
@@ -327,6 +329,7 @@ files:
327
329
  - lib/super/useful/enum.rb
328
330
  - lib/super/version.rb
329
331
  - lib/super/view_helper.rb
332
+ - lib/tasks/super/cheat.rake
330
333
  homepage:
331
334
  licenses:
332
335
  - LGPL-3.0-only
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Navigation
5
- # Traverses the defined Rails Routes and attempts to build a list of links.
6
- # This is used for building the nav bar on each admin page.
7
- class Automatic
8
- def initialize(route_namespace: Super.configuration.path)
9
- route_namespace = route_namespace.strip.gsub(%r{\A/+}, "").gsub(%r{/+\z}, "").strip
10
-
11
- if route_namespace.include?("/")
12
- raise "Can't be nested namespace"
13
- end
14
-
15
- @route_namespace = route_namespace
16
- end
17
-
18
- def each
19
- if !block_given?
20
- return enum_for(:each)
21
- end
22
-
23
- navigable_namespace_routes = Rails.application.routes.routes.select do |route|
24
- path_spec = route.path.spec
25
-
26
- next if route.verb != "GET"
27
- next if !path_spec.respond_to?(:right)
28
- next if path_spec.right.left.to_s != @route_namespace
29
- next if route.required_parts.any?
30
- next if route.defaults.empty?
31
-
32
- true
33
- end
34
-
35
- navigable_defaults = navigable_namespace_routes.map do |route|
36
- controller_name = route.defaults[:controller] + "_controller"
37
- _controller =
38
- begin
39
- controller_name.camelize.constantize
40
- rescue NameError
41
- warn("[super] Couldn't find controller: #{controller_name}")
42
- next
43
- end
44
-
45
- route.defaults
46
- end
47
-
48
- grouped_navigable_defaults =
49
- navigable_defaults.compact.uniq.group_by { |d| d[:controller] }
50
-
51
- grouped_navigable_defaults.each do |controller, defaults|
52
- actions = defaults.map { |d| [d[:action], d[:action]] }.to_h
53
- action = actions["index"] || actions["show"]
54
-
55
- next if action.nil?
56
-
57
- path =
58
- begin
59
- Rails.application.routes.url_for(
60
- controller: controller,
61
- action: action,
62
- only_path: true
63
- )
64
- rescue ActionController::UrlGenerationError
65
- next
66
- end
67
-
68
- yield(controller.split("/").last.humanize, path)
69
- end
70
- end
71
- end
72
- end
73
- end