rails_module_unification 0.7.0 → 0.7.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 369fdde3d87f5a85780905994dbdf681cd649355
|
4
|
+
data.tar.gz: 81611173e795da1a64bd7427984dd3cfecd822af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9ee53bbd5e68def83faa2787ad9618869ed49537d6cbf57938a27d96aee4e7de442ba426faf98e5de97d1ae364e1bc9a9f7d7d9bd8080e3ef254517d2644579
|
7
|
+
data.tar.gz: 477a3e292c488bda8a1a458f2328bac4f754e85ed51a56f370527b906cc56f758d2cd44409bfad5e378f36fb00c6c1736c986ae079283be19332fc36e5c476e3
|
data/README.md
CHANGED
@@ -14,6 +14,10 @@ With large rails application, the default architecture can result in a resource'
|
|
14
14
|
|
15
15
|
This gem provides a way to re-structure your app so that like-objects are grouped together.
|
16
16
|
|
17
|
+
All this gem does is add some new autoloading / path resolution logic. This gem does not provide any service/operation/policy/etc functionality.
|
18
|
+
|
19
|
+
**All of this is optional, and can be slowly migrated to over time. Adding this gem does not force you to change your app.**
|
20
|
+
|
17
21
|
### The new structure
|
18
22
|
|
19
23
|
```
|
@@ -42,8 +46,37 @@ app/
|
|
42
46
|
|
43
47
|
```
|
44
48
|
|
49
|
+
Does this new structure mean you have to change the class names of all your classes? Nope. In the above example file structure, `app/resources/posts/controller.rb` _still_ defines `class PostsController < ApplicationController`
|
50
|
+
|
45
51
|
[Checkout the sample rails app in the tests directory.](https://github.com/NullVoxPopuli/rails_module_unification/tree/master/spec/support/rails_app/app)
|
46
52
|
|
53
|
+
### The Convention
|
54
|
+
|
55
|
+
Say, for example, you have _any_ class/module defined as:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
module Api # {namespace
|
59
|
+
module V3 # namespace}
|
60
|
+
module UserServices # {resource_name}{resource_type}
|
61
|
+
module Authentication # {class_path
|
62
|
+
class OAuth2 # class_path/file_name}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
As long as some part of the fully qualified class name (in this example: `Api::V3::UserServices::Authentication::OAuth2`) contains any of the [defined keywords](https://github.com/NullVoxPopuli/rails_module_unification/blob/master/lib/rails_module_unification/active_support/dependency_extensions.rb#L4), the file will be found at `app/resources/api/v3/users/services/authentication/oauth2.rb`.
|
71
|
+
|
72
|
+
The pattern for this is: `app/resources/:namespace/:resource_name/:resource_type/:class_path` where:
|
73
|
+
- `:namespace` is the namespace/parents of the `UserService`
|
74
|
+
- `:resource_type` is a suffix that may be inferred by checking of the inclusion of the defined keywords (linked above)
|
75
|
+
- `:resource_name` is the same module/class as what the `resource_type` is derived from, sans the `resource_type`
|
76
|
+
- `:class_path` is the remaining namespaces and eventually the class that the target file defines.
|
77
|
+
|
78
|
+
So... what if you have a set of classes that don't fit the pattern exactly? You can leave those files where they are currently, or move them to `app/resources`, if it makes sense to do so. Feel free to open an issue / PR if you feel the list of resource types needs updating.
|
79
|
+
|
47
80
|
## Usage
|
48
81
|
|
49
82
|
```ruby
|
@@ -13,32 +13,5 @@ module RailsModuleUnification
|
|
13
13
|
super(path)
|
14
14
|
@path = path
|
15
15
|
end
|
16
|
-
|
17
|
-
# def find_templates(name, prefix, partial, details)
|
18
|
-
# binding.pry
|
19
|
-
# super(name, prefix, partial, details)
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# def build_query(path, details)
|
23
|
-
#
|
24
|
-
# query = @pattern.dup
|
25
|
-
#
|
26
|
-
# binding.pry
|
27
|
-
# prefix = path.prefix.empty? ? '' : "#{escape_entry(path.prefix)}\\1"
|
28
|
-
# query.gsub!(/:prefix(\/)?/, prefix)
|
29
|
-
#
|
30
|
-
# partial = escape_entry(path.partial? ? "_#{path.name}" : path.name)
|
31
|
-
# query.gsub!(/:action/, partial)
|
32
|
-
#
|
33
|
-
# details.each do |ext, candidates|
|
34
|
-
# if ext == :variants && candidates == :any
|
35
|
-
# query.gsub!(/:#{ext}/, "*")
|
36
|
-
# else
|
37
|
-
# query.gsub!(/:#{ext}/, "{#{candidates.compact.uniq.join(',')}}")
|
38
|
-
# end
|
39
|
-
# end
|
40
|
-
# puts File.expand_path(query, @path)
|
41
|
-
# File.expand_path(query, @path)
|
42
|
-
# end
|
43
16
|
end
|
44
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_module_unification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
@@ -189,5 +189,5 @@ rubyforge_project:
|
|
189
189
|
rubygems_version: 2.6.7
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
|
-
summary: RailsModuleUnification-0.7.
|
192
|
+
summary: RailsModuleUnification-0.7.1
|
193
193
|
test_files: []
|