feature_pack 0.3.1 → 0.6.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/README.md +1 -1
- data/doc/feature_pack.md +1 -1
- data/lib/feature_pack/controller.rb +2 -2
- data/lib/feature_pack/error.rb +1 -1
- data/lib/feature_pack/group_controller.rb +3 -3
- data/lib/feature_pack.rb +11 -11
- data/lib/generators/feature_pack/add_group/add_group_generator.rb +6 -6
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c1076c32434b482c422874b1b2c5d7a0ba473270d62664988f31f57dff4056c
|
4
|
+
data.tar.gz: 6c630b91094c255f7db27664feb3304bf77e106b2333867712b25ef04597d7c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8041b9f8610deac2e85dcae82b695aaa45466cefd7de6a49c8d1628c7c4e4122e2637455640489ff7aa71d8b08af6008d07f362a94d683e0a9de8bba3da10cd5
|
7
|
+
data.tar.gz: 3ef150857c0f8627253d5dff543553d06eb20fdb5fc4b46f343b0d8d19b898a49b47d66502baa3d2b17956c7c4451c1c54499f2d35c47719b13765c0da8353e4
|
data/README.md
CHANGED
@@ -51,7 +51,7 @@ FeaturePack.groups.each do |group|
|
|
51
51
|
group_module = FeaturePack.const_set(group.name.name.camelize, Module.new)
|
52
52
|
|
53
53
|
%w[Lib AI Jobs].each do |submodule_name|
|
54
|
-
submodule_path = File.join(group.relative_path, '
|
54
|
+
submodule_path = File.join(group.relative_path, '_group_space', submodule_name.downcase)
|
55
55
|
if Dir.exist?(submodule_path)
|
56
56
|
submodule = group_module.const_set(submodule_name, Module.new)
|
57
57
|
Rails.autoloaders.main.push_dir(submodule_path, namespace: submodule)
|
data/doc/feature_pack.md
CHANGED
@@ -16,7 +16,7 @@ class FeaturePack::Controller < ApplicationController
|
|
16
16
|
def set_view_lookup_context_prefix
|
17
17
|
unless lookup_context.prefixes.include?(@feature.views_relative_path)
|
18
18
|
lookup_context.prefixes.prepend(@feature.views_relative_path)
|
19
|
-
end
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def set_layout_paths
|
@@ -30,7 +30,7 @@ class FeaturePack::Controller < ApplicationController
|
|
30
30
|
|
31
31
|
feature_partials_path = @feature.views_relative_path.join('partials')
|
32
32
|
group_partials_path = @feature.group.views_path.concat('/partials')
|
33
|
-
|
33
|
+
|
34
34
|
if template_exists?('header', feature_partials_path, true)
|
35
35
|
@header_layout_path = @feature.view('partials/header')
|
36
36
|
elsif template_exists?('header', group_partials_path, true)
|
data/lib/feature_pack/error.rb
CHANGED
@@ -5,7 +5,7 @@ class FeaturePack::GroupController < ApplicationController
|
|
5
5
|
|
6
6
|
def index; end
|
7
7
|
|
8
|
-
private
|
8
|
+
private
|
9
9
|
|
10
10
|
def set_group
|
11
11
|
group_name = params[:controller].split('/')[1].to_sym
|
@@ -20,13 +20,13 @@ class FeaturePack::GroupController < ApplicationController
|
|
20
20
|
|
21
21
|
def set_layout_paths
|
22
22
|
patials_path = @group.views_path.concat('/partials')
|
23
|
-
|
23
|
+
|
24
24
|
if template_exists?('header', patials_path, true)
|
25
25
|
@header_layout_path = @group.view('partials/header')
|
26
26
|
end
|
27
27
|
|
28
28
|
if template_exists?('footer', patials_path, true)
|
29
29
|
@footer_layout_path = @group.view('partials/footer')
|
30
|
-
end
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/feature_pack.rb
CHANGED
@@ -3,7 +3,7 @@ require 'active_support/all'
|
|
3
3
|
module FeaturePack
|
4
4
|
GROUP_ID_PATTERN = /^group_.*?_/.freeze
|
5
5
|
FEATURE_ID_PATTERN = /^feature_.*?_/.freeze
|
6
|
-
|
6
|
+
GROUP_SPACE_DIRECTORY = '_group_space'.freeze
|
7
7
|
MANIFEST_FILE_NAME = 'manifest.yaml'.freeze
|
8
8
|
CONTROLLER_FILE_NAME = 'controller.rb'.freeze
|
9
9
|
|
@@ -17,13 +17,13 @@ module FeaturePack
|
|
17
17
|
javascript_files_paths
|
18
18
|
].freeze
|
19
19
|
|
20
|
-
def self.setup(
|
20
|
+
def self.setup()
|
21
21
|
raise 'FeaturePack already setup!' if defined?(@@setup_executed_flag)
|
22
22
|
|
23
23
|
@@path = Pathname.new(__dir__)
|
24
24
|
load @@path.join('feature_pack/error.rb')
|
25
25
|
|
26
|
-
@@features_path = Pathname.new(
|
26
|
+
@@features_path = Pathname.new(Rails.root.join('app/feature_packs'))
|
27
27
|
raise "Invalid features_path: '#{@@features_path}'" if @@features_path.nil?
|
28
28
|
raise "Inexistent features_path: '#{@@features_path}'" unless Dir.exist?(@@features_path)
|
29
29
|
|
@@ -46,20 +46,20 @@ module FeaturePack
|
|
46
46
|
base_path = File.basename(group_path, File::SEPARATOR)
|
47
47
|
|
48
48
|
# On route draw call, the extension is ignored
|
49
|
-
routes_file = File.exist?(File.join(group_path,
|
49
|
+
routes_file = File.exist?(File.join(group_path, GROUP_SPACE_DIRECTORY, 'routes.rb')) ? File.join(base_path, GROUP_SPACE_DIRECTORY, 'routes') : nil
|
50
50
|
|
51
|
-
@@groups_controllers_paths << File.join(group_path,
|
51
|
+
@@groups_controllers_paths << File.join(group_path, GROUP_SPACE_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('_'),
|
56
56
|
name: base_path.gsub(GROUP_ID_PATTERN, '').to_sym,
|
57
|
-
metadata_path: @@features_path.join(group_path,
|
57
|
+
metadata_path: @@features_path.join(group_path, GROUP_SPACE_DIRECTORY),
|
58
58
|
relative_path: relative_path,
|
59
59
|
base_dir: File.basename(relative_path, File::SEPARATOR),
|
60
60
|
routes_file: routes_file,
|
61
61
|
features: [],
|
62
|
-
manifest: YAML.load_file(File.join(group_path,
|
62
|
+
manifest: YAML.load_file(File.join(group_path, GROUP_SPACE_DIRECTORY, MANIFEST_FILE_NAME)).deep_symbolize_keys
|
63
63
|
)
|
64
64
|
|
65
65
|
group.manifest.fetch(:const_aliases, []).each do |alias_data|
|
@@ -68,9 +68,9 @@ module FeaturePack
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def group.feature(feature_name) = features.find { |p| p.name.eql?(feature_name) }
|
71
|
-
def group.views_path = "#{base_dir}/#{
|
72
|
-
def group.view(view_name) = "#{base_dir}/#{
|
73
|
-
def group.javascript_module(javascript_file_name) = "#{base_dir}/#{
|
71
|
+
def group.views_path = "#{base_dir}/#{GROUP_SPACE_DIRECTORY}/views"
|
72
|
+
def group.view(view_name) = "#{base_dir}/#{GROUP_SPACE_DIRECTORY}/views/#{view_name}"
|
73
|
+
def group.javascript_module(javascript_file_name) = "#{base_dir}/#{GROUP_SPACE_DIRECTORY}/javascript/#{javascript_file_name}"
|
74
74
|
|
75
75
|
group
|
76
76
|
end
|
@@ -121,7 +121,7 @@ module FeaturePack
|
|
121
121
|
feature.define_singleton_method(alias_method_name) { "#{class_name}::#{alias_const_name}".constantize }
|
122
122
|
end
|
123
123
|
|
124
|
-
def feature.view(view_name) = "#{views_relative_path}/#{view_name}"
|
124
|
+
def feature.view(view_name) = "#{views_relative_path}/#{view_name}"
|
125
125
|
def feature.javascript_module(javascript_file_name) = "#{javascript_relative_path}/#{javascript_file_name}"
|
126
126
|
|
127
127
|
group.features << feature
|
@@ -18,11 +18,11 @@ class FeaturePack::AddGroupGenerator < Rails::Generators::NamedBase
|
|
18
18
|
group_id = name.gsub('_', '-') + '-' + '999'
|
19
19
|
group_dir = FeaturePack.features_path.join("group_#{group_id}_#{name}")
|
20
20
|
|
21
|
-
template './
|
22
|
-
template './
|
23
|
-
template './
|
24
|
-
template './
|
25
|
-
template './
|
26
|
-
template './
|
21
|
+
template './_group_space/controller.rb.tt', group_dir.join('_group_space', 'controller.rb')
|
22
|
+
template './_group_space/manifest.yaml.tt', group_dir.join('_group_space', 'manifest.yaml')
|
23
|
+
template './_group_space/routes.rb.disabled.tt', group_dir.join('_group_space', 'routes.rb.disabled')
|
24
|
+
template './_group_space/views/index.html.slim.tt', group_dir.join('_group_space', 'views/index.html.slim')
|
25
|
+
template './_group_space/views/partials/_header.html.slim.tt', group_dir.join('_group_space', 'views/partials/_header.html.slim')
|
26
|
+
template './_group_space/views/partials/_footer.html.slim.tt', group_dir.join('_group_space', 'views/partials/_footer.html.slim')
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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-
|
11
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7.
|
19
|
+
version: '7.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '9.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '7.0'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '9.0'
|
27
33
|
description: Organizes and sets up the architecture of micro-applications within a
|
28
34
|
Rails application, enabling the segregation of code, management, and isolation of
|
29
35
|
functionalities, which can be developed, tested, and maintained independently of
|
@@ -77,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
83
|
- !ruby/object:Gem::Version
|
78
84
|
version: '0'
|
79
85
|
requirements: []
|
80
|
-
rubygems_version: 3.5.
|
86
|
+
rubygems_version: 3.5.23
|
81
87
|
signing_key:
|
82
88
|
specification_version: 4
|
83
89
|
summary: New way to organize app features in Rails.
|