feature_pack 0.3.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a358d066012fe6059153050e3887849afec64faf789a3668c696c8606347044c
4
- data.tar.gz: 27141fe3653ff391a85301d9fcc5ea8676084403d0ad259b06528c22b6fab0ed
3
+ metadata.gz: 9c1076c32434b482c422874b1b2c5d7a0ba473270d62664988f31f57dff4056c
4
+ data.tar.gz: 6c630b91094c255f7db27664feb3304bf77e106b2333867712b25ef04597d7c6
5
5
  SHA512:
6
- metadata.gz: 22d7b9a11292d34b1fc5920741ac4e4033dbc1417cb59dd534ff4acd564b34ed46440b9f163aba77b077b70977852b6ad136f3c28363e927e394034b6a3b9f1a
7
- data.tar.gz: c3b4d00e9a16dd5767a8ce1c79bfc689ddc3b07d2890c52c88d5046c7261a432c318a1d5950600d3bc5ffcc674175f3d54b5a3a919ebe94930777bc8ea53f308
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, '_group_metadata', submodule_name.downcase)
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
@@ -87,7 +87,7 @@ The library expects the following file structure:
87
87
  ```
88
88
  features_path/
89
89
  ├── group_name_1/
90
- │ ├── _group_metadata/
90
+ │ ├── _group_space/
91
91
  │ │ ├── manifest.yaml
92
92
  │ │ ├── controller.rb
93
93
  │ │ └── routes.rb (optional)
@@ -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)
@@ -3,4 +3,4 @@ module FeaturePack::Error
3
3
  end
4
4
  class NoGroup < StandardError
5
5
  end
6
- end
6
+ end
@@ -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
- GROUP_METADATA_DIRECTORY = '_group_metadata'.freeze
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(features_path:)
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(features_path)
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, GROUP_METADATA_DIRECTORY, 'routes.rb')) ? File.join(base_path, GROUP_METADATA_DIRECTORY, 'routes') : nil
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, GROUP_METADATA_DIRECTORY, CONTROLLER_FILE_NAME)
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, GROUP_METADATA_DIRECTORY),
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, GROUP_METADATA_DIRECTORY, MANIFEST_FILE_NAME)).deep_symbolize_keys
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}/#{GROUP_METADATA_DIRECTORY}/views"
72
- def group.view(view_name) = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/views/#{view_name}"
73
- def group.javascript_module(javascript_file_name) = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/javascript/#{javascript_file_name}"
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 './_group_metadata/controller.rb.tt', group_dir.join('_group_metadata', 'controller.rb')
22
- template './_group_metadata/manifest.yaml.tt', group_dir.join('_group_metadata', 'manifest.yaml')
23
- template './_group_metadata/routes.rb.disabled.tt', group_dir.join('_group_metadata', 'routes.rb.disabled')
24
- template './_group_metadata/views/index.html.slim.tt', group_dir.join('_group_metadata', 'views/index.html.slim')
25
- template './_group_metadata/views/partials/_header.html.slim.tt', group_dir.join('_group_metadata', 'views/partials/_header.html.slim')
26
- template './_group_metadata/views/partials/_footer.html.slim.tt', group_dir.join('_group_metadata', 'views/partials/_footer.html.slim')
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.3.1
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-08-30 00:00:00.000000000 Z
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.2'
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: '7.2'
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.18
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.