rufus-jig 0.1.6 → 0.1.7

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/CHANGELOG.txt CHANGED
@@ -2,6 +2,12 @@
2
2
  = rufus-jig CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-jig - 0.1.7 not yet released
6
+
7
+ - implemented :force_json => true for services returning JSON in plain/text
8
+ - :accept => :json as a shorcut for :accept -> 'application/json'
9
+
10
+
5
11
  == rufus-jig - 0.1.6 released 2009/12/21
6
12
 
7
13
  - implemented close for Http and Couch classes
data/TODO.txt CHANGED
@@ -21,3 +21,5 @@
21
21
 
22
22
  [ ] patron : http can steal each other's patron session (inside the same thread)
23
23
 
24
+ [ ] why not a :force_json ?
25
+
@@ -192,6 +192,7 @@ module Rufus::Jig
192
192
  def rehash_options (opts)
193
193
 
194
194
  opts['Accept'] ||= (opts.delete(:accept) || 'application/json')
195
+ opts['Accept'] = 'application/json' if opts['Accept'] == :json
195
196
 
196
197
  if ct = opts.delete(:content_type)
197
198
  opts['Content-Type'] = ct
@@ -267,7 +268,7 @@ module Rufus::Jig
267
268
  b = response.body
268
269
  ct = response.headers['Content-Type']
269
270
 
270
- if ct && ct.match(/^application\/json/)
271
+ if opts[:force_json] || (ct && ct.match(/^application\/json/))
271
272
  Rufus::Jig::Json.decode(b)
272
273
  else
273
274
  b
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Rufus
3
3
  module Jig
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
6
6
  end
7
7
 
data/rufus-jig.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rufus-jig}
8
- s.version = "0.1.6"
8
+ s.version = "0.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Mettraux", "Kenneth Kalmer"]
12
- s.date = %q{2009-12-21}
12
+ s.date = %q{2009-12-24}
13
13
  s.description = %q{
14
14
  Json Internet Get.
15
15
 
data/test/server.rb CHANGED
@@ -36,6 +36,13 @@ get '/document_accept' do
36
36
  '{"car":"Saab"}'
37
37
  end
38
38
 
39
+ get '/document_json_plain' do
40
+
41
+ content_type 'text/plain'
42
+
43
+ '{"car":"Peugeot"}'
44
+ end
45
+
39
46
  get '/document_utf8' do
40
47
 
41
48
  content_type 'application/json', :charset => 'utf-8'
@@ -84,6 +84,21 @@ class UtHttpGetTest < Test::Unit::TestCase
84
84
  assert_equal 'Saab', r['car']
85
85
 
86
86
  assert_equal 0, @h.cache.size
87
+
88
+ r = @h.get('/document_accept', :accept => :json)
89
+
90
+ assert_equal Hash, r.class
91
+ end
92
+
93
+ def test_get_force_json
94
+
95
+ r = @h.get('/document_json_plain', :accept => :json)
96
+
97
+ assert_equal('{"car":"Peugeot"}', r)
98
+
99
+ r = @h.get('/document_json_plain', :force_json => true)
100
+
101
+ assert_equal({ 'car' => 'Peugeot' }, r)
87
102
  end
88
103
 
89
104
  def test_conditional_get
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-jig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-21 00:00:00 +09:00
13
+ date: 2009-12-24 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency