component-framework 0.1.2 → 0.2.3
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 +4 -4
- data/README.md +13 -2
- data/lib/component/framework.rb +36 -7
- data/lib/component/framework/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da855042888484421b1f621360157021aa99ee01
|
4
|
+
data.tar.gz: aa093726bcb6d8fcf6d038d090c8ea0bacd145ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3882972a53ca9222608d836ca07a6eecf77cca425435f65ca3dbce947a90d1603e5126a71d1183fcfca402c924a31a2f507855730d2799b8149f6fcd627d4157
|
7
|
+
data.tar.gz: 35caf9b3402ed1da0bff8a07efd4a2801491117fe2fe96b88a7369dbc967374ad84258d33a8655cf2a62987781992434cb9e129cb24d121be069d27b88ee950e
|
data/README.md
CHANGED
@@ -32,9 +32,20 @@ module My
|
|
32
32
|
...
|
33
33
|
end
|
34
34
|
|
35
|
-
Component::Framework.initialize(
|
35
|
+
Component::Framework.initialize(My::Application)
|
36
|
+
|
37
|
+
end
|
36
38
|
```
|
37
39
|
|
40
|
+
to get the components initialization output specify `verbose: true` parameter in framework initialization call
|
41
|
+
|
42
|
+
in case you don't use Sprockets assets pipeline, you can explicitly disable it's configuration by specifying
|
43
|
+
`assets_pipeline: false` in framework initialization call
|
44
|
+
|
45
|
+
e.g.
|
46
|
+
`Component::Framework.initialize(My::Application, assets_pipeline: false, verbose: true)`
|
47
|
+
|
48
|
+
|
38
49
|
### Conventions
|
39
50
|
|
40
51
|
|
@@ -83,7 +94,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
83
94
|
|
84
95
|
## Contributing
|
85
96
|
|
86
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
97
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/brokermint/component-framework. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
87
98
|
|
88
99
|
## License
|
89
100
|
|
data/lib/component/framework.rb
CHANGED
@@ -10,11 +10,19 @@ module Component
|
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
|
+
# Components root folder path
|
14
|
+
#
|
15
|
+
# @return [string] Components root folder path
|
13
16
|
def self.components_base_dir
|
14
17
|
@base_dir ||= Rails.root.join("components")
|
15
18
|
end
|
16
19
|
|
17
20
|
|
21
|
+
# Initialize Component Framework
|
22
|
+
#
|
23
|
+
# @param application [Rails::Application] the application class
|
24
|
+
# @param assets_pipeline [bool] specifies whether Sprockets asset_pipeline should be configured for components
|
25
|
+
# @param verbose [bool] allows to show components initialization log, default `false`
|
18
26
|
def self.initialize(application, assets_pipeline: true, verbose: false)
|
19
27
|
@verbose = verbose
|
20
28
|
|
@@ -42,15 +50,27 @@ module Component
|
|
42
50
|
_initialize_assets_pipeline(application)
|
43
51
|
end
|
44
52
|
|
45
|
-
# Initialize components
|
46
|
-
|
53
|
+
# Initialize components
|
54
|
+
#
|
55
|
+
# Initialization happen in 2 steps to allow components to perform actions upon initialized components.
|
56
|
+
# First cycle is a part of Rails initialization, so it's possible to configure Rails env in it
|
57
|
+
# like registering middleware etc.
|
58
|
+
application.initializer :initialize_components, group: :all do |app|
|
47
59
|
|
48
|
-
log("Load Components Initializers")
|
49
|
-
_load_components_initializers
|
60
|
+
Component::Framework.log("Load Components Initializers")
|
61
|
+
Component::Framework._load_components_initializers
|
50
62
|
|
51
|
-
components = get_component_modules
|
52
|
-
log("Initialize Components")
|
63
|
+
components = Component::Framework.get_component_modules
|
64
|
+
Component::Framework.log("Initialize Components")
|
53
65
|
components.each {|component| component.send("init") if component.respond_to?("init") }
|
66
|
+
end
|
67
|
+
|
68
|
+
# Post initialization of components
|
69
|
+
# when all the other parts are ready to be referenced
|
70
|
+
#
|
71
|
+
# A place to register subscribers as well as call other component's services.
|
72
|
+
application.config.after_initialize do |app|
|
73
|
+
components = get_component_modules
|
54
74
|
|
55
75
|
log("Post-Initialize Components")
|
56
76
|
components.each {|component| component.send("ready") if component.respond_to?("ready") }
|
@@ -61,18 +81,27 @@ module Component
|
|
61
81
|
log("Configuration Finished")
|
62
82
|
end
|
63
83
|
|
64
|
-
|
84
|
+
# List of component names
|
85
|
+
#
|
86
|
+
# @return [Array<string>] List of component names
|
65
87
|
def self.get_component_names
|
66
88
|
Dir.entries(components_base_dir)
|
67
89
|
.select { |entry| (entry !="." && entry != "..") and File.directory? components_base_dir.join(entry) }
|
68
90
|
end
|
69
91
|
|
70
92
|
|
93
|
+
# List of component root modules
|
94
|
+
#
|
95
|
+
# @return [Array<Object>] List of component root modules
|
71
96
|
def self.get_component_modules
|
72
97
|
get_component_names.map { |name| component_module_by_name(name) }
|
73
98
|
end
|
74
99
|
|
75
100
|
|
101
|
+
# Get the component root module by component name
|
102
|
+
#
|
103
|
+
# @param name [string] the component name
|
104
|
+
# @return [Object] Component root module
|
76
105
|
def self.component_module_by_name(name)
|
77
106
|
return name.camelize.constantize
|
78
107
|
rescue NameError, ArgumentError
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: component-framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Yegorov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|