Permalink
Browse files

Rearranging dependencies

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@279 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6b5df89 commit 595a4a591b6f4f863d52e28046e2fc1c51dfcad5 @dhh dhh committed Dec 29, 2004
@@ -25,6 +25,7 @@
require 'action_controller/support/clean_logger'
require 'action_controller/support/misc'
+require 'action_controller/support/dependencies'
require 'action_controller/base'
require 'action_controller/rescue'
View
@@ -61,14 +61,14 @@ Rake::RDocTask.new { |rdoc|
# Publish beta gem
desc "Publish the beta gem"
task :pgem => [:package] do
- Rake::SshFilePublisher.new("davidhh@one.textdrive.com", "domains/rubyonrails.org/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
- `ssh davidhh@one.textdrive.com './gemupdate.sh'`
+ Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
+ `ssh davidhh@comox.textdrive.com './gemupdate.sh'`
end
# Publish documentation
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
- Rake::SshDirPublisher.new("davidhh@one.textdrive.com", "domains/rubyonrails.org/ar", "doc").upload
+ Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/ar", "doc").upload
end
@@ -96,7 +96,7 @@ spec = Gem::Specification.new do |s|
s.author = "David Heinemeier Hansson"
s.email = "david@loudthinking.com"
- s.homepage = "http://activerecord.rubyonrails.org"
+ s.homepage = "http://www.rubyonrails.com"
s.rubyforge_project = "activerecord"
end
@@ -26,6 +26,7 @@
require 'active_record/support/clean_logger'
require 'active_record/support/misc'
+require 'active_record/support/dependencies'
require 'active_record/base'
require 'active_record/observer'
@@ -1,122 +0,0 @@
-require 'abstract_unit'
-
-class InflectorTest < Test::Unit::TestCase
- SingularToPlural = {
- "search" => "searches",
- "switch" => "switches",
- "fix" => "fixes",
- "box" => "boxes",
- "process" => "processes",
- "address" => "addresses",
- "case" => "cases",
- "stack" => "stacks",
-
- "category" => "categories",
- "query" => "queries",
- "ability" => "abilities",
- "agency" => "agencies",
- "movie" => "movies",
-
- "wife" => "wives",
- "safe" => "saves",
- "half" => "halves",
-
- "salesperson" => "salespeople",
- "person" => "people",
-
- "spokesman" => "spokesmen",
- "man" => "men",
- "woman" => "women",
-
- "basis" => "bases",
- "diagnosis" => "diagnoses",
-
- "datum" => "data",
- "medium" => "media",
-
- "node_child" => "node_children",
- "child" => "children",
-
- "experience" => "experiences",
- "day" => "days",
-
- "comment" => "comments",
- "foobar" => "foobars"
- }
-
- CamelToUnderscore = {
- "Product" => "product",
- "SpecialGuest" => "special_guest",
- "ApplicationController" => "application_controller"
- }
-
- ClassNameToForeignKeyWithUnderscore = {
- "Person" => "person_id",
- "MyApplication::Billing::Account" => "account_id"
- }
-
- ClassNameToForeignKeyWithoutUnderscore = {
- "Person" => "personid",
- "MyApplication::Billing::Account" => "accountid"
- }
-
- ClassNameToTableName = {
- "PrimarySpokesman" => "primary_spokesmen",
- "NodeChild" => "node_children"
- }
-
- def test_pluralize
- SingularToPlural.each do |singular, plural|
- assert_equal(plural, Inflector.pluralize(singular))
- end
-
- assert_equal("plurals", Inflector.pluralize("plurals"))
- end
-
- def test_singularize
- SingularToPlural.each do |singular, plural|
- assert_equal(singular, Inflector.singularize(plural))
- end
- end
-
- def test_camelize
- CamelToUnderscore.each do |camel, underscore|
- assert_equal(camel, Inflector.camelize(underscore))
- end
- end
-
- def test_underscore
- CamelToUnderscore.each do |camel, underscore|
- assert_equal(underscore, Inflector.underscore(camel))
- end
-
- assert_equal "html_tidy", Inflector.underscore("HTMLTidy")
- assert_equal "html_tidy_generator", Inflector.underscore("HTMLTidyGenerator")
- end
-
- def test_demodulize
- assert_equal "Account", Inflector.demodulize("MyApplication::Billing::Account")
- end
-
- def test_foreign_key
- ClassNameToForeignKeyWithUnderscore.each do |klass, foreign_key|
- assert_equal(foreign_key, Inflector.foreign_key(klass))
- end
-
- ClassNameToForeignKeyWithoutUnderscore.each do |klass, foreign_key|
- assert_equal(foreign_key, Inflector.foreign_key(klass, false))
- end
- end
-
- def test_tableize
- ClassNameToTableName.each do |class_name, table_name|
- assert_equal(table_name, Inflector.tableize(class_name))
- end
- end
-
- def test_classify
- ClassNameToTableName.each do |class_name, table_name|
- assert_equal(class_name, Inflector.classify(table_name))
- end
- end
-end
@@ -0,0 +1,81 @@
+begin
+ require 'simplecc'
+rescue LoadError
+ def Continuation.create(*args, &block)
+ cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
+ result ||= args
+ return *[cc, *result]
+ end
+end
+
+# This method returns the binding of the method that called your
+# method. It will raise an Exception when you're not inside a method.
+#
+# It's used like this:
+# def inc_counter(amount = 1)
+# Binding.of_caller do |binding|
+# # Create a lambda that will increase the variable 'counter'
+# # in the caller of this method when called.
+# inc = eval("lambda { |arg| counter += arg }", binding)
+# # We can refer to amount from inside this block safely.
+# inc.call(amount)
+# end
+# # No other statements can go here. Put them inside the block.
+# end
+# counter = 0
+# 2.times { inc_counter }
+# counter # => 2
+#
+# Binding.of_caller must be the last statement in the method.
+# This means that you will have to put everything you want to
+# do after the call to Binding.of_caller into the block of it.
+# This should be no problem however, because Ruby has closures.
+# If you don't do this an Exception will be raised. Because of
+# the way that Binding.of_caller is implemented it has to be
+# done this way.
+def Binding.of_caller(&block)
+ old_critical = Thread.critical
+ Thread.critical = true
+ count = 0
+ cc, result, error, extra_data = Continuation.create(nil, nil)
+ error.call if error
+
+ tracer = lambda do |*args|
+ type, context, extra_data = args[0], args[4], args
+ if type == "return"
+ count += 1
+ # First this method and then calling one will return --
+ # the trace event of the second event gets the context
+ # of the method which called the method that called this
+ # method.
+ if count == 2
+ # It would be nice if we could restore the trace_func
+ # that was set before we swapped in our own one, but
+ # this is impossible without overloading set_trace_func
+ # in current Ruby.
+ set_trace_func(nil)
+ cc.call(eval("binding", context), nil, extra_data)
+ end
+ elsif type == "line" then
+ nil
+ elsif type == "c-return" and extra_data[3] == :set_trace_func then
+ nil
+ else
+ set_trace_func(nil)
+ error_msg = "Binding.of_caller used in non-method context or " +
+ "trailing statements of method using it aren't in the block."
+ cc.call(nil, lambda { raise(ArgumentError, error_msg) }, nil)
+ end
+ end
+
+ unless result
+ set_trace_func(tracer)
+ return nil
+ else
+ Thread.critical = old_critical
+ case block.arity
+ when 1 then yield(result)
+ else yield(result, extra_data)
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 595a4a5

Please sign in to comment.