chaplin 0.0.1 → 0.0.2
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/lib/chaplin/api_endpoint.rb +12 -11
- data/lib/chaplin/server.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b88b42dd226a2e3d9553ddb47250d83ac43e07d
|
4
|
+
data.tar.gz: 02828e7fec8444d4de837ed409e08bfdd317c296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c40e4fa22f823b9a3403690ef7ec8b81dfc68271219422c7be3bf089d65f3bd5699122cd8cab01aad5b40c1efe4bf19b11cdc018aeb5937de20ec850a4678e8
|
7
|
+
data.tar.gz: d87c879b813e303e658398add11fce95ea7de0606074ea88b41f94317d5c38f053b9e0f1444b69510c264283dfcd5234036dafefdfd788fcb232ad26c55a549a
|
data/lib/chaplin/api_endpoint.rb
CHANGED
@@ -23,27 +23,28 @@ class Chaplin
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def render(chaplin_request_params)
|
26
|
-
|
26
|
+
full_params = chaplin_request_params.merge(env: ENV)
|
27
|
+
response_body = api_response(full_params).body
|
27
28
|
return nil if (response_body == 'null' or response_body == '')
|
28
29
|
JSON.parse(response_body)
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
32
33
|
|
33
|
-
def api_response(
|
34
|
+
def api_response(full_params)
|
34
35
|
@@client.send(
|
35
36
|
http_method,
|
36
|
-
parsed_path(
|
37
|
-
api_request_params(
|
37
|
+
parsed_path(full_params),
|
38
|
+
api_request_params(full_params),
|
38
39
|
@@default_headers
|
39
40
|
)
|
40
41
|
end
|
41
42
|
|
42
|
-
def api_request_params(
|
43
|
+
def api_request_params(full_params)
|
43
44
|
if json_request? && [:post, :put, :patch].include?(http_method)
|
44
|
-
Mustache.render(params.to_json,
|
45
|
+
Mustache.render(params.to_json, full_params)
|
45
46
|
else
|
46
|
-
rendered_params(
|
47
|
+
rendered_params(full_params)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -55,14 +56,14 @@ class Chaplin
|
|
55
56
|
@@default_headers.merge(headers)
|
56
57
|
end
|
57
58
|
|
58
|
-
def rendered_params(
|
59
|
+
def rendered_params(full_params)
|
59
60
|
params.each_with_object({}) do |(key, value), rendered_params|
|
60
|
-
rendered_params[key] = Mustache.render(value,
|
61
|
+
rendered_params[key] = Mustache.render(value, full_params)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
|
-
def parsed_path(
|
65
|
-
Mustache.render(path,
|
65
|
+
def parsed_path(full_params)
|
66
|
+
Mustache.render(path, full_params)
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
data/lib/chaplin/server.rb
CHANGED
@@ -7,6 +7,11 @@ class Chaplin
|
|
7
7
|
|
8
8
|
def self.setup(project_path)
|
9
9
|
set :public_folder, project_path + '/public'
|
10
|
+
set :show_exceptions, false
|
11
|
+
|
12
|
+
error do
|
13
|
+
env['sinatra.error'].message + "\n" + env['sinatra.error'].backtrace.join("\n")
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def self.add_route(endpoint, response)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chaplin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Mours
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -267,3 +267,4 @@ signing_key:
|
|
267
267
|
specification_version: 4
|
268
268
|
summary: Build HTML apps from JSON APIs in no time
|
269
269
|
test_files: []
|
270
|
+
has_rdoc:
|