saddle 0.0.11 → 0.0.12
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 +8 -8
- data/README.md +7 -5
- data/lib/saddle.rb +1 -3
- data/lib/saddle/client_attributes.rb +6 -2
- data/lib/saddle/middleware/logging/statsd.rb +4 -2
- data/lib/saddle/version.rb +1 -1
- data/saddle.gemspec +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGJkMTFhMzc3ZGU3YWQwZWFlOGQ3ZjdiYmM2OTk3NzRkMjg4OTRiMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTQxMzRjZDdmODhmMGI1ZTA5NzAyYzFhYTVjMzg2MGViMzMwYTY1Yw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGJmMTZhZTAzOWFmMzg0ODE1Zjc5N2E0Yjk4N2M5N2U4NWNiYjc0MzA1MjJm
|
10
|
+
ZmRhODc3MGYxMjZhNDlmYmNjYTA4ZTQ3ZTVmOTU0MDA5NmQ0MjAxYmEzMzAx
|
11
|
+
YWIxN2NjODdlYmYzYzVlMjY3MmViY2UwM2JiOTcwMDlmMmE3M2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzZmOWM1M2RkM2IwNjRmNGM0OGM2NGQ3NmI5ZDAxMjBmY2U3OTEwNjE5YzEz
|
14
|
+
MDA2YzQ2YWQxODY4NmZhMTM1MzQ4NzY3MDQ0YTcwNjUwMDViNGRkOTkyZjQy
|
15
|
+
MzhlYWIwMzAyNWIwMTYxZjVmZTI0NWJkM2Y4MDUyODJjZjNmZGE=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# saddle
|
2
2
|
|
3
|
-
|
3
|
+
Giddyup nerd! Wrangle your SOA.
|
4
4
|
|
5
5
|
Saddle makes writing service clients as easy as giving high fives. :hand:
|
6
6
|
|
@@ -41,15 +41,17 @@ Saddle enables you to create beautifully stable and functionaly API clients, in
|
|
41
41
|
[saddle-example](https://github.com/mLewisLogic/saddle-example)
|
42
42
|
|
43
43
|
### client construction
|
44
|
-
0. For the sake of cleanliness, pick a namespace that everything related to your client should live in. For this example, we'll use
|
45
|
-
1. Inherit your client class
|
44
|
+
0. For the sake of cleanliness, pick a namespace that everything related to your client should live in. For this example, we'll use __SaddleExample__
|
45
|
+
1. Inherit your client class, __SaddleExample::Client__, from __Saddle::Client__
|
46
46
|
2. Create an _endpoints_ directory at the same level as your client class file
|
47
|
-
3. Create endpoint classes in the _endpoints_ directory that inherit from
|
47
|
+
3. Create endpoint classes in the _endpoints_ directory that inherit from __Saddle::TraversalEndpoint__ and are under the __SaddleExample::Endpoints__ namespace module
|
48
48
|
1. Give these endpoints methods that call _get_ or _post_ to perform the actual request
|
49
|
-
2. Their module/class namespace determines how they are accessed in the client's call tree. For example, the
|
49
|
+
2. Their module/class namespace determines how they are accessed in the client's call tree. For example, the get\_all() in __SaddleExample::Endpoints::Fish::Guppy__ would be accessed by:
|
50
50
|
|
51
51
|
client.fish.guppy.get_all()
|
52
52
|
|
53
|
+
3. If you need REST style endpoints like client.fish('guppy').catch() then check out __Saddle::ResourceEndpoint__ and how it's used in [saddle-example](https://github.com/mLewisLogic/saddle-example/blob/master/lib/endpoints/kitten.rb)
|
54
|
+
|
53
55
|
4. Initialize an instance of your client. ex:
|
54
56
|
|
55
57
|
saddle_example_client = SaddleExample::Client.create
|
data/lib/saddle.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
+
require 'saddle/client_attributes'
|
1
2
|
require 'saddle/method_tree_builder'
|
2
3
|
require 'saddle/options'
|
3
|
-
require 'saddle/client_attributes'
|
4
4
|
require 'saddle/requester'
|
5
|
-
require 'saddle/errors'
|
6
5
|
|
7
6
|
|
8
|
-
# Ghost ride the whip.
|
9
7
|
# Inherit your client implementation from Saddle::Client
|
10
8
|
# then call YourCrayClient.create to get a client instance.
|
11
9
|
|
@@ -3,8 +3,12 @@ module Saddle::ClientAttributes
|
|
3
3
|
def self.included(obj)
|
4
4
|
obj.extend ClassMethods
|
5
5
|
|
6
|
-
#
|
7
|
-
obj.additional_middlewares =
|
6
|
+
# Clone the parent's additional_middlewares
|
7
|
+
obj.additional_middlewares = if defined?(obj.superclass.additional_middlewares)
|
8
|
+
obj.superclass.additional_middlewares.clone
|
9
|
+
else
|
10
|
+
[]
|
11
|
+
end
|
8
12
|
|
9
13
|
# We know that this module is included when saddle client is inherited,
|
10
14
|
# so we're actually interested in the path of the caller two levels deep.
|
@@ -28,15 +28,17 @@ module Saddle::Middleware
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def call(env)
|
31
|
+
# Try to build up a path for the STATSD logging
|
31
32
|
statsd_path = nil
|
32
33
|
if env[:request][:statsd_path]
|
33
34
|
statsd_path = env[:request][:statsd_path]
|
34
35
|
elsif env[:request][:saddle] && env[:request][:saddle][:call_chain] && env[:request][:saddle][:action]
|
35
|
-
statsd_path = (env[:request][:saddle][:call_chain] + [env[:request][:saddle][:action]]).join('.')
|
36
|
+
statsd_path = (['saddle'] + env[:request][:saddle][:call_chain] + [env[:request][:saddle][:action]]).join('.')
|
36
37
|
end
|
37
38
|
|
39
|
+
# If we have a path, wrap the ensuing app call in STATSD timing
|
38
40
|
if statsd_path
|
39
|
-
self.statsd.time
|
41
|
+
self.statsd.time(statsd_path) do
|
40
42
|
@app.call(env)
|
41
43
|
end
|
42
44
|
else
|
data/lib/saddle/version.rb
CHANGED
data/saddle.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.name = 'saddle'
|
9
9
|
s.version = Saddle::VERSION
|
10
10
|
|
11
|
-
s.authors = ['Mike Lewis'
|
12
|
-
s.email = 'mike@
|
11
|
+
s.authors = ['Mike Lewis']
|
12
|
+
s.email = 'mike.lewis@airbnb.com'
|
13
13
|
s.description = %q{Makes writing API clients as easy as giving high fives}
|
14
14
|
s.summary = %q{
|
15
15
|
A full-featured, generic consumer layer for you to build API client implementations with.
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Lewis
|
8
|
-
- Naseem Hakim
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
@@ -54,7 +53,7 @@ dependencies:
|
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: 0.9.0
|
56
55
|
description: Makes writing API clients as easy as giving high fives
|
57
|
-
email: mike@
|
56
|
+
email: mike.lewis@airbnb.com
|
58
57
|
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|