phlex-rails 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ff15970d3e9f51641fcf4739a1ce10cf7d026a3e11bacf88892372a5aa8180
|
4
|
+
data.tar.gz: dcd2019092caec7c33a8fb837396d072b2894e13819074423c679a6555809f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f60d2e3e17bafb9d40ac0e7287346cd97146954e2a3901e45c82d5d937bea4eb9468d7d573bceff4043a7244834426a0cf8c35065027582901534c68e9e8911d
|
7
|
+
data.tar.gz: 6b4141a6ffc3a44c294370ba17cf15a8e9d683e6beeae00fd1b7045f842820155d1c8de8e396892f991af4eec5ca5759012ca606009213dc30bdf727669ed9ab
|
@@ -5,9 +5,19 @@ module Phlex
|
|
5
5
|
class ControllerGenerator < ::Rails::Generators::NamedBase # :nodoc:
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
7
7
|
|
8
|
-
argument :actions,
|
9
|
-
|
10
|
-
|
8
|
+
argument :actions,
|
9
|
+
type: :array,
|
10
|
+
default: [],
|
11
|
+
banner: "action action"
|
12
|
+
|
13
|
+
class_option :skip_routes,
|
14
|
+
type: :boolean,
|
15
|
+
desc: "Don't add routes to config/routes.rb."
|
16
|
+
|
17
|
+
class_option :parent,
|
18
|
+
type: :string,
|
19
|
+
default: "ApplicationController",
|
20
|
+
desc: "The parent class for the generated controller"
|
11
21
|
|
12
22
|
check_class_collision suffix: "Controller"
|
13
23
|
|
@@ -20,15 +30,19 @@ module Phlex
|
|
20
30
|
empty_directory base_path
|
21
31
|
|
22
32
|
actions.each do |action|
|
23
|
-
Rails::Generators.invoke("phlex:
|
33
|
+
::Rails::Generators.invoke("phlex:page", [name + "/" + action])
|
24
34
|
end
|
25
35
|
end
|
26
36
|
|
27
37
|
def add_routes
|
28
38
|
return if options[:skip_routes]
|
29
|
-
return if actions.empty?
|
30
39
|
|
31
|
-
routing_code =
|
40
|
+
routing_code = "resources :#{file_name}"
|
41
|
+
|
42
|
+
if actions.any?
|
43
|
+
routing_code << ", only: [#{actions.map { ":#{_1}" }.join(', ')}]"
|
44
|
+
end
|
45
|
+
|
32
46
|
route routing_code, namespace: regular_class_path
|
33
47
|
end
|
34
48
|
|
@@ -43,7 +57,11 @@ module Phlex
|
|
43
57
|
end
|
44
58
|
|
45
59
|
def file_name
|
46
|
-
|
60
|
+
remove_possible_suffix(super)
|
61
|
+
end
|
62
|
+
|
63
|
+
def name
|
64
|
+
remove_possible_suffix(super)
|
47
65
|
end
|
48
66
|
|
49
67
|
def remove_possible_suffix(name)
|
data/lib/phlex/rails/version.rb
CHANGED