rails 2.1.2 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +27 -3
- data/Rakefile +70 -10
- data/bin/about +0 -0
- data/bin/console +0 -0
- data/bin/destroy +0 -0
- data/bin/generate +0 -0
- data/bin/performance/benchmarker +0 -0
- data/bin/performance/profiler +0 -0
- data/bin/performance/request +0 -0
- data/bin/plugin +0 -0
- data/bin/process/inspector +0 -0
- data/bin/process/reaper +0 -0
- data/bin/process/spawner +0 -0
- data/bin/runner +0 -0
- data/bin/server +0 -0
- data/config.ru +17 -0
- data/configs/apache.conf +0 -0
- data/configs/databases/ibm_db.yml +62 -0
- data/configs/databases/mysql.yml +3 -0
- data/configs/databases/postgresql.yml +3 -0
- data/configs/databases/sqlite2.yml +3 -0
- data/configs/databases/sqlite3.yml +3 -0
- data/configs/locales/en.yml +5 -0
- data/dispatches/dispatch.fcgi +1 -1
- data/dispatches/dispatch.rb +2 -2
- data/dispatches/gateway.cgi +2 -2
- data/doc/README_FOR_APP +5 -2
- data/doc/guides/html/2_2_release_notes.html +1185 -0
- data/doc/guides/html/actioncontroller_basics.html +1270 -0
- data/doc/guides/html/activerecord_validations_callbacks.html +749 -0
- data/doc/guides/html/association_basics.html +2585 -0
- data/doc/guides/html/authors.html +240 -0
- data/doc/guides/html/benchmarking_and_profiling.html +1018 -0
- data/doc/guides/html/caching_with_rails.html +583 -0
- data/doc/guides/html/command_line.html +434 -0
- data/doc/guides/html/configuring.html +438 -0
- data/doc/guides/html/creating_plugins.html +1594 -0
- data/doc/guides/html/debugging_rails_applications.html +1175 -0
- data/doc/guides/html/finders.html +1090 -0
- data/doc/guides/html/form_helpers.html +638 -0
- data/doc/guides/html/getting_started_with_rails.html +2066 -0
- data/doc/guides/html/index.html +349 -0
- data/doc/guides/html/layouts_and_rendering.html +1406 -0
- data/doc/guides/html/migrations.html +921 -0
- data/doc/guides/html/routing_outside_in.html +2213 -0
- data/doc/guides/html/security.html +1346 -0
- data/doc/guides/html/testing_rails_applications.html +1859 -0
- data/doc/guides/source/2_2_release_notes.txt +435 -0
- data/doc/guides/source/actioncontroller_basics/changelog.txt +5 -0
- data/doc/guides/source/actioncontroller_basics/cookies.txt +34 -0
- data/doc/guides/source/actioncontroller_basics/csrf.txt +32 -0
- data/doc/guides/source/actioncontroller_basics/filters.txt +119 -0
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +24 -0
- data/doc/guides/source/actioncontroller_basics/index.txt +40 -0
- data/doc/guides/source/actioncontroller_basics/introduction.txt +9 -0
- data/doc/guides/source/actioncontroller_basics/methods.txt +39 -0
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +14 -0
- data/doc/guides/source/actioncontroller_basics/params.txt +93 -0
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +43 -0
- data/doc/guides/source/actioncontroller_basics/rescue.txt +67 -0
- data/doc/guides/source/actioncontroller_basics/session.txt +187 -0
- data/doc/guides/source/actioncontroller_basics/streaming.txt +91 -0
- data/doc/guides/source/actioncontroller_basics/verification.txt +40 -0
- data/doc/guides/source/active_record_basics.txt +181 -0
- data/doc/guides/source/activerecord_validations_callbacks.txt +404 -0
- data/doc/guides/source/association_basics.txt +1840 -0
- data/doc/guides/source/authors.txt +39 -0
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +95 -0
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +105 -0
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +185 -0
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +27 -0
- data/doc/guides/source/benchmarking_and_profiling/index.txt +242 -0
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +179 -0
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +57 -0
- data/doc/guides/source/caching_with_rails.txt +367 -0
- data/doc/guides/source/command_line.txt +147 -0
- data/doc/guides/source/configuring.txt +225 -0
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +191 -0
- data/doc/guides/source/creating_plugins/appendix.txt +46 -0
- data/doc/guides/source/creating_plugins/controllers.txt +59 -0
- data/doc/guides/source/creating_plugins/core_ext.txt +123 -0
- data/doc/guides/source/creating_plugins/custom_route.txt +69 -0
- data/doc/guides/source/creating_plugins/gem.txt +1 -0
- data/doc/guides/source/creating_plugins/generator_method.txt +89 -0
- data/doc/guides/source/creating_plugins/helpers.txt +51 -0
- data/doc/guides/source/creating_plugins/index.txt +52 -0
- data/doc/guides/source/creating_plugins/migration_generator.txt +156 -0
- data/doc/guides/source/creating_plugins/models.txt +76 -0
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +69 -0
- data/doc/guides/source/creating_plugins/test_setup.txt +230 -0
- data/doc/guides/source/debugging_rails_applications.txt +733 -0
- data/doc/guides/source/finders.txt +668 -0
- data/doc/guides/source/form_helpers.txt +345 -0
- data/doc/guides/source/getting_started_with_rails.txt +1256 -0
- data/doc/guides/source/images/belongs_to.png +0 -0
- data/doc/guides/source/images/bullet.gif +0 -0
- data/doc/guides/source/images/csrf.png +0 -0
- data/doc/guides/source/images/habtm.png +0 -0
- data/doc/guides/source/images/has_many.png +0 -0
- data/doc/guides/source/images/has_many_through.png +0 -0
- data/doc/guides/source/images/has_one.png +0 -0
- data/doc/guides/source/images/has_one_through.png +0 -0
- data/doc/guides/source/images/header_backdrop.png +0 -0
- data/doc/guides/source/images/icons/README +5 -0
- data/doc/guides/source/images/icons/callouts/1.png +0 -0
- data/doc/guides/source/images/icons/callouts/10.png +0 -0
- data/doc/guides/source/images/icons/callouts/11.png +0 -0
- data/doc/guides/source/images/icons/callouts/12.png +0 -0
- data/doc/guides/source/images/icons/callouts/13.png +0 -0
- data/doc/guides/source/images/icons/callouts/14.png +0 -0
- data/doc/guides/source/images/icons/callouts/15.png +0 -0
- data/doc/guides/source/images/icons/callouts/2.png +0 -0
- data/doc/guides/source/images/icons/callouts/3.png +0 -0
- data/doc/guides/source/images/icons/callouts/4.png +0 -0
- data/doc/guides/source/images/icons/callouts/5.png +0 -0
- data/doc/guides/source/images/icons/callouts/6.png +0 -0
- data/doc/guides/source/images/icons/callouts/7.png +0 -0
- data/doc/guides/source/images/icons/callouts/8.png +0 -0
- data/doc/guides/source/images/icons/callouts/9.png +0 -0
- data/doc/guides/source/images/icons/caution.png +0 -0
- data/doc/guides/source/images/icons/example.png +0 -0
- data/doc/guides/source/images/icons/home.png +0 -0
- data/doc/guides/source/images/icons/important.png +0 -0
- data/doc/guides/source/images/icons/next.png +0 -0
- data/doc/guides/source/images/icons/note.png +0 -0
- data/doc/guides/source/images/icons/prev.png +0 -0
- data/doc/guides/source/images/icons/tip.png +0 -0
- data/doc/guides/source/images/icons/up.png +0 -0
- data/doc/guides/source/images/icons/warning.png +0 -0
- data/doc/guides/source/images/polymorphic.png +0 -0
- data/doc/guides/source/images/rails_logo_remix.gif +0 -0
- data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
- data/doc/guides/source/images/session_fixation.png +0 -0
- data/doc/guides/source/index.txt +118 -0
- data/doc/guides/source/layouts_and_rendering.txt +982 -0
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +85 -0
- data/doc/guides/source/migrations/changelog.txt +5 -0
- data/doc/guides/source/migrations/creating_a_migration.txt +109 -0
- data/doc/guides/source/migrations/foreign_keys.txt +8 -0
- data/doc/guides/source/migrations/index.txt +22 -0
- data/doc/guides/source/migrations/rakeing_around.txt +111 -0
- data/doc/guides/source/migrations/scheming.txt +47 -0
- data/doc/guides/source/migrations/using_models_in_migrations.txt +46 -0
- data/doc/guides/source/migrations/writing_a_migration.txt +159 -0
- data/doc/guides/source/routing_outside_in.txt +986 -0
- data/doc/guides/source/security.txt +984 -0
- data/doc/guides/source/stylesheets/base.css +358 -0
- data/doc/guides/source/stylesheets/forms.css +35 -0
- data/doc/guides/source/stylesheets/more.css +82 -0
- data/doc/guides/source/templates/guides.html.erb +97 -0
- data/doc/guides/source/templates/inline.css +165 -0
- data/doc/guides/source/testing_rails_applications.txt +995 -0
- data/environments/boot.rb +2 -2
- data/environments/environment.rb +9 -1
- data/environments/production.rb +3 -1
- data/helpers/performance_test.rb +9 -0
- data/html/500.html +4 -1
- data/html/javascripts/controls.js +72 -72
- data/html/javascripts/dragdrop.js +165 -164
- data/html/javascripts/effects.js +173 -165
- data/html/javascripts/prototype.js +362 -267
- data/lib/commands/console.rb +13 -0
- data/lib/commands/dbconsole.rb +2 -2
- data/lib/commands/ncgi/listener +2 -2
- data/lib/commands/ncgi/tracker +2 -2
- data/lib/commands/plugin.rb +41 -24
- data/lib/commands/process/spawner.rb +4 -4
- data/lib/commands/runner.rb +1 -1
- data/lib/commands/server.rb +11 -1
- data/lib/commands/servers/thin.rb +25 -0
- data/lib/fcgi_handler.rb +1 -3
- data/lib/initializer.rb +162 -39
- data/lib/performance_test_help.rb +5 -0
- data/lib/rails/gem_builder.rb +3 -3
- data/lib/rails/gem_dependency.rb +155 -33
- data/lib/rails/mongrel_server/commands.rb +1 -1
- data/lib/rails/plugin.rb +10 -2
- data/lib/rails/rack.rb +6 -0
- data/lib/rails/rack/logger.rb +28 -0
- data/lib/rails/rack/static.rb +35 -0
- data/lib/rails/vendor_gem_source_index.rb +140 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails_generator/commands.rb +10 -16
- data/lib/rails_generator/generated_attribute.rb +4 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +9 -3
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -1
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -1
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +1 -1
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +2 -2
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +1 -1
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +2 -3
- data/lib/rails_generator/generators/components/model/model_generator.rb +1 -1
- data/lib/rails_generator/generators/components/model/templates/model.rb +3 -0
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -1
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +1 -1
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +1 -1
- data/lib/rails_generator/generators/components/performance_test/USAGE +8 -0
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +16 -0
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +9 -0
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +11 -11
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +3 -0
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +4 -4
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +1 -1
- data/lib/rails_generator/generators/components/scaffold/USAGE +9 -5
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -3
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +7 -7
- data/lib/rails_generator/scripts.rb +1 -1
- data/lib/rails_generator/scripts/destroy.rb +6 -7
- data/lib/rails_generator/secret_key_generator.rb +5 -147
- data/lib/tasks/annotations.rake +8 -11
- data/lib/tasks/databases.rake +42 -15
- data/lib/tasks/documentation.rake +15 -0
- data/lib/tasks/framework.rake +5 -1
- data/lib/tasks/gems.rake +24 -8
- data/lib/tasks/misc.rake +3 -4
- data/lib/tasks/testing.rake +25 -4
- data/lib/test_help.rb +1 -2
- data/lib/webrick_server.rb +2 -11
- metadata +165 -9
@@ -45,7 +45,7 @@ module Rails
|
|
45
45
|
usage = "\nInstalled Generators\n"
|
46
46
|
Rails::Generator::Base.sources.inject([]) do |mem, source|
|
47
47
|
# Using an association list instead of a hash to preserve order,
|
48
|
-
# for
|
48
|
+
# for aesthetic reasons more than anything else.
|
49
49
|
label = source.label.to_s.capitalize
|
50
50
|
pair = mem.assoc(label)
|
51
51
|
mem << (pair = [label, []]) if pair.nil?
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../scripts'
|
|
3
3
|
module Rails::Generator::Scripts
|
4
4
|
class Destroy < Base
|
5
5
|
mandatory_options :command => :destroy
|
6
|
-
|
6
|
+
|
7
7
|
protected
|
8
8
|
def usage_message
|
9
9
|
usage = "\nInstalled Generators\n"
|
@@ -15,14 +15,13 @@ module Rails::Generator::Scripts
|
|
15
15
|
|
16
16
|
usage << <<end_blurb
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
script/destroy scaffold Post will delete the posts controller and
|
18
|
+
script/generate command. For instance, 'script/destroy migration CreatePost'
|
19
|
+
will delete the appropriate XXX_create_post.rb migration file in db/migrate,
|
20
|
+
while 'script/destroy scaffold Post' will delete the posts controller and
|
22
21
|
views, post model and migration, all associated tests, and the map.resources
|
23
22
|
:posts line in config/routes.rb.
|
24
|
-
|
25
|
-
For instructions on finding new generators, run script/generate
|
23
|
+
|
24
|
+
For instructions on finding new generators, run script/generate.
|
26
25
|
end_blurb
|
27
26
|
return usage
|
28
27
|
end
|
@@ -5,160 +5,18 @@ module Rails
|
|
5
5
|
#
|
6
6
|
# generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name")
|
7
7
|
# generator.generate_secret # => "f3f1be90053fa851... (some long string)"
|
8
|
+
#
|
9
|
+
# This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom.
|
10
|
+
# It is currently a wrapper around ActiveSupport::SecureRandom.
|
8
11
|
class SecretKeyGenerator
|
9
|
-
GENERATORS = [ :secure_random, :win32_api, :urandom, :openssl, :prng ].freeze
|
10
|
-
|
11
12
|
def initialize(identifier)
|
12
|
-
@identifier = identifier
|
13
13
|
end
|
14
14
|
|
15
15
|
# Generate a random secret key with the best possible method available on
|
16
16
|
# the current platform.
|
17
17
|
def generate_secret
|
18
|
-
|
19
|
-
self.class.send("supports_#{g}?")
|
20
|
-
end
|
21
|
-
send("generate_secret_with_#{generator}")
|
22
|
-
end
|
23
|
-
|
24
|
-
# Generate a random secret key by using the Win32 API. Raises LoadError
|
25
|
-
# if the current platform cannot make use of the Win32 API. Raises
|
26
|
-
# SystemCallError if some other error occured.
|
27
|
-
def generate_secret_with_win32_api
|
28
|
-
# Following code is based on David Garamond's GUID library for Ruby.
|
29
|
-
require 'Win32API'
|
30
|
-
|
31
|
-
crypt_acquire_context = Win32API.new("advapi32", "CryptAcquireContext",
|
32
|
-
'PPPII', 'L')
|
33
|
-
crypt_gen_random = Win32API.new("advapi32", "CryptGenRandom",
|
34
|
-
'LIP', 'L')
|
35
|
-
crypt_release_context = Win32API.new("advapi32", "CryptReleaseContext",
|
36
|
-
'LI', 'L')
|
37
|
-
prov_rsa_full = 1
|
38
|
-
crypt_verifycontext = 0xF0000000
|
39
|
-
|
40
|
-
hProvStr = " " * 4
|
41
|
-
if crypt_acquire_context.call(hProvStr, nil, nil, prov_rsa_full,
|
42
|
-
crypt_verifycontext) == 0
|
43
|
-
raise SystemCallError, "CryptAcquireContext failed: #{lastWin32ErrorMessage}"
|
44
|
-
end
|
45
|
-
hProv, = hProvStr.unpack('L')
|
46
|
-
bytes = " " * 64
|
47
|
-
if crypt_gen_random.call(hProv, bytes.size, bytes) == 0
|
48
|
-
raise SystemCallError, "CryptGenRandom failed: #{lastWin32ErrorMessage}"
|
49
|
-
end
|
50
|
-
if crypt_release_context.call(hProv, 0) == 0
|
51
|
-
raise SystemCallError, "CryptReleaseContext failed: #{lastWin32ErrorMessage}"
|
52
|
-
end
|
53
|
-
bytes.unpack("H*")[0]
|
54
|
-
end
|
55
|
-
|
56
|
-
# Generate a random secret key with Ruby 1.9's SecureRandom module.
|
57
|
-
# Raises LoadError if the current Ruby version does not support
|
58
|
-
# SecureRandom.
|
59
|
-
def generate_secret_with_secure_random
|
60
|
-
require 'securerandom'
|
61
|
-
return SecureRandom.hex(64)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Generate a random secret key with OpenSSL. If OpenSSL is not
|
65
|
-
# already loaded, then this method will attempt to load it.
|
66
|
-
# LoadError will be raised if that fails.
|
67
|
-
def generate_secret_with_openssl
|
68
|
-
require 'openssl'
|
69
|
-
if !File.exist?("/dev/urandom")
|
70
|
-
# OpenSSL transparently seeds the random number generator with
|
71
|
-
# data from /dev/urandom. On platforms where that is not
|
72
|
-
# available, such as Windows, we have to provide OpenSSL with
|
73
|
-
# our own seed. Unfortunately there's no way to provide a
|
74
|
-
# secure seed without OS support, so we'll have to do with
|
75
|
-
# rand() and Time.now.usec().
|
76
|
-
OpenSSL::Random.seed(rand(0).to_s + Time.now.usec.to_s)
|
77
|
-
end
|
78
|
-
data = OpenSSL::BN.rand(2048, -1, false).to_s
|
79
|
-
|
80
|
-
if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00908000
|
81
|
-
OpenSSL::Digest::SHA512.new(data).hexdigest
|
82
|
-
else
|
83
|
-
generate_secret_with_prng
|
84
|
-
end
|
18
|
+
ActiveSupport::SecureRandom.hex(64)
|
85
19
|
end
|
86
|
-
|
87
|
-
# Generate a random secret key with /dev/urandom.
|
88
|
-
# Raises SystemCallError on failure.
|
89
|
-
def generate_secret_with_urandom
|
90
|
-
return File.read("/dev/urandom", 64).unpack("H*")[0]
|
91
|
-
end
|
92
|
-
|
93
|
-
# Generate a random secret key with Ruby's pseudo random number generator,
|
94
|
-
# as well as some environment information.
|
95
|
-
#
|
96
|
-
# This is the least cryptographically secure way to generate a secret key,
|
97
|
-
# and should be avoided whenever possible.
|
98
|
-
def generate_secret_with_prng
|
99
|
-
require 'digest/sha2'
|
100
|
-
sha = Digest::SHA2.new(512)
|
101
|
-
now = Time.now
|
102
|
-
sha << now.to_s
|
103
|
-
sha << String(now.usec)
|
104
|
-
sha << String(rand(0))
|
105
|
-
sha << String($$)
|
106
|
-
sha << @identifier
|
107
|
-
return sha.hexdigest
|
108
|
-
end
|
109
|
-
|
110
|
-
private
|
111
|
-
def lastWin32ErrorMessage
|
112
|
-
# Following code is based on David Garamond's GUID library for Ruby.
|
113
|
-
get_last_error = Win32API.new("kernel32", "GetLastError", '', 'L')
|
114
|
-
format_message = Win32API.new("kernel32", "FormatMessageA",
|
115
|
-
'LPLLPLPPPPPPPP', 'L')
|
116
|
-
format_message_ignore_inserts = 0x00000200
|
117
|
-
format_message_from_system = 0x00001000
|
118
|
-
|
119
|
-
code = get_last_error.call
|
120
|
-
msg = "\0" * 1024
|
121
|
-
len = format_message.call(format_message_ignore_inserts +
|
122
|
-
format_message_from_system, 0,
|
123
|
-
code, 0, msg, 1024, nil, nil,
|
124
|
-
nil, nil, nil, nil, nil, nil)
|
125
|
-
msg[0, len].tr("\r", '').chomp
|
126
|
-
end
|
127
|
-
|
128
|
-
def self.supports_secure_random?
|
129
|
-
begin
|
130
|
-
require 'securerandom'
|
131
|
-
true
|
132
|
-
rescue LoadError
|
133
|
-
false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def self.supports_win32_api?
|
138
|
-
return false unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
139
|
-
begin
|
140
|
-
require 'Win32API'
|
141
|
-
true
|
142
|
-
rescue LoadError
|
143
|
-
false
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def self.supports_urandom?
|
148
|
-
File.exist?('/dev/urandom')
|
149
|
-
end
|
150
|
-
|
151
|
-
def self.supports_openssl?
|
152
|
-
begin
|
153
|
-
require 'openssl'
|
154
|
-
true
|
155
|
-
rescue LoadError
|
156
|
-
false
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def self.supports_prng?
|
161
|
-
true
|
162
|
-
end
|
20
|
+
deprecate :generate_secret=>"You should use ActiveSupport::SecureRandom.hex(64)"
|
163
21
|
end
|
164
22
|
end
|
data/lib/tasks/annotations.rake
CHANGED
@@ -6,18 +6,15 @@ task :notes do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
namespace :notes do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
|
10
|
+
desc "Enumerate all #{annotation} annotations"
|
11
|
+
task annotation.downcase.intern do
|
12
|
+
SourceAnnotationExtractor.enumerate annotation
|
13
|
+
end
|
12
14
|
end
|
13
15
|
|
14
|
-
desc "Enumerate
|
15
|
-
task :
|
16
|
-
SourceAnnotationExtractor.enumerate
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "Enumerate all TODO annotations"
|
20
|
-
task :todo do
|
21
|
-
SourceAnnotationExtractor.enumerate "TODO"
|
16
|
+
desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX"
|
17
|
+
task :custom do
|
18
|
+
SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
|
22
19
|
end
|
23
20
|
end
|
data/lib/tasks/databases.rake
CHANGED
@@ -28,8 +28,24 @@ namespace :db do
|
|
28
28
|
|
29
29
|
def create_database(config)
|
30
30
|
begin
|
31
|
-
|
32
|
-
|
31
|
+
if config['adapter'] =~ /sqlite/
|
32
|
+
if File.exist?(config['database'])
|
33
|
+
$stderr.puts "#{config['database']} already exists"
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
# Create the SQLite database
|
37
|
+
ActiveRecord::Base.establish_connection(config)
|
38
|
+
ActiveRecord::Base.connection
|
39
|
+
rescue
|
40
|
+
$stderr.puts $!, *($!.backtrace)
|
41
|
+
$stderr.puts "Couldn't create database for #{config.inspect}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
return # Skip the else clause of begin/rescue
|
45
|
+
else
|
46
|
+
ActiveRecord::Base.establish_connection(config)
|
47
|
+
ActiveRecord::Base.connection
|
48
|
+
end
|
33
49
|
rescue
|
34
50
|
case config['adapter']
|
35
51
|
when 'mysql'
|
@@ -52,10 +68,6 @@ namespace :db do
|
|
52
68
|
$stderr.puts $!, *($!.backtrace)
|
53
69
|
$stderr.puts "Couldn't create database for #{config.inspect}"
|
54
70
|
end
|
55
|
-
when 'sqlite'
|
56
|
-
`sqlite "#{config['database']}"`
|
57
|
-
when 'sqlite3'
|
58
|
-
`sqlite3 "#{config['database']}"`
|
59
71
|
end
|
60
72
|
else
|
61
73
|
$stderr.puts "#{config['database']} already exists"
|
@@ -101,8 +113,16 @@ namespace :db do
|
|
101
113
|
end
|
102
114
|
|
103
115
|
namespace :migrate do
|
104
|
-
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x'
|
105
|
-
task :redo =>
|
116
|
+
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
|
117
|
+
task :redo => :environment do
|
118
|
+
if ENV["VERSION"]
|
119
|
+
Rake::Task["db:migrate:down"].invoke
|
120
|
+
Rake::Task["db:migrate:up"].invoke
|
121
|
+
else
|
122
|
+
Rake::Task["db:rollback"].invoke
|
123
|
+
Rake::Task["db:migrate"].invoke
|
124
|
+
end
|
125
|
+
end
|
106
126
|
|
107
127
|
desc 'Resets your database using your migrations for the current environment'
|
108
128
|
task :reset => ["db:drop", "db:create", "db:migrate"]
|
@@ -141,6 +161,9 @@ namespace :db do
|
|
141
161
|
when 'mysql'
|
142
162
|
ActiveRecord::Base.establish_connection(config)
|
143
163
|
puts ActiveRecord::Base.connection.charset
|
164
|
+
when 'postgresql'
|
165
|
+
ActiveRecord::Base.establish_connection(config)
|
166
|
+
puts ActiveRecord::Base.connection.encoding
|
144
167
|
else
|
145
168
|
puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
|
146
169
|
end
|
@@ -179,16 +202,19 @@ namespace :db do
|
|
179
202
|
end
|
180
203
|
|
181
204
|
namespace :fixtures do
|
182
|
-
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
205
|
+
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
183
206
|
task :load => :environment do
|
184
207
|
require 'active_record/fixtures'
|
185
|
-
ActiveRecord::Base.establish_connection(
|
186
|
-
|
187
|
-
|
208
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
209
|
+
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
210
|
+
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
211
|
+
|
212
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
213
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
188
214
|
end
|
189
215
|
end
|
190
216
|
|
191
|
-
desc "Search for a fixture given a LABEL or ID."
|
217
|
+
desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
192
218
|
task :identify => :environment do
|
193
219
|
require "active_record/fixtures"
|
194
220
|
|
@@ -197,7 +223,8 @@ namespace :db do
|
|
197
223
|
|
198
224
|
puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
|
199
225
|
|
200
|
-
|
226
|
+
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
227
|
+
Dir["#{base_dir}/**/*.yml"].each do |file|
|
201
228
|
if data = YAML::load(ERB.new(IO.read(file)).result)
|
202
229
|
data.keys.each do |key|
|
203
230
|
key_id = Fixtures.identify(key)
|
@@ -314,7 +341,7 @@ namespace :db do
|
|
314
341
|
case abcs["test"]["adapter"]
|
315
342
|
when "mysql"
|
316
343
|
ActiveRecord::Base.establish_connection(:test)
|
317
|
-
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
|
344
|
+
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
|
318
345
|
when "postgresql"
|
319
346
|
ActiveRecord::Base.clear_active_connections!
|
320
347
|
drop_database(abcs['test'])
|
@@ -52,9 +52,23 @@ namespace :doc do
|
|
52
52
|
rm_rf 'doc/plugins' rescue nil
|
53
53
|
end
|
54
54
|
|
55
|
+
desc "Generate Rails guides"
|
56
|
+
task :guides do
|
57
|
+
source = File.join(RAILTIES_PATH, "doc/guides")
|
58
|
+
destination = File.join(RAILS_ROOT, "doc/guides")
|
59
|
+
FileUtils.rm_r(destination) if File.directory?(destination)
|
60
|
+
FileUtils.mkdir(destination)
|
61
|
+
|
62
|
+
FileUtils.cp_r File.join(source, 'html/.'), File.join(destination)
|
63
|
+
# Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
|
64
|
+
FileUtils.cp_r File.join(source, 'source/images'), File.join(destination)
|
65
|
+
FileUtils.cp_r File.join(source, 'source/stylesheets'), File.join(destination, 'stylesheets')
|
66
|
+
end
|
67
|
+
|
55
68
|
namespace :plugins do
|
56
69
|
# Define doc tasks for each plugin
|
57
70
|
plugins.each do |plugin|
|
71
|
+
desc "Generate documentation for the #{plugin} plugin"
|
58
72
|
task(plugin => :environment) do
|
59
73
|
plugin_base = "vendor/plugins/#{plugin}"
|
60
74
|
options = []
|
@@ -62,6 +76,7 @@ namespace :doc do
|
|
62
76
|
options << "-o doc/plugins/#{plugin}"
|
63
77
|
options << "--title '#{plugin.titlecase} Plugin Documentation'"
|
64
78
|
options << '--line-numbers' << '--inline-source'
|
79
|
+
options << '--charset' << 'utf-8'
|
65
80
|
options << '-T html'
|
66
81
|
|
67
82
|
files.include("#{plugin_base}/lib/**/*.rb")
|
data/lib/tasks/framework.rake
CHANGED
@@ -5,7 +5,6 @@ namespace :rails do
|
|
5
5
|
deps = %w(actionpack activerecord actionmailer activesupport activeresource)
|
6
6
|
require 'rubygems'
|
7
7
|
require 'rubygems/gem_runner'
|
8
|
-
Gem.manage_gems
|
9
8
|
|
10
9
|
rails = (version = ENV['VERSION']) ?
|
11
10
|
Gem.cache.find_name('rails', "= #{version}").first :
|
@@ -43,9 +42,12 @@ namespace :rails do
|
|
43
42
|
require 'open-uri'
|
44
43
|
version = ENV["RELEASE"] || "edge"
|
45
44
|
target = "rails_#{version}.zip"
|
45
|
+
commits = "http://github.com/api/v1/yaml/rails/rails/commits/master"
|
46
46
|
url = "http://dev.rubyonrails.org/archives/#{target}"
|
47
47
|
|
48
48
|
chdir 'vendor' do
|
49
|
+
latest_revision = YAML.load(open(commits))["commits"].first["id"]
|
50
|
+
|
49
51
|
puts "Downloading Rails from #{url}"
|
50
52
|
File.open('rails.zip', 'wb') do |dst|
|
51
53
|
open url do |src|
|
@@ -61,6 +63,8 @@ namespace :rails do
|
|
61
63
|
%w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner|
|
62
64
|
rm_f goner
|
63
65
|
end
|
66
|
+
|
67
|
+
touch "rails/REVISION_#{latest_revision}"
|
64
68
|
end
|
65
69
|
|
66
70
|
puts 'Updating current scripts, javascripts, and configuration settings'
|
data/lib/tasks/gems.rake
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
desc "List the gems that this rails application depends on"
|
2
2
|
task :gems => 'gems:base' do
|
3
3
|
Rails.configuration.gems.each do |gem|
|
4
|
-
|
5
|
-
puts "[#{code}] #{gem.name} #{gem.requirement.to_s}"
|
4
|
+
print_gem_status(gem)
|
6
5
|
end
|
7
6
|
puts
|
8
7
|
puts "I = Installed"
|
9
8
|
puts "F = Frozen"
|
9
|
+
puts "R = Framework (loaded before rails starts)"
|
10
|
+
end
|
11
|
+
|
12
|
+
def print_gem_status(gem, indent=1)
|
13
|
+
code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
|
14
|
+
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
|
15
|
+
gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
|
10
16
|
end
|
11
17
|
|
12
18
|
namespace :gems do
|
@@ -19,7 +25,7 @@ namespace :gems do
|
|
19
25
|
task :build do
|
20
26
|
$rails_gem_installer = true
|
21
27
|
require 'rails/gem_builder'
|
22
|
-
Dir[File.join(
|
28
|
+
Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir|
|
23
29
|
spec_file = File.join(gem_dir, '.specification')
|
24
30
|
next unless File.exists?(spec_file)
|
25
31
|
specification = YAML::load_file(spec_file)
|
@@ -28,7 +34,7 @@ namespace :gems do
|
|
28
34
|
puts "Built gem: '#{gem_dir}'"
|
29
35
|
end
|
30
36
|
end
|
31
|
-
|
37
|
+
|
32
38
|
desc "Installs all required gems for this application."
|
33
39
|
task :install => :base do
|
34
40
|
require 'rubygems'
|
@@ -42,10 +48,10 @@ namespace :gems do
|
|
42
48
|
require 'rubygems/gem_runner'
|
43
49
|
Rails.configuration.gems.each do |gem|
|
44
50
|
next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
45
|
-
gem.unpack_to(
|
51
|
+
gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
|
46
52
|
end
|
47
53
|
end
|
48
|
-
|
54
|
+
|
49
55
|
namespace :unpack do
|
50
56
|
desc "Unpacks the specified gems and its dependencies into vendor/gems"
|
51
57
|
task :dependencies => :unpack do
|
@@ -54,11 +60,21 @@ namespace :gems do
|
|
54
60
|
Rails.configuration.gems.each do |gem|
|
55
61
|
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
|
56
62
|
gem.dependencies.each do |dependency|
|
57
|
-
dependency.add_load_paths # double check that we have not already unpacked
|
58
63
|
next if dependency.frozen?
|
59
|
-
dependency.unpack_to(
|
64
|
+
dependency.unpack_to(Rails::GemDependency.unpacked_path)
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
69
|
+
|
70
|
+
desc "Regenerate gem specifications in correct format."
|
71
|
+
task :refresh_specs => :base do
|
72
|
+
require 'rubygems'
|
73
|
+
require 'rubygems/gem_runner'
|
74
|
+
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
75
|
+
Rails.configuration.gems.each do |gem|
|
76
|
+
next unless gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
77
|
+
gem.refresh_spec(Rails::GemDependency.unpacked_path) if gem.loaded?
|
78
|
+
end
|
79
|
+
end
|
64
80
|
end
|