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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: beefc3a9ec7594370a31fe42de16d6b109d90279
4
- data.tar.gz: 8e4f95b742475e7a91239708ce8f3f81707e7b3a
3
+ metadata.gz: 272469cb6b6176387cccd84e5b0dbfddd5008b5e
4
+ data.tar.gz: 2dba20cdaafa5f307bf1ab53bada70134591b5d1
5
5
  SHA512:
6
- metadata.gz: fabfb619c581c0ddc07404061e7b336d80aa846c181ec362891cf823fe0b656dca7f5908e86125b726e43ac5e8d4af809190e83f331e8b787dd4204e56b44c47
7
- data.tar.gz: f56daa9f43805b1572a853655abb43ca367dd605423f1cfe4be250ce13b400e683533a46718d05425b833e8ec780a1613a77035366ecd188a92588489ed8cc43
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
@@ -9,7 +9,7 @@ require "appfuel/version"
9
9
  require "appfuel/types"
10
10
  require "appfuel/errors"
11
11
  require "appfuel/run_error"
12
-
12
+ require "appfuel/log_formatter"
13
13
  require "appfuel/configuration"
14
14
  require "appfuel/application"
15
15
  require "appfuel/initialize"
@@ -0,0 +1,3 @@
1
+ require_relative 'logger'
2
+ require_relative 'db'
3
+ require_relative 'web_api'
@@ -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
@@ -0,0 +1,4 @@
1
+ Appfuel::Initialize.define('global.http_adapter') do |config, container|
2
+ require 'rest-client'
3
+ container.register('web_api.http_adapter', RestClient)
4
+ end
@@ -0,0 +1,9 @@
1
+ require 'time'
2
+
3
+ module Appfuel
4
+ class LogFormatter < Logger::Formatter
5
+ def self.call(severity, time, progname, msg)
6
+ "#{progname} #{time.utc.iso8601} p-#{Process.pid} #{severity}: #{msg}\n"
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Appfuel
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.4
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