rails 2.2.2 → 3.0.0
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/bin/rails +8 -18
- metadata +118 -452
- data/CHANGELOG +0 -2071
- data/MIT-LICENSE +0 -20
- data/README +0 -256
- data/Rakefile +0 -411
- data/bin/about +0 -4
- data/bin/console +0 -3
- data/bin/dbconsole +0 -3
- data/bin/destroy +0 -3
- data/bin/generate +0 -3
- data/bin/performance/benchmarker +0 -3
- data/bin/performance/profiler +0 -3
- data/bin/performance/request +0 -3
- data/bin/plugin +0 -3
- data/bin/process/inspector +0 -3
- data/bin/process/reaper +0 -3
- data/bin/process/spawner +0 -3
- data/bin/runner +0 -3
- data/bin/server +0 -3
- data/builtin/rails_info/rails/info.rb +0 -125
- data/builtin/rails_info/rails/info_controller.rb +0 -9
- data/builtin/rails_info/rails/info_helper.rb +0 -2
- data/builtin/rails_info/rails_info_controller.rb +0 -2
- data/config.ru +0 -17
- data/configs/apache.conf +0 -40
- data/configs/databases/frontbase.yml +0 -28
- data/configs/databases/ibm_db.yml +0 -62
- data/configs/databases/mysql.yml +0 -57
- data/configs/databases/oracle.yml +0 -39
- data/configs/databases/postgresql.yml +0 -51
- data/configs/databases/sqlite2.yml +0 -19
- data/configs/databases/sqlite3.yml +0 -22
- data/configs/empty.log +0 -0
- data/configs/initializers/inflections.rb +0 -10
- data/configs/initializers/mime_types.rb +0 -5
- data/configs/initializers/new_rails_defaults.rb +0 -17
- data/configs/lighttpd.conf +0 -54
- data/configs/locales/en.yml +0 -5
- data/configs/routes.rb +0 -43
- data/dispatches/dispatch.fcgi +0 -24
- data/dispatches/dispatch.rb +0 -10
- data/dispatches/gateway.cgi +0 -97
- data/doc/README_FOR_APP +0 -5
- data/doc/guides/html/2_2_release_notes.html +0 -1185
- data/doc/guides/html/actioncontroller_basics.html +0 -1270
- data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
- data/doc/guides/html/association_basics.html +0 -2585
- data/doc/guides/html/authors.html +0 -240
- data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
- data/doc/guides/html/caching_with_rails.html +0 -583
- data/doc/guides/html/command_line.html +0 -434
- data/doc/guides/html/configuring.html +0 -438
- data/doc/guides/html/creating_plugins.html +0 -1594
- data/doc/guides/html/debugging_rails_applications.html +0 -1175
- data/doc/guides/html/finders.html +0 -1090
- data/doc/guides/html/form_helpers.html +0 -638
- data/doc/guides/html/getting_started_with_rails.html +0 -2066
- data/doc/guides/html/index.html +0 -349
- data/doc/guides/html/layouts_and_rendering.html +0 -1406
- data/doc/guides/html/migrations.html +0 -921
- data/doc/guides/html/routing_outside_in.html +0 -2213
- data/doc/guides/html/security.html +0 -1346
- data/doc/guides/html/testing_rails_applications.html +0 -1859
- data/doc/guides/source/2_2_release_notes.txt +0 -435
- data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
- data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
- data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
- data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
- data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
- data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
- data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
- data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
- data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
- data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
- data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
- data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
- data/doc/guides/source/active_record_basics.txt +0 -181
- data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
- data/doc/guides/source/association_basics.txt +0 -1840
- data/doc/guides/source/authors.txt +0 -39
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
- data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
- data/doc/guides/source/caching_with_rails.txt +0 -367
- data/doc/guides/source/command_line.txt +0 -147
- data/doc/guides/source/configuring.txt +0 -225
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
- data/doc/guides/source/creating_plugins/appendix.txt +0 -46
- data/doc/guides/source/creating_plugins/controllers.txt +0 -59
- data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
- data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
- data/doc/guides/source/creating_plugins/gem.txt +0 -1
- data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
- data/doc/guides/source/creating_plugins/helpers.txt +0 -51
- data/doc/guides/source/creating_plugins/index.txt +0 -52
- data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
- data/doc/guides/source/creating_plugins/models.txt +0 -76
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
- data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
- data/doc/guides/source/debugging_rails_applications.txt +0 -733
- data/doc/guides/source/finders.txt +0 -668
- data/doc/guides/source/form_helpers.txt +0 -345
- data/doc/guides/source/getting_started_with_rails.txt +0 -1256
- 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 +0 -5
- 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 +0 -118
- data/doc/guides/source/layouts_and_rendering.txt +0 -982
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
- data/doc/guides/source/migrations/changelog.txt +0 -5
- data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
- data/doc/guides/source/migrations/foreign_keys.txt +0 -8
- data/doc/guides/source/migrations/index.txt +0 -22
- data/doc/guides/source/migrations/rakeing_around.txt +0 -111
- data/doc/guides/source/migrations/scheming.txt +0 -47
- data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
- data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
- data/doc/guides/source/routing_outside_in.txt +0 -986
- data/doc/guides/source/security.txt +0 -984
- data/doc/guides/source/stylesheets/base.css +0 -358
- data/doc/guides/source/stylesheets/forms.css +0 -35
- data/doc/guides/source/stylesheets/more.css +0 -82
- data/doc/guides/source/templates/guides.html.erb +0 -97
- data/doc/guides/source/templates/inline.css +0 -165
- data/doc/guides/source/testing_rails_applications.txt +0 -995
- data/environments/boot.rb +0 -109
- data/environments/development.rb +0 -17
- data/environments/environment.rb +0 -75
- data/environments/production.rb +0 -24
- data/environments/test.rb +0 -22
- data/fresh_rakefile +0 -10
- data/helpers/application.rb +0 -15
- data/helpers/application_helper.rb +0 -3
- data/helpers/performance_test.rb +0 -9
- data/helpers/test_helper.rb +0 -38
- data/html/404.html +0 -30
- data/html/422.html +0 -30
- data/html/500.html +0 -33
- data/html/favicon.ico +0 -0
- data/html/images/rails.png +0 -0
- data/html/index.html +0 -274
- data/html/javascripts/application.js +0 -2
- data/html/javascripts/controls.js +0 -963
- data/html/javascripts/dragdrop.js +0 -973
- data/html/javascripts/effects.js +0 -1128
- data/html/javascripts/prototype.js +0 -4320
- data/html/robots.txt +0 -5
- data/lib/code_statistics.rb +0 -107
- data/lib/commands.rb +0 -17
- data/lib/commands/about.rb +0 -3
- data/lib/commands/console.rb +0 -45
- data/lib/commands/dbconsole.rb +0 -67
- data/lib/commands/destroy.rb +0 -6
- data/lib/commands/generate.rb +0 -6
- data/lib/commands/ncgi/listener +0 -86
- data/lib/commands/ncgi/tracker +0 -69
- data/lib/commands/performance/benchmarker.rb +0 -24
- data/lib/commands/performance/profiler.rb +0 -50
- data/lib/commands/performance/request.rb +0 -6
- data/lib/commands/plugin.rb +0 -967
- data/lib/commands/process/inspector.rb +0 -68
- data/lib/commands/process/reaper.rb +0 -149
- data/lib/commands/process/spawner.rb +0 -219
- data/lib/commands/process/spinner.rb +0 -57
- data/lib/commands/runner.rb +0 -48
- data/lib/commands/server.rb +0 -49
- data/lib/commands/servers/base.rb +0 -31
- data/lib/commands/servers/lighttpd.rb +0 -94
- data/lib/commands/servers/mongrel.rb +0 -69
- data/lib/commands/servers/new_mongrel.rb +0 -16
- data/lib/commands/servers/thin.rb +0 -25
- data/lib/commands/servers/webrick.rb +0 -66
- data/lib/commands/update.rb +0 -4
- data/lib/console_app.rb +0 -30
- data/lib/console_sandbox.rb +0 -6
- data/lib/console_with_helpers.rb +0 -26
- data/lib/dispatcher.rb +0 -24
- data/lib/fcgi_handler.rb +0 -237
- data/lib/initializer.rb +0 -1038
- data/lib/performance_test_help.rb +0 -5
- data/lib/rails/gem_builder.rb +0 -21
- data/lib/rails/gem_dependency.rb +0 -251
- data/lib/rails/mongrel_server/commands.rb +0 -342
- data/lib/rails/mongrel_server/handler.rb +0 -55
- data/lib/rails/plugin.rb +0 -124
- data/lib/rails/plugin/loader.rb +0 -152
- data/lib/rails/plugin/locator.rb +0 -100
- data/lib/rails/rack.rb +0 -6
- data/lib/rails/rack/logger.rb +0 -28
- data/lib/rails/rack/static.rb +0 -35
- data/lib/rails/vendor_gem_source_index.rb +0 -140
- data/lib/rails/version.rb +0 -9
- data/lib/rails_generator.rb +0 -43
- data/lib/rails_generator/base.rb +0 -263
- data/lib/rails_generator/commands.rb +0 -616
- data/lib/rails_generator/generated_attribute.rb +0 -46
- data/lib/rails_generator/generators/applications/app/USAGE +0 -9
- data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -184
- data/lib/rails_generator/generators/components/controller/USAGE +0 -29
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -37
- data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
- data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
- data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
- data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
- data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
- data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
- data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
- data/lib/rails_generator/generators/components/migration/USAGE +0 -29
- data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
- data/lib/rails_generator/generators/components/model/USAGE +0 -27
- data/lib/rails_generator/generators/components/model/model_generator.rb +0 -45
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -19
- data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
- data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
- data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/observer/USAGE +0 -13
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
- data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
- data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
- data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
- data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
- data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
- data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
- data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
- data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
- data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -3
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
- data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/USAGE +0 -23
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -74
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -100
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -85
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
- data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
- data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
- data/lib/rails_generator/lookup.rb +0 -249
- data/lib/rails_generator/manifest.rb +0 -53
- data/lib/rails_generator/options.rb +0 -150
- data/lib/rails_generator/scripts.rb +0 -89
- data/lib/rails_generator/scripts/destroy.rb +0 -29
- data/lib/rails_generator/scripts/generate.rb +0 -7
- data/lib/rails_generator/scripts/update.rb +0 -12
- data/lib/rails_generator/secret_key_generator.rb +0 -22
- data/lib/rails_generator/simple_logger.rb +0 -46
- data/lib/rails_generator/spec.rb +0 -44
- data/lib/railties_path.rb +0 -1
- data/lib/ruby_version_check.rb +0 -17
- data/lib/rubyprof_ext.rb +0 -35
- data/lib/source_annotation_extractor.rb +0 -102
- data/lib/tasks/annotations.rake +0 -20
- data/lib/tasks/databases.rake +0 -416
- data/lib/tasks/documentation.rake +0 -95
- data/lib/tasks/framework.rake +0 -118
- data/lib/tasks/gems.rake +0 -80
- data/lib/tasks/log.rake +0 -9
- data/lib/tasks/misc.rake +0 -56
- data/lib/tasks/rails.rb +0 -8
- data/lib/tasks/routes.rake +0 -17
- data/lib/tasks/statistics.rake +0 -18
- data/lib/tasks/testing.rake +0 -139
- data/lib/tasks/tmp.rake +0 -37
- data/lib/test_help.rb +0 -27
- data/lib/webrick_server.rb +0 -156
@@ -1,50 +0,0 @@
|
|
1
|
-
if ARGV.empty?
|
2
|
-
$stderr.puts "Usage: ./script/performance/profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]"
|
3
|
-
exit(1)
|
4
|
-
end
|
5
|
-
|
6
|
-
# Keep the expensive require out of the profile.
|
7
|
-
$stderr.puts 'Loading Rails...'
|
8
|
-
require RAILS_ROOT + '/config/environment'
|
9
|
-
|
10
|
-
# Define a method to profile.
|
11
|
-
if ARGV[1] and ARGV[1].to_i > 1
|
12
|
-
eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
|
13
|
-
else
|
14
|
-
eval "def profile_me() #{ARGV[0]} end"
|
15
|
-
end
|
16
|
-
|
17
|
-
# Use the ruby-prof extension if available. Fall back to stdlib profiler.
|
18
|
-
begin
|
19
|
-
begin
|
20
|
-
require "ruby-prof"
|
21
|
-
$stderr.puts 'Using the ruby-prof extension.'
|
22
|
-
RubyProf.measure_mode = RubyProf::WALL_TIME
|
23
|
-
RubyProf.start
|
24
|
-
profile_me
|
25
|
-
results = RubyProf.stop
|
26
|
-
if ARGV[2]
|
27
|
-
printer_class = RubyProf.const_get((ARGV[2] + "_printer").classify)
|
28
|
-
else
|
29
|
-
printer_class = RubyProf::FlatPrinter
|
30
|
-
end
|
31
|
-
printer = printer_class.new(results)
|
32
|
-
printer.print($stderr, 0)
|
33
|
-
rescue LoadError
|
34
|
-
require "prof"
|
35
|
-
$stderr.puts 'Using the old ruby-prof extension.'
|
36
|
-
Prof.clock_mode = Prof::GETTIMEOFDAY
|
37
|
-
Prof.start
|
38
|
-
profile_me
|
39
|
-
results = Prof.stop
|
40
|
-
require 'rubyprof_ext'
|
41
|
-
Prof.print_profile(results, $stderr)
|
42
|
-
end
|
43
|
-
rescue LoadError
|
44
|
-
require 'profiler'
|
45
|
-
$stderr.puts 'Using the standard Ruby profiler.'
|
46
|
-
Profiler__.start_profile
|
47
|
-
profile_me
|
48
|
-
Profiler__.stop_profile
|
49
|
-
Profiler__.print_profile($stderr)
|
50
|
-
end
|
data/lib/commands/plugin.rb
DELETED
@@ -1,967 +0,0 @@
|
|
1
|
-
# Rails Plugin Manager.
|
2
|
-
#
|
3
|
-
# Listing available plugins:
|
4
|
-
#
|
5
|
-
# $ ./script/plugin list
|
6
|
-
# continuous_builder http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder
|
7
|
-
# asset_timestamping http://svn.aviditybytes.com/rails/plugins/asset_timestamping
|
8
|
-
# enumerations_mixin http://svn.protocool.com/rails/plugins/enumerations_mixin/trunk
|
9
|
-
# calculations http://techno-weenie.net/svn/projects/calculations/
|
10
|
-
# ...
|
11
|
-
#
|
12
|
-
# Installing plugins:
|
13
|
-
#
|
14
|
-
# $ ./script/plugin install continuous_builder asset_timestamping
|
15
|
-
#
|
16
|
-
# Finding Repositories:
|
17
|
-
#
|
18
|
-
# $ ./script/plugin discover
|
19
|
-
#
|
20
|
-
# Adding Repositories:
|
21
|
-
#
|
22
|
-
# $ ./script/plugin source http://svn.protocool.com/rails/plugins/
|
23
|
-
#
|
24
|
-
# How it works:
|
25
|
-
#
|
26
|
-
# * Maintains a list of subversion repositories that are assumed to have
|
27
|
-
# a plugin directory structure. Manage them with the (source, unsource,
|
28
|
-
# and sources commands)
|
29
|
-
#
|
30
|
-
# * The discover command scrapes the following page for things that
|
31
|
-
# look like subversion repositories with plugins:
|
32
|
-
# http://wiki.rubyonrails.org/rails/pages/Plugins
|
33
|
-
#
|
34
|
-
# * Unless you specify that you want to use svn, script/plugin uses plain old
|
35
|
-
# HTTP for downloads. The following bullets are true if you specify
|
36
|
-
# that you want to use svn.
|
37
|
-
#
|
38
|
-
# * If `vendor/plugins` is under subversion control, the script will
|
39
|
-
# modify the svn:externals property and perform an update. You can
|
40
|
-
# use normal subversion commands to keep the plugins up to date.
|
41
|
-
#
|
42
|
-
# * Or, if `vendor/plugins` is not under subversion control, the
|
43
|
-
# plugin is pulled via `svn checkout` or `svn export` but looks
|
44
|
-
# exactly the same.
|
45
|
-
#
|
46
|
-
# Specifying revisions:
|
47
|
-
#
|
48
|
-
# * Subversion revision is a single integer.
|
49
|
-
#
|
50
|
-
# * Git revision format:
|
51
|
-
# - full - 'refs/tags/1.8.0' or 'refs/heads/experimental'
|
52
|
-
# - short: 'experimental' (equivalent to 'refs/heads/experimental')
|
53
|
-
# 'tag 1.8.0' (equivalent to 'refs/tags/1.8.0')
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# This is Free Software, copyright 2005 by Ryan Tomayko (rtomayko@gmail.com)
|
57
|
-
# and is licensed MIT: (http://www.opensource.org/licenses/mit-license.php)
|
58
|
-
|
59
|
-
$verbose = false
|
60
|
-
|
61
|
-
|
62
|
-
require 'open-uri'
|
63
|
-
require 'fileutils'
|
64
|
-
require 'tempfile'
|
65
|
-
|
66
|
-
include FileUtils
|
67
|
-
|
68
|
-
class RailsEnvironment
|
69
|
-
attr_reader :root
|
70
|
-
|
71
|
-
def initialize(dir)
|
72
|
-
@root = dir
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.find(dir=nil)
|
76
|
-
dir ||= pwd
|
77
|
-
while dir.length > 1
|
78
|
-
return new(dir) if File.exist?(File.join(dir, 'config', 'environment.rb'))
|
79
|
-
dir = File.dirname(dir)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.default
|
84
|
-
@default ||= find
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.default=(rails_env)
|
88
|
-
@default = rails_env
|
89
|
-
end
|
90
|
-
|
91
|
-
def install(name_uri_or_plugin)
|
92
|
-
if name_uri_or_plugin.is_a? String
|
93
|
-
if name_uri_or_plugin =~ /:\/\//
|
94
|
-
plugin = Plugin.new(name_uri_or_plugin)
|
95
|
-
else
|
96
|
-
plugin = Plugins[name_uri_or_plugin]
|
97
|
-
end
|
98
|
-
else
|
99
|
-
plugin = name_uri_or_plugin
|
100
|
-
end
|
101
|
-
unless plugin.nil?
|
102
|
-
plugin.install
|
103
|
-
else
|
104
|
-
puts "Plugin not found: #{name_uri_or_plugin}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def use_svn?
|
109
|
-
require 'active_support/core_ext/kernel'
|
110
|
-
silence_stderr {`svn --version` rescue nil}
|
111
|
-
!$?.nil? && $?.success?
|
112
|
-
end
|
113
|
-
|
114
|
-
def use_externals?
|
115
|
-
use_svn? && File.directory?("#{root}/vendor/plugins/.svn")
|
116
|
-
end
|
117
|
-
|
118
|
-
def use_checkout?
|
119
|
-
# this is a bit of a guess. we assume that if the rails environment
|
120
|
-
# is under subversion then they probably want the plugin checked out
|
121
|
-
# instead of exported. This can be overridden on the command line
|
122
|
-
File.directory?("#{root}/.svn")
|
123
|
-
end
|
124
|
-
|
125
|
-
def best_install_method
|
126
|
-
return :http unless use_svn?
|
127
|
-
case
|
128
|
-
when use_externals? then :externals
|
129
|
-
when use_checkout? then :checkout
|
130
|
-
else :export
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def externals
|
135
|
-
return [] unless use_externals?
|
136
|
-
ext = `svn propget svn:externals "#{root}/vendor/plugins"`
|
137
|
-
ext.reject{ |line| line.strip == '' }.map do |line|
|
138
|
-
line.strip.split(/\s+/, 2)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def externals=(items)
|
143
|
-
unless items.is_a? String
|
144
|
-
items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n")
|
145
|
-
end
|
146
|
-
Tempfile.open("svn-set-prop") do |file|
|
147
|
-
file.write(items)
|
148
|
-
file.flush
|
149
|
-
system("svn propset -q svn:externals -F \"#{file.path}\" \"#{root}/vendor/plugins\"")
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
class Plugin
|
156
|
-
attr_reader :name, :uri
|
157
|
-
|
158
|
-
def initialize(uri, name=nil)
|
159
|
-
@uri = uri
|
160
|
-
guess_name(uri)
|
161
|
-
end
|
162
|
-
|
163
|
-
def self.find(name)
|
164
|
-
name =~ /\// ? new(name) : Repositories.instance.find_plugin(name)
|
165
|
-
end
|
166
|
-
|
167
|
-
def to_s
|
168
|
-
"#{@name.ljust(30)}#{@uri}"
|
169
|
-
end
|
170
|
-
|
171
|
-
def svn_url?
|
172
|
-
@uri =~ /svn(?:\+ssh)?:\/\/*/
|
173
|
-
end
|
174
|
-
|
175
|
-
def git_url?
|
176
|
-
@uri =~ /^git:\/\// || @uri =~ /\.git$/
|
177
|
-
end
|
178
|
-
|
179
|
-
def installed?
|
180
|
-
File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \
|
181
|
-
or rails_env.externals.detect{ |name, repo| self.uri == repo }
|
182
|
-
end
|
183
|
-
|
184
|
-
def install(method=nil, options = {})
|
185
|
-
method ||= rails_env.best_install_method?
|
186
|
-
if :http == method
|
187
|
-
method = :export if svn_url?
|
188
|
-
method = :git if git_url?
|
189
|
-
end
|
190
|
-
|
191
|
-
uninstall if installed? and options[:force]
|
192
|
-
|
193
|
-
unless installed?
|
194
|
-
send("install_using_#{method}", options)
|
195
|
-
run_install_hook
|
196
|
-
else
|
197
|
-
puts "already installed: #{name} (#{uri}). pass --force to reinstall"
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def uninstall
|
202
|
-
path = "#{rails_env.root}/vendor/plugins/#{name}"
|
203
|
-
if File.directory?(path)
|
204
|
-
puts "Removing 'vendor/plugins/#{name}'" if $verbose
|
205
|
-
run_uninstall_hook
|
206
|
-
rm_r path
|
207
|
-
else
|
208
|
-
puts "Plugin doesn't exist: #{path}"
|
209
|
-
end
|
210
|
-
# clean up svn:externals
|
211
|
-
externals = rails_env.externals
|
212
|
-
externals.reject!{|n,u| name == n or name == u}
|
213
|
-
rails_env.externals = externals
|
214
|
-
end
|
215
|
-
|
216
|
-
def info
|
217
|
-
tmp = "#{rails_env.root}/_tmp_about.yml"
|
218
|
-
if svn_url?
|
219
|
-
cmd = "svn export #{@uri} \"#{rails_env.root}/#{tmp}\""
|
220
|
-
puts cmd if $verbose
|
221
|
-
system(cmd)
|
222
|
-
end
|
223
|
-
open(svn_url? ? tmp : File.join(@uri, 'about.yml')) do |stream|
|
224
|
-
stream.read
|
225
|
-
end rescue "No about.yml found in #{uri}"
|
226
|
-
ensure
|
227
|
-
FileUtils.rm_rf tmp if svn_url?
|
228
|
-
end
|
229
|
-
|
230
|
-
private
|
231
|
-
|
232
|
-
def run_install_hook
|
233
|
-
install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb"
|
234
|
-
load install_hook_file if File.exist? install_hook_file
|
235
|
-
end
|
236
|
-
|
237
|
-
def run_uninstall_hook
|
238
|
-
uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb"
|
239
|
-
load uninstall_hook_file if File.exist? uninstall_hook_file
|
240
|
-
end
|
241
|
-
|
242
|
-
def install_using_export(options = {})
|
243
|
-
svn_command :export, options
|
244
|
-
end
|
245
|
-
|
246
|
-
def install_using_checkout(options = {})
|
247
|
-
svn_command :checkout, options
|
248
|
-
end
|
249
|
-
|
250
|
-
def install_using_externals(options = {})
|
251
|
-
externals = rails_env.externals
|
252
|
-
externals.push([@name, uri])
|
253
|
-
rails_env.externals = externals
|
254
|
-
install_using_checkout(options)
|
255
|
-
end
|
256
|
-
|
257
|
-
def install_using_http(options = {})
|
258
|
-
root = rails_env.root
|
259
|
-
mkdir_p "#{root}/vendor/plugins/#{@name}"
|
260
|
-
Dir.chdir "#{root}/vendor/plugins/#{@name}" do
|
261
|
-
puts "fetching from '#{uri}'" if $verbose
|
262
|
-
fetcher = RecursiveHTTPFetcher.new(uri, -1)
|
263
|
-
fetcher.quiet = true if options[:quiet]
|
264
|
-
fetcher.fetch
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def install_using_git(options = {})
|
269
|
-
root = rails_env.root
|
270
|
-
install_path = mkdir_p "#{root}/vendor/plugins/#{name}"
|
271
|
-
Dir.chdir install_path do
|
272
|
-
init_cmd = "git init"
|
273
|
-
init_cmd += " -q" if options[:quiet] and not $verbose
|
274
|
-
puts init_cmd if $verbose
|
275
|
-
system(init_cmd)
|
276
|
-
base_cmd = "git pull --depth 1 #{uri}"
|
277
|
-
base_cmd += " -q" if options[:quiet] and not $verbose
|
278
|
-
base_cmd += " #{options[:revision]}" if options[:revision]
|
279
|
-
puts base_cmd if $verbose
|
280
|
-
if system(base_cmd)
|
281
|
-
puts "removing: .git" if $verbose
|
282
|
-
rm_rf ".git"
|
283
|
-
else
|
284
|
-
rm_rf install_path
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
def svn_command(cmd, options = {})
|
290
|
-
root = rails_env.root
|
291
|
-
mkdir_p "#{root}/vendor/plugins"
|
292
|
-
base_cmd = "svn #{cmd} #{uri} \"#{root}/vendor/plugins/#{name}\""
|
293
|
-
base_cmd += ' -q' if options[:quiet] and not $verbose
|
294
|
-
base_cmd += " -r #{options[:revision]}" if options[:revision]
|
295
|
-
puts base_cmd if $verbose
|
296
|
-
system(base_cmd)
|
297
|
-
end
|
298
|
-
|
299
|
-
def guess_name(url)
|
300
|
-
@name = File.basename(url)
|
301
|
-
if @name == 'trunk' || @name.empty?
|
302
|
-
@name = File.basename(File.dirname(url))
|
303
|
-
end
|
304
|
-
@name.gsub!(/\.git$/, '') if @name =~ /\.git$/
|
305
|
-
end
|
306
|
-
|
307
|
-
def rails_env
|
308
|
-
@rails_env || RailsEnvironment.default
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
|
-
class Repositories
|
313
|
-
include Enumerable
|
314
|
-
|
315
|
-
def initialize(cache_file = File.join(find_home, ".rails-plugin-sources"))
|
316
|
-
@cache_file = File.expand_path(cache_file)
|
317
|
-
load!
|
318
|
-
end
|
319
|
-
|
320
|
-
def each(&block)
|
321
|
-
@repositories.each(&block)
|
322
|
-
end
|
323
|
-
|
324
|
-
def add(uri)
|
325
|
-
unless find{|repo| repo.uri == uri }
|
326
|
-
@repositories.push(Repository.new(uri)).last
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
def remove(uri)
|
331
|
-
@repositories.reject!{|repo| repo.uri == uri}
|
332
|
-
end
|
333
|
-
|
334
|
-
def exist?(uri)
|
335
|
-
@repositories.detect{|repo| repo.uri == uri }
|
336
|
-
end
|
337
|
-
|
338
|
-
def all
|
339
|
-
@repositories
|
340
|
-
end
|
341
|
-
|
342
|
-
def find_plugin(name)
|
343
|
-
@repositories.each do |repo|
|
344
|
-
repo.each do |plugin|
|
345
|
-
return plugin if plugin.name == name
|
346
|
-
end
|
347
|
-
end
|
348
|
-
return nil
|
349
|
-
end
|
350
|
-
|
351
|
-
def load!
|
352
|
-
contents = File.exist?(@cache_file) ? File.read(@cache_file) : defaults
|
353
|
-
contents = defaults if contents.empty?
|
354
|
-
@repositories = contents.split(/\n/).reject do |line|
|
355
|
-
line =~ /^\s*#/ or line =~ /^\s*$/
|
356
|
-
end.map { |source| Repository.new(source.strip) }
|
357
|
-
end
|
358
|
-
|
359
|
-
def save
|
360
|
-
File.open(@cache_file, 'w') do |f|
|
361
|
-
each do |repo|
|
362
|
-
f.write(repo.uri)
|
363
|
-
f.write("\n")
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
def defaults
|
369
|
-
<<-DEFAULTS
|
370
|
-
http://dev.rubyonrails.com/svn/rails/plugins/
|
371
|
-
DEFAULTS
|
372
|
-
end
|
373
|
-
|
374
|
-
def find_home
|
375
|
-
['HOME', 'USERPROFILE'].each do |homekey|
|
376
|
-
return ENV[homekey] if ENV[homekey]
|
377
|
-
end
|
378
|
-
if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
379
|
-
return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
|
380
|
-
end
|
381
|
-
begin
|
382
|
-
File.expand_path("~")
|
383
|
-
rescue StandardError => ex
|
384
|
-
if File::ALT_SEPARATOR
|
385
|
-
"C:/"
|
386
|
-
else
|
387
|
-
"/"
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
def self.instance
|
393
|
-
@instance ||= Repositories.new
|
394
|
-
end
|
395
|
-
|
396
|
-
def self.each(&block)
|
397
|
-
self.instance.each(&block)
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
class Repository
|
402
|
-
include Enumerable
|
403
|
-
attr_reader :uri, :plugins
|
404
|
-
|
405
|
-
def initialize(uri)
|
406
|
-
@uri = uri.chomp('/') << "/"
|
407
|
-
@plugins = nil
|
408
|
-
end
|
409
|
-
|
410
|
-
def plugins
|
411
|
-
unless @plugins
|
412
|
-
if $verbose
|
413
|
-
puts "Discovering plugins in #{@uri}"
|
414
|
-
puts index
|
415
|
-
end
|
416
|
-
|
417
|
-
@plugins = index.reject{ |line| line !~ /\/$/ }
|
418
|
-
@plugins.map! { |name| Plugin.new(File.join(@uri, name), name) }
|
419
|
-
end
|
420
|
-
|
421
|
-
@plugins
|
422
|
-
end
|
423
|
-
|
424
|
-
def each(&block)
|
425
|
-
plugins.each(&block)
|
426
|
-
end
|
427
|
-
|
428
|
-
private
|
429
|
-
def index
|
430
|
-
@index ||= RecursiveHTTPFetcher.new(@uri).ls
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
|
435
|
-
# load default environment and parse arguments
|
436
|
-
require 'optparse'
|
437
|
-
module Commands
|
438
|
-
|
439
|
-
class Plugin
|
440
|
-
attr_reader :environment, :script_name, :sources
|
441
|
-
def initialize
|
442
|
-
@environment = RailsEnvironment.default
|
443
|
-
@rails_root = RailsEnvironment.default.root
|
444
|
-
@script_name = File.basename($0)
|
445
|
-
@sources = []
|
446
|
-
end
|
447
|
-
|
448
|
-
def environment=(value)
|
449
|
-
@environment = value
|
450
|
-
RailsEnvironment.default = value
|
451
|
-
end
|
452
|
-
|
453
|
-
def options
|
454
|
-
OptionParser.new do |o|
|
455
|
-
o.set_summary_indent(' ')
|
456
|
-
o.banner = "Usage: #{@script_name} [OPTIONS] command"
|
457
|
-
o.define_head "Rails plugin manager."
|
458
|
-
|
459
|
-
o.separator ""
|
460
|
-
o.separator "GENERAL OPTIONS"
|
461
|
-
|
462
|
-
o.on("-r", "--root=DIR", String,
|
463
|
-
"Set an explicit rails app directory.",
|
464
|
-
"Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
|
465
|
-
o.on("-s", "--source=URL1,URL2", Array,
|
466
|
-
"Use the specified plugin repositories instead of the defaults.") { |sources| @sources = sources}
|
467
|
-
|
468
|
-
o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
|
469
|
-
o.on("-h", "--help", "Show this help message.") { puts o; exit }
|
470
|
-
|
471
|
-
o.separator ""
|
472
|
-
o.separator "COMMANDS"
|
473
|
-
|
474
|
-
o.separator " discover Discover plugin repositories."
|
475
|
-
o.separator " list List available plugins."
|
476
|
-
o.separator " install Install plugin(s) from known repositories or URLs."
|
477
|
-
o.separator " update Update installed plugins."
|
478
|
-
o.separator " remove Uninstall plugins."
|
479
|
-
o.separator " source Add a plugin source repository."
|
480
|
-
o.separator " unsource Remove a plugin repository."
|
481
|
-
o.separator " sources List currently configured plugin repositories."
|
482
|
-
|
483
|
-
o.separator ""
|
484
|
-
o.separator "EXAMPLES"
|
485
|
-
o.separator " Install a plugin:"
|
486
|
-
o.separator " #{@script_name} install continuous_builder\n"
|
487
|
-
o.separator " Install a plugin from a subversion URL:"
|
488
|
-
o.separator " #{@script_name} install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n"
|
489
|
-
o.separator " Install a plugin from a git URL:"
|
490
|
-
o.separator " #{@script_name} install git://github.com/SomeGuy/my_awesome_plugin.git\n"
|
491
|
-
o.separator " Install a plugin and add a svn:externals entry to vendor/plugins"
|
492
|
-
o.separator " #{@script_name} install -x continuous_builder\n"
|
493
|
-
o.separator " List all available plugins:"
|
494
|
-
o.separator " #{@script_name} list\n"
|
495
|
-
o.separator " List plugins in the specified repository:"
|
496
|
-
o.separator " #{@script_name} list --source=http://dev.rubyonrails.com/svn/rails/plugins/\n"
|
497
|
-
o.separator " Discover and prompt to add new repositories:"
|
498
|
-
o.separator " #{@script_name} discover\n"
|
499
|
-
o.separator " Discover new repositories but just list them, don't add anything:"
|
500
|
-
o.separator " #{@script_name} discover -l\n"
|
501
|
-
o.separator " Add a new repository to the source list:"
|
502
|
-
o.separator " #{@script_name} source http://dev.rubyonrails.com/svn/rails/plugins/\n"
|
503
|
-
o.separator " Remove a repository from the source list:"
|
504
|
-
o.separator " #{@script_name} unsource http://dev.rubyonrails.com/svn/rails/plugins/\n"
|
505
|
-
o.separator " Show currently configured repositories:"
|
506
|
-
o.separator " #{@script_name} sources\n"
|
507
|
-
end
|
508
|
-
end
|
509
|
-
|
510
|
-
def parse!(args=ARGV)
|
511
|
-
general, sub = split_args(args)
|
512
|
-
options.parse!(general)
|
513
|
-
|
514
|
-
command = general.shift
|
515
|
-
if command =~ /^(list|discover|install|source|unsource|sources|remove|update|info)$/
|
516
|
-
command = Commands.const_get(command.capitalize).new(self)
|
517
|
-
command.parse!(sub)
|
518
|
-
else
|
519
|
-
puts "Unknown command: #{command}"
|
520
|
-
puts options
|
521
|
-
exit 1
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
def split_args(args)
|
526
|
-
left = []
|
527
|
-
left << args.shift while args[0] and args[0] =~ /^-/
|
528
|
-
left << args.shift if args[0]
|
529
|
-
return [left, args]
|
530
|
-
end
|
531
|
-
|
532
|
-
def self.parse!(args=ARGV)
|
533
|
-
Plugin.new.parse!(args)
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
|
-
|
538
|
-
class List
|
539
|
-
def initialize(base_command)
|
540
|
-
@base_command = base_command
|
541
|
-
@sources = []
|
542
|
-
@local = false
|
543
|
-
@remote = true
|
544
|
-
end
|
545
|
-
|
546
|
-
def options
|
547
|
-
OptionParser.new do |o|
|
548
|
-
o.set_summary_indent(' ')
|
549
|
-
o.banner = "Usage: #{@base_command.script_name} list [OPTIONS] [PATTERN]"
|
550
|
-
o.define_head "List available plugins."
|
551
|
-
o.separator ""
|
552
|
-
o.separator "Options:"
|
553
|
-
o.separator ""
|
554
|
-
o.on( "-s", "--source=URL1,URL2", Array,
|
555
|
-
"Use the specified plugin repositories.") {|sources| @sources = sources}
|
556
|
-
o.on( "--local",
|
557
|
-
"List locally installed plugins.") {|local| @local, @remote = local, false}
|
558
|
-
o.on( "--remote",
|
559
|
-
"List remotely available plugins. This is the default behavior",
|
560
|
-
"unless --local is provided.") {|remote| @remote = remote}
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
def parse!(args)
|
565
|
-
options.order!(args)
|
566
|
-
unless @sources.empty?
|
567
|
-
@sources.map!{ |uri| Repository.new(uri) }
|
568
|
-
else
|
569
|
-
@sources = Repositories.instance.all
|
570
|
-
end
|
571
|
-
if @remote
|
572
|
-
@sources.map{|r| r.plugins}.flatten.each do |plugin|
|
573
|
-
if @local or !plugin.installed?
|
574
|
-
puts plugin.to_s
|
575
|
-
end
|
576
|
-
end
|
577
|
-
else
|
578
|
-
cd "#{@base_command.environment.root}/vendor/plugins"
|
579
|
-
Dir["*"].select{|p| File.directory?(p)}.each do |name|
|
580
|
-
puts name
|
581
|
-
end
|
582
|
-
end
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
|
587
|
-
class Sources
|
588
|
-
def initialize(base_command)
|
589
|
-
@base_command = base_command
|
590
|
-
end
|
591
|
-
|
592
|
-
def options
|
593
|
-
OptionParser.new do |o|
|
594
|
-
o.set_summary_indent(' ')
|
595
|
-
o.banner = "Usage: #{@base_command.script_name} sources [OPTIONS] [PATTERN]"
|
596
|
-
o.define_head "List configured plugin repositories."
|
597
|
-
o.separator ""
|
598
|
-
o.separator "Options:"
|
599
|
-
o.separator ""
|
600
|
-
o.on( "-c", "--check",
|
601
|
-
"Report status of repository.") { |sources| @sources = sources}
|
602
|
-
end
|
603
|
-
end
|
604
|
-
|
605
|
-
def parse!(args)
|
606
|
-
options.parse!(args)
|
607
|
-
Repositories.each do |repo|
|
608
|
-
puts repo.uri
|
609
|
-
end
|
610
|
-
end
|
611
|
-
end
|
612
|
-
|
613
|
-
|
614
|
-
class Source
|
615
|
-
def initialize(base_command)
|
616
|
-
@base_command = base_command
|
617
|
-
end
|
618
|
-
|
619
|
-
def options
|
620
|
-
OptionParser.new do |o|
|
621
|
-
o.set_summary_indent(' ')
|
622
|
-
o.banner = "Usage: #{@base_command.script_name} source REPOSITORY [REPOSITORY [REPOSITORY]...]"
|
623
|
-
o.define_head "Add new repositories to the default search list."
|
624
|
-
end
|
625
|
-
end
|
626
|
-
|
627
|
-
def parse!(args)
|
628
|
-
options.parse!(args)
|
629
|
-
count = 0
|
630
|
-
args.each do |uri|
|
631
|
-
if Repositories.instance.add(uri)
|
632
|
-
puts "added: #{uri.ljust(50)}" if $verbose
|
633
|
-
count += 1
|
634
|
-
else
|
635
|
-
puts "failed: #{uri.ljust(50)}"
|
636
|
-
end
|
637
|
-
end
|
638
|
-
Repositories.instance.save
|
639
|
-
puts "Added #{count} repositories."
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
|
644
|
-
class Unsource
|
645
|
-
def initialize(base_command)
|
646
|
-
@base_command = base_command
|
647
|
-
end
|
648
|
-
|
649
|
-
def options
|
650
|
-
OptionParser.new do |o|
|
651
|
-
o.set_summary_indent(' ')
|
652
|
-
o.banner = "Usage: #{@base_command.script_name} unsource URI [URI [URI]...]"
|
653
|
-
o.define_head "Remove repositories from the default search list."
|
654
|
-
o.separator ""
|
655
|
-
o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
|
656
|
-
end
|
657
|
-
end
|
658
|
-
|
659
|
-
def parse!(args)
|
660
|
-
options.parse!(args)
|
661
|
-
count = 0
|
662
|
-
args.each do |uri|
|
663
|
-
if Repositories.instance.remove(uri)
|
664
|
-
count += 1
|
665
|
-
puts "removed: #{uri.ljust(50)}"
|
666
|
-
else
|
667
|
-
puts "failed: #{uri.ljust(50)}"
|
668
|
-
end
|
669
|
-
end
|
670
|
-
Repositories.instance.save
|
671
|
-
puts "Removed #{count} repositories."
|
672
|
-
end
|
673
|
-
end
|
674
|
-
|
675
|
-
|
676
|
-
class Discover
|
677
|
-
def initialize(base_command)
|
678
|
-
@base_command = base_command
|
679
|
-
@list = false
|
680
|
-
@prompt = true
|
681
|
-
end
|
682
|
-
|
683
|
-
def options
|
684
|
-
OptionParser.new do |o|
|
685
|
-
o.set_summary_indent(' ')
|
686
|
-
o.banner = "Usage: #{@base_command.script_name} discover URI [URI [URI]...]"
|
687
|
-
o.define_head "Discover repositories referenced on a page."
|
688
|
-
o.separator ""
|
689
|
-
o.separator "Options:"
|
690
|
-
o.separator ""
|
691
|
-
o.on( "-l", "--list",
|
692
|
-
"List but don't prompt or add discovered repositories.") { |list| @list, @prompt = list, !@list }
|
693
|
-
o.on( "-n", "--no-prompt",
|
694
|
-
"Add all new repositories without prompting.") { |v| @prompt = !v }
|
695
|
-
end
|
696
|
-
end
|
697
|
-
|
698
|
-
def parse!(args)
|
699
|
-
options.parse!(args)
|
700
|
-
args = ['http://wiki.rubyonrails.org/rails/pages/Plugins'] if args.empty?
|
701
|
-
args.each do |uri|
|
702
|
-
scrape(uri) do |repo_uri|
|
703
|
-
catch(:next_uri) do
|
704
|
-
if @prompt
|
705
|
-
begin
|
706
|
-
$stdout.print "Add #{repo_uri}? [Y/n] "
|
707
|
-
throw :next_uri if $stdin.gets !~ /^y?$/i
|
708
|
-
rescue Interrupt
|
709
|
-
$stdout.puts
|
710
|
-
exit 1
|
711
|
-
end
|
712
|
-
elsif @list
|
713
|
-
puts repo_uri
|
714
|
-
throw :next_uri
|
715
|
-
end
|
716
|
-
Repositories.instance.add(repo_uri)
|
717
|
-
puts "discovered: #{repo_uri}" if $verbose or !@prompt
|
718
|
-
end
|
719
|
-
end
|
720
|
-
end
|
721
|
-
Repositories.instance.save
|
722
|
-
end
|
723
|
-
|
724
|
-
def scrape(uri)
|
725
|
-
require 'open-uri'
|
726
|
-
puts "Scraping #{uri}" if $verbose
|
727
|
-
dupes = []
|
728
|
-
content = open(uri).each do |line|
|
729
|
-
begin
|
730
|
-
if line =~ /<a[^>]*href=['"]([^'"]*)['"]/ || line =~ /(svn:\/\/[^<|\n]*)/
|
731
|
-
uri = $1
|
732
|
-
if uri =~ /^\w+:\/\// && uri =~ /\/plugins\// && uri !~ /\/browser\// && uri !~ /^http:\/\/wiki\.rubyonrails/ && uri !~ /http:\/\/instiki/
|
733
|
-
uri = extract_repository_uri(uri)
|
734
|
-
yield uri unless dupes.include?(uri) || Repositories.instance.exist?(uri)
|
735
|
-
dupes << uri
|
736
|
-
end
|
737
|
-
end
|
738
|
-
rescue
|
739
|
-
puts "Problems scraping '#{uri}': #{$!.to_s}"
|
740
|
-
end
|
741
|
-
end
|
742
|
-
end
|
743
|
-
|
744
|
-
def extract_repository_uri(uri)
|
745
|
-
uri.match(/(svn|https?):.*\/plugins\//i)[0]
|
746
|
-
end
|
747
|
-
end
|
748
|
-
|
749
|
-
class Install
|
750
|
-
def initialize(base_command)
|
751
|
-
@base_command = base_command
|
752
|
-
@method = :http
|
753
|
-
@options = { :quiet => false, :revision => nil, :force => false }
|
754
|
-
end
|
755
|
-
|
756
|
-
def options
|
757
|
-
OptionParser.new do |o|
|
758
|
-
o.set_summary_indent(' ')
|
759
|
-
o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]"
|
760
|
-
o.define_head "Install one or more plugins."
|
761
|
-
o.separator ""
|
762
|
-
o.separator "Options:"
|
763
|
-
o.on( "-x", "--externals",
|
764
|
-
"Use svn:externals to grab the plugin.",
|
765
|
-
"Enables plugin updates and plugin versioning.") { |v| @method = :externals }
|
766
|
-
o.on( "-o", "--checkout",
|
767
|
-
"Use svn checkout to grab the plugin.",
|
768
|
-
"Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout }
|
769
|
-
o.on( "-e", "--export",
|
770
|
-
"Use svn export to grab the plugin.",
|
771
|
-
"Exports the plugin, allowing you to check it into your local repository. Does not enable updates, or add an svn:externals entry.") { |v| @method = :export }
|
772
|
-
o.on( "-q", "--quiet",
|
773
|
-
"Suppresses the output from installation.",
|
774
|
-
"Ignored if -v is passed (./script/plugin -v install ...)") { |v| @options[:quiet] = true }
|
775
|
-
o.on( "-r REVISION", "--revision REVISION",
|
776
|
-
"Checks out the given revision from subversion or git.",
|
777
|
-
"Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
|
778
|
-
o.on( "-f", "--force",
|
779
|
-
"Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
|
780
|
-
o.separator ""
|
781
|
-
o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to "
|
782
|
-
o.separator "a plugin repository."
|
783
|
-
end
|
784
|
-
end
|
785
|
-
|
786
|
-
def determine_install_method
|
787
|
-
best = @base_command.environment.best_install_method
|
788
|
-
@method = :http if best == :http and @method == :export
|
789
|
-
case
|
790
|
-
when (best == :http and @method != :http)
|
791
|
-
msg = "Cannot install using subversion because `svn' cannot be found in your PATH"
|
792
|
-
when (best == :export and (@method != :export and @method != :http))
|
793
|
-
msg = "Cannot install using #{@method} because this project is not under subversion."
|
794
|
-
when (best != :externals and @method == :externals)
|
795
|
-
msg = "Cannot install using externals because vendor/plugins is not under subversion."
|
796
|
-
end
|
797
|
-
if msg
|
798
|
-
puts msg
|
799
|
-
exit 1
|
800
|
-
end
|
801
|
-
@method
|
802
|
-
end
|
803
|
-
|
804
|
-
def parse!(args)
|
805
|
-
options.parse!(args)
|
806
|
-
environment = @base_command.environment
|
807
|
-
install_method = determine_install_method
|
808
|
-
puts "Plugins will be installed using #{install_method}" if $verbose
|
809
|
-
args.each do |name|
|
810
|
-
::Plugin.find(name).install(install_method, @options)
|
811
|
-
end
|
812
|
-
rescue StandardError => e
|
813
|
-
puts "Plugin not found: #{args.inspect}"
|
814
|
-
puts e.inspect if $verbose
|
815
|
-
exit 1
|
816
|
-
end
|
817
|
-
end
|
818
|
-
|
819
|
-
class Update
|
820
|
-
def initialize(base_command)
|
821
|
-
@base_command = base_command
|
822
|
-
end
|
823
|
-
|
824
|
-
def options
|
825
|
-
OptionParser.new do |o|
|
826
|
-
o.set_summary_indent(' ')
|
827
|
-
o.banner = "Usage: #{@base_command.script_name} update [name [name]...]"
|
828
|
-
o.on( "-r REVISION", "--revision REVISION",
|
829
|
-
"Checks out the given revision from subversion.",
|
830
|
-
"Ignored if subversion is not used.") { |v| @revision = v }
|
831
|
-
o.define_head "Update plugins."
|
832
|
-
end
|
833
|
-
end
|
834
|
-
|
835
|
-
def parse!(args)
|
836
|
-
options.parse!(args)
|
837
|
-
root = @base_command.environment.root
|
838
|
-
cd root
|
839
|
-
args = Dir["vendor/plugins/*"].map do |f|
|
840
|
-
File.directory?("#{f}/.svn") ? File.basename(f) : nil
|
841
|
-
end.compact if args.empty?
|
842
|
-
cd "vendor/plugins"
|
843
|
-
args.each do |name|
|
844
|
-
if File.directory?(name)
|
845
|
-
puts "Updating plugin: #{name}"
|
846
|
-
system("svn #{$verbose ? '' : '-q'} up \"#{name}\" #{@revision ? "-r #{@revision}" : ''}")
|
847
|
-
else
|
848
|
-
puts "Plugin doesn't exist: #{name}"
|
849
|
-
end
|
850
|
-
end
|
851
|
-
end
|
852
|
-
end
|
853
|
-
|
854
|
-
class Remove
|
855
|
-
def initialize(base_command)
|
856
|
-
@base_command = base_command
|
857
|
-
end
|
858
|
-
|
859
|
-
def options
|
860
|
-
OptionParser.new do |o|
|
861
|
-
o.set_summary_indent(' ')
|
862
|
-
o.banner = "Usage: #{@base_command.script_name} remove name [name]..."
|
863
|
-
o.define_head "Remove plugins."
|
864
|
-
end
|
865
|
-
end
|
866
|
-
|
867
|
-
def parse!(args)
|
868
|
-
options.parse!(args)
|
869
|
-
root = @base_command.environment.root
|
870
|
-
args.each do |name|
|
871
|
-
::Plugin.new(name).uninstall
|
872
|
-
end
|
873
|
-
end
|
874
|
-
end
|
875
|
-
|
876
|
-
class Info
|
877
|
-
def initialize(base_command)
|
878
|
-
@base_command = base_command
|
879
|
-
end
|
880
|
-
|
881
|
-
def options
|
882
|
-
OptionParser.new do |o|
|
883
|
-
o.set_summary_indent(' ')
|
884
|
-
o.banner = "Usage: #{@base_command.script_name} info name [name]..."
|
885
|
-
o.define_head "Shows plugin info at {url}/about.yml."
|
886
|
-
end
|
887
|
-
end
|
888
|
-
|
889
|
-
def parse!(args)
|
890
|
-
options.parse!(args)
|
891
|
-
args.each do |name|
|
892
|
-
puts ::Plugin.find(name).info
|
893
|
-
puts
|
894
|
-
end
|
895
|
-
end
|
896
|
-
end
|
897
|
-
end
|
898
|
-
|
899
|
-
class RecursiveHTTPFetcher
|
900
|
-
attr_accessor :quiet
|
901
|
-
def initialize(urls_to_fetch, level = 1, cwd = ".")
|
902
|
-
@level = level
|
903
|
-
@cwd = cwd
|
904
|
-
@urls_to_fetch = RUBY_VERSION >= '1.9' ? urls_to_fetch.lines : urls_to_fetch.to_a
|
905
|
-
@quiet = false
|
906
|
-
end
|
907
|
-
|
908
|
-
def ls
|
909
|
-
@urls_to_fetch.collect do |url|
|
910
|
-
if url =~ /^svn(\+ssh)?:\/\/.*/
|
911
|
-
`svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil
|
912
|
-
else
|
913
|
-
open(url) do |stream|
|
914
|
-
links("", stream.read)
|
915
|
-
end rescue nil
|
916
|
-
end
|
917
|
-
end.flatten
|
918
|
-
end
|
919
|
-
|
920
|
-
def push_d(dir)
|
921
|
-
@cwd = File.join(@cwd, dir)
|
922
|
-
FileUtils.mkdir_p(@cwd)
|
923
|
-
end
|
924
|
-
|
925
|
-
def pop_d
|
926
|
-
@cwd = File.dirname(@cwd)
|
927
|
-
end
|
928
|
-
|
929
|
-
def links(base_url, contents)
|
930
|
-
links = []
|
931
|
-
contents.scan(/href\s*=\s*\"*[^\">]*/i) do |link|
|
932
|
-
link = link.sub(/href="/i, "")
|
933
|
-
next if link =~ /svnindex.xsl$/
|
934
|
-
next if link =~ /^(\w*:|)\/\// || link =~ /^\./
|
935
|
-
links << File.join(base_url, link)
|
936
|
-
end
|
937
|
-
links
|
938
|
-
end
|
939
|
-
|
940
|
-
def download(link)
|
941
|
-
puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet
|
942
|
-
open(link) do |stream|
|
943
|
-
File.open(File.join(@cwd, File.basename(link)), "wb") do |file|
|
944
|
-
file.write(stream.read)
|
945
|
-
end
|
946
|
-
end
|
947
|
-
end
|
948
|
-
|
949
|
-
def fetch(links = @urls_to_fetch)
|
950
|
-
links.each do |l|
|
951
|
-
(l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l)
|
952
|
-
end
|
953
|
-
end
|
954
|
-
|
955
|
-
def fetch_dir(url)
|
956
|
-
@level += 1
|
957
|
-
push_d(File.basename(url)) if @level > 0
|
958
|
-
open(url) do |stream|
|
959
|
-
contents = stream.read
|
960
|
-
fetch(links(url, contents))
|
961
|
-
end
|
962
|
-
pop_d if @level > 0
|
963
|
-
@level -= 1
|
964
|
-
end
|
965
|
-
end
|
966
|
-
|
967
|
-
Commands::Plugin.parse!
|