saddle 0.0.38 → 0.0.41

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/.travis.yml CHANGED
@@ -4,4 +4,4 @@ rvm:
4
4
  - 1.9.3
5
5
  - jruby-19mode # JRuby in 1.9 mode
6
6
 
7
- script: rspec
7
+ script: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,2 +1,17 @@
1
+ # 0.0.41
2
+ * Cleanup of the path building chain makes nicer URLs
3
+
4
+ # 0.0.40
5
+ * Support for client-specified HTTP adapter. Preparing for Thrawn.
6
+
7
+ # 0.0.39
8
+ * DEPRECATION warning: root_endpoint.rb is no longer supported
9
+
10
+ # 0.0.38
11
+ * Support for `ABSOLUTE_PATH` on endpoints
12
+
13
+ # 0.0.37
14
+ * Lowered the default # of retries
15
+
1
16
  # 0.0.36
2
17
  * Parse JSON before throwing an error. The body may have useful failure info.
@@ -77,17 +77,23 @@ module Saddle
77
77
 
78
78
  # Get the url path for this endpoint/action combo
79
79
  def _path(action=nil)
80
- if defined?(self.class::ABSOLUTE_PATH)
81
- [self.class::ABSOLUTE_PATH, action].compact.join('/')
82
- else
83
- paths = _path_array()
84
- paths << action unless action.nil?
85
- paths.join('/')
86
- end
80
+ # Use the absolute path if present, otherwise get the relative path
81
+ pre_action_paths =
82
+ if defined?(self.class::ABSOLUTE_PATH)
83
+ [self.class::ABSOLUTE_PATH]
84
+ else
85
+ _path_array()
86
+ end
87
+ # Strip out empty elements
88
+ pre_action_paths.compact!
89
+ pre_action_paths.reject! { |p| p.empty? }
90
+ # Join it with the action
91
+ pre_action_paths << action
92
+ "/#{pre_action_paths.join('/')}"
87
93
  end
88
94
 
89
95
  def _path_array
90
- _endpoint_chain().map(&:relative_path).reject{|p| p.nil?}
96
+ _endpoint_chain().map(&:relative_path).compact
91
97
  end
92
98
 
93
99
  # Get the parent chain that led to this endpoint
@@ -37,6 +37,7 @@ module Saddle
37
37
  'root_endpoint.rb'
38
38
  )
39
39
  if File.file?(root_endpoint_file)
40
+ warn "[DEPRECATION] `root_endpoint.rb` is deprecated. Please use `ABSOLUTE_PATH` in your endpoints."
40
41
  # Load it and create our base endpoint
41
42
  require(root_endpoint_file)
42
43
  # RootEndpoint is the special class name for a root endpoint
@@ -14,8 +14,9 @@ module Saddle
14
14
  :request_style => request_style,
15
15
  :num_retries => num_retries,
16
16
  :timeout => timeout,
17
- :additional_middlewares => self.additional_middlewares,
17
+ :http_adapter => http_adapter,
18
18
  :stubs => stubs,
19
+ :additional_middlewares => self.additional_middlewares,
19
20
  }
20
21
  end
21
22
 
@@ -55,9 +56,13 @@ module Saddle
55
56
  30
56
57
  end
57
58
 
58
- # If you want to set up an ActiveSupport::Notification, give your client
59
- # an instrumentation key to monitor.
60
- def instrumentation_key
59
+ # Support specification of the HTTP adapter being used
60
+ def http_adapter
61
+ :net_http
62
+ end
63
+
64
+ # If the Typhoeus adapter is being used, pass stubs to it for testing.
65
+ def stubs
61
66
  nil
62
67
  end
63
68
 
@@ -76,10 +81,5 @@ module Saddle
76
81
  self.additional_middlewares << m
77
82
  end
78
83
 
79
- # If the Typhoeus adapter is being used, pass stubs to it for testing.
80
- def stubs
81
- nil
82
- end
83
-
84
84
  end
85
85
  end
@@ -58,6 +58,8 @@ module Saddle
58
58
  raise ':additional_middleware must be an Array' unless @additional_middlewares.is_a?(Array)
59
59
  raise 'invalid middleware found' unless @additional_middlewares.all? { |m| m[:klass] < Faraday::Middleware }
60
60
  raise 'middleware arguments must be an array' unless @additional_middlewares.all? { |m| m[:args].nil? || m[:args].is_a?(Array) }
61
+ @http_adapter = opt[:http_adapter] || :net_http
62
+ raise ':http_adapter must be a symbol' unless @http_adapter.is_a?(Symbol)
61
63
  @stubs = opt[:stubs] || nil
62
64
  unless @stubs.nil?
63
65
  raise ':stubs must be a Faraday::Adapter::Test::Stubs' unless @stubs.is_a?(Faraday::Adapter::Test::Stubs)
@@ -166,7 +168,7 @@ module Saddle
166
168
  # Set up our adapter
167
169
  if @stubs.nil?
168
170
  # Use the default adapter
169
- builder.adapter(:net_http)
171
+ builder.adapter(@http_adapter)
170
172
  else
171
173
  # Use the test adapter
172
174
  builder.adapter(:test, @stubs)
@@ -1,3 +1,3 @@
1
1
  module Saddle
2
- VERSION = '0.0.38'
2
+ VERSION = '0.0.41'
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.38
4
+ version: 0.0.41
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-31 00:00:00.000000000 Z
12
+ date: 2013-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport