restify 0.1.2.1.b40 → 0.1.2.1.b41

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGI1NWFhZGEzMzc5YjJlMmM5NDRjMGY5NzNhMjliZjcwZWI5MjBmZA==
4
+ OWUzY2Q1OGUzZDI1YTdhM2Q5YTExMTI1YmY2ZmFiMDkxNzAwZjU0YQ==
5
5
  data.tar.gz: !binary |-
6
- YTMxY2I3Mjg2ZjdhNjZiM2E2YWM1ZTgyMjFkODc3YzczZGRhNTg5Ng==
6
+ ZDcyMTAxMzdlMjFjOGNiOGYzMGRjYzQ5ZmQyOTc2MTllMDg2ZGY3Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2IzZGYwOGM5OWRiOTBlYWM0YjNlMDQxYzhkNzhiNGFhZTE2MDBmNDVhZDU2
10
- ZmIyY2FjNGY4NGJlN2FmZmU0YmU5MmE0YTM5NjA4ZjMzYzFhODNhZjU2YzVi
11
- YTA5MjE4ZGZkYTg1ODM4YWI3NjkwNTQ1ZDQzN2M5Y2E3ZmY4NWY=
9
+ ODI0MTdmYmMzYWVmZmI2MDAyY2ZhMTllZjllMGZkNGIxNzkyYWQ3ODllYTkw
10
+ ZWQ1MjZiMTg2NGJkYTFiZjJhZDQwODExNGFmOTZhMjFiMGJkOTM4ZjAzMWIy
11
+ MDNkMWM2MTk0YjAyYzdmMzc0YjFkZWI5MGU1YTdmNzU5ZTIyNmQ=
12
12
  data.tar.gz: !binary |-
13
- MjI4ZmUyNjk5NmVmY2MzMWU4MTE5ZDdhNTY3ZDY0YWI2YjBmMTAzYTQwNjA2
14
- YWE1YjkzYThjYjk5Nzk2MWI4ODA3MGMyNDgzY2RmMmU1Y2NkZmIzODVlMGY3
15
- MjVlMTgzZjQ3MjNlMzUwNTk2ZDFmMGY3NWZiNTMzMjAyOTY0NzE=
13
+ NTYxMGJkYWRjZjMzOWQ5NGQ0N2U5ZDdmZDRmNTExMWIwYWJjNTY0ZjA0ZGIw
14
+ ODdlMzRhZTI1MDFjZWYyYTE4YmU1MjMzOTViMmIyNzRmNDk3NWU3NjMzMGZi
15
+ ODVjMzJmZjIyODdlMGYzNmZmYWJkYWVhNGViMGM4MWMwODU1MWU=
@@ -33,14 +33,23 @@ module Restify
33
33
  (other.is_a?(String) && @source == other)
34
34
  end
35
35
 
36
- private
36
+ def expand(params)
37
+ @template.expand extracted params
38
+ end
37
39
 
38
- attr_reader :client, :template
40
+ private
39
41
 
40
42
  def request(method, data, params)
41
- uri = template.expand params
43
+ @context.request method, expand(params), data
44
+ end
42
45
 
43
- @context.request method, uri, data
46
+ def extracted(params)
47
+ @template.variables.each_with_object({}) do |var, hash|
48
+ if (value = params.delete(var) { params.delete(var.to_sym) { nil }})
49
+ value = value.to_param if value.respond_to?(:to_param)
50
+ hash[var] = value
51
+ end
52
+ end
44
53
  end
45
54
 
46
55
  def to_template(pattern)
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Restify::Relation do
4
4
  let(:context) { double 'context' }
5
5
  let(:source) { '/resource/{id}' }
6
- let(:pattern) { "http://test.host/#{source}" }
6
+ let(:pattern) { "http://test.host#{source}" }
7
7
  let(:relation) { described_class.new context, source, pattern }
8
8
  subject { relation }
9
9
 
@@ -16,4 +16,24 @@ describe Restify::Relation do
16
16
  expect(subject).to eq pattern
17
17
  end
18
18
  end
19
+
20
+ describe '#expand' do
21
+ let(:params) { {id: 1337} }
22
+
23
+ subject { relation.expand params }
24
+
25
+ it { is_expected.to be_a Addressable::URI }
26
+
27
+ context 'with #to_param object' do
28
+ class ParamObject
29
+ def to_param
30
+ 42
31
+ end
32
+ end
33
+
34
+ let(:params) { {id: ParamObject.new} }
35
+
36
+ it { expect(subject.to_s).to eq 'http://test.host/resource/42' }
37
+ end
38
+ end
19
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.1.b40
4
+ version: 0.1.2.1.b41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen