Skip to content
Permalink
Browse files

Rails::Plugin has gone

  • Loading branch information...
spastorino committed Jan 2, 2012
1 parent b627923 commit dad7fdc5734a3813246f238ac5760b2076932216
Showing with 30 additions and 1,186 deletions.
  1. +1 −1 activerecord/lib/active_record/railties/databases.rake
  2. +6 −0 railties/CHANGELOG.md
  3. +2 −4 railties/guides/code/getting_started/README.rdoc
  4. +0 −4 railties/guides/code/getting_started/config/application.rb
  5. +2 −0 railties/guides/source/3_2_release_notes.textile
  6. +0 −7 railties/guides/source/api_documentation_guidelines.textile
  7. +0 −16 railties/guides/source/command_line.textile
  8. +3 −7 railties/guides/source/configuring.textile
  9. +0 −16 railties/guides/source/generators.textile
  10. +1 −1 railties/guides/source/getting_started.textile
  11. +0 −35 railties/guides/source/plugins.textile
  12. +1 −26 railties/guides/source/rails_application_templates.textile
  13. +0 −1 railties/guides/source/testing.textile
  14. +2 −3 railties/lib/rails/application.rb
  15. +1 −1 railties/lib/rails/application/configuration.rb
  16. +1 −1 railties/lib/rails/application/railties.rb
  17. +1 −1 railties/lib/rails/commands.rb
  18. +0 −544 railties/lib/rails/commands/plugin.rb
  19. +0 −2 railties/lib/rails/engine/configuration.rb
  20. +1 −8 railties/lib/rails/engine/railties.rb
  21. +0 −11 railties/lib/rails/generators.rb
  22. +0 −34 railties/lib/rails/generators/actions.rb
  23. +0 −5 railties/lib/rails/generators/rails/app/app_generator.rb
  24. +2 −4 railties/lib/rails/generators/rails/app/templates/README
  25. +0 −4 railties/lib/rails/generators/rails/app/templates/config/application.rb
  26. +0 −91 railties/lib/rails/plugin.rb
  27. +4 −4 railties/lib/rails/railtie.rb
  28. +1 −39 railties/lib/rails/tasks/documentation.rake
  29. +1 −11 railties/lib/rails/test_unit/testing.rake
  30. +0 −1 railties/test/application/paths_test.rb
  31. +0 −37 railties/test/generators/actions_test.rb
  32. +0 −1 railties/test/generators/app_generator_test.rb
  33. +0 −14 railties/test/isolation/abstract_unit.rb
  34. +0 −40 railties/test/railties/engine_test.rb
  35. +0 −76 railties/test/railties/plugin_ordering_test.rb
  36. +0 −123 railties/test/railties/plugin_test.rb
  37. +0 −13 railties/test/railties/shared_tests.rb
@@ -539,7 +539,7 @@ end

namespace :railties do
namespace :install do
# desc "Copies missing migrations from Railties (e.g. plugins, engines). You can specify Railties to use with FROM=railtie1,railtie2"
# desc "Copies missing migrations from Railties (e.g. engines). You can specify Railties to use with FROM=railtie1,railtie2"
task :migrations => :'db:load_config' do
to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map {|n| n.strip }
railties = ActiveSupport::OrderedHash.new
@@ -1,5 +1,11 @@
## Rails 4.0.0 (unreleased) ##

* Rails::Plugin has gone. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies. *Santiago Pastorino*

## Rails 3.2.0 (unreleased) ##

* Rails::Plugin is deprecated and will be removed in Rails 4.0. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies. *Santiago Pastorino*

* Guides are available as a single .mobi for the Kindle and free Kindle readers apps. *Michael Pearson & Xavier Noria*

