rest-core 2.0.1 → 2.0.2

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/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGES
2
2
 
3
+ ## rest-core 2.0.2 -- 2013-02-07
4
+
5
+ ### Bugs fixes
6
+
7
+ * [`Cache`] Fix cache with multiline response body. This might invalidate
8
+ your existing cache.
9
+
3
10
  ## rest-core 2.0.1 -- 2013-01-08
4
11
 
5
12
  ### Bugs fixes
@@ -92,14 +92,16 @@ class RestCore::Cache
92
92
 
93
93
  def data_construct res
94
94
  "#{ res[RESPONSE_STATUS]}\n" \
95
- "#{(res[RESPONSE_HEADERS]||{}).map{|k,v|"#{k}: #{v}"}.join("\n")}\n\n" \
95
+ "#{(res[RESPONSE_HEADERS]||{}).map{|k,v|"#{k}: #{v}\n"}.join}\n\n" \
96
96
  "#{ res[RESPONSE_BODY]}"
97
97
  end
98
98
 
99
99
  def data_extract data
100
- _, status, headers, body = data.match(/\A(\d+)\n(.*)\n\n(.*)\Z/m).to_a
100
+ _, status, headers, body =
101
+ data.match(/\A(\d+)\n([^\n]+\n)*\n\n(.*)\Z/m).to_a
102
+
101
103
  {RESPONSE_BODY => body,
102
- RESPONSE_HEADERS => Hash[(headers||'').scan(/([^:]+): ([^\n]+)\n?/)],
104
+ RESPONSE_HEADERS => Hash[(headers||'').scan(/([^:]+): ([^\n]+)\n/)],
103
105
  RESPONSE_STATUS => status.to_i}
104
106
  end
105
107
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module RestCore
3
- VERSION = '2.0.1'
3
+ VERSION = '2.0.2'
4
4
  end
@@ -2,13 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rest-core"
5
- s.version = "2.0.1"
5
+ s.version = "2.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [
9
9
  "Cardinal Blue",
10
10
  "Lin Jen-Shin (godfat)"]
11
- s.date = "2013-01-08"
11
+ s.date = "2013-02-07"
12
12
  s.description = "Modular Ruby clients interface for REST APIs\n\nThere has been an explosion in the number of REST APIs available today.\nTo address the need for a way to access these APIs easily and elegantly,\nwe have developed rest-core, which consists of composable middleware\nthat allows you to build a REST client for any REST API. Or in the case of\ncommon APIs such as Facebook, Github, and Twitter, you can simply use the\ndedicated clients provided by [rest-more][].\n\n[rest-more]: https://github.com/cardinalblue/rest-more"
13
13
  s.email = ["dev (XD) cardinalblue.com"]
14
14
  s.files = [
@@ -25,7 +25,7 @@ describe RC::Cache do
25
25
  end.new
26
26
  c.get('/')
27
27
  key = Digest::MD5.hexdigest('get:/:')
28
- c.cache.should.eq("rest-core:cache:#{key}" => "200\nA: B\n\nresponse")
28
+ c.cache.should.eq("rest-core:cache:#{key}" => "200\nA: B\n\n\nresponse")
29
29
  c.app.app.tick.should.eq 1
30
30
  c.get('/')
31
31
  c.app.app.tick.should.eq 1
@@ -107,6 +107,16 @@ describe RC::Cache do
107
107
  c.cache.values.first.should.eq "200\n\n\n#{body}"
108
108
  end
109
109
 
110
+ should 'multiline response' do
111
+ c = RC::Builder.client do
112
+ use RC::Cache, {}, 3600
113
+ end.new
114
+ stub_request(:get, 'html').to_return(:body => body = "a\n\nb")
115
+ c.get('html').should.eq body
116
+ c.cache.values.first.should.eq "200\n\n\n#{body}"
117
+ c.get('html') .should.eq body
118
+ end
119
+
110
120
  should "follow redirect with cache.update correctly" do
111
121
  c = RC::Builder.client do
112
122
  use RC::FollowRedirect, 10
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-08 00:00:00.000000000 Z
13
+ date: 2013-02-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client