saddle 0.0.14 → 0.0.15

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDE2NjI0YTFjNzExNzNhNTVjZGIxNDc0MjBmNjQ4ZWUzNzA1ODFkMA==
4
+ M2YwNjAwMDc5ODM3M2JlMDE0NGU5ZWRiYTlhN2FhZmNkYTNjNWE2Nw==
5
5
  data.tar.gz: !binary |-
6
- ZDkyZTUxZjgwNjMyNmFjYmEwMDc5ZWNkOTZiYTU3ZjZlYzI2NzVkZA==
6
+ MDIzODc3NjJmYmFhNTlmYmM3MTE4MjZjYzEzYTgxNmViZmNlNjQ4NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- N2Y2ZDFiMmNhZjNmNmM5NzYxNzIzZWQ1YThmMGUzMTdkNTM3ZDM5YzJkNWJm
10
- Y2Q5MGFkYzM0MGQ1NzdlNGY1ZmExMjFhN2JiZGNlZjRkMTIxZjQ0ZTUxMzNk
11
- YWIxNWMxNTQ1YWQ4NjdkM2EzNDVjNTFkYjk3NjRiMmMxYmU5NWU=
9
+ ZjIyN2IyMzJkZjg0NDcyNTY4YTM0NmRjYWVjNzM5MDc5YTRjNGJhZDM1NzAz
10
+ ZGM2NmY4NzRlNzZlOWMyODE3YWNjNjVkNTEzNGYwNzVjOGQ2MTcwNGM3ODMy
11
+ OTNiZTc1N2Q1ZThjZDE3NjYyNTM4NGZkOGJhZGQwNDM2YTcyYjI=
12
12
  data.tar.gz: !binary |-
13
- Yzc0MzU4M2E5ZmQzYTQ5NTNlNjFlYzdjODJiYzgwZWNkOGRmZjg0OTYzMTU3
14
- ZWZkZmUwZjMyMTBhZmI3OWY1YzdiNWQyYWY4NzkwNjk5Nzc3MzQ1ZDI2MTNm
15
- NDdhYmRmZWI1YWQ0OTE3OWY5NTk1Yzg5NjRkYWQ2ZGE0MmE2YjU=
13
+ M2MwYzg4NTBlODA5YjkwMTVjYjI4MmRiOTdhMDM2ZmI0NDJjNjgzZjA1ZmUw
14
+ YThmMThmOGRmNGUyMTVkNDZkMmU1ODYxYTAyZmE1NzExMzBkYWM0OTkxNjMy
15
+ N2Y1MzUyZmRjNDY0ZDFhMjczNjhhNWFkNTc0MzczNDliYjYwOGM=
@@ -13,7 +13,7 @@ module Saddle
13
13
  def initialize(requester, relative_path=nil, parent=nil)
14
14
  @requester = requester
15
15
  @relative_path = relative_path
16
- @parent = parent.is_a?(BaseEndpoint) ? parent : nil
16
+ @parent = parent
17
17
  end
18
18
 
19
19
 
@@ -40,6 +40,7 @@ module Saddle
40
40
  def request(method, action, params={}, options={})
41
41
  # Augment in interesting options
42
42
  options[:saddle] = {
43
+ :client_name => self.client_name,
43
44
  :call_chain => path_array,
44
45
  :action => action,
45
46
  }
@@ -62,13 +63,27 @@ module Saddle
62
63
  def endpoint_chain
63
64
  chain = []
64
65
  node = self
65
- until node.nil?
66
+ while node.is_a?(BaseEndpoint)
66
67
  chain << node
67
68
  node = node.parent
68
69
  end
69
70
  chain.reverse
70
71
  end
71
72
 
73
+ # Traverse back until we find the original client
74
+ def client
75
+ node = self
76
+ while node.is_a?(BaseEndpoint)
77
+ node = node.parent
78
+ end
79
+ node
80
+ end
81
+
82
+ # Underscore name of the client
83
+ def client_name
84
+ ActiveSupport::Inflector.underscore(self.client.name.split('::')[-2])
85
+ end
86
+
72
87
 
73
88
  # Create an endpoint instance and foist it upon this node
74
89
  def build_and_attach_node(endpoint_class, method_name)
@@ -81,11 +96,7 @@ module Saddle
81
96
  # This will create a resource endpoint, based upon the parameters
82
97
  # of this current node endpoint
83
98
  def create_resource_endpoint(endpoint_class, resource_id)
84
- endpoint_class.new(
85
- @requester,
86
- (path_array + [resource_id]).join('/')
87
- # no parent so that it can free up memory
88
- )
99
+ endpoint_class.new(@requester, resource_id, self)
89
100
  end
90
101
  end
91
102
 
@@ -36,15 +36,16 @@ module Saddle
36
36
  if File.file?(root_endpoint_file)
37
37
  # Load it and create our base endpoint
38
38
  load(root_endpoint_file)
39
- self.implementation_module::RootEndpoint.new(requester)
39
+ root_node_class = self.implementation_module::RootEndpoint
40
40
  else
41
41
  # 'root_endpoint.rb' doesn't exist, so create a dummy endpoint
42
- Saddle::BaseEndpoint.new(requester)
42
+ root_node_class = Saddle::BaseEndpoint
43
43
  end
44
44
  else
45
45
  # we don't even have an implementation root, so create a dummy endpoint
46
- Saddle::BaseEndpoint.new(requester)
46
+ root_node_class = Saddle::BaseEndpoint
47
47
  end
48
+ root_node_class.new(requester, nil, self)
48
49
  end
49
50
 
50
51
 
@@ -33,8 +33,13 @@ module Saddle
33
33
  statsd_path = nil
34
34
  if env[:request][:statsd_path]
35
35
  statsd_path = env[:request][:statsd_path]
36
- elsif env[:request][:saddle] && env[:request][:saddle][:call_chain] && env[:request][:saddle][:action]
37
- statsd_path = (['saddle'] + env[:request][:saddle][:call_chain] + [env[:request][:saddle][:action]]).join('.')
36
+ elsif env[:request][:saddle]
37
+ statsd_path = (
38
+ ['saddle'] +
39
+ env[:request][:saddle][:client_name] +
40
+ env[:request][:saddle][:call_chain] +
41
+ [env[:request][:saddle][:action]]
42
+ ).join('.')
38
43
  end
39
44
 
40
45
  # If we have a path, wrap the ensuing app call in STATSD timing
@@ -1,3 +1,3 @@
1
1
  module Saddle
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Lewis