* Allow scaffold/model/migration generators to accept a "index" and "uniq" modifiers, as in: "tracking_id:integer:uniq" in order to generate (unique) indexes. Some types also accept custom options, for instance, you can specify the precision and scale for decimals as "price:decimal{7,2}". *Dmitrii Samoilov*
@@ -191,7 +191,6 @@ The default directory structure of a generated Ruby on Rails application:
`-- vendor
|-- assets
`-- stylesheets
`-- plugins

app
Holds all the code that's specific to this particular application.
@@ -256,6 +255,5 @@ test
directory.

vendor
External libraries that the application depends on. Also includes the plugins
subdirectory. If the app has frozen rails, those gems also go here, under
vendor/rails/. This directory is in the load path.
External libraries that the application depends on. If the app has frozen rails,
those gems also go here, under vendor/rails/. This directory is in the load path.
@@ -18,10 +18,6 @@ class Application < Rails::Application
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

@@ -67,6 +67,8 @@ When running a multi-user, multi-account application, it's a great help to be ab

h3. Railties

* Rails::Plugin is deprecated and will be removed in Rails 4.0. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies.

* Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting <tt>config.reload_classes_only_on_change</tt> to false.

* New applications get a flag <tt>config.active_record.auto_explain_threshold_in_seconds</tt> in the environments configuration files. With a value of <tt>0.5</tt> in <tt>development.rb</tt> and commented out in <tt>production.rb</tt>. No mention in <tt>test.rb</tt>.
@@ -134,13 +134,6 @@ h4. Regular Font

When "true" and "false" are English words rather than Ruby keywords use a regular font:

<ruby>
# If <tt>reload_plugins?</tt> is false, add this to your plugin's <tt>init.rb</tt>
# to make it reloadable:
#
# Dependencies.load_once_paths.delete lib_path
</ruby>

h3. Description Lists

In lists of options, parameters, etc. use a hyphen between the item and its description (reads better than a colon because normally options are symbols):
@@ -45,8 +45,6 @@ $ rails new commandsapp
...
create tmp/cache
create tmp/pids
create vendor/plugins
create vendor/plugins/.gitkeep
</shell>

Rails will set you up with what seems like a huge amount of stuff for such a tiny command! You've got the entire Rails directory structure now with all the code you need to run our simple application right out of the box.
@@ -295,18 +293,6 @@ h4. +rails dbconsole+

You can also use the alias "db" to invoke the dbconsole: <tt>rails db</tt>.

h4. +rails plugin+

The +rails plugin+ command simplifies plugin management. Plugins can be installed by name or their repository URLs. You need to have Git installed if you want to install a plugin from a Git repo. The same holds for Subversion too.

<shell>
$ rails plugin install https://github.com/technoweenie/acts_as_paranoid.git
+ ./CHANGELOG
+ ./MIT-LICENSE
...
...
</shell>

h4. +rails runner+

<tt>runner</tt> runs Ruby code in the context of Rails non-interactively. For instance:
@@ -415,8 +401,6 @@ The +doc:+ namespace has the tools to generate documentation for your app, API d
* +rake doc:app+ generates documentation for your application in +doc/app+.
* +rake doc:guides+ generates Rails guides in +doc/guides+.
* +rake doc:rails+ generates API documentation for Rails in +doc/api+.
* +rake doc:plugins+ generates API documentation for all the plugins installed in the application in +doc/plugins+.
* +rake doc:clobber_plugins+ removes the generated documentation for all plugins.

h4. +notes+

@@ -42,7 +42,7 @@ h4. Rails General Configuration

These configuration methods are to be called on a +Rails::Railtie+ object, such as a subclass of +Rails::Engine+ or +Rails::Application+.

* +config.after_initialize+ takes a block which will be run _after_ Rails has finished initializing the application. That includes the initialization of the framework itself, plugins, engines, and all the application's initializers in +config/initializers+. Note that this block _will_ be run for rake tasks. Useful for configuring values set up by other initializers:
* +config.after_initialize+ takes a block which will be run _after_ Rails has finished initializing the application. That includes the initialization of the framework itself, engines, and all the application's initializers in +config/initializers+. Note that this block _will_ be run for rake tasks. Useful for configuring values set up by other initializers:

<ruby>
config.after_initialize do
@@ -98,14 +98,10 @@ NOTE. The +config.asset_path+ configuration is ignored if the asset pipeline is

* +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware":#configuring-middleware section below.

* +config.plugins+ accepts the list of plugins to load. The default is +nil+ in which case all plugins will be loaded. If this is set to +[]+, no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. This option lets you enforce some particular loading order, useful when dependencies between plugins require it. For that use case, put first the plugins you want to be loaded in a certain order, and then the special symbol +:all+ to have the rest loaded without the need to specify them.

* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Enabled by +config.threadsafe!+. Defaults to +nil+, so is disabled.

* +config.reload_classes_only_on_change+ enables or disables reloading of classes only when tracked files change. By default tracks everything on autoload paths and is set to true. If +config.cache_classes+ is true, this option is ignored.

* +config.reload_plugins+ enables or disables plugin reloading. Defaults to false.

* +config.secret_token+ used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. Applications get +config.secret_token+ initialized to a random key in +config/initializers/secret_token.rb+.

* +config.serve_static_assets+ configures Rails itself to serve static assets. Defaults to true, but in the production environment is turned off as the server software (e.g. Nginx or Apache) used to run the application should serve static assets instead. Unlike the default setting set this to true when running (absolutely not recommended!) or testing your app in production mode using WEBrick. Otherwise you won´t be able use page caching and requests for files that exist regularly under the public directory will anyway hit your Rails app.
@@ -462,7 +458,7 @@ Some parts of Rails can also be configured externally by supplying environment v

h3. Using Initializer Files

After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks, plugins and gems are loaded, such as options to configure settings for these parts.
After loading the framework and any gems in your application, Rails turns to loading initializers. An initializer is any Ruby file stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and gems are loaded, such as options to configure settings for these parts.

NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down.

@@ -617,7 +613,7 @@ The error occurred while evaluating nil.each

*+prepend_helpers_path+* Adds the directory +app/helpers+ from the application, railties and engines to the lookup path for helpers for the application.

*+load_config_initializers+* Loads all Ruby files from +config/initializers+ in the application, railties and engines. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
*+load_config_initializers+* Loads all Ruby files from +config/initializers+ in the application, railties and engines. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks are loaded.

*+engines_blank_point+* Provides a point-in-initialization to hook into if you wish to do anything before engines are loaded. After this point, all railtie and engine initializers are ran.

@@ -406,22 +406,6 @@ The following are methods available for both generators and templates for Rails.

NOTE: Methods provided by Thor are not covered this guide and can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html

h4. +plugin+

+plugin+ will install a plugin into the current application.

<ruby>
plugin("dynamic-form", :git => "git://github.com/rails/dynamic-form.git")
</ruby>

Available options are:

* +:git+ - Takes the path to the git repository where this plugin can be found.
* +:branch+ - The name of the branch of the git repository where the plugin is found.
* +:submodule+ - Set to +true+ for the plugin to be installed as a submodule. Defaults to +false+.
* +:svn+ - Takes the path to the svn repository where this plugin can be found.
* +:revision+ - The revision of the plugin in an SVN repository.

h4. +gem+

Specifies a gem dependency of the application.
@@ -290,7 +290,7 @@ rundown on the function of each of the files and folders that Rails created by d
|script/|Contains the rails script that starts your app and can contain other scripts you use to deploy or run your application.|
|test/|Unit tests, fixtures, and other test apparatus. These are covered in "Testing Rails Applications":testing.html|
|tmp/|Temporary files|
|vendor/|A place for all third-party code. In a typical Rails application, this includes Ruby Gems, the Rails source code (if you optionally install it into your project) and plugins containing additional prepackaged functionality.|
|vendor/|A place for all third-party code. In a typical Rails application, this includes Ruby Gems and the Rails source code (if you optionally install it into your project).|

h4. Configuring a Database

@@ -30,16 +30,6 @@ Before you continue, take a moment to decide if your new plugin will be potentia
* If your plugin is specific to your application, your new plugin will be a _vendored plugin_.
* If you think your plugin may be used across applications, build it as a _gemified plugin_.

h4. Either generate a vendored plugin...

Use the +rails generate plugin+ command in your Rails root directory
to create a new plugin that will live in the +vendor/plugins+
directory. See usage and options by asking for help:

<shell>
$ rails generate plugin --help
</shell>

h4. Or generate a gemified plugin.

This comment has been minimized.

Copy link
@semaperepelitsa

semaperepelitsa Jan 3, 2012

Contributor

"Or" is not meaningful here anymore. And there is left a mention of plugins a few lines above.

This comment has been minimized.

Copy link
@spastorino

spastorino Jan 3, 2012

Author Member

Please send a PR fixing it, thanks


Writing your Rails plugin as a gem, rather than as a vendored plugin,
@@ -412,30 +402,6 @@ After running +bundle install+, your gem functionality will be available to the
When the gem is ready to be shared as a formal release, it can be published to "RubyGems":http://www.rubygems.org.
For more information about publishing gems to RubyGems, see: "http://blog.thepete.net/2010/11/creating-and-publishing-your-first-ruby.html":http://blog.thepete.net/2010/11/creating-and-publishing-your-first-ruby.html

h3. Non-Gem Plugins

Non-gem plugins are useful for functionality that won't be shared with another project. Keeping your custom functionality in the
vendor/plugins directory un-clutters the rest of the application.

Move the directory that you created for the gem based plugin into the vendor/plugins directory of a generated Rails application, create a vendor/plugins/yaffle/init.rb file that contains "require 'yaffle'" and everything will still work.

<ruby>
# yaffle/init.rb

require 'yaffle'
</ruby>

You can test this by changing to the Rails application that you added the plugin to and starting a rails console. Once in the
console we can check to see if the String has an instance method to_squawk:

<shell>
$ cd my_app
$ rails console
$ "Rails plugins are easy!".to_squawk
</shell>

You can also remove the .gemspec, Gemfile and Gemfile.lock files as they will no longer be needed.

h3. RDoc Documentation

Once your plugin is stable and you are ready to deploy do everyone else a favor and document it! Luckily, writing documentation for your plugin is easy.
@@ -461,4 +427,3 @@ h4. References
* "Using Gemspecs As Intended":http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/
* "Gemspec Reference":http://docs.rubygems.org/read/chapter/20
* "GemPlugins":http://www.mbleigh.com/2008/06/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins
* "Keeping init.rb thin":http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html
@@ -1,6 +1,6 @@
h2. Rails Application Templates

Application templates are simple Ruby files containing DSL for adding plugins/gems/initializers etc. to your freshly created Rails project or an existing Rails project.
Application templates are simple Ruby files containing DSL for adding gems/initializers etc. to your freshly created Rails project or an existing Rails project.

By referring to this guide, you will be able to:

@@ -82,31 +82,6 @@ For example, if you need to source a gem from "http://code.whytheluckystiff.net"
add_source "http://code.whytheluckystiff.net"
</ruby>

h4. plugin(name, options = {})

Installs a plugin to the generated application.

Plugin can be installed from Git:

<ruby>
plugin 'authentication', :git => 'git://github.com/foor/bar.git'
</ruby>

You can even install plugins as git submodules:

<ruby>
plugin 'authentication', :git => 'git://github.com/foor/bar.git',
:submodule => true
</ruby>

Please note that you need to +git :init+ before you can install a plugin as a submodule.

Or use plain old SVN:

<ruby>
plugin 'usingsvn', :svn => 'svn://example.com/usingsvn/trunk'
</ruby>

h4. vendor/lib/file/initializer(filename, data = nil, &block)

Adds an initializer to the generated application’s +config/initializers+ directory.
@@ -738,7 +738,6 @@ You don't need to set up and run your tests by hand on a test-by-test basis. Rai
|+rake test:benchmark+ |Benchmark the performance tests|
|+rake test:functionals+ |Runs all the functional tests from +test/functional+|
|+rake test:integration+ |Runs all the integration tests from +test/integration+|
|+rake test:plugins+ |Run all the plugin tests from +vendor/plugins/*/**/test+ (or specify with +PLUGIN=_name_+)|
|+rake test:profile+ |Profile the performance tests|
|+rake test:recent+ |Tests recent changes|
|+rake test:uncommitted+ |Runs all the tests which are uncommitted. Supports Subversion and Git|
@@ -1,6 +1,5 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'fileutils'
require 'rails/plugin'
require 'rails/engine'

module Rails
@@ -9,7 +8,7 @@ module Rails
#
# == Initialization
#
# Rails::Application is responsible for executing all railties, engines and plugin
# Rails::Application is responsible for executing all railties and engines
# initializers. It also executes some bootstrap initializers (check
# Rails::Application::Bootstrap) and finishing initializers, after all the others
# are executed (check Rails::Application::Finisher).
@@ -19,7 +18,7 @@ module Rails
# Besides providing the same configuration as Rails::Engine and Rails::Railtie,
# the application object has several specific configurations, for example
# "allow_concurrency", "cache_classes", "consider_all_requests_local", "filter_parameters",
# "logger", "reload_plugins" and so forth.
# "logger" and so forth.
#
# Check Rails::Application::Configuration to see them all.
#
@@ -10,7 +10,7 @@ class Configuration < ::Rails::Engine::Configuration
:cache_classes, :cache_store, :consider_all_requests_local,
:dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
:force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
:railties_order, :relative_url_root, :reload_plugins, :secret_token,
:railties_order, :relative_url_root, :secret_token,
:serve_static_assets, :ssl_options, :static_cache_control, :session_options,
:time_zone, :reload_classes_only_on_change

@@ -4,7 +4,7 @@ module Rails
class Application < Engine
class Railties < Rails::Engine::Railties
def all(&block)
@all ||= railties + engines + plugins
@all ||= railties + engines
@all.each(&block) if block
@all
end
@@ -91,7 +91,7 @@
destroy Undo code generated with "generate" (short-cut alias: "d")
benchmarker See how fast a piece of code runs
profiler Get profile information from a piece of code
plugin Install a plugin
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
Oops, something went wrong.

15 comments on commit dad7fdc

@drogus

This comment has been minimized.

Copy link
Member

replied Jan 3, 2012

Cool! :D

I always wanted to see such commit!

@qoobaa

This comment has been minimized.

Copy link
Contributor

replied Jan 3, 2012

There was my code ;-(

@josevalim

This comment has been minimized.

Copy link
Contributor

replied Jan 3, 2012

@qoobaa

This comment has been minimized.

Copy link
Contributor

replied Jan 3, 2012

:-D

@pavelvasev

This comment has been minimized.

Copy link

replied Jan 9, 2012

Why do decide to remove plugins from Rails? Is there any explanation available? Please provide it.. Thanks!

@spastorino

This comment has been minimized.

Copy link
Member Author

replied Jan 9, 2012

@pavelvasev you have an explaination here 853de2b#commitcomment-835327

@pavelvasev

This comment has been minimized.

Copy link

replied Jan 9, 2012

Dear Spastorino, thank you for fast reply!

The link you provide shows only one explanation: "vendor/plugins/* were on their way out with Rails 3.0, moving to gems instead. This is their last hurrah."

So actually we still have unanswered question - why plugins are moving out from Rails?

@spastorino

This comment has been minimized.

Copy link
Member Author

replied Jan 9, 2012

Because there's a newer/better way of developing plugins since 3.0 and doesn't worth to keep the old (2.3) way in Rails 4.0. @jeremy Can you explain it better?

@drogus

This comment has been minimized.

Copy link
Member

replied Jan 9, 2012

@pavelvasev till now 2 versions of plugins needed to be maintained by rails team: vendor/plugins and regular gems (which can contain Railtie or Engine). If you want to simply extract a bunch of code to a plugin you can still easily do it, just generate a plugin somewhere in your app's dir, like

rails plugin new vendor/foo

and add it to gemfile like that:

gem 'foo', :path => "vendor/foo"

The second step (ie. adding line to a Gemfile) is done automatically if you create plugin somewhere inside app's directory on master.

@drogus

This comment has been minimized.

Copy link
Member

replied Jan 9, 2012

So to sum it up - it's still dead easy to have vendor/plugins functionality, but without any additional code, just using bundler. And you can quickly push such gem to rubygems without any changes (well, almost without any changes, you may need to set a few things in a gemspec).

@spastorino

This comment has been minimized.

Copy link
Member Author

replied Jan 9, 2012

@drogus thanks for the help, my english sucks :(

@drogus

This comment has been minimized.

Copy link
Member

replied Jan 9, 2012

@spastorino no problem :) and your english does not suck!

@spastorino

This comment has been minimized.

Copy link
Member Author

replied Jan 9, 2012

@drogus it just took me 20 minutes to write two sentences :P

@pavelvasev

This comment has been minimized.

Copy link

replied Jan 9, 2012

@spastorino @drogus Dear friends!

Thank you for your detailed reply!
So for our team as a users of Rails it matters that we still can ship some of "external" code within app, using gem :path => "

@drogus The only one is that I cannot understand:
The second step (ie. adding line to a Gemfile) is done automatically if you create plugin somewhere inside app's directory on master.

Can you explain the phraze "on master"?

Once again, thank you for explanations and for the job you do for all of the Rails worlds.

@drogus

This comment has been minimized.

Copy link
Member

replied Jan 9, 2012

@pavelvasev I meant that it works on edge rails (4.0.0.beta) from master branch at github

Please sign in to comment.
You can’t perform that action at this time.