activeresource 3.0.0.beta4 → 3.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeresource might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *Rails 3.0.0 [release candidate] (July 26th, 2010)*
2
+
3
+ * No material changes
4
+
5
+
1
6
  *Rails 3.0.0 [beta 4] (June 8th, 2010)*
2
7
 
3
8
  * JSON: set Base.include_root_in_json = true to include a root value in the JSON: {"post": {"title": ...}}. Mirrors the Active Record option. [Santiago Pastorino]
File without changes
@@ -7,7 +7,6 @@ require 'active_support/core_ext/module/attr_accessor_with_default'
7
7
  require 'active_support/core_ext/module/delegation'
8
8
  require 'active_support/core_ext/module/aliasing'
9
9
  require 'active_support/core_ext/object/blank'
10
- require 'active_support/core_ext/object/misc'
11
10
  require 'active_support/core_ext/object/to_query'
12
11
  require 'active_support/core_ext/object/duplicable'
13
12
  require 'set'
@@ -17,6 +16,7 @@ require 'active_resource/exceptions'
17
16
  require 'active_resource/connection'
18
17
  require 'active_resource/formats'
19
18
  require 'active_resource/schema'
19
+ require 'active_resource/log_subscriber'
20
20
 
21
21
  module ActiveResource
22
22
  # ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
@@ -212,7 +212,7 @@ module ActiveResource
212
212
  # # is requested with invalid values, the response is:
213
213
  # #
214
214
  # # Response (422):
215
- # # <errors type="array"><error>First cannot be empty</error></errors>
215
+ # # <errors><error>First cannot be empty</error></errors>
216
216
  # # or
217
217
  # # {"errors":["First cannot be empty"]}
218
218
  # #
@@ -577,7 +577,7 @@ module ActiveResource
577
577
  # Default value is <tt>site.path</tt>.
578
578
  def prefix=(value = '/')
579
579
  # Replace :placeholders with '#{embedded options[:lookups]}'
580
- prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" }
580
+ prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.escape options[#{key}].to_s}" }
581
581
 
582
582
  # Clear prefix parameters in case they have been cached
583
583
  @prefix_parameters = nil
@@ -622,7 +622,7 @@ module ActiveResource
622
622
  #
623
623
  def element_path(id, prefix_options = {}, query_options = nil)
624
624
  prefix_options, query_options = split_options(prefix_options) if query_options.nil?
625
- "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}"
625
+ "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
626
626
  end
627
627
 
628
628
  # Gets the new element path for REST resources.
@@ -763,7 +763,7 @@ module ActiveResource
763
763
  # With any other scope, find returns nil when no data is returned.
764
764
  #
765
765
  # Person.find(1)
766
- # # => raises ResourcenotFound
766
+ # # => raises ResourceNotFound
767
767
  #
768
768
  # Person.find(:all)
769
769
  # Person.find(:first)
@@ -941,7 +941,7 @@ module ActiveResource
941
941
  end
942
942
 
943
943
  # This is a list of known attributes for this resource. Either
944
- # gathered fromthe provided <tt>schema</tt>, or from the attributes
944
+ # gathered from the provided <tt>schema</tt>, or from the attributes
945
945
  # set on this instance after it has been fetched from the remote system.
946
946
  def known_attributes
947
947
  self.class.known_attributes + self.attributes.keys.map(&:to_s)
@@ -148,16 +148,28 @@ module ActiveResource
148
148
  attr_accessor :path, :method, :body, :headers
149
149
 
150
150
  def initialize(method, path, body = nil, headers = {})
151
- @method, @path, @body, @headers = method, path, body, headers.merge(ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method] => 'application/xml')
151
+ @method, @path, @body, @headers = method, path, body, headers
152
152
  end
153
153
 
154
154
  def ==(req)
155
- path == req.path && method == req.method && headers == req.headers
155
+ path == req.path && method == req.method && headers_match?(req)
156
156
  end
157
157
 
158
158
  def to_s
159
159
  "<#{method.to_s.upcase}: #{path} [#{headers}] (#{body})>"
160
160
  end
161
+
162
+ private
163
+
164
+ def headers_match?(req)
165
+ # Ignore format header on equality if it's not defined
166
+ format_header = ActiveResource::Connection::HTTP_FORMAT_HEADER_NAMES[method]
167
+ if headers[format_header].present? || req.headers[format_header].blank?
168
+ headers == req.headers
169
+ else
170
+ headers.dup.merge(format_header => req.headers[format_header]) == req.headers
171
+ end
172
+ end
161
173
  end
162
174
 
163
175
  class Response
@@ -0,0 +1,15 @@
1
+ module ActiveResource
2
+ class LogSubscriber < ActiveSupport::LogSubscriber
3
+ def request(event)
4
+ result = event.payload[:result]
5
+ info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}"
6
+ info "--> %d %s %d (%.1fms)" % [result.code, result.message, result.body.to_s.length, event.duration]
7
+ end
8
+
9
+ def logger
10
+ ActiveResource::Base.logger
11
+ end
12
+ end
13
+ end
14
+
15
+ ActiveResource::LogSubscriber.attach_to :active_resource
@@ -5,9 +5,6 @@ module ActiveResource
5
5
  class Railtie < Rails::Railtie
