feature_pack 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a358d066012fe6059153050e3887849afec64faf789a3668c696c8606347044c
4
- data.tar.gz: 27141fe3653ff391a85301d9fcc5ea8676084403d0ad259b06528c22b6fab0ed
3
+ metadata.gz: dd18a6901bd123d6449e6570022136ecbd36e473b0cf572f27f6c91f80bd702d
4
+ data.tar.gz: 322a89e29a1e357dd6680f31b30adda1f53fcaf4139a8357bbf855e3a27287ae
5
5
  SHA512:
6
- metadata.gz: 22d7b9a11292d34b1fc5920741ac4e4033dbc1417cb59dd534ff4acd564b34ed46440b9f163aba77b077b70977852b6ad136f3c28363e927e394034b6a3b9f1a
7
- data.tar.gz: c3b4d00e9a16dd5767a8ce1c79bfc689ddc3b07d2890c52c88d5046c7261a432c318a1d5950600d3bc5ffcc674175f3d54b5a3a919ebe94930777bc8ea53f308
6
+ metadata.gz: 2efc9f88f00cfdad138a79cab42c1cbda2e10a9147ecf37bbf5991bd024a5eb1cdc7e23f297ed442d2f9f20c5a488d11da714aec7e026f8fdf13a49c74463120
7
+ data.tar.gz: df6e3f3a8635ca73b43caef82c78f6cb1d13c8bc90a249d72ee2c74ddf09e554b9ab68c52ef643658f8cdd1aafea30101ee72cf737285400f4237b7bef877fcb
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
 
@@ -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,14 +1,14 @@
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.4.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-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.5.18
80
+ rubygems_version: 3.5.22
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: New way to organize app features in Rails.