feature_pack 0.1.4 → 0.3.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 +4 -4
- data/lib/feature_pack/controller.rb +6 -4
- data/lib/feature_pack/feature_pack_routes.rb +4 -4
- data/lib/feature_pack/group_controller.rb +1 -2
- data/lib/feature_pack.rb +11 -6
- data/lib/generators/feature_pack/add_feature/add_feature_generator.rb +1 -1
- data/lib/generators/feature_pack/add_feature/templates/controller.rb.tt +1 -1
- data/lib/generators/feature_pack/add_feature/templates/manifest.yaml.tt +2 -0
- data/lib/generators/feature_pack/add_feature/templates/routes.rb.tt +1 -1
- data/lib/generators/feature_pack/add_feature/templates/views/home.html.slim.tt +1 -1
- data/lib/generators/feature_pack/add_group/add_group_generator.rb +1 -7
- data/lib/generators/feature_pack/add_group/templates/_group_metadata/controller.rb.tt +1 -1
- data/lib/generators/feature_pack/add_group/templates/_group_metadata/routes.rb.disabled.tt +1 -1
- data/lib/generators/feature_pack/add_group/templates/_group_metadata/views/index.html.slim.tt +2 -0
- metadata +4 -4
- data/lib/generators/feature_pack/add_group/templates/_group_metadata/views/home.html.slim.tt +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4d4c06a3ac9cc919e20a0616c0ec7b0d1da2553f43a4c5b140ef7a8bc29147a
|
4
|
+
data.tar.gz: 21ae0804c870c884ee4270168327fa81eade33b261bb4adb915f87f49764ca41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66fab958817fe7391449fe39d04043b9729e3bfc4a40b18e8ad6458e4a2f2c6a7ff863dfb0c8acf5841024bfdb34bb48e79c631c58949d655d1d0ca809fb8ec
|
7
|
+
data.tar.gz: bcc1750715d4f4a88587b557bd75e5ed0e3c698fec80a1691942b5ff895ecd3b6041636dd4b325de811d3008551a1244aa10635b5a28e7180a41642a86420b54
|
@@ -1,14 +1,16 @@
|
|
1
1
|
class FeaturePack::Controller < ApplicationController
|
2
|
-
before_action :
|
2
|
+
before_action :set_group_and_feature
|
3
3
|
before_action :set_view_lookup_context_prefix
|
4
4
|
before_action :set_layout_paths
|
5
5
|
|
6
|
-
def
|
6
|
+
def index; end
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
-
def
|
11
|
-
|
10
|
+
def set_group_and_feature
|
11
|
+
group_name, feature_name = params['controller'].delete_prefix('feature_pack/').split('/').map(&:to_sym)
|
12
|
+
@group = FeaturePack.group group_name
|
13
|
+
@feature = FeaturePack.feature group_name, feature_name
|
12
14
|
end
|
13
15
|
|
14
16
|
def set_view_lookup_context_prefix
|
@@ -1,9 +1,9 @@
|
|
1
1
|
FeaturePack.groups.each do |group|
|
2
2
|
unless group.manifest[:namespace_only]
|
3
|
-
# Default
|
3
|
+
# Default 'index' route every group has to have.
|
4
4
|
get group.manifest[:url],
|
5
|
-
|
6
|
-
|
5
|
+
to: "#{group.name.name}#index",
|
6
|
+
as: group.name.name
|
7
7
|
|
8
8
|
unless group.routes_file.nil?
|
9
9
|
scope group.manifest[:url] do
|
@@ -14,7 +14,7 @@ FeaturePack.groups.each do |group|
|
|
14
14
|
|
15
15
|
namespace group.name, path: group.manifest[:url] do
|
16
16
|
group.features.each do |feature|
|
17
|
-
scope feature.manifest[:url], as: feature.name.name do
|
17
|
+
scope feature.manifest[:url], as: feature.name.name.pluralize do
|
18
18
|
draw(feature.routes_file)
|
19
19
|
end
|
20
20
|
end
|
data/lib/feature_pack.rb
CHANGED
@@ -17,7 +17,7 @@ module FeaturePack
|
|
17
17
|
javascript_files_paths
|
18
18
|
].freeze
|
19
19
|
|
20
|
-
def self.setup(features_path:)
|
20
|
+
def self.setup(features_path:)
|
21
21
|
raise 'FeaturePack already setup!' if defined?(@@setup_executed_flag)
|
22
22
|
|
23
23
|
@@path = Pathname.new(__dir__)
|
@@ -36,7 +36,7 @@ module FeaturePack
|
|
36
36
|
.map { |js_path| js_path.sub(/^#{Regexp.escape(@@features_path.to_s)}\//, '') }.to_a
|
37
37
|
|
38
38
|
ATTR_READERS.each { |attr| define_singleton_method(attr) { class_variable_get("@@#{attr}") } }
|
39
|
-
|
39
|
+
|
40
40
|
@@ignored_paths << @@path.join('feature_pack/feature_pack_routes.rb')
|
41
41
|
|
42
42
|
# raise "No Groups found in: '#{@@features_path}'" if Dir.glob("#{@@features_path}/[!_]*/").empty?
|
@@ -49,7 +49,7 @@ module FeaturePack
|
|
49
49
|
routes_file = File.exist?(File.join(group_path, GROUP_METADATA_DIRECTORY, 'routes.rb')) ? File.join(base_path, GROUP_METADATA_DIRECTORY, 'routes') : nil
|
50
50
|
|
51
51
|
@@groups_controllers_paths << File.join(group_path, GROUP_METADATA_DIRECTORY, CONTROLLER_FILE_NAME)
|
52
|
-
|
52
|
+
|
53
53
|
raise "Group '#{base_path}' does not have a valid ID" if base_path.scan(GROUP_ID_PATTERN).empty?
|
54
54
|
group = OpenStruct.new(
|
55
55
|
id: base_path.scan(GROUP_ID_PATTERN).first.delete_suffix('_'),
|
@@ -62,6 +62,11 @@ module FeaturePack
|
|
62
62
|
manifest: YAML.load_file(File.join(group_path, GROUP_METADATA_DIRECTORY, MANIFEST_FILE_NAME)).deep_symbolize_keys
|
63
63
|
)
|
64
64
|
|
65
|
+
group.manifest.fetch(:const_aliases, []).each do |alias_data|
|
66
|
+
alias_method_name, alias_const_name = alias_data.first
|
67
|
+
group.define_singleton_method(alias_method_name) { "FeaturePack::#{group.name.name.camelize}::#{alias_const_name}".constantize }
|
68
|
+
end
|
69
|
+
|
65
70
|
def group.feature(feature_name) = features.find { |p| p.name.eql?(feature_name) }
|
66
71
|
def group.views_path = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/views"
|
67
72
|
def group.view(view_name) = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/views/#{view_name}"
|
@@ -75,16 +80,16 @@ module FeaturePack
|
|
75
80
|
absolute_path = @@features_path.join(feature_path)
|
76
81
|
relative_path = Pathname.new(feature_path)
|
77
82
|
base_path = File.basename(feature_path, File::SEPARATOR)
|
78
|
-
|
83
|
+
|
79
84
|
feature_name = base_path.gsub(FEATURE_ID_PATTERN, '').to_sym
|
80
|
-
|
85
|
+
|
81
86
|
routes_file_path = relative_path.join('routes.rb')
|
82
87
|
|
83
88
|
# The custom routes file loads before the Rails default routes,
|
84
89
|
# leading to errors like NoMethodError for 'scope'.
|
85
90
|
# Ignoring them is required to prevent these issues.
|
86
91
|
@@ignored_paths << routes_file_path
|
87
|
-
|
92
|
+
|
88
93
|
# Due to Zeiwerk rules, Controllers have special load process
|
89
94
|
@@features_controllers_paths << relative_path.join(CONTROLLER_FILE_NAME)
|
90
95
|
|
@@ -25,7 +25,7 @@ class FeaturePack::AddFeatureGenerator < Rails::Generators::NamedBase
|
|
25
25
|
template './controller.rb.tt', @feature_dir.join('controller.rb')
|
26
26
|
template './manifest.yaml.tt', @feature_dir.join('manifest.yaml')
|
27
27
|
template './routes.rb.tt', @feature_dir.join('routes.rb')
|
28
|
-
template './views/
|
28
|
+
template './views/index.html.slim.tt', @feature_dir.join('views/index.html.slim')
|
29
29
|
template './views/partials/_header.html.slim.tt', @feature_dir.join('views/partials/_header.html.slim')
|
30
30
|
template './views/partials/_footer.html.slim.tt', @feature_dir.join('views/partials/_footer.html.slim')
|
31
31
|
template './doc/readme.md.tt', @feature_dir.join('doc/readme.md')
|
@@ -1 +1 @@
|
|
1
|
-
get '/', to: '<%= @feature_name %>#
|
1
|
+
get '/', to: '<%= @feature_name %>#index'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
h1 Feature <%= @group_class_name%>::<%=@feature_class_name %>
|
1
|
+
h1 Feature <%= @group_class_name%>::<%=@feature_class_name %> Index
|
2
2
|
p = "Find-me at #{__FILE__}"
|
@@ -21,14 +21,8 @@ class FeaturePack::AddGroupGenerator < Rails::Generators::NamedBase
|
|
21
21
|
template './_group_metadata/controller.rb.tt', group_dir.join('_group_metadata', 'controller.rb')
|
22
22
|
template './_group_metadata/manifest.yaml.tt', group_dir.join('_group_metadata', 'manifest.yaml')
|
23
23
|
template './_group_metadata/routes.rb.disabled.tt', group_dir.join('_group_metadata', 'routes.rb.disabled')
|
24
|
-
template './_group_metadata/views/
|
24
|
+
template './_group_metadata/views/index.html.slim.tt', group_dir.join('_group_metadata', 'views/index.html.slim')
|
25
25
|
template './_group_metadata/views/partials/_header.html.slim.tt', group_dir.join('_group_metadata', 'views/partials/_header.html.slim')
|
26
26
|
template './_group_metadata/views/partials/_footer.html.slim.tt', group_dir.join('_group_metadata', 'views/partials/_footer.html.slim')
|
27
|
-
|
28
|
-
# create_file "app/models/#{group_name.underscore}/#{name.underscore}.rb", <<-FILE
|
29
|
-
# class #{group_name.camelize}::#{name.camelize} < ApplicationRecord
|
30
|
-
# # Lógicas específicas da feature, como validações e associações
|
31
|
-
# end
|
32
|
-
# FILE
|
33
27
|
end
|
34
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- lib/generators/feature_pack/add_group/templates/_group_metadata/controller.rb.tt
|
55
55
|
- lib/generators/feature_pack/add_group/templates/_group_metadata/manifest.yaml.tt
|
56
56
|
- lib/generators/feature_pack/add_group/templates/_group_metadata/routes.rb.disabled.tt
|
57
|
-
- lib/generators/feature_pack/add_group/templates/_group_metadata/views/
|
57
|
+
- lib/generators/feature_pack/add_group/templates/_group_metadata/views/index.html.slim.tt
|
58
58
|
- lib/generators/feature_pack/add_group/templates/_group_metadata/views/partials/_footer.html.slim.tt
|
59
59
|
- lib/generators/feature_pack/add_group/templates/_group_metadata/views/partials/_header.html.slim.tt
|
60
60
|
homepage: https://github.com/gedean/feature_pack
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.5.
|
79
|
+
rubygems_version: 3.5.18
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: New way to organize app features in Rails.
|