# |
diff --git a/app/views/repositories/changes.rhtml b/app/views/repositories/changes.rhtml
index 341c6cb..85695ec 100644
--- a/app/views/repositories/changes.rhtml
+++ b/app/views/repositories/changes.rhtml
@@ -4,12 +4,12 @@
<% if @repository.supports_cat? %>
- <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> |
+ <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> |
<% end %>
<% if @repository.supports_annotate? %>
- <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> |
+ <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> |
<% end %>
-<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
+<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml
index d0ff1de..04c0e21 100644
--- a/app/views/repositories/revision.rhtml
+++ b/app/views/repositories/revision.rhtml
@@ -55,7 +55,7 @@
<%= "(#{change.revision})" unless change.revision.blank? %>
<% if change.action == "M" %>
-<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.relative_path), :rev => @changeset.revision %>
+<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => to_path_param(change.relative_path), :rev => @changeset.revision %>
<% end %>
|
diff --git a/config/boot.rb b/config/boot.rb
index 9fcd50f..cd21fb9 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,19 +1,109 @@
-# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
-unless defined?(RAILS_ROOT)
- root_path = File.join(File.dirname(__FILE__), '..')
- unless RUBY_PLATFORM =~ /mswin32/
- require 'pathname'
- root_path = Pathname.new(root_path).cleanpath(true).to_s
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
end
- RAILS_ROOT = root_path
-end
-if File.directory?("#{RAILS_ROOT}/vendor/rails")
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
-else
- require 'rubygems'
- require 'initializer'
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ require 'rubygems'
+
+ unless rubygems_version >= '0.9.4'
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
end
-Rails::Initializer.run(:set_load_path)
+# All that for this:
+Rails.boot!
diff --git a/config/environment.rb b/config/environment.rb
index f09c100..b0f16c3 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
@@ -71,32 +71,3 @@ Rails::Initializer.run do |config|
config.action_mailer.delivery_method = :smtp
end
-
-ActiveRecord::Errors.default_error_messages = {
- :inclusion => "activerecord_error_inclusion",
- :exclusion => "activerecord_error_exclusion",
- :invalid => "activerecord_error_invalid",
- :confirmation => "activerecord_error_confirmation",
- :accepted => "activerecord_error_accepted",
- :empty => "activerecord_error_empty",
- :blank => "activerecord_error_blank",
- :too_long => "activerecord_error_too_long",
- :too_short => "activerecord_error_too_short",
- :wrong_length => "activerecord_error_wrong_length",
- :taken => "activerecord_error_taken",
- :not_a_number => "activerecord_error_not_a_number"
-}
-
-ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
-
-Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)
-Mime::Type.register 'application/pdf', :pdf
-
-GLoc.set_config :default_language => :en
-GLoc.clear_strings
-GLoc.set_kcode
-GLoc.load_localized_strings
-GLoc.set_config(:raise_string_not_found_errors => false)
-
-require 'redmine'
-
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
new file mode 100644
index 0000000..fcc0919
--- /dev/null
+++ b/config/initializers/10-patches.rb
@@ -0,0 +1,17 @@
+
+ActiveRecord::Errors.default_error_messages = {
+ :inclusion => "activerecord_error_inclusion",
+ :exclusion => "activerecord_error_exclusion",
+ :invalid => "activerecord_error_invalid",
+ :confirmation => "activerecord_error_confirmation",
+ :accepted => "activerecord_error_accepted",
+ :empty => "activerecord_error_empty",
+ :blank => "activerecord_error_blank",
+ :too_long => "activerecord_error_too_long",
+ :too_short => "activerecord_error_too_short",
+ :wrong_length => "activerecord_error_wrong_length",
+ :taken => "activerecord_error_taken",
+ :not_a_number => "activerecord_error_not_a_number"
+}
+
+ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
diff --git a/config/initializers/20-mime_types.rb b/config/initializers/20-mime_types.rb
new file mode 100644
index 0000000..269742b
--- /dev/null
+++ b/config/initializers/20-mime_types.rb
@@ -0,0 +1,4 @@
+# Add new mime types for use in respond_to blocks:
+
+Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)
+Mime::Type.register 'application/pdf', :pdf
diff --git a/config/initializers/30-redmine.rb b/config/initializers/30-redmine.rb
new file mode 100644
index 0000000..f2a9f6a
--- /dev/null
+++ b/config/initializers/30-redmine.rb
@@ -0,0 +1,7 @@
+GLoc.set_config :default_language => :en
+GLoc.clear_strings
+GLoc.set_kcode
+GLoc.load_localized_strings
+GLoc.set_config(:raise_string_not_found_errors => false)
+
+require 'redmine'
diff --git a/db/migrate/072_add_enumerations_position.rb b/db/migrate/072_add_enumerations_position.rb
index e0beaf3..22558a6 100644
--- a/db/migrate/072_add_enumerations_position.rb
+++ b/db/migrate/072_add_enumerations_position.rb
@@ -1,7 +1,7 @@
class AddEnumerationsPosition < ActiveRecord::Migration
def self.up
add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position')
- Enumeration.find(:all).group_by(&:opt).each_value do |enums|
+ Enumeration.find(:all).group_by(&:opt).each do |opt, enums|
enums.each_with_index do |enum, i|
# do not call model callbacks
Enumeration.update_all "position = #{i+1}", {:id => enum.id}
diff --git a/db/migrate/078_add_custom_fields_position.rb b/db/migrate/078_add_custom_fields_position.rb
index 7ee8abb..1c42ae7 100644
--- a/db/migrate/078_add_custom_fields_position.rb
+++ b/db/migrate/078_add_custom_fields_position.rb
@@ -1,7 +1,7 @@
class AddCustomFieldsPosition < ActiveRecord::Migration
def self.up
add_column(:custom_fields, :position, :integer, :default => 1)
- CustomField.find(:all).group_by(&:type).each_value do |fields|
+ CustomField.find(:all).group_by(&:type).each do |t, fields|
fields.each_with_index do |field, i|
# do not call model callbacks
CustomField.update_all "position = #{i+1}", {:id => field.id}
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index 5b331fe..88e35a6 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -22,7 +22,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def initialize(object_name, object, template, options, proc)
set_language_if_valid options.delete(:lang)
- @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
+ super
end
(field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
diff --git a/script/dbconsole b/script/dbconsole
new file mode 100644
index 0000000..caa60ce
--- /dev/null
+++ b/script/dbconsole
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/dbconsole'
diff --git a/script/performance/request b/script/performance/request
new file mode 100644
index 0000000..ae3f38c
--- /dev/null
+++ b/script/performance/request
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/performance/request'
diff --git a/script/process/inspector b/script/process/inspector
new file mode 100644
index 0000000..bf25ad8
--- /dev/null
+++ b/script/process/inspector
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/process/inspector'
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 88c0319..88a9fae 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -38,7 +38,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_template 'index'
assert_not_nil assigns(:project_tree)
# Root project as hash key
- assert assigns(:project_tree).has_key?(Project.find(1))
+ assert assigns(:project_tree).keys.include?(Project.find(1))
# Subproject in corresponding value
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
end
diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb
index 1b57ba8..2ef933f 100644
--- a/test/integration/issues_test.rb
+++ b/test/integration/issues_test.rb
@@ -20,8 +20,11 @@ require "#{File.dirname(__FILE__)}/../test_helper"
class IssuesTest < ActionController::IntegrationTest
fixtures :projects,
:users,
+ :roles,
+ :members,
:trackers,
:projects_trackers,
+ :enabled_modules,
:issue_statuses,
:issues,
:enumerations,
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 1340f9c..f61b88d 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -65,20 +65,3 @@ class Test::Unit::TestCase
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
end
end
-
-
-# ActionController::TestUploadedFile bug
-# see http://dev.rubyonrails.org/ticket/4635
-class String
- def original_filename
- "testfile.txt"
- end
-
- def content_type
- "text/plain"
- end
-
- def read
- self.to_s
- end
-end
diff --git a/test/unit/role_test.rb b/test/unit/role_test.rb
index 5e0d167..b98af2e 100644
--- a/test/unit/role_test.rb
+++ b/test/unit/role_test.rb
@@ -26,7 +26,7 @@ class RoleTest < Test::Unit::TestCase
target = Role.new(:name => 'Target')
assert target.save
- assert target.workflows.copy(source)
+ target.workflows.copy(source)
target.reload
assert_equal 90, target.workflows.size
end
diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb
index 406bdd6..6dab889 100644
--- a/test/unit/tracker_test.rb
+++ b/test/unit/tracker_test.rb
@@ -26,7 +26,7 @@ class TrackerTest < Test::Unit::TestCase
target = Tracker.new(:name => 'Target')
assert target.save
- assert target.workflows.copy(source)
+ target.workflows.copy(source)
target.reload
assert_equal 89, target.workflows.size
end
diff --git a/vendor/plugins/acts_as_versioned/Rakefile b/vendor/plugins/acts_as_versioned/Rakefile
index 3ae69e9..5bccb5d 100644
--- a/vendor/plugins/acts_as_versioned/Rakefile
+++ b/vendor/plugins/acts_as_versioned/Rakefile
@@ -1,182 +1,182 @@
-require 'rubygems'
-
-Gem::manage_gems
-
-require 'rake/rdoctask'
-require 'rake/packagetask'
-require 'rake/gempackagetask'
-require 'rake/testtask'
-require 'rake/contrib/rubyforgepublisher'
-
-PKG_NAME = 'acts_as_versioned'
-PKG_VERSION = '0.3.1'
-PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
-PROD_HOST = "technoweenie@bidwell.textdrive.com"
-RUBY_FORGE_PROJECT = 'ar-versioned'
-RUBY_FORGE_USER = 'technoweenie'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the calculations plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the calculations plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "#{PKG_NAME} -- Simple versioning with active record models"
- rdoc.options << '--line-numbers --inline-source'
- rdoc.rdoc_files.include('README', 'CHANGELOG', 'RUNNING_UNIT_TESTS')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
-spec = Gem::Specification.new do |s|
- s.name = PKG_NAME
- s.version = PKG_VERSION
- s.platform = Gem::Platform::RUBY
- s.summary = "Simple versioning with active record models"
- s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG RUNNING_UNIT_TESTS)
- s.files.delete "acts_as_versioned_plugin.sqlite.db"
- s.files.delete "acts_as_versioned_plugin.sqlite3.db"
- s.files.delete "test/debug.log"
- s.require_path = 'lib'
- s.autorequire = 'acts_as_versioned'
- s.has_rdoc = true
- s.test_files = Dir['test/**/*_test.rb']
- s.add_dependency 'activerecord', '>= 1.10.1'
- s.add_dependency 'activesupport', '>= 1.1.1'
- s.author = "Rick Olson"
- s.email = "technoweenie@gmail.com"
- s.homepage = "http://techno-weenie.net"
-end
-
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.need_tar = true
-end
-
-desc "Publish the API documentation"
-task :pdoc => [:rdoc] do
- Rake::RubyForgePublisher.new(RUBY_FORGE_PROJECT, RUBY_FORGE_USER).upload
-end
-
-desc 'Publish the gem and API docs'
-task :publish => [:pdoc, :rubyforge_upload]
-
-desc "Publish the release files to RubyForge."
-task :rubyforge_upload => :package do
- files = %w(gem tgz).map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
-
- if RUBY_FORGE_PROJECT then
- require 'net/http'
- require 'open-uri'
-
- project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
- project_data = open(project_uri) { |data| data.read }
- group_id = project_data[/[?&]group_id=(\d+)/, 1]
- raise "Couldn't get group id" unless group_id
-
- # This echos password to shell which is a bit sucky
- if ENV["RUBY_FORGE_PASSWORD"]
- password = ENV["RUBY_FORGE_PASSWORD"]
- else
- print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
- password = STDIN.gets.chomp
- end
-
- login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
- data = [
- "login=1",
- "form_loginname=#{RUBY_FORGE_USER}",
- "form_pw=#{password}"
- ].join("&")
- http.post("/account/login.php", data)
- end
-
- cookie = login_response["set-cookie"]
- raise "Login failed" unless cookie
- headers = { "Cookie" => cookie }
-
- release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
- release_data = open(release_uri, headers) { |data| data.read }
- package_id = release_data[/[?&]package_id=(\d+)/, 1]
- raise "Couldn't get package id" unless package_id
-
- first_file = true
- release_id = ""
-
- files.each do |filename|
- basename = File.basename(filename)
- file_ext = File.extname(filename)
- file_data = File.open(filename, "rb") { |file| file.read }
-
- puts "Releasing #{basename}..."
-
- release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
- release_date = Time.now.strftime("%Y-%m-%d %H:%M")
- type_map = {
- ".zip" => "3000",
- ".tgz" => "3110",
- ".gz" => "3110",
- ".gem" => "1400"
- }; type_map.default = "9999"
- type = type_map[file_ext]
- boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
-
- query_hash = if first_file then
- {
- "group_id" => group_id,
- "package_id" => package_id,
- "release_name" => PKG_FILE_NAME,
- "release_date" => release_date,
- "type_id" => type,
- "processor_id" => "8000", # Any
- "release_notes" => "",
- "release_changes" => "",
- "preformatted" => "1",
- "submit" => "1"
- }
- else
- {
- "group_id" => group_id,
- "release_id" => release_id,
- "package_id" => package_id,
- "step2" => "1",
- "type_id" => type,
- "processor_id" => "8000", # Any
- "submit" => "Add This File"
- }
- end
-
- query = "?" + query_hash.map do |(name, value)|
- [name, URI.encode(value)].join("=")
- end.join("&")
-
- data = [
- "--" + boundary,
- "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
- "Content-Type: application/octet-stream",
- "Content-Transfer-Encoding: binary",
- "", file_data, ""
- ].join("\x0D\x0A")
-
- release_headers = headers.merge(
- "Content-Type" => "multipart/form-data; boundary=#{boundary}"
- )
-
- target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
- http.post(target + query, data, release_headers)
- end
-
- if first_file then
- release_id = release_response.body[/release_id=(\d+)/, 1]
- raise("Couldn't get release id") unless release_id
- end
-
- first_file = false
- end
- end
+require 'rubygems'
+
+Gem::manage_gems
+
+require 'rake/rdoctask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/testtask'
+require 'rake/contrib/rubyforgepublisher'
+
+PKG_NAME = 'acts_as_versioned'
+PKG_VERSION = '0.3.1'
+PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
+PROD_HOST = "technoweenie@bidwell.textdrive.com"
+RUBY_FORGE_PROJECT = 'ar-versioned'
+RUBY_FORGE_USER = 'technoweenie'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the calculations plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the calculations plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{PKG_NAME} -- Simple versioning with active record models"
+ rdoc.options << '--line-numbers --inline-source'
+ rdoc.rdoc_files.include('README', 'CHANGELOG', 'RUNNING_UNIT_TESTS')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+spec = Gem::Specification.new do |s|
+ s.name = PKG_NAME
+ s.version = PKG_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "Simple versioning with active record models"
+ s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG RUNNING_UNIT_TESTS)
+ s.files.delete "acts_as_versioned_plugin.sqlite.db"
+ s.files.delete "acts_as_versioned_plugin.sqlite3.db"
+ s.files.delete "test/debug.log"
+ s.require_path = 'lib'
+ s.autorequire = 'acts_as_versioned'
+ s.has_rdoc = true
+ s.test_files = Dir['test/**/*_test.rb']
+ s.add_dependency 'activerecord', '>= 1.10.1'
+ s.add_dependency 'activesupport', '>= 1.1.1'
+ s.author = "Rick Olson"
+ s.email = "technoweenie@gmail.com"
+ s.homepage = "http://techno-weenie.net"
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_tar = true
+end
+
+desc "Publish the API documentation"
+task :pdoc => [:rdoc] do
+ Rake::RubyForgePublisher.new(RUBY_FORGE_PROJECT, RUBY_FORGE_USER).upload
+end
+
+desc 'Publish the gem and API docs'
+task :publish => [:pdoc, :rubyforge_upload]
+
+desc "Publish the release files to RubyForge."
+task :rubyforge_upload => :package do
+ files = %w(gem tgz).map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
+
+ if RUBY_FORGE_PROJECT then
+ require 'net/http'
+ require 'open-uri'
+
+ project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
+ project_data = open(project_uri) { |data| data.read }
+ group_id = project_data[/[?&]group_id=(\d+)/, 1]
+ raise "Couldn't get group id" unless group_id
+
+ # This echos password to shell which is a bit sucky
+ if ENV["RUBY_FORGE_PASSWORD"]
+ password = ENV["RUBY_FORGE_PASSWORD"]
+ else
+ print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
+ password = STDIN.gets.chomp
+ end
+
+ login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
+ data = [
+ "login=1",
+ "form_loginname=#{RUBY_FORGE_USER}",
+ "form_pw=#{password}"
+ ].join("&")
+ http.post("/account/login.php", data)
+ end
+
+ cookie = login_response["set-cookie"]
+ raise "Login failed" unless cookie
+ headers = { "Cookie" => cookie }
+
+ release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
+ release_data = open(release_uri, headers) { |data| data.read }
+ package_id = release_data[/[?&]package_id=(\d+)/, 1]
+ raise "Couldn't get package id" unless package_id
+
+ first_file = true
+ release_id = ""
+
+ files.each do |filename|
+ basename = File.basename(filename)
+ file_ext = File.extname(filename)
+ file_data = File.open(filename, "rb") { |file| file.read }
+
+ puts "Releasing #{basename}..."
+
+ release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
+ release_date = Time.now.strftime("%Y-%m-%d %H:%M")
+ type_map = {
+ ".zip" => "3000",
+ ".tgz" => "3110",
+ ".gz" => "3110",
+ ".gem" => "1400"
+ }; type_map.default = "9999"
+ type = type_map[file_ext]
+ boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
+
+ query_hash = if first_file then
+ {
+ "group_id" => group_id,
+ "package_id" => package_id,
+ "release_name" => PKG_FILE_NAME,
+ "release_date" => release_date,
+ "type_id" => type,
+ "processor_id" => "8000", # Any
+ "release_notes" => "",
+ "release_changes" => "",
+ "preformatted" => "1",
+ "submit" => "1"
+ }
+ else
+ {
+ "group_id" => group_id,
+ "release_id" => release_id,
+ "package_id" => package_id,
+ "step2" => "1",
+ "type_id" => type,
+ "processor_id" => "8000", # Any
+ "submit" => "Add This File"
+ }
+ end
+
+ query = "?" + query_hash.map do |(name, value)|
+ [name, URI.encode(value)].join("=")
+ end.join("&")
+
+ data = [
+ "--" + boundary,
+ "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
+ "Content-Type: application/octet-stream",
+ "Content-Transfer-Encoding: binary",
+ "", file_data, ""
+ ].join("\x0D\x0A")
+
+ release_headers = headers.merge(
+ "Content-Type" => "multipart/form-data; boundary=#{boundary}"
+ )
+
+ target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
+ http.post(target + query, data, release_headers)
+ end
+
+ if first_file then
+ release_id = release_response.body[/release_id=(\d+)/, 1]
+ raise("Couldn't get release id") unless release_id
+ end
+
+ first_file = false
+ end
+ end
end
\ No newline at end of file
diff --git a/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb b/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
index 5e6f6e6..bba10c4 100644
--- a/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
+++ b/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
@@ -22,7 +22,7 @@
module ActiveRecord #:nodoc:
module Acts #:nodoc:
# Specify this act if you want to save a copy of the row in a versioned table. This assumes there is a
- # versioned table ready and that your model has a version field. This works with optimisic locking if the lock_version
+ # versioned table ready and that your model has a version field. This works with optimistic locking if the lock_version
# column is present as well.
#
# The class for the versioned model is derived the first time it is seen. Therefore, if you change your database schema you have to restart
@@ -49,9 +49,24 @@ module ActiveRecord #:nodoc:
# page.revert_to(page.versions.last) # using versioned instance
# page.title # => 'hello world'
#
+ # page.versions.earliest # efficient query to find the first version
+ # page.versions.latest # efficient query to find the most recently created version
+ #
+ #
+ # Simple Queries to page between versions
+ #
+ # page.versions.before(version)
+ # page.versions.after(version)
+ #
+ # Access the previous/next versions from the versioned model itself
+ #
+ # version = page.versions.latest
+ # version.previous # go back one version
+ # version.next # go forward one version
+ #
# See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options
module Versioned
- CALLBACKS = [:set_new_version, :save_version_on_create, :save_version?, :clear_changed_attributes]
+ CALLBACKS = [:set_new_version, :save_version_on_create, :save_version?, :clear_altered_attributes]
def self.included(base) # :nodoc:
base.extend ClassMethods
end
@@ -80,7 +95,7 @@ module ActiveRecord #:nodoc:
# end
#
# *