psc 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ 0.1.0
2
+ =====
3
+
4
+ - Add middleware to set a reasonable default Accept header for PSC. (#5)
5
+
1
6
  0.0.2
2
7
  =====
3
8
 
@@ -37,6 +37,7 @@ module Psc
37
37
  super do |builder|
38
38
  builder.use *authentication_middleware(options[:authenticator])
39
39
  builder.use Psc::Faraday::StringIsXml
40
+ builder.use Psc::Faraday::AcceptPscTypes
40
41
  builder.request :json
41
42
  builder.request :url_encoded
42
43
  builder.use FaradayStack::ResponseXML, :content_type => 'text/xml'
@@ -5,7 +5,8 @@ require 'faraday'
5
5
  ##
6
6
  # The custom Faraday middleware used in `psc.rb`.
7
7
  module Psc::Faraday
8
- autoload :HttpBasic, 'psc/faraday/http_basic'
9
- autoload :PscToken, 'psc/faraday/psc_token'
10
- autoload :StringIsXml, 'psc/faraday/string_is_xml'
8
+ autoload :AcceptPscTypes, 'psc/faraday/accept_psc_types'
9
+ autoload :HttpBasic, 'psc/faraday/http_basic'
10
+ autoload :PscToken, 'psc/faraday/psc_token'
11
+ autoload :StringIsXml, 'psc/faraday/string_is_xml'
11
12
  end
@@ -0,0 +1,24 @@
1
+ require 'psc/faraday'
2
+
3
+ module Psc
4
+ module Faraday
5
+ ##
6
+ # Middleware which sets the Accept header to `application/json,text/xml` if
7
+ # it is not already set.
8
+ class AcceptPscTypes
9
+ DEFAULT_ACCEPT_HEADER = 'application/json,text/xml'
10
+
11
+ def initialize(app)
12
+ @app = app
13
+ end
14
+
15
+ ##
16
+ # Sets the Accept header if appropriate
17
+ def call(env)
18
+ env[:request_headers]['Accept'] ||= DEFAULT_ACCEPT_HEADER
19
+
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Psc
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -40,7 +40,7 @@ module Psc
40
40
  end
41
41
  end
42
42
 
43
- DEFAULT_MIDDLEWARE_COUNT = 6
43
+ DEFAULT_MIDDLEWARE_COUNT = 7
44
44
 
45
45
  describe 'the default middleware' do
46
46
  it 'has the authentication middleware first' do
@@ -51,20 +51,24 @@ module Psc
51
51
  conn.builder[1].should == Psc::Faraday::StringIsXml
52
52
  end
53
53
 
54
+ it 'has the accept header middleware next' do
55
+ conn.builder[2].should == Psc::Faraday::AcceptPscTypes
56
+ end
57
+
54
58
  it 'has the Faraday JSON request middleware next' do
55
- conn.builder[2].should == ::Faraday::Request::JSON
59
+ conn.builder[3].should == ::Faraday::Request::JSON
56
60
  end
57
61
 
58
62
  it 'has the Faraday URL-encoded request middleware next' do
59
- conn.builder[3].should == ::Faraday::Request::UrlEncoded
63
+ conn.builder[4].should == ::Faraday::Request::UrlEncoded
60
64
  end
61
65
 
62
66
  it 'has the FaradayStack XML parser middleware next' do
63
- conn.builder[4].should == ::FaradayStack::ResponseXML
67
+ conn.builder[5].should == ::FaradayStack::ResponseXML
64
68
  end
65
69
 
66
70
  it 'has the FaradayStack JSON parser middleware next' do
67
- conn.builder[5].should == ::FaradayStack::ResponseJSON
71
+ conn.builder[6].should == ::FaradayStack::ResponseJSON
68
72
  end
69
73
  end
70
74
 
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ module Psc::Faraday
4
+ describe AcceptPscTypes do
5
+ include_context 'middleware'
6
+ include_context 'unconditional middleware'
7
+
8
+ subject { AcceptPscTypes.new(app) }
9
+
10
+ it 'sets the accept header if not set' do
11
+ do_call
12
+
13
+ headers['Accept'].should == 'application/json,text/xml'
14
+ end
15
+
16
+ it 'leaves the accept header alone if set' do
17
+ headers['Accept'] = 'application/x-calendar'
18
+ do_call
19
+ headers['Accept'].should == 'application/x-calendar'
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-11 00:00:00.000000000Z
12
+ date: 2012-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
16
- requirement: &2156680720 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.7.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156680720
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: builder
27
- requirement: &2156680200 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.1.2
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2156680200
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.1.2
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: faraday-stack
38
- requirement: &2156679660 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.1.1
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *2156679660
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.1
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: nokogiri
49
- requirement: &2156679180 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '1.4'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *2156679180
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.4'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: activesupport
60
- requirement: &2156678720 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '2.3'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *2156678720
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '2.3'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rake
71
- requirement: &2156678260 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: 0.9.2
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *2156678260
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.2
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rspec
82
- requirement: &2156677800 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '2.6'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *2156677800
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.6'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: ci_reporter
93
- requirement: &2156677280 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ~>
@@ -98,21 +133,31 @@ dependencies:
98
133
  version: '1.6'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *2156677280
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.6'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: cucumber
104
- requirement: &2156676820 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
- - - =
147
+ - - '='
108
148
  - !ruby/object:Gem::Version
109
149
  version: 0.10.7
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *2156676820
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: 0.10.7
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: childprocess
115
- requirement: &2156676360 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
163
  - - ~>
@@ -120,10 +165,15 @@ dependencies:
120
165
  version: '0.1'
121
166
  type: :development
122
167
  prerelease: false
123
- version_requirements: *2156676360
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '0.1'
124
174
  - !ruby/object:Gem::Dependency
125
175
  name: highline
126
- requirement: &2156675980 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
127
177
  none: false
128
178
  requirements:
129
179
  - - ! '>='
@@ -131,10 +181,15 @@ dependencies:
131
181
  version: '0'
132
182
  type: :development
133
183
  prerelease: false
134
- version_requirements: *2156675980
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
135
190
  - !ruby/object:Gem::Dependency
136
191
  name: webmock
137
- requirement: &2156620280 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
138
193
  none: false
139
194
  requirements:
140
195
  - - ~>
@@ -142,10 +197,15 @@ dependencies:
142
197
  version: '1.6'
143
198
  type: :development
144
199
  prerelease: false
145
- version_requirements: *2156620280
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '1.6'
146
206
  - !ruby/object:Gem::Dependency
147
207
  name: yard
148
- requirement: &2156619460 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
149
209
  none: false
150
210
  requirements:
151
211
  - - ~>
@@ -153,7 +213,12 @@ dependencies:
153
213
  version: 0.7.1
154
214
  type: :development
155
215
  prerelease: false
156
- version_requirements: *2156619460
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: 0.7.1
157
222
  description: A lightweight ruby client for Patient Study Calendar's RESTful HTTP API
158
223
  email:
159
224
  - r-sutphin@northwestern.edu
@@ -191,6 +256,7 @@ files:
191
256
  - lib/psc/client.rb
192
257
  - lib/psc/connection.rb
193
258
  - lib/psc/faraday.rb
259
+ - lib/psc/faraday/accept_psc_types.rb
194
260
  - lib/psc/faraday/http_basic.rb
195
261
  - lib/psc/faraday/psc_token.rb
196
262
  - lib/psc/faraday/string_is_xml.rb
@@ -200,6 +266,7 @@ files:
200
266
  - spec/middleware_helper.rb
201
267
  - spec/psc/client_spec.rb
202
268
  - spec/psc/connection_spec.rb
269
+ - spec/psc/faraday/accept_psc_types_spec.rb
203
270
  - spec/psc/faraday/http_basic_spec.rb
204
271
  - spec/psc/faraday/psc_token_spec.rb
205
272
  - spec/psc/faraday/string_is_xml_spec.rb
@@ -229,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
296
  version: '0'
230
297
  requirements: []
231
298
  rubyforge_project:
232
- rubygems_version: 1.8.10
299
+ rubygems_version: 1.8.24
233
300
  signing_key:
234
301
  specification_version: 3
235
302
  summary: A lightweight ruby client for Patient Study Calendar's RESTful HTTP API
@@ -243,9 +310,11 @@ test_files:
243
310
  - spec/middleware_helper.rb
244
311
  - spec/psc/client_spec.rb
245
312
  - spec/psc/connection_spec.rb
313
+ - spec/psc/faraday/accept_psc_types_spec.rb
246
314
  - spec/psc/faraday/http_basic_spec.rb
247
315
  - spec/psc/faraday/psc_token_spec.rb
248
316
  - spec/psc/faraday/string_is_xml_spec.rb
249
317
  - spec/psc/version_spec.rb
250
318
  - spec/psc_spec.rb
251
319
  - spec/spec_helper.rb
320
+ has_rdoc: