opi 0.2 → 0.3

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: c83ed04de99dfd5352546b0548455cd791b4434c
4
- data.tar.gz: 436349cc1d191ae3d38447f991fdac2f64ef26c2
3
+ metadata.gz: d14b10a860811f91e4d861947341d296ab2420a6
4
+ data.tar.gz: 086b83d0e8918ae26cde595aaa34e34e220d9d36
5
5
  SHA512:
6
- metadata.gz: 9d446295c4c31a858d8d0a1795c4fc87e864fb47bad18b143349f3a20b7138165fda6669ed1d04f3ea512ba730464eeb81152bc8722dda339b2e006c812a59d2
7
- data.tar.gz: 25f21eae30b44928e3af096159e39bda11f7d0ee2d098d1873e4337a8b6ef56f2df2dc191876ac84fcf008569fad7f55b84bec0c10be42b0cac43afc7875fd88
6
+ metadata.gz: 7328546ad02aaa19bedeb5f220b39b18bc0910f7da8068318c0eb7e895506e9ac9c7b6e0573ca49be9ef36bf48718521bc14bccdba3964ad5bdd9ba17d5bc438
7
+ data.tar.gz: 14747631c52650d4710daccbdece06c9d12c9607598c270038e1233a961c50705ceaa99ef500a9b4e8398805e2004e05f07cdb93e94ffa4155469edf82460ca4
data/README.md CHANGED
@@ -21,10 +21,6 @@ of the controller but you are strongly encouraged to only ever execute actions
21
21
  in these blocks (the server is looking out for those actions as responses).
22
22
  The only role of the 'controller' here is to map HTTP inputs to Action inputs.
23
23
 
24
- **Action-based**. All logic is an action. Actions validate their own inputs
25
- and have no access to anything HTTP-related. These are domain-specific actions
26
- that can be pulled out and used anywhere.
27
-
28
24
  **No Sessions or Cookies**. None.
29
25
 
30
26
  But this has its advantages. It is *fast* and *simple*.
data/lib/opi.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  require 'rack'
2
2
  require 'colored'
3
3
  require 'json'
4
- require 'mutations'
5
4
 
6
5
  require_relative './opi/version'
7
6
  require_relative './opi/router'
8
7
  require_relative './opi/api'
9
8
  require_relative './opi/request'
10
9
  require_relative './opi/response'
11
- require_relative './opi/action'
12
10
  require_relative './opi/context'
13
11
  require_relative './opi/loader'
14
12
 
@@ -64,14 +64,14 @@ module Opi
64
64
  request.params.merge!(params) if params and params.is_a? Hash
65
65
  request.params.merge!('splat' => params.join(',')) if params and params.is_a? Array
66
66
 
67
- return [404, {'Content-Type' => 'application/json'}, ["{\"error\":\"404 Not Found\"}", "\n"]] unless route
67
+ return [404, {'Content-Type' => 'application/json; charset=utf-8'}, ["{\"error\":\"404 Not Found\"}", "\n"]] unless route
68
68
 
69
69
  context = Context.new(env, route, request, self.class.before_filters, self.class.after_filters)
70
70
  response = context.run
71
71
 
72
72
  [response.status, response.header, response.body]
73
73
  rescue Exception => e
74
- return [500, {'Content-Type' => 'application/json'}, ["{\"error\":\"500 Internal Server Error\", \"message\":\"#{e.message}\"}", "\n"]]
74
+ return [500, {'Content-Type' => 'application/json; charset=utf-8'}, ["{\"error\":\"500 Internal Server Error\", \"message\":\"#{e.message}\"}", "\n"]]
75
75
  end
76
76
  end
77
77
 
@@ -43,7 +43,7 @@ module Opi
43
43
  # before filters must have succeeded
44
44
  action = instance_eval &route[:block]
45
45
 
46
- if action.kind_of? Opi::Action or action.kind_of? Mutations::Outcome
46
+ if action.respond_to? :success?
47
47
  if action.success?
48
48
  response.status = 200
49
49
  response.body = [action.result.to_json, "\n"]
@@ -4,7 +4,7 @@ module Opi
4
4
  def initialize
5
5
  @status, @body = 200, ["{}","\n"]
6
6
  @header = Rack::Utils::HeaderHash.new({
7
- 'Content-Type' => 'application/json'
7
+ 'Content-Type' => 'application/json; charset=utf-8'
8
8
  # 'Server' => 'TBD/1.0'
9
9
  })
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Opi
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opi
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.8.1
55
- - !ruby/object:Gem::Dependency
56
- name: mutations
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.6.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 0.6.0
69
55
  description: The very opinionated API service library.
70
56
  email: moomerman@gmail.com
71
57
  executables: []
@@ -75,7 +61,6 @@ files:
75
61
  - LICENSE
76
62
  - README.md
77
63
  - lib/opi.rb
78
- - lib/opi/action.rb
79
64
  - lib/opi/api.rb
80
65
  - lib/opi/context.rb
81
66
  - lib/opi/loader.rb
@@ -1,4 +0,0 @@
1
- module Opi
2
- class Action < Mutations::Command
3
- end
4
- end