activeresource_csi 2.3.5.p6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,292 @@
1
+ *2.3.5 (November 25, 2009)*
2
+
3
+ * Minor Bug Fixes and deprecation warnings
4
+
5
+ * More flexible content type handling when parsing responses.
6
+
7
+ Ensures that ARes will handle responses like test/xml, or content types
8
+ with charsets included.
9
+
10
+ *2.3.4 (September 4, 2009)*
11
+
12
+ * Add support for errors in JSON format. #1956 [Fabien Jakimowicz]
13
+
14
+ * Recognizes 410 as Resource Gone. #2316 [Jordan Brough, Jatinder Singh]
15
+
16
+ * More thorough SSL support. #2370 [Roy Nicholson]
17
+
18
+ * HTTP proxy support. #2133 [Marshall Huss, Sébastien Dabet]
19
+
20
+
21
+ *2.3.3 (July 12, 2009)*
22
+
23
+ * No changes, just a version bump.
24
+
25
+
26
+ *2.3.2 [Final] (March 15, 2009)*
27
+
28
+ * Nothing new, just included in 2.3.2
29
+
30
+
31
+ *2.2.1 [RC2] (November 14th, 2008)*
32
+
33
+ * Fixed that ActiveResource#post would post an empty string when it shouldn't be posting anything #525 [Paolo Angelini]
34
+
35
+
36
+ *2.2.0 [RC1] (October 24th, 2008)*
37
+
38
+ * Add ActiveResource::Base#to_xml and ActiveResource::Base#to_json. #1011 [Rasik Pandey, Cody Fauser]
39
+
40
+ * Add ActiveResource::Base.find(:last). [#754 state:resolved] (Adrian Mugnolo)
41
+
42
+ * Fixed problems with the logger used if the logging string included %'s [#840 state:resolved] (Jamis Buck)
43
+
44
+ * Fixed Base#exists? to check status code as integer [#299 state:resolved] (Wes Oldenbeuving)
45
+
46
+
47
+ *2.1.0 (May 31st, 2008)*
48
+
49
+ * Fixed response logging to use length instead of the entire thing (seangeo) [#27]
50
+
51
+ * Fixed that to_param should be used and honored instead of hardcoding the id #11406 [gspiers]
52
+
53
+ * Improve documentation. [Ryan Bigg, Jan De Poorter, Cheah Chu Yeow, Xavier Shay, Jack Danger Canty, Emilio Tagua, Xavier Noria, Sunny Ripert]
54
+
55
+ * Use HEAD instead of GET in exists? [bscofield]
56
+
57
+ * Fix small documentation typo. Closes #10670 [Luca Guidi]
58
+
59
+ * find_or_create_resource_for handles module nesting. #10646 [xavier]
60
+
61
+ * Allow setting ActiveResource::Base#format before #site. [Rick Olson]
62
+
63
+ * Support agnostic formats when calling custom methods. Closes #10635 [joerichsen]
64
+
65
+ * Document custom methods. #10589 [Cheah Chu Yeow]
66
+
67
+ * Ruby 1.9 compatibility. [Jeremy Kemper]
68
+
69
+
70
+ *2.0.2* (December 16th, 2007)
71
+
72
+ * Added more specific exceptions for 400, 401, and 403 (all descending from ClientError so existing rescues will work) #10326 [trek]
73
+
74
+ * Correct empty response handling. #10445 [seangeo]
75
+
76
+
77
+ *2.0.1* (December 7th, 2007)
78
+
79
+ * Don't cache net/http object so that ActiveResource is more thread-safe. Closes #10142 [kou]
80
+
81
+ * Update XML documentation examples to include explicit type attributes. Closes #9754 [Josh Susser]
82
+
83
+ * Added one-off declarations of mock behavior [David Heinemeier Hansson]. Example:
84
+
85
+ Before:
86
+ ActiveResource::HttpMock.respond_to do |mock|
87
+ mock.get "/people/1.xml", {}, "<person><name>David</name></person>"
88
+ end
89
+
90
+ Now:
91
+ ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>"
92
+
93
+ * Added ActiveResource.format= which defaults to :xml but can also be set to :json [David Heinemeier Hansson]. Example:
94
+
95
+ class Person < ActiveResource::Base
96
+ self.site = "http://app/"
97
+ self.format = :json
98
+ end
99
+
100
+ person = Person.find(1) # => GET http://app/people/1.json
101
+ person.name = "David"
102
+ person.save # => PUT http://app/people/1.json {name: "David"}
103
+
104
+ Person.format = :xml
105
+ person.name = "Mary"
106
+ person.save # => PUT http://app/people/1.json <person><name>Mary</name></person>
107
+
108
+ * Fix reload error when path prefix is used. #8727 [Ian Warshak]
109
+
110
+ * Remove ActiveResource::Struct because it hasn't proven very useful. Creating a new ActiveResource::Base subclass is often less code and always clearer. #8612 [Josh Peek]
111
+
112
+ * Fix query methods on resources. [Cody Fauser]
113
+
114
+ * pass the prefix_options to the instantiated record when using find without a specific id. Closes #8544 [Eloy Duran]
115
+
116
+ * Recognize and raise an exception on 405 Method Not Allowed responses. #7692 [Josh Peek]
117
+
118
+ * Handle string and symbol param keys when splitting params into prefix params and query params.
119
+
120
+ Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 })
121
+
122
+ * Added find-one with symbol [David Heinemeier Hansson]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml
123
+
124
+ * BACKWARDS INCOMPATIBLE: Changed the finder API to be more extensible with :params and more strict usage of scopes [David Heinemeier Hansson]. Changes:
125
+
126
+ Person.find(:all, :title => "CEO") ...becomes: Person.find(:all, :params => { :title => "CEO" })
127
+ Person.find(:managers) ...becomes: Person.find(:all, :from => :managers)
128
+ Person.find("/companies/1/manager.xml") ...becomes: Person.find(:one, :from => "/companies/1/manager.xml")
129
+
130
+ * Add support for setting custom headers per Active Resource model [Rick Olson]
131
+
132
+ class Project
133
+ headers['X-Token'] = 'foo'
134
+ end
135
+
136
+ # makes the GET request with the custom X-Token header
137
+ Project.find(:all)
138
+
139
+ * Added find-by-path options to ActiveResource::Base.find [David Heinemeier Hansson]. Examples:
140
+
141
+ employees = Person.find(:all, :from => "/companies/1/people.xml") # => GET /companies/1/people.xml
142
+ manager = Person.find("/companies/1/manager.xml") # => GET /companies/1/manager.xml
143
+
144
+
145
+ * Added support for using classes from within a single nested module [David Heinemeier Hansson]. Example:
146
+
147
+ module Highrise
148
+ class Note < ActiveResource::Base
149
+ self.site = "http://37s.sunrise.i:3000"
150
+ end
151
+
152
+ class Comment < ActiveResource::Base
153
+ self.site = "http://37s.sunrise.i:3000"
154
+ end
155
+ end
156
+
157
+ assert_kind_of Highrise::Comment, Note.find(1).comments.first
158
+
159
+
160
+ * Added load_attributes_from_response as a way of loading attributes from other responses than just create [David Heinemeier Hansson]
161
+
162
+ class Highrise::Task < ActiveResource::Base
163
+ def complete
164
+ load_attributes_from_response(post(:complete))
165
+ end
166
+ end
167
+
168
+ ...will set "done_at" when complete is called.
169
+
170
+
171
+ * Added support for calling custom methods #6979 [rwdaigle]
172
+
173
+ Person.find(:managers) # => GET /people/managers.xml
174
+ Kase.find(1).post(:close) # => POST /kases/1/close.xml
175
+
176
+ * Remove explicit prefix_options parameter for ActiveResource::Base#initialize. [Rick Olson]
177
+ ActiveResource splits the prefix_options from it automatically.
178
+
179
+ * Allow ActiveResource::Base.delete with custom prefix. [Rick Olson]
180
+
181
+ * Add ActiveResource::Base#dup [Rick Olson]
182
+
183
+ * Fixed constant warning when fetching the same object multiple times [David Heinemeier Hansson]
184
+
185
+ * Added that saves which get a body response (and not just a 201) will use that response to update themselves [David Heinemeier Hansson]
186
+
187
+ * Disregard namespaces from the default element name, so Highrise::Person will just try to fetch from "/people", not "/highrise/people" [David Heinemeier Hansson]
188
+
189
+ * Allow array and hash query parameters. #7756 [Greg Spurrier]
190
+
191
+ * Loading a resource preserves its prefix_options. #7353 [Ryan Daigle]
192
+
193
+ * Carry over the convenience of #create from ActiveRecord. Closes #7340. [Ryan Daigle]
194
+
195
+ * Increase ActiveResource::Base test coverage. Closes #7173, #7174 [Rich Collins]
196
+
197
+ * Interpret 422 Unprocessable Entity as ResourceInvalid. #7097 [dkubb]
198
+
199
+ * Mega documentation patches. #7025, #7069 [rwdaigle]
200
+
201
+ * Base.exists?(id, options) and Base#exists? check whether the resource is found. #6970 [rwdaigle]
202
+
203
+ * Query string support. [untext, Jeremy Kemper]
204
+ # GET /forums/1/topics.xml?sort=created_at
205
+ Topic.find(:all, :forum_id => 1, :sort => 'created_at')
206
+
207
+ * Base#==, eql?, and hash methods. == returns true if its argument is identical to self or if it's an instance of the same class, is not new?, and has the same id. eql? is an alias for ==. hash delegates to id. [Jeremy Kemper]
208
+
209
+ * Allow subclassed resources to share the site info [Rick Olson, Jeremy Kemper]
210
+ d
211
+ class BeastResource < ActiveResource::Base
212
+ self.site = 'http://beast.caboo.se'
213
+ end
214
+
215
+ class Forum < BeastResource
216
+ # taken from BeastResource
217
+ # self.site = 'http://beast.caboo.se'
218
+ end
219
+
220
+ class Topic < BeastResource
221
+ self.site += '/forums/:forum_id'
222
+ end
223
+
224
+ * Fix issues with ActiveResource collection handling. Closes #6291. [bmilekic]
225
+
226
+ * Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway]
227
+
228
+ * Add basic logging support for logging outgoing requests. [Jamis Buck]
229
+
230
+ * Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck]
231
+
232
+ * Make #save behavior mimic AR::Base#save (true on success, false on failure). [Jamis Buck]
233
+
234
+ * Add Basic HTTP Authentication to ActiveResource (closes #6305). [jonathan]
235
+
236
+ * Extracted #id_from_response as an entry point for customizing how a created resource gets its own ID.
237
+ By default, it extracts from the Location response header.
238
+
239
+ * Optimistic locking: raise ActiveResource::ResourceConflict on 409 Conflict response. [Jeremy Kemper]
240
+
241
+ # Example controller action
242
+ def update
243
+ @person.save!
244
+ rescue ActiveRecord::StaleObjectError
245
+ render :xml => @person.reload.to_xml, :status => '409 Conflict'
246
+ end
247
+
248
+ * Basic validation support [Rick Olson]
249
+
250
+ Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors.
251
+
252
+ render :xml => @person.errors.to_xml, :status => '400 Validation Error'
253
+
254
+ * Deep hashes are converted into collections of resources. [Jeremy Kemper]
255
+ Person.new :name => 'Bob',
256
+ :address => { :id => 1, :city => 'Portland' },
257
+ :contacts => [{ :id => 1 }, { :id => 2 }]
258
+ Looks for Address and Contact resources and creates them if unavailable.
259
+ So clients can fetch a complex resource in a single request if you e.g.
260
+ render :xml => @person.to_xml(:include => [:address, :contacts])
261
+ in your controller action.
262
+
263
+ * Major updates [Rick Olson]
264
+
265
+ * Add full support for find/create/update/destroy
266
+ * Add support for specifying prefixes.
267
+ * Allow overriding of element_name, collection_name, and primary key
268
+ * Provide simpler HTTP mock interface for testing
269
+
270
+ # rails routing code
271
+ map.resources :posts do |post|
272
+ post.resources :comments
273
+ end
274
+
275
+ # ActiveResources
276
+ class Post < ActiveResource::Base
277
+ self.site = "http://37s.sunrise.i:3000/"
278
+ end
279
+
280
+ class Comment < ActiveResource::Base
281
+ self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
282
+ end
283
+
284
+ @post = Post.find 5
285
+ @comments = Comment.find :all, :post_id => @post.id
286
+
287
+ @comment = Comment.new({:body => 'hello world'}, {:post_id => @post.id})
288
+ @comment.save
289
+
290
+ * Base.site= accepts URIs. 200...400 are valid response codes. PUT and POST request bodies default to ''. [Jeremy Kemper]
291
+
292
+ * Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [David Heinemeier Hansson]
data/README ADDED
@@ -0,0 +1,165 @@
1
+ = Active Resource
2
+
3
+ Active Resource (ARes) connects business objects and Representational State Transfer (REST)
4
+ web services. It implements object-relational mapping for REST webservices to provide transparent
5
+ proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing
6
+ in ActionController::Resources).
7
+
8
+ == Philosophy
9
+
10
+ Active Resource attempts to provide a coherent wrapper object-relational mapping for REST
11
+ web services. It follows the same philosophy as Active Record, in that one of its prime aims
12
+ is to reduce the amount of code needed to map to these resources. This is made possible
13
+ by relying on a number of code- and protocol-based conventions that make it easy for Active Resource
14
+ to infer complex relations and structures. These conventions are outlined in detail in the documentation
15
+ for ActiveResource::Base.
16
+
17
+ == Overview
18
+
19
+ Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database
20
+ tables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result
21
+ received and serialized into a usable Ruby object.
22
+
23
+ === Configuration and Usage
24
+
25
+ Putting ActiveResource to use is very similar to ActiveRecord. It's as simple as creating a model class
26
+ that inherits from ActiveResource::Base and providing a <tt>site</tt> class variable to it:
27
+
28
+ class Person < ActiveResource::Base
29
+ self.site = "http://api.people.com:3000/"
30
+ end
31
+
32
+ Now the Person class is REST enabled and can invoke REST services very similarly to how ActiveRecord invokes
33
+ lifecycle methods that operate against a persistent store.
34
+
35
+ # Find a person with id = 1
36
+ ryan = Person.find(1)
37
+ Person.exists?(1) #=> true
38
+
39
+ As you can see, the methods are quite similar to Active Record's methods for dealing with database
40
+ records. But rather than dealing directly with a database record, you're dealing with HTTP resources (which may or may not be database records).
41
+
42
+ ==== Protocol
43
+
44
+ Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing
45
+ built into ActionController but will also work with any other REST service that properly implements the protocol.
46
+ REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification:
47
+
48
+ * GET requests are used for finding and retrieving resources.
49
+ * POST requests are used to create new resources.
50
+ * PUT requests are used to update existing resources.
51
+ * DELETE requests are used to delete resources.
52
+
53
+ For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation;
54
+ for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer].
55
+
56
+ ==== Find
57
+
58
+ GET Http requests expect the XML form of whatever resource/resources is/are being requested. So,
59
+ for a request for a single element - the XML of that item is expected in response:
60
+
61
+ # Expects a response of
62
+ #
63
+ # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person>
64
+ #
65
+ # for GET http://api.people.com:3000/people/1.xml
66
+ #
67
+ ryan = Person.find(1)
68
+
69
+ The XML document that is received is used to build a new object of type Person, with each
70
+ XML element becoming an attribute on the object.
71
+
72
+ ryan.is_a? Person #=> true
73
+ ryan.attribute1 #=> 'value1'
74
+
75
+ Any complex element (one that contains other elements) becomes its own object:
76
+
77
+ # With this response:
78
+ #
79
+ # <person><id>1</id><attribute1>value1</attribute1><complex><attribute2>value2</attribute2></complex></person>
80
+ #
81
+ # for GET http://api.people.com:3000/people/1.xml
82
+ #
83
+ ryan = Person.find(1)
84
+ ryan.complex #=> <Person::Complex::xxxxx>
85
+ ryan.complex.attribute2 #=> 'value2'
86
+
87
+ Collections can also be requested in a similar fashion
88
+
89
+ # Expects a response of
90
+ #
91
+ # <people type="array">
92
+ # <person><id type="integer">1</id><first>Ryan</first></person>
93
+ # <person><id type="integer">2</id><first>Jim</first></person>
94
+ # </people>
95
+ #
96
+ # for GET http://api.people.com:3000/people.xml
97
+ #
98
+ people = Person.find(:all)
99
+ people.first #=> <Person::xxx 'first' => 'Ryan' ...>
100
+ people.last #=> <Person::xxx 'first' => 'Jim' ...>
101
+
102
+ ==== Create
103
+
104
+ Creating a new resource submits the xml form of the resource as the body of the request and expects
105
+ a 'Location' header in the response with the RESTful URL location of the newly created resource. The
106
+ id of the newly created resource is parsed out of the Location response header and automatically set
107
+ as the id of the ARes object.
108
+
109
+ # <person><first>Ryan</first></person>
110
+ #
111
+ # is submitted as the body on
112
+ #
113
+ # POST http://api.people.com:3000/people.xml
114
+ #
115
+ # when save is called on a new Person object. An empty response is
116
+ # is expected with a 'Location' header value:
117
+ #
118
+ # Response (201): Location: http://api.people.com:3000/people/2
119
+ #
120
+ ryan = Person.new(:first => 'Ryan')
121
+ ryan.new? #=> true
122
+ ryan.save #=> true
123
+ ryan.new? #=> false
124
+ ryan.id #=> 2
125
+
126
+ ==== Update
127
+
128
+ 'save' is also used to update an existing resource - and follows the same protocol as creating a resource
129
+ with the exception that no response headers are needed - just an empty response when the update on the
130
+ server side was successful.
131
+
132
+ # <person><first>Ryan</first></person>
133
+ #
134
+ # is submitted as the body on
135
+ #
136
+ # PUT http://api.people.com:3000/people/1.xml
137
+ #
138
+ # when save is called on an existing Person object. An empty response is
139
+ # is expected with code (204)
140
+ #
141
+ ryan = Person.find(1)
142
+ ryan.first #=> 'Ryan'
143
+ ryan.first = 'Rizzle'
144
+ ryan.save #=> true
145
+
146
+ ==== Delete
147
+
148
+ Destruction of a resource can be invoked as a class and instance method of the resource.
149
+
150
+ # A request is made to
151
+ #
152
+ # DELETE http://api.people.com:3000/people/1.xml
153
+ #
154
+ # for both of these forms. An empty response with
155
+ # is expected with response code (200)
156
+ #
157
+ ryan = Person.find(1)
158
+ ryan.destroy #=> true
159
+ ryan.exists? #=> false
160
+ Person.delete(2) #=> true
161
+ Person.exists?(2) #=> false
162
+
163
+
164
+ You can find more usage information in the ActiveResource::Base documentation.
165
+
data/Rakefile ADDED
@@ -0,0 +1,139 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+
8
+ require File.join(File.dirname(__FILE__), 'lib', 'active_resource', 'version')
9
+
10
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11
+ PKG_NAME = 'activeresource_csi'
12
+ PKG_VERSION = ActiveResource::VERSION::STRING + PKG_BUILD
13
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
14
+
15
+ RELEASE_NAME = "REL #{PKG_VERSION}"
16
+
17
+ RUBY_FORGE_PROJECT = "activerecord"
18
+ RUBY_FORGE_USER = "webster132"
19
+
20
+ PKG_FILES = FileList[
21
+ "lib/**/*", "test/**/*", "[A-Z]*", "Rakefile"
22
+ ].exclude(/\bCVS\b|~$/)
23
+
24
+ desc "Default Task"
25
+ task :default => [ :test ]
26
+
27
+ # Run the unit tests
28
+
29
+ Rake::TestTask.new { |t|
30
+ activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib"
31
+ t.libs << activesupport_path if File.directory?(activesupport_path)
32
+ t.libs << "test"
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = true
35
+ t.warning = true
36
+ }
37
+
38
+
39
+ # Generate the RDoc documentation
40
+
41
+ Rake::RDocTask.new { |rdoc|
42
+ rdoc.rdoc_dir = 'doc'
43
+ rdoc.title = "Active Resource -- Object-oriented REST services"
44
+ rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
45
+ rdoc.options << '--charset' << 'utf-8'
46
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
47
+ rdoc.rdoc_files.include('README', 'CHANGELOG')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ rdoc.rdoc_files.exclude('lib/activeresource.rb')
50
+ }
51
+
52
+
53
+ # Create compressed packages
54
+
55
+ dist_dirs = [ "lib", "test", "examples", "dev-utils" ]
56
+
57
+ spec = Gem::Specification.new do |s|
58
+ s.platform = Gem::Platform::RUBY
59
+ s.name = PKG_NAME
60
+ s.version = PKG_VERSION
61
+ s.summary = "Think Active Record for web resources."
62
+ s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.}
63
+
64
+ s.files = [ "Rakefile", "README", "CHANGELOG" ]
65
+ dist_dirs.each do |dir|
66
+ s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
67
+ end
68
+
69
+ s.add_dependency('activesupport', '= 2.3.5' + PKG_BUILD)
70
+
71
+ s.require_path = 'lib'
72
+ s.autorequire = 'active_resource'
73
+
74
+ s.has_rdoc = true
75
+ s.extra_rdoc_files = %w( README )
76
+ s.rdoc_options.concat ['--main', 'README']
77
+
78
+ s.author = "David Heinemeier Hansson"
79
+ s.email = "david@loudthinking.com"
80
+ s.homepage = "http://www.rubyonrails.org"
81
+ s.rubyforge_project = "activeresource"
82
+ end
83
+
84
+ Rake::GemPackageTask.new(spec) do |p|
85
+ p.gem_spec = spec
86
+ p.need_tar = true
87
+ p.need_zip = true
88
+ end
89
+
90
+ task :lines do
91
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
92
+
93
+ for file_name in FileList["lib/active_resource/**/*.rb"]
94
+ next if file_name =~ /vendor/
95
+ f = File.open(file_name)
96
+
97
+ while line = f.gets
98
+ lines += 1
99
+ next if line =~ /^\s*$/
100
+ next if line =~ /^\s*#/
101
+ codelines += 1
102
+ end
103
+ puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
104
+
105
+ total_lines += lines
106
+ total_codelines += codelines
107
+
108
+ lines, codelines = 0, 0
109
+ end
110
+
111
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
112
+ end
113
+
114
+
115
+ # Publishing ------------------------------------------------------
116
+
117
+ desc "Publish the beta gem"
118
+ task :pgem => [:package] do
119
+ require 'rake/contrib/sshpublisher'
120
+ Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
121
+ `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
122
+ end
123
+
124
+ desc "Publish the API documentation"
125
+ task :pdoc => [:rdoc] do
126
+ require 'rake/contrib/sshpublisher'
127
+ Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ar", "doc").upload
128
+ end
129
+
130
+ desc "Publish the release files to RubyForge."
131
+ task :release => [ :package ] do
132
+ `rubyforge login`
133
+
134
+ for ext in %w( gem tgz zip )
135
+ release_command = "rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
136
+ puts release_command
137
+ system(release_command)
138
+ end
139
+ end