feature_pack 0.1.6 → 0.3.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: 281dd30e4d1dfff4a4be468c364b5528c910fd79afb3eec21fd8e9d8436f1fee
4
- data.tar.gz: 25ec88a0b0c8626977687d642954fda17abdd617bdf422fb2c09774c6667341d
3
+ metadata.gz: c4d4c06a3ac9cc919e20a0616c0ec7b0d1da2553f43a4c5b140ef7a8bc29147a
4
+ data.tar.gz: 21ae0804c870c884ee4270168327fa81eade33b261bb4adb915f87f49764ca41
5
5
  SHA512:
6
- metadata.gz: 214735c4ec76ee1a6c23f36acda37ab1ec009c10234695390ea6e75a4102bb33522450eb30eea1616a4592c408a21b9e5b2b62efe8a953151346db9ee2edf30c
7
- data.tar.gz: 91e5690231a142beb0abbcd0bef2f745926ca5cb5e113b605703ce974b7ee371ea65535b3bb71ffff6d14250cb50ecfb21de0b8785e96e8332847da7cc06209d
6
+ metadata.gz: a66fab958817fe7391449fe39d04043b9729e3bfc4a40b18e8ad6458e4a2f2c6a7ff863dfb0c8acf5841024bfdb34bb48e79c631c58949d655d1d0ca809fb8ec
7
+ data.tar.gz: bcc1750715d4f4a88587b557bd75e5ed0e3c698fec80a1691942b5ff895ecd3b6041636dd4b325de811d3008551a1244aa10635b5a28e7180a41642a86420b54
@@ -3,7 +3,7 @@ class FeaturePack::Controller < ApplicationController
3
3
  before_action :set_view_lookup_context_prefix
4
4
  before_action :set_layout_paths
5
5
 
6
- def home; end
6
+ def index; end
7
7
 
8
8
  private
9
9
 
@@ -1,9 +1,9 @@
1
1
  FeaturePack.groups.each do |group|
2
2
  unless group.manifest[:namespace_only]
3
- # Default "home" route every group has to have.
3
+ # Default 'index' route every group has to have.
4
4
  get group.manifest[:url],
5
- to: "#{group.name.name}#home",
6
- as: group.name.name
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
@@ -3,8 +3,7 @@ class FeaturePack::GroupController < ApplicationController
3
3
  before_action :set_view_lookup_context_prefix
4
4
  before_action :set_layout_paths
5
5
 
6
- def home
7
- end
6
+ def index; end
8
7
 
9
8
  private
10
9
 
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('_'),
@@ -66,7 +66,7 @@ module FeaturePack
66
66
  alias_method_name, alias_const_name = alias_data.first
67
67
  group.define_singleton_method(alias_method_name) { "FeaturePack::#{group.name.name.camelize}::#{alias_const_name}".constantize }
68
68
  end
69
-
69
+
70
70
  def group.feature(feature_name) = features.find { |p| p.name.eql?(feature_name) }
71
71
  def group.views_path = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/views"
72
72
  def group.view(view_name) = "#{base_dir}/#{GROUP_METADATA_DIRECTORY}/views/#{view_name}"
@@ -80,16 +80,16 @@ module FeaturePack
80
80
  absolute_path = @@features_path.join(feature_path)
81
81
  relative_path = Pathname.new(feature_path)
82
82
  base_path = File.basename(feature_path, File::SEPARATOR)
83
-
83
+
84
84
  feature_name = base_path.gsub(FEATURE_ID_PATTERN, '').to_sym
85
-
85
+
86
86
  routes_file_path = relative_path.join('routes.rb')
87
87
 
88
88
  # The custom routes file loads before the Rails default routes,
89
89
  # leading to errors like NoMethodError for 'scope'.
90
90
  # Ignoring them is required to prevent these issues.
91
91
  @@ignored_paths << routes_file_path
92
-
92
+
93
93
  # Due to Zeiwerk rules, Controllers have special load process
94
94
  @@features_controllers_paths << relative_path.join(CONTROLLER_FILE_NAME)
95
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/home.html.slim.tt', @feature_dir.join('views/home.html.slim')
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,3 +1,3 @@
1
1
  class FeaturePack::<%= @group_class_name %>::<%= @feature_class_name %>Controller < FeaturePack::Controller
2
- # home defined in parent controller
2
+ # index defined in parent controller
3
3
  end
@@ -1 +1 @@
1
- get '/', to: '<%= @feature_name %>#home'
1
+ get '/', to: '<%= @feature_name %>#index'
@@ -1,2 +1,2 @@
1
- h1 Feature <%= @group_class_name%>::<%=@feature_class_name %> Home
1
+ h1 Feature <%= @group_class_name%>::<%=@feature_class_name %> Index
2
2
  p = "Find-me at #{__FILE__}"
@@ -21,7 +21,7 @@ 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/home.html.slim.tt', group_dir.join('_group_metadata', 'views/home.html.slim')
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
27
  end
@@ -1,3 +1,3 @@
1
1
  class FeaturePack::<%= class_name %>Controller < FeaturePack::GroupController
2
- # 'home' already defined in RootGroupController
2
+ # 'index' already defined in RootGroupController
3
3
  end
@@ -1,3 +1,3 @@
1
- # You don't need enable this file if the only action is 'home'
1
+ # You don't need enable this file if the only action is 'index'
2
2
 
3
3
  get '/action-name-url', to: '<%= name %>#action_name'
@@ -0,0 +1,2 @@
1
+ h1 Group <%= class_name%> Index
2
+ p = "Find-me at #{__FILE__}"
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.1.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gedean Dias
@@ -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/home.html.slim.tt
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.9
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.
@@ -1,2 +0,0 @@
1
- h1 Group <%= class_name%> Home
2
- p = "Find-me at #{__FILE__}"