rails 0.14.2 → 0.14.3
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 +83 -0
- data/README +16 -53
- data/Rakefile +10 -11
- data/bin/about +3 -0
- data/bin/plugin +3 -0
- data/configs/database.yml +65 -3
- data/configs/lighttpd.conf +40 -0
- data/environments/boot.rb +2 -2
- data/environments/environment.rb +3 -3
- data/environments/test.rb +1 -7
- data/helpers/test_helper.rb +19 -4
- data/html/javascripts/controls.js +18 -5
- data/html/javascripts/dragdrop.js +6 -3
- data/html/javascripts/effects.js +181 -290
- data/html/javascripts/prototype.js +13 -11
- data/lib/commands/about.rb +2 -0
- data/lib/commands/plugin.rb +823 -0
- data/lib/commands/process/reaper.rb +3 -3
- data/lib/commands/server.rb +23 -54
- data/lib/commands/servers/lighttpd.rb +56 -0
- data/lib/commands/servers/webrick.rb +59 -0
- data/lib/dispatcher.rb +30 -8
- data/lib/fcgi_handler.rb +6 -1
- data/lib/initializer.rb +107 -42
- data/lib/rails_generator/generators/applications/app/app_generator.rb +14 -12
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +52 -5
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +2 -2
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -5
- data/lib/rails_generator/generators/components/plugin/USAGE +33 -0
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +33 -0
- data/lib/rails_generator/generators/components/plugin/templates/README +4 -0
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
- data/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +6 -1
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +1 -1
- data/lib/rails_generator/lookup.rb +1 -0
- data/lib/rails_info.rb +94 -0
- data/lib/rails_version.rb +1 -1
- data/lib/tasks/databases.rake +8 -5
- data/lib/tasks/documentation.rake +34 -1
- data/lib/tasks/framework.rake +50 -12
- data/lib/tasks/misc.rake +5 -1
- data/lib/tasks/rails.rb +2 -2
- data/lib/tasks/testing.rake +14 -1
- metadata +28 -9
- data/html/javascripts/scriptaculous.js +0 -47
- data/html/javascripts/slider.js +0 -258
@@ -11,7 +11,7 @@ class AppGenerator < Rails::Generator::Base
|
|
11
11
|
super
|
12
12
|
usage if args.empty?
|
13
13
|
@destination_root = args.shift
|
14
|
-
@socket = MYSQL_SOCKET_LOCATIONS.find {|f| File.exists?(f) }
|
14
|
+
@socket = MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) }
|
15
15
|
@socket = '/path/to/your/mysql.sock' if @socket.blank?
|
16
16
|
end
|
17
17
|
|
@@ -26,7 +26,6 @@ class AppGenerator < Rails::Generator::Base
|
|
26
26
|
# Root
|
27
27
|
m.file "fresh_rakefile", "Rakefile"
|
28
28
|
m.file "README", "README"
|
29
|
-
m.file "CHANGELOG", "CHANGELOG"
|
30
29
|
|
31
30
|
# Application
|
32
31
|
m.template "helpers/application.rb", "app/controllers/application.rb"
|
@@ -38,8 +37,8 @@ class AppGenerator < Rails::Generator::Base
|
|
38
37
|
:app_name => File.basename(File.expand_path(@destination_root)),
|
39
38
|
:socket => @socket
|
40
39
|
}
|
41
|
-
m.template "configs/routes.rb",
|
42
|
-
m.template "configs/apache.conf",
|
40
|
+
m.template "configs/routes.rb", "config/routes.rb"
|
41
|
+
m.template "configs/apache.conf", "public/.htaccess"
|
43
42
|
|
44
43
|
# Environments
|
45
44
|
m.file "environments/boot.rb", "config/boot.rb"
|
@@ -49,7 +48,7 @@ class AppGenerator < Rails::Generator::Base
|
|
49
48
|
m.file "environments/test.rb", "config/environments/test.rb"
|
50
49
|
|
51
50
|
# Scripts
|
52
|
-
%w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server ).each do |file|
|
51
|
+
%w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin ).each do |file|
|
53
52
|
m.file "bin/#{file}", "script/#{file}", script_options
|
54
53
|
end
|
55
54
|
|
@@ -68,11 +67,9 @@ class AppGenerator < Rails::Generator::Base
|
|
68
67
|
|
69
68
|
# Javascripts
|
70
69
|
m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
|
71
|
-
m.file "html/javascripts/scriptaculous.js", "public/javascripts/scriptaculous.js"
|
72
70
|
m.file "html/javascripts/effects.js", "public/javascripts/effects.js"
|
73
71
|
m.file "html/javascripts/dragdrop.js", "public/javascripts/dragdrop.js"
|
74
72
|
m.file "html/javascripts/controls.js", "public/javascripts/controls.js"
|
75
|
-
m.file "html/javascripts/slider.js", "public/javascripts/slider.js"
|
76
73
|
|
77
74
|
# Docs
|
78
75
|
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
|
@@ -103,7 +100,6 @@ class AppGenerator < Rails::Generator::Base
|
|
103
100
|
# Installation skeleton. Intermediate directories are automatically
|
104
101
|
# created so don't sweat their absence here.
|
105
102
|
BASEDIRS = %w(
|
106
|
-
app/apis
|
107
103
|
app/controllers
|
108
104
|
app/helpers
|
109
105
|
app/models
|
@@ -129,8 +125,14 @@ class AppGenerator < Rails::Generator::Base
|
|
129
125
|
vendor/plugins
|
130
126
|
)
|
131
127
|
|
132
|
-
MYSQL_SOCKET_LOCATIONS = [
|
133
|
-
|
134
|
-
|
135
|
-
|
128
|
+
MYSQL_SOCKET_LOCATIONS = [
|
129
|
+
"/tmp/mysql.sock", # default
|
130
|
+
"/var/run/mysqld/mysqld.sock", # debian/gentoo
|
131
|
+
"/var/tmp/mysql.sock", # freebsd
|
132
|
+
"/var/lib/mysql/mysql.sock", # fedora
|
133
|
+
"/opt/local/lib/mysql/mysql.sock", # fedora
|
134
|
+
"/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
|
135
|
+
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
136
|
+
"/opt/local/var/run/mysql5/mysqld.sock" # mac + darwinports + mysql5
|
137
|
+
]
|
136
138
|
end
|
@@ -1,11 +1,58 @@
|
|
1
1
|
class MigrationGenerator < Rails::Generator::NamedBase
|
2
2
|
def manifest
|
3
3
|
record do |m|
|
4
|
-
m.directory
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
m.directory 'db/migrate'
|
5
|
+
m.migration_template 'migration.rb', 'db/migrate'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
protected
|
10
|
+
def existing_migrations(file_name)
|
11
|
+
Dir.glob("db/migrate/[0-9]*_#{file_name}.rb")
|
12
|
+
end
|
13
|
+
|
14
|
+
def migration_exists?(file_name)
|
15
|
+
not existing_migrations(file_name).empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
def current_migration_number
|
19
|
+
Dir.glob('db/migrate/[0-9]*.rb').inject(0) do |max, file_path|
|
20
|
+
n = File.basename(file_path).split('_', 2).first.to_i
|
21
|
+
if n > max then n else max end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def next_migration_number
|
26
|
+
current_migration_number + 1
|
27
|
+
end
|
28
|
+
|
29
|
+
def next_migration_string(padding = 3)
|
30
|
+
"%.#{padding}d" % next_migration_number
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Rails::Generator::Commands
|
35
|
+
# When creating, it knows to find the first available file in db/migrate and use the migration.rb template.
|
36
|
+
class Create
|
37
|
+
def migration_template(relative_source, relative_destination, template_options = {})
|
38
|
+
raise "Another migration is already named #{file_name}: #{existing_migrations(file_name).first}" if migration_exists?(file_name)
|
39
|
+
template(relative_source, "#{relative_destination}/#{next_migration_string}_#{file_name}.rb", template_options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# When deleting, it knows to delete every file named "[0-9]*_#{file_name}".
|
44
|
+
class Destroy
|
45
|
+
def migration_template(relative_source, relative_destination, template_options = {})
|
46
|
+
raise "There is no migration named #{file_name}" unless migration_exists?(file_name)
|
47
|
+
existing_migrations(file_name).each do |file_path|
|
48
|
+
file(relative_source, file_path, template_options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class List
|
54
|
+
def migration_template(relative_source, relative_destination, options = {})
|
55
|
+
logger.migration_template file_name
|
9
56
|
end
|
10
57
|
end
|
11
58
|
end
|
@@ -3,12 +3,8 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class <%= class_name %>Test < Test::Unit::TestCase
|
4
4
|
fixtures :<%= table_name %>
|
5
5
|
|
6
|
-
def setup
|
7
|
-
@<%= singular_name %> = <%= class_name %>.find(1)
|
8
|
-
end
|
9
|
-
|
10
6
|
# Replace this with your real tests.
|
11
7
|
def test_truth
|
12
|
-
assert_kind_of <%= class_name %>,
|
8
|
+
assert_kind_of <%= class_name %>, <%= table_name %>(:first)
|
13
9
|
end
|
14
10
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Description:
|
2
|
+
The plugin generator creates stubs for a new plugin.
|
3
|
+
|
4
|
+
The generator takes a plugin name as its argument. The plugin name may be
|
5
|
+
given in CamelCase or under_score and should not be suffixed with 'Plugin'.
|
6
|
+
|
7
|
+
The generator creates a plugin directory in vendor/plugins that includes
|
8
|
+
both init.rb and README files as well as lib, task, and test directories.
|
9
|
+
|
10
|
+
It's also possible to generate stub files for a generator to go with the
|
11
|
+
plugin by using --with-generator
|
12
|
+
|
13
|
+
Example:
|
14
|
+
./script/generate plugin BrowserFilters
|
15
|
+
|
16
|
+
This will create:
|
17
|
+
vendor/plugins/browser_filters/README
|
18
|
+
vendor/plugins/browser_filters/init.rb
|
19
|
+
vendor/plugins/browser_filters/lib/browser_filters.rb
|
20
|
+
vendor/plugins/browser_filters/test/browser_filters_test.rb
|
21
|
+
vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake
|
22
|
+
|
23
|
+
./script/generate plugin BrowserFilters --with-generator
|
24
|
+
|
25
|
+
This will create:
|
26
|
+
vendor/plugins/browser_filters/README
|
27
|
+
vendor/plugins/browser_filters/init.rb
|
28
|
+
vendor/plugins/browser_filters/lib/browser_filters.rb
|
29
|
+
vendor/plugins/browser_filters/test/browser_filters_test.rb
|
30
|
+
vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake
|
31
|
+
vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb
|
32
|
+
vendor/plugins/browser_filters/generators/browser_filters/USAGE
|
33
|
+
vendor/plugins/browser_filters/generators/browser_filters/templates/
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class PluginGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_reader :plugin_path
|
3
|
+
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
5
|
+
@with_generator = runtime_args.delete("--with-generator")
|
6
|
+
super
|
7
|
+
@plugin_path = "vendor/plugins/#{file_name}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def manifest
|
11
|
+
record do |m|
|
12
|
+
m.directory "#{plugin_path}/lib"
|
13
|
+
m.directory "#{plugin_path}/tasks"
|
14
|
+
m.directory "#{plugin_path}/test"
|
15
|
+
|
16
|
+
m.template 'README', "#{plugin_path}/README"
|
17
|
+
m.template 'Rakefile', "#{plugin_path}/Rakefile"
|
18
|
+
m.template 'init.rb', "#{plugin_path}/init.rb"
|
19
|
+
m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb"
|
20
|
+
m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake"
|
21
|
+
m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb"
|
22
|
+
|
23
|
+
if @with_generator
|
24
|
+
m.directory "#{plugin_path}/generators"
|
25
|
+
m.directory "#{plugin_path}/generators/#{file_name}"
|
26
|
+
m.directory "#{plugin_path}/generators/#{file_name}/templates"
|
27
|
+
|
28
|
+
m.template 'generator.rb', "#{plugin_path}/generators/#{file_name}/#{file_name}_generator.rb"
|
29
|
+
m.template 'USAGE', "#{plugin_path}/generators/#{file_name}/USAGE"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the <%= file_name %> plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the <%= file_name %> plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = '<%= class_name %>'
|
19
|
+
rdoc.options << '--line-numbers --inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
@@ -0,0 +1 @@
|
|
1
|
+
# <%= class_name %>
|
@@ -46,9 +46,14 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
46
46
|
|
47
47
|
def initialize(runtime_args, runtime_options = {})
|
48
48
|
super
|
49
|
-
|
49
|
+
|
50
|
+
# Take controller name from the next argument. Default to the pluralized model name.
|
51
|
+
@controller_name = args.shift
|
52
|
+
@controller_name ||= ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name
|
53
|
+
|
50
54
|
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
51
55
|
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
56
|
+
|
52
57
|
if @controller_class_nesting.empty?
|
53
58
|
@controller_class_name = @controller_class_name_without_nesting
|
54
59
|
else
|
@@ -12,7 +12,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
12
12
|
|
13
13
|
<% end -%>
|
14
14
|
def list<%= suffix %>
|
15
|
-
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%=
|
15
|
+
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
|
16
16
|
end
|
17
17
|
|
18
18
|
def show<%= suffix %>
|
@@ -99,6 +99,7 @@ module Rails
|
|
99
99
|
def use_component_sources!
|
100
100
|
reset_sources
|
101
101
|
sources << PathSource.new(:app, "#{::RAILS_ROOT}/lib/generators") if defined? ::RAILS_ROOT
|
102
|
+
sources << PathSource.new(:plugins, "#{::RAILS_ROOT}/vendor/plugins/**/generators") if defined? ::RAILS_ROOT
|
102
103
|
sources << PathSource.new(:user, "#{Dir.user_home}/.rails/generators")
|
103
104
|
sources << GemSource.new if Object.const_defined?(:Gem)
|
104
105
|
sources << PathSource.new(:builtin, "#{File.dirname(__FILE__)}/generators/components")
|
data/lib/rails_info.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'rails_version'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Info
|
5
|
+
mattr_accessor :properties
|
6
|
+
class << (@@properties = [])
|
7
|
+
def names
|
8
|
+
map {|(name, )| name}
|
9
|
+
end
|
10
|
+
|
11
|
+
def value_for(property_name)
|
12
|
+
find {|(name, )| name == property_name}.last rescue nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self #:nodoc:
|
17
|
+
def property(name, value = nil)
|
18
|
+
value ||= yield
|
19
|
+
properties << [name, value] if value
|
20
|
+
rescue Exception
|
21
|
+
end
|
22
|
+
|
23
|
+
def components
|
24
|
+
%w( active_record action_pack action_web_service action_mailer active_support )
|
25
|
+
end
|
26
|
+
|
27
|
+
def component_version(component)
|
28
|
+
require "#{component}/version"
|
29
|
+
"#{component.classify}::Version::STRING".constantize
|
30
|
+
end
|
31
|
+
|
32
|
+
def edge_rails_revision(info = svn_info)
|
33
|
+
info[/^Revision: (\d+)/, 1]
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
column_width = properties.names.map {|name| name.length}.max
|
38
|
+
["About your application's environment", *properties.map do |property|
|
39
|
+
"%-#{column_width}s %s" % property
|
40
|
+
end] * "\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
alias inspect to_s
|
44
|
+
|
45
|
+
protected
|
46
|
+
def svn_info
|
47
|
+
Dir.chdir("#{RAILS_ROOT}/vendor/rails") do
|
48
|
+
silence_stderr { `svn info` }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)".
|
54
|
+
property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})"
|
55
|
+
|
56
|
+
# The RubyGems version, if it's installed.
|
57
|
+
property 'RubyGems version' do
|
58
|
+
Gem::RubyGemsVersion
|
59
|
+
end
|
60
|
+
|
61
|
+
# The Rails version.
|
62
|
+
property 'Rails version' do
|
63
|
+
Rails::Version::STRING
|
64
|
+
end
|
65
|
+
|
66
|
+
# Versions of each Rails component (Active Record, Action Pack,
|
67
|
+
# Action Web Service, Action Mailer, and Active Support).
|
68
|
+
components.each do |component|
|
69
|
+
property "#{component.titlecase} version" do
|
70
|
+
component_version(component)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# The Rails SVN revision, if it's checked out into vendor/rails.
|
75
|
+
property 'Edge Rails revision' do
|
76
|
+
edge_rails_revision
|
77
|
+
end
|
78
|
+
|
79
|
+
# The application's location on the filesystem.
|
80
|
+
property 'Application root' do
|
81
|
+
File.expand_path(RAILS_ROOT)
|
82
|
+
end
|
83
|
+
|
84
|
+
# The current Rails environment (development, test, or production).
|
85
|
+
property 'Environment' do
|
86
|
+
RAILS_ENV
|
87
|
+
end
|
88
|
+
|
89
|
+
# The name of the database adapter for the current environment.
|
90
|
+
property 'Database adapter' do
|
91
|
+
ActiveRecord::Base.configurations[RAILS_ENV]['adapter']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|