appfuel 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/appfuel.rb +1 -1
- data/lib/appfuel/initializers/all.rb +3 -0
- data/lib/appfuel/initializers/db.rb +21 -0
- data/lib/appfuel/initializers/logging.rb +36 -0
- data/lib/appfuel/initializers/web_api.rb +4 -0
- data/lib/appfuel/log_formatter.rb +9 -0
- data/lib/appfuel/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272469cb6b6176387cccd84e5b0dbfddd5008b5e
|
4
|
+
data.tar.gz: 2dba20cdaafa5f307bf1ab53bada70134591b5d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b69ff2a0ebb4d5276d40c9f2b7d5aebccc090996ae9b6404e75839a8b40bcc3d9948366756c4137722d6f6d406e54edcc295d8e11e56ee819538d18a213f17e5
|
7
|
+
data.tar.gz: d0e5af1cb92b21b0b36436ef76ab15f382b913cf82e0f3080734f873948693bd41432abe9a937004e2df29cfdb368638acdc368d4067d67c19ae454a92297714
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. (Pending ap
|
|
5
5
|
|
6
6
|
|
7
7
|
# Releases
|
8
|
+
## [[0.4.0]](https://github.com/rsb/appfuel/releases/tag/0.4.0) 2017-06-21
|
9
|
+
### Added
|
10
|
+
- logging, db and `web_api` initializers have been added
|
11
|
+
- added log formatter
|
12
|
+
|
8
13
|
## [[0.3.4]](https://github.com/rsb/appfuel/releases/tag/0.3.4) 2017-06-20
|
9
14
|
### Changed
|
10
15
|
- `web api model` changed `url` to `uri`
|
data/lib/appfuel.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
Appfuel::Initialize.define('global.db') do |config, container|
|
2
|
+
fail "[initializer db] :db config not found" unless config.key?(:db)
|
3
|
+
fail "[initializer db] :main not found in :db" unless config[:db].key?(:main)
|
4
|
+
|
5
|
+
require 'pg'
|
6
|
+
require 'active_record'
|
7
|
+
config[:db][:main] = config[:db][:main].with_indifferent_access
|
8
|
+
|
9
|
+
ActiveSupport.on_load(:active_record) do
|
10
|
+
if ActiveRecord::Base.connected?
|
11
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
12
|
+
end
|
13
|
+
|
14
|
+
if container.key?(:logger)
|
15
|
+
ActiveRecord::Base.logger = container[:logger]
|
16
|
+
end
|
17
|
+
|
18
|
+
ActiveRecord::Base.establish_connection(config[:db][:main])
|
19
|
+
end
|
20
|
+
nil
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Appfuel::Initialize.define('global.logging') do |config, container|
|
2
|
+
log_file = config[:logfile] || 'stdout'
|
3
|
+
log_level = config[:log_level] || 'info'
|
4
|
+
|
5
|
+
logfile_coercer = ->(file) {
|
6
|
+
file = file.to_s
|
7
|
+
if file.empty? || file.downcase == 'stdout'
|
8
|
+
file = $stdout
|
9
|
+
elsif file.downcase == 'stderr'
|
10
|
+
file = $stderr
|
11
|
+
else
|
12
|
+
file
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
log_formatter = Appfuel::LogFormatter
|
17
|
+
|
18
|
+
logger_factory = ->(file, level = nil, formatter = nil) {
|
19
|
+
logger = Logger.new(file)
|
20
|
+
if level
|
21
|
+
logger.level = Logger.const_get(level.to_s.upcase)
|
22
|
+
end
|
23
|
+
|
24
|
+
if formatter
|
25
|
+
logger.formatter = log_formatter
|
26
|
+
end
|
27
|
+
|
28
|
+
logger
|
29
|
+
}
|
30
|
+
|
31
|
+
logger = logger_factory.call(log_file, log_level, log_formatter)
|
32
|
+
container.register(:log_formatter, log_formatter)
|
33
|
+
container.register(:logfile_coercer, logfile_coercer)
|
34
|
+
container.register(:logger_factory, logger_factory)
|
35
|
+
container.register(:logger, logger)
|
36
|
+
end
|
data/lib/appfuel/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appfuel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Scott-Buccleuch
|
@@ -314,6 +314,11 @@ files:
|
|
314
314
|
- lib/appfuel/handler/validator_dsl.rb
|
315
315
|
- lib/appfuel/initialize.rb
|
316
316
|
- lib/appfuel/initialize/initializer.rb
|
317
|
+
- lib/appfuel/initializers/all.rb
|
318
|
+
- lib/appfuel/initializers/db.rb
|
319
|
+
- lib/appfuel/initializers/logging.rb
|
320
|
+
- lib/appfuel/initializers/web_api.rb
|
321
|
+
- lib/appfuel/log_formatter.rb
|
317
322
|
- lib/appfuel/msg_request.rb
|
318
323
|
- lib/appfuel/predicates.rb
|
319
324
|
- lib/appfuel/presenter.rb
|