feature_pack 0.0.7 → 0.0.9

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +66 -0
  3. data/lib/feature_pack.rb +4 -6
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40810174db4e0624612e8dfa7979635a371faaa60996b99094ca634fca170dda
4
- data.tar.gz: 3239738c0fc17863242bc29ead5159a43dd04b57ffc2930c158877cee71725f6
3
+ metadata.gz: 55973cae577c2295ae4baffaef95d5416d969c8ab76afa261cdf5c38897d977c
4
+ data.tar.gz: b77ab0ea523c05867e533eae860bc7227166329438c2bd96eba98f77aa08d93b
5
5
  SHA512:
6
- metadata.gz: 7ddd0d2fdf111a39fa11685d752fae9d9aceb607fab96369ea86ae72e9d846df682ba9da58cedca847969afd60bd499094294dec72a3017b3553c0dac2dffdf8
7
- data.tar.gz: 83ff3aa09bb1cc710a78935554af7b9e5a2daa0e83cc06a42706a386a8f950e41f5f525087b5592e8e7427fa4fc4b3d9715b612af70932199fe25f49f5402c50
6
+ metadata.gz: be2356f348450d5eadbb8e554253904d1ef6388744eee2c1055c07c3cbfea0bbe6ffa1d59566a64b30f9c4b71bc45d657765446f0c6e8cf7aad5d4d68e84439c
7
+ data.tar.gz: a0af2ec40af2851ebc0e88366525440096257a8027570621c353682d3000fd777555d243d805e29c6b2f11e1bfcd52657fe5d61ba03288dd0b1d1c855a65de24
data/README.md CHANGED
@@ -1,2 +1,68 @@
1
1
  # Feature Pack
2
2
  Organizes and sets up the architecture of micro-applications within a Rails application, enabling the segregation of code, management, and isolation of functionalities, which can be developed, tested, and maintained independently of each other.
3
+
4
+ ## Installation
5
+ Meanwhile installer isn't done, follow the steps below to install FeaturePack GEM:
6
+
7
+ ```ruby
8
+ # Add feature_pack to Gemfile
9
+ gem 'feature_pack'
10
+ ```
11
+
12
+ ```bash
13
+ bundle install
14
+ ```
15
+
16
+ Setup loading
17
+ ```ruby
18
+ # config/application.rb
19
+
20
+ feature_packs_path = Rails.root.join('app/feature_packs')
21
+ FeaturePack.setup(features_path: feature_packs_path)
22
+
23
+ FeaturePack.ignored_paths.each { |path| Rails.autoloaders.main.ignore(Rails.root.join(path)) }
24
+
25
+ config.eager_load_paths << FeaturePack.features_path
26
+ config.paths['app/views'] << FeaturePack.features_path
27
+
28
+ config.paths['config/routes'] << (FeaturePack.path.to_s << '/feature_pack')
29
+ config.paths['config/routes'] << FeaturePack.features_path
30
+ config.assets.paths << FeaturePack.features_path.to_s
31
+
32
+ Zeitwerk::Loader.eager_load_all
33
+
34
+ config.after_initialize do
35
+ load FeaturePack.path.join('feature_pack/group_controller.rb')
36
+ load FeaturePack.path.join('feature_pack/controller.rb')
37
+
38
+ FeaturePack.groups_controllers_paths.each { |group_controller_path| load group_controller_path }
39
+ FeaturePack.features_controllers_paths.each { |controller_path| load controller_path }
40
+ end
41
+ ```
42
+
43
+ ```ruby
44
+ # initializers/feature_pack.rb
45
+
46
+ FeaturePack.groups.each do |group|
47
+ group_module = FeaturePack.const_set(group.name.name.camelize, Module.new)
48
+
49
+ %w[Lib AI Jobs].each do |submodule_name|
50
+ submodule_path = File.join(group.relative_path, '_group_metadata', submodule_name.downcase)
51
+ if Dir.exist?(submodule_path)
52
+ submodule = group_module.const_set(submodule_name, Module.new)
53
+ Rails.autoloaders.main.push_dir(submodule_path, namespace: submodule)
54
+ end
55
+ end
56
+
57
+ group.features.each do |feature|
58
+ feature_module = group_module.const_set(feature.name.name.camelize, Module.new)
59
+ Rails.autoloaders.main.push_dir(feature.relative_path, namespace: feature_module)
60
+ end
61
+ end
62
+ ```
63
+
64
+ ```ruby
65
+ # app/helpers/application_helper.rb
66
+ def feature_pack_group_path(group, *params) = send("feature_pack_#{group.name}_path".to_sym, *params)
67
+ def feature_pack_path(group, feature, *params) = send("feature_pack_#{group.name}_#{feature.name}_path".to_sym, *params)
68
+ ```
data/lib/feature_pack.rb CHANGED
@@ -35,9 +35,6 @@ module FeaturePack
35
35
  @@javascript_files_paths = Dir.glob("#{@@features_path}/[!_]*/**/*.js")
36
36
  .map { |js_path| js_path.sub(/^#{Regexp.escape(@@features_path.to_s)}\//, '') }.to_a
37
37
 
38
- # @@layouts_paths = Dir.glob("#{@@features_path}/[!_]*/**/views/layouts")
39
- # .map { |layout_path| layout_path.delete_suffix '/layouts' }
40
-
41
38
  ATTR_READERS.each { |attr| define_singleton_method(attr) { class_variable_get("@@#{attr}") } }
42
39
 
43
40
  @@ignored_paths << @@path.join('feature_pack/feature_pack_routes.rb')
@@ -80,7 +77,8 @@ module FeaturePack
80
77
 
81
78
  feature_name = base_path.gsub(FEATURE_ID_PATTERN, '').to_sym
82
79
  feature_class_name = "#{group.name.name.camelize}::#{feature_name.name.camelize}"
83
- # FIX-ME
80
+
81
+ # FIX-ME (decouple Params class)
84
82
  # params_class_name = "#{feature_pack_class_name}::Params"
85
83
 
86
84
  routes_file_path = relative_path.join('routes.rb')
@@ -110,12 +108,12 @@ module FeaturePack
110
108
  views_absolute_path: absolute_path.join('views'),
111
109
  views_relative_path: relative_path.sub(/^#{Regexp.escape(@@features_path.to_s)}\//, '').join('views'),
112
110
  class_name: feature_class_name,
113
- # FIX-ME
111
+ # FIX-ME (decouple Params class)
114
112
  #params_class_name: params_class_name,
115
113
  manifest: YAML.load_file(File.join(feature_path, MANIFEST_FILE_NAME)).deep_symbolize_keys
116
114
  )
117
115
 
118
- # FIX-ME
116
+ # FIX-ME (decouple Params class)
119
117
  # def feature.params_class = params_class_name.constantize
120
118
  def feature.view(view_name) = "#{views_relative_path}/#{view_name}"
121
119
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gedean Dias