dandy 0.7.4 → 0.8.0

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: 957ee61c0f0fc8a9891b30d458af1c6f0c4e08b9
4
- data.tar.gz: 7fa0d88828eec48189ee75e54191663853a69e37
3
+ metadata.gz: 638225663a3c7bb092445c17472c8ea044a83a56
4
+ data.tar.gz: 447b928898b071c070a4ecdc08c6a940b65cdef2
5
5
  SHA512:
6
- metadata.gz: d604e83febbd93b0e10ba5dfd100c83d1675ca9a0f1ffa03affb9f0d4074a0c634b622d3a1febb524c73f700626ef57751c2408a8c39bae0012aef6125e50f69
7
- data.tar.gz: 7b7691cc316bc47363c272f7be1a29de5bdac66f73403789c92d3e0b9eaa2b228287177d07f91a961187ea4ac9bedbd78c2afb8c082bbffba95dde4f09d9abe1
6
+ metadata.gz: d117ca4ae73aeb227f93c53fbb77239d0b41f662891fb0ad7d0f9c3ebee77149b0244bfab012700d2a7127423e64cfa258fadf6ecbcce3817f006b074b8c4e06
7
+ data.tar.gz: c962ed1ef887d8ef5f481ade14964e106ae7b22705839f68e0a6a14982cb80009cfe9e72c951096c6372746b11a1f045abf7bcaf6eb90c792b4b6b8600ea0a61
data/lib/dandy/config.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require 'yaml'
2
+ require 'erb'
2
3
  require 'dandy/extensions/hash'
3
4
 
4
5
  module Dandy
5
6
  class Config
6
7
  def initialize(config_file_path)
7
8
  path = File.join(Dir.pwd, config_file_path)
8
- @params = YAML.load_file(path).deep_symbolize_keys!
9
+ yaml = ERB.new(File.read(path)).result
10
+ @params = YAML.load(yaml).deep_symbolize_keys!
9
11
  end
10
12
 
11
13
  def [](key)
@@ -1,2 +1,5 @@
1
1
  class HandleErrors < Dandy::HandleErrors
2
+ def call
3
+ puts @dandy_error
4
+ end
2
5
  end
@@ -1,4 +1,4 @@
1
1
  :receive
2
2
  .->
3
3
  GET -> message@welcome -> :respond <- show_welcome
4
- :catch -> handle_errors
4
+ :catch -> common/handle_errors
@@ -16,7 +16,7 @@ use Rack::Cors do
16
16
  # end
17
17
  end
18
18
 
19
- if ENV['DANDY_ENV'] == 'development' || ENV['DANDY_ENV'] == ''
19
+ if ENV['DANDY_ENV'] == 'development' || ENV['DANDY_ENV'].nil?
20
20
  use Rack::Reloader
21
21
  end
22
22
 
data/lib/dandy/request.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  require 'dandy/chain_factory'
2
3
  require 'dandy/view_factory'
3
4
 
@@ -30,9 +31,13 @@ module Dandy
30
31
  register_params(data, :dandy_data)
31
32
 
32
33
  chain = @chain_factory.create(match)
33
- result = chain.execute
34
+ chain_result = chain.execute
34
35
 
35
- body = match.route.view ? @view_factory.create(match.route.view, content_type) : result
36
+ if match.route.view
37
+ body = @view_factory.create(match.route.view, content_type)
38
+ else
39
+ body = chain_result.is_a?(String) ? chain_result : JSON.generate(chain_result)
40
+ end
36
41
 
37
42
  status = @container.resolve(:dandy_status)
38
43
  result = [status, { 'Content-Type' => content_type }, [body]]
@@ -28,7 +28,7 @@ grammar Syntax
28
28
  end
29
29
 
30
30
  rule path
31
- ('.' / ('/' [a-z0-9_\-]+)) 1..1 <Path>
31
+ ('.' / (('/' [a-z0-9_\-]+)+)) 1..1 <Path>
32
32
  end
33
33
 
34
34
  rule http_verb
data/lib/dandy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dandy
2
- VERSION = '0.7.4'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Kalinkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-18 00:00:00.000000000 Z
11
+ date: 2018-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hypo