Skip to content

Commit

Permalink
Rails::Plugin has gone
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jan 3, 2012
1 parent b627923 commit dad7fdc
Show file tree
Hide file tree
Showing 37 changed files with 30 additions and 1,186 deletions.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/railties/databases.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions railties/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
6 changes: 2 additions & 4 deletions railties/guides/code/getting_started/README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
4 changes: 0 additions & 4 deletions railties/guides/code/getting_started/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions railties/guides/source/3_2_release_notes.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand Down
7 changes: 0 additions & 7 deletions railties/guides/source/api_documentation_guidelines.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 0 additions & 16 deletions railties/guides/source/command_line.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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+

Expand Down
10 changes: 3 additions & 7 deletions railties/guides/source/configuring.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
16 changes: 0 additions & 16 deletions railties/guides/source/generators.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/getting_started.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 0 additions & 35 deletions railties/guides/source/plugins.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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 Contributor

Please send a PR fixing it, thanks


Writing your Rails plugin as a gem, rather than as a vendored plugin,
Expand Down Expand Up @@ -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.
Expand All @@ -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
27 changes: 1 addition & 26 deletions railties/guides/source/rails_application_templates.textile
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion railties/guides/source/testing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
5 changes: 2 additions & 3 deletions railties/lib/rails/application.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'active_support/core_ext/hash/reverse_merge'
require 'fileutils'
require 'rails/plugin'
require 'rails/engine'

module Rails
Expand All @@ -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).
Expand All @@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application/railties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

15 comments on commit dad7fdc

@drogus
Copy link
Member

@drogus drogus commented on dad7fdc Jan 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! :D

I always wanted to see such commit!

@qoobaa
Copy link
Contributor

@qoobaa qoobaa commented on dad7fdc Jan 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was my code ;-(

@josevalim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qoobaa
Copy link
Contributor

@qoobaa qoobaa commented on dad7fdc Jan 3, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-D

@pavelvasev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@spastorino
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@pavelvasev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

@drogus drogus commented on dad7fdc Jan 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@drogus drogus commented on dad7fdc Jan 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@drogus
Copy link
Member

@drogus drogus commented on dad7fdc Jan 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@spastorino
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@pavelvasev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@drogus drogus commented on dad7fdc Jan 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.