opi 0.3.11 → 0.3.13

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: 574af283fb9fd743e2dee26fbc63e4a75bb4819c
4
- data.tar.gz: d188146b704c8252f20d036828a6ddb2342790a0
3
+ metadata.gz: 09b8df30901e0e79a902246bc575f64e1c864659
4
+ data.tar.gz: a84fb9fbe8d3230683b9229ef57e45a7752565f2
5
5
  SHA512:
6
- metadata.gz: c884ccc671827468d88ba6a6192bce7b10447d674ac9f581944c1530e208a7fb28785a5dc0bf8e7ce0c1573339bcf0d3d5f747b5014e6fee6287058c467742ba
7
- data.tar.gz: 7dff41c84726bfbf38fca7d538ea34cd2ccdf1db693004f8f41b6ff4b29636b23df91a2c1601c1d51cd9bc4319d8b661671c6a8b9bb66c7bb9538e02bd9f602f
6
+ metadata.gz: 87ee5a7dd3d2b495ac2ed08dba3055d14291a760e212f85c4c0d5813018c51eec7dc8ababc34cb08805312a3b76dedb0627a087f3d94914f45e383066af7582d
7
+ data.tar.gz: 397f07bd4faf2c386f6f63d442b8ee68dd013a07db3f468da778d44d19185b338db8cf2e5d1594c2beae35d02304db18e5676e058fd431b5235f02b2e6531f06
@@ -11,7 +11,7 @@ module Opi
11
11
  route 'POST', path, options, block
12
12
  end
13
13
 
14
- def put(path, &block)
14
+ def put(path, options={}, &block)
15
15
  route 'PUT', path, options, block
16
16
  end
17
17
 
@@ -79,7 +79,7 @@ module Opi
79
79
 
80
80
  if route
81
81
  logger.debug "#{request.method} #{request.path} => route #{route.inspect}".green
82
- context = Context.new(env, route, request, response, self.class.before_filters, self.class.after_filters)
82
+ context = Context.new(env, logger, route, request, response, self.class.before_filters, self.class.after_filters)
83
83
  response = context.run
84
84
  else
85
85
  logger.debug "#{request.method} #{request.path} => route not found".red
@@ -87,6 +87,7 @@ module Opi
87
87
  end
88
88
 
89
89
  rescue Exception => e
90
+ logger.error "#{e.message.red}\n #{e.backtrace[0..9].join("\n ").yellow}"
90
91
  response.internal_server_error!(e)
91
92
  end
92
93
 
@@ -1,10 +1,11 @@
1
1
  module Opi
2
2
  class Context
3
3
 
4
- attr_reader :env, :route, :request, :response, :before, :after, :error
4
+ attr_reader :env, :logger, :route, :request, :response, :before, :after, :error
5
5
 
6
- def initialize(env, route, request, response, before, after)
6
+ def initialize(env, logger, route, request, response, before, after)
7
7
  @env = env
8
+ @logger = logger
8
9
  @route = route
9
10
  @request = request
10
11
  @response = response
@@ -50,6 +51,7 @@ module Opi
50
51
  else
51
52
  response.status = 400
52
53
  response.body = [action.errors.symbolic.to_json, "\n"]
54
+ logger.error "Reponse: #{action.errors.symbolic.to_json}".red
53
55
  end
54
56
  else
55
57
  response.status = 200
@@ -65,4 +67,4 @@ module Opi
65
67
  end
66
68
 
67
69
  end
68
- end
70
+ end
@@ -30,9 +30,7 @@ module Opi
30
30
  end
31
31
 
32
32
  def reload!
33
- Dir["#{@prefix}lib/*.rb"].each { |x| funkyload x }
34
33
  Dir["#{@prefix}app/**/*.rb"].each { |x| funkyload x }
35
- Dir["#{@prefix}*.rb"].each { |x| funkyload x unless x == 'Rakefile.rb' }
36
34
  end
37
35
 
38
36
  end
@@ -1,3 +1,3 @@
1
1
  module Opi
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Taylor