6
6
  config.active_resource = ActiveSupport::OrderedOptions.new
7
7
 
8
- require "active_resource/railties/log_subscriber"
9
- log_subscriber :active_resource, ActiveResource::Railties::LogSubscriber.new
10
-
11
8
  initializer "active_resource.set_configs" do |app|
12
9
  app.config.active_resource.each do |k,v|
13
10
  ActiveResource::Base.send "#{k}=", v
@@ -27,7 +27,7 @@ module ActiveResource
27
27
 
28
28
  # Grabs errors from a json response.
29
29
  def from_json(json, save_cache = false)
30
- array = ActiveSupport::JSON.decode(json)['errors'] rescue []
30
+ array = Array.wrap(ActiveSupport::JSON.decode(json)['errors']) rescue []
31
31
  from_array array, save_cache
32
32
  end
33
33
 
@@ -3,7 +3,7 @@ module ActiveResource
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "beta4"
6
+ BUILD = "rc"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7712042
4
5
  prerelease: true
5
6
  segments:
6
7
  - 3
7
8
  - 0
8
9
  - 0
9
- - beta4
10
- version: 3.0.0.beta4
10
+ - rc
11
+ version: 3.0.0.rc
11
12
  platform: ruby
12
13
  authors:
13
14
  - David Heinemeier Hansson
@@ -15,37 +16,41 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-06-08 00:00:00 -04:00
19
+ date: 2010-07-26 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: activesupport
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 7712042
28
31
  segments:
29
32
  - 3
30
33
  - 0
31
34
  - 0
32
- - beta4
33
- version: 3.0.0.beta4
35
+ - rc
36
+ version: 3.0.0.rc
34
37
  type: :runtime
35
38
  version_requirements: *id001
36
39
  - !ruby/object:Gem::Dependency
37
40
  name: activemodel
38
41
  prerelease: false
39
42
  requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
40
44
  requirements:
41
45
  - - "="
42
46
  - !ruby/object:Gem::Version
47
+ hash: 7712042
43
48
  segments:
44
49
  - 3
45
50
  - 0
46
51
  - 0
47
- - beta4
48
- version: 3.0.0.beta4
52
+ - rc
53
+ version: 3.0.0.rc
49
54
  type: :runtime
50
55
  version_requirements: *id002
51
56
  description: REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.
@@ -55,10 +60,10 @@ executables: []
55
60
  extensions: []
56
61
 
57
62
  extra_rdoc_files:
58
- - README
63
+ - README.rdoc
59
64
  files:
60
65
  - CHANGELOG
61
- - README
66
+ - README.rdoc
62
67
  - examples/simple.rb
63
68
  - lib/active_resource/base.rb
64
69
  - lib/active_resource/connection.rb
@@ -68,9 +73,9 @@ files:
68
73
  - lib/active_resource/formats/xml_format.rb
69
74
  - lib/active_resource/formats.rb
70
75
  - lib/active_resource/http_mock.rb
76
+ - lib/active_resource/log_subscriber.rb
71
77
  - lib/active_resource/observing.rb
72
78
  - lib/active_resource/railtie.rb
73
- - lib/active_resource/railties/log_subscriber.rb
74
79
  - lib/active_resource/schema.rb
75
80
  - lib/active_resource/validations.rb
76
81
  - lib/active_resource/version.rb
@@ -82,22 +87,26 @@ licenses: []
82
87
  post_install_message:
83
88
  rdoc_options:
84
89
  - --main
85
- - README
90
+ - README.rdoc
86
91
  require_paths:
87
92
  - lib
88
93
  required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
89
95
  requirements:
90
96
  - - ">="
91
97
  - !ruby/object:Gem::Version
98
+ hash: 57
92
99
  segments:
93
100
  - 1
94
101
  - 8
95
102
  - 7
96
103
  version: 1.8.7
97
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
98
106
  requirements:
99
107
  - - ">"
100
108
  - !ruby/object:Gem::Version
109
+ hash: 25
101
110
  segments:
102
111
  - 1
103
112
  - 3
@@ -106,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
115
  requirements: []
107
116
 
108
117
  rubyforge_project: activeresource
109
- rubygems_version: 1.3.6
118
+ rubygems_version: 1.3.7
110
119
  signing_key:
111
120
  specification_version: 3
112
121
  summary: REST modeling framework (part of Rails).
@@ -1,15 +0,0 @@
1
- module ActiveResource
2
- module Railties
3
- class LogSubscriber < Rails::LogSubscriber
4
- def request(event)
5
- result = event.payload[:result]
6
- info "#{event.payload[:method].to_s.upcase} #{event.payload[:request_uri]}"
7
- info "--> %d %s %d (%.1fms)" % [result.code, result.message, result.body.to_s.length, event.duration]
8
- end
9
-
10
- def logger
11
- ActiveResource::Base.logger
12
- end
13
- end
14
- end
15
- end