appfuel 0.2.6 → 0.2.7

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: 730ab86942bed445ca95032499fb709e294614e5
4
- data.tar.gz: 9b6fb2eeb4ad17c1737d9ff66a459edb11e86625
3
+ metadata.gz: d3c3ec8718b6e4fb9df7ef555193402e6f02c931
4
+ data.tar.gz: bb6b14d5574937ef8a7656ba3d9e8341cfd42a15
5
5
  SHA512:
6
- metadata.gz: 94cd230b06bd3fafb420f909c329f531b9e227d0ef9213432399fa531d05ac01914bcee6e026030733fb7c6ec5362047cf585b1cf5d139179092c98ad54f3cfe
7
- data.tar.gz: 85e629ee6586d4495b700b4713fbc1a7af980af062e4394b67ccbd0b44cba48f4a1c0dd0f6f5da4ebe6c9a8aa810efb1c77c2f6251a3dba3b749001a1d634741
6
+ metadata.gz: 24449913484eabff5fffe4299dc89c6c7379901ab4176a19fc1b2fd11d4d12967c8b7be88bb5a4ed9060b10144fb1cd151d580aaaa4dc79182b40cedf7569133
7
+ data.tar.gz: 6464c583c605012bc135411526d9143dd852572f7a9debd372d2a75070022a09cd8270910fd683fe0ccbf54a0ab3d4904561af558d6ff10b493b71180f9ca87a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. (Pending ap
4
4
  # [Unreleased]
5
5
 
6
6
  # Releases
7
+ ## [[0.2.7]](https://github.com/rsb/appfuel/releases/tag/0.2.6) 2017-06-07
8
+ ### Changed
9
+ - Initializers are now stored in the app container and separate runlist
10
+ determines the order for which they run
11
+
12
+ ## [[0.2.6]](https://github.com/rsb/appfuel/releases/tag/0.2.6) 2017-06-06
13
+ ### Added
14
+ - dispatcher mixin
15
+
16
+ ### Changed
17
+ - moved domain parsing to repository namespace
7
18
  ## [[0.2.5]](https://github.com/rsb/appfuel/releases/tag/0.2.5) 2017-05-23
8
19
  ### Fixed
9
20
  - feature initializer has invalid reference `register?`
@@ -21,11 +32,3 @@ All notable changes to this project will be documented in this file. (Pending ap
21
32
 
22
33
  ### Added
23
34
  - added exists interface to db mapper, will finalize the repo on next release
24
-
25
- ## [[0.2.6]](https://github.com/rsb/appfuel/releases/tag/0.2.6) 2017-06-6
26
-
27
- ### Added
28
- - dispatcher mixin
29
-
30
- ### Changed
31
- - moved domain parsing to repository namespace
@@ -6,9 +6,9 @@ module Appfuel
6
6
  begin
7
7
  container[:feature_initializer].call(request.feature, container)
8
8
  action = container[:action_loader].call(request.namespace, container)
9
- response = action.run(inputs)
9
+ response = action.run(request.inputs)
10
10
  rescue => e
11
- handler_error(e, container)
11
+ handle_error(e, container)
12
12
  end
13
13
 
14
14
  if response.failure?
@@ -18,10 +18,8 @@ module Appfuel
18
18
 
19
19
  private
20
20
  def handle_error(e, container)
21
- unless container.key?(:error_handler)
22
- return default_error_handling(e, contianer) unless container.key?(:error_handler)
23
- end
24
-
21
+ p e.message
22
+ p e.backtrace
25
23
  end
26
24
 
27
25
  def default_error_handling(e, container)
@@ -1,7 +1,7 @@
1
1
  module Appfuel
2
2
  module Application
3
3
  module Root
4
- extend Dispatcher
4
+ include Dispatcher
5
5
 
6
6
  # Initialize Appfuel by creating an application container for the
7
7
  # app represented by the root module passed in. The app container is
@@ -24,6 +24,9 @@ module Appfuel
24
24
  app_container.register(:app_name, app_name)
25
25
  framework_container.register(app_name, app_container)
26
26
 
27
+ initialize = params.fetch(:initialize) { [] }
28
+ app_container.register('global.initializers.run', initialize)
29
+
27
30
  if params.key?(:on_after_setup)
28
31
  handle_after_setup(params[:on_after_setup], app_container)
29
32
  end
@@ -11,9 +11,32 @@ module Appfuel
11
11
  # @param name [String] name of the initializer
12
12
  # @param envs [String, Symbol, Array] A env,list of envs this can run in
13
13
  # @param app_name [String] name of app for this initializer
14
- def define(namespace_key, name, envs = [], app_name = nil, &block)
15
- initializers = Appfuel.resolve("#{namespace_key}.initializers", app_name)
16
- initializers << Initializer.new(name, envs, &block)
14
+ def define(name, envs = [], app_name = nil, &block)
15
+ if !name.is_a?(String) && !name.include?('.')
16
+ fail "initializer name must be a string in the in the form of " +
17
+ "([feature|global].initializer_name)"
18
+ end
19
+ top, name = name.split('.')
20
+ top = "features.#{top}" unless top == 'global'
21
+ namespace = "#{top}.initializers.#{name}"
22
+ container = Appfuel.app_container(app_name)
23
+ initializer = Initializer.new(name, envs, &block)
24
+ container.register(namespace, initializer)
25
+
26
+ initializer
27
+ end
28
+
29
+ def runlist(name, list, app_name = nil)
30
+ namespace = "#{name}.initializers.run"
31
+ unless name == 'global'
32
+ namespace = "features.#{namespace}"
33
+ end
34
+ list = [list] unless list.is_a?(Array)
35
+ fail "run list must be [String|Symbol|Array]" unless list.is_a?(Array)
36
+
37
+ container = Appfuel.app_container(app_name)
38
+ container.register(namespace, list)
39
+ nil
17
40
  end
18
41
 
19
42
  # Populate configuration definition that is in the container and
@@ -1,3 +1,3 @@
1
1
  module Appfuel
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
data/lib/appfuel.rb CHANGED
@@ -140,11 +140,20 @@ module Appfuel
140
140
  unless exclude.is_a?(Array)
141
141
  fail ArgumentError, ":exclude must be an array"
142
142
  end
143
+
143
144
  exclude.map! {|item| item.to_s}
145
+ namespace = "#{key}.initializers"
146
+ runlist_key = "#{namespace}.run"
147
+ env = container['env']
148
+ config = container['config']
149
+ runlist = container[runlist_key]
150
+ unless runlist.respond_to?(:each)
151
+ fail "[initialize] runlist (#{runlist_key}) must implement :each"
152
+ end
144
153
 
145
- env = container[:env]
146
- config = container[:config]
147
- container["#{key}.initializers"].each do |init|
154
+ runlist.each do |initializer_key|
155
+ initializer_key = "#{namespace}.#{initializer_key}"
156
+ init = container[initializer_key]
148
157
  if !init.env_allowed?(env) || exclude.include?(init.name)
149
158
  next
150
159
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appfuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord