opi 0.2 → 0.3
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 +4 -4
- data/README.md +0 -4
- data/lib/opi.rb +0 -2
- data/lib/opi/api.rb +2 -2
- data/lib/opi/context.rb +1 -1
- data/lib/opi/response.rb +1 -1
- data/lib/opi/version.rb +1 -1
- metadata +2 -17
- data/lib/opi/action.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14b10a860811f91e4d861947341d296ab2420a6
|
4
|
+
data.tar.gz: 086b83d0e8918ae26cde595aaa34e34e220d9d36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/opi/api.rb
CHANGED
@@ -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
|
|
data/lib/opi/context.rb
CHANGED
@@ -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.
|
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"]
|
data/lib/opi/response.rb
CHANGED
data/lib/opi/version.rb
CHANGED
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.
|
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-
|
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
|
data/lib/opi/action.rb
DELETED