api_smith 1.0.0 → 1.1.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.
- data/lib/api_smith/client.rb +13 -1
- data/lib/api_smith/version.rb +1 -1
- data/lib/api_smith/web_mock_extensions.rb +4 -2
- metadata +5 -7
data/lib/api_smith/client.rb
CHANGED
@@ -110,7 +110,10 @@ module APISmith
|
|
110
110
|
request_options[type] = merged_options_for(type, options)
|
111
111
|
end
|
112
112
|
# Finally, use HTTParty to get the response
|
113
|
-
response =
|
113
|
+
response = nil
|
114
|
+
instrument_request method, full_path, options do
|
115
|
+
response = self.class.send method, full_path, request_options
|
116
|
+
end
|
114
117
|
# Pre-process the response to check for errors.
|
115
118
|
check_response_errors response
|
116
119
|
# Unpack the response using the :response_container option
|
@@ -121,6 +124,15 @@ module APISmith
|
|
121
124
|
|
122
125
|
private
|
123
126
|
|
127
|
+
# Provides a hook developers can utilitise to implement logging / instrumentation.
|
128
|
+
# @param [Symbol] method the HTTP method to use
|
129
|
+
# @param [String] full_path the full path being hit
|
130
|
+
# @param [Hash] options an options being passed to the request
|
131
|
+
# @param [#call] the block to invoke it with.
|
132
|
+
def instrument_request(method, full_path, options)
|
133
|
+
yield if block_given?
|
134
|
+
end
|
135
|
+
|
124
136
|
# Provides a hook to handle checking errors on API responses. This is called
|
125
137
|
# post-fetch and pre-unpacking / transformation. It is passed the apis response
|
126
138
|
# post-decoding (meaning JSON etc have been parsed into normal ruby objects).
|
data/lib/api_smith/version.rb
CHANGED
@@ -13,7 +13,9 @@ module APISmith
|
|
13
13
|
subject.is_a?(Class) ? subject : subject.class
|
14
14
|
end
|
15
15
|
|
16
|
-
# Returns an instance of the subject class, created via allocate (vs. new)
|
16
|
+
# Returns an instance of the subject class, created via allocate (vs. new). Useful
|
17
|
+
# for giving access to utility methods used inside of the class without having to\
|
18
|
+
# initialize a new client.
|
17
19
|
# @return [Object] the instance
|
18
20
|
def subject_class_instance
|
19
21
|
@subject_class_instance ||= subject_api_class.allocate
|
@@ -35,7 +37,7 @@ module APISmith
|
|
35
37
|
# @param [String] the relative path for the api
|
36
38
|
# @return [Object] the result from stub_request
|
37
39
|
def stub_api(type, path)
|
38
|
-
stub_request
|
40
|
+
stub_request type, api_url_for(path)
|
39
41
|
end
|
40
42
|
|
41
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Darcy Laycock
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
20
|
-
default_executable:
|
19
|
+
date: 2011-12-12 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: httparty
|
@@ -107,7 +106,6 @@ files:
|
|
107
106
|
- lib/api_smith/version.rb
|
108
107
|
- lib/api_smith/web_mock_extensions.rb
|
109
108
|
- lib/api_smith.rb
|
110
|
-
has_rdoc: true
|
111
109
|
homepage: http://github.com/thefrontiergroup
|
112
110
|
licenses: []
|
113
111
|
|
@@ -139,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
137
|
requirements: []
|
140
138
|
|
141
139
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.8.10
|
143
141
|
signing_key:
|
144
142
|
specification_version: 3
|
145
143
|
summary: A simple layer on top of HTTParty for building API's
|