From 287bb6990cf0c8a6e4b5ff4c0d75ecfa9bab33fa Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 25 Feb 2011 02:59:37 +0530 Subject: [PATCH] standardize all shell commands with the $ prefix --- .../guides/source/3_0_release_notes.textile | 8 +-- .../source/action_mailer_basics.textile | 2 +- .../source/action_view_overview.textile | 12 ++-- ...ctive_record_validations_callbacks.textile | 2 +- railties/guides/source/command_line.textile | 2 +- .../contributing_to_ruby_on_rails.textile | 72 +++++++++---------- .../debugging_rails_applications.textile | 8 +-- railties/guides/source/generators.textile | 4 +- .../source/layouts_and_rendering.textile | 2 +- railties/guides/source/migrations.textile | 20 +++--- .../guides/source/performance_testing.textile | 2 +- railties/guides/source/plugins.textile | 22 +++--- 12 files changed, 78 insertions(+), 78 deletions(-) diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index db5a9ce644..001f458fd9 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -22,7 +22,7 @@ To install Rails 3: # Use sudo if your setup requires it -gem install rails +$ gem install rails @@ -47,8 +47,8 @@ h4. script/* replaced by script/rails The new script/rails replaces all the scripts that used to be in the script directory. You do not run script/rails directly though, the +rails+ command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is: -rails console # instead of script/console -rails g scaffold post title:string # instead of script/generate scaffold post title:string +$ rails console # instead of script/console +$ rails g scaffold post title:string # instead of script/generate scaffold post title:string Run rails --help for a list of all the options. @@ -64,7 +64,7 @@ To help with the upgrade process, a plugin named "Rails Upgrade":http://github.c Simply install the plugin, then run +rake rails:upgrade:check+ to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a +Gemfile+ based on your current +config.gem+ calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following: -ruby script/plugin install git://github.com/rails/rails_upgrade.git +$ ruby script/plugin install git://github.com/rails/rails_upgrade.git You can see an example of how that works at "Rails Upgrade is now an Official Plugin":http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile index 6ee17ee5b8..56da360972 100644 --- a/railties/guides/source/action_mailer_basics.textile +++ b/railties/guides/source/action_mailer_basics.textile @@ -19,7 +19,7 @@ h4. Walkthrough to Generating a Mailer h5. Create the Mailer -rails generate mailer UserMailer +$ rails generate mailer UserMailer create app/mailers/user_mailer.rb invoke erb create app/views/user_mailer diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 39f4c33397..bf592c06ed 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -29,8 +29,8 @@ Action View works well with Action Record, but it can also be used with other Ru Let's start by ensuring that you have the Action Pack and Rack gems installed: -gem install actionpack -gem install rack +$ gem install actionpack +$ gem install rack Now we'll create a simple "Hello World" application that uses the +titleize+ method provided by Active Support. @@ -52,7 +52,7 @@ Rack::Handler::Mongrel.run method(:hello_world), :Port => 4567 We can see this all come together by starting up the application and then visiting +http://localhost:4567/+ -ruby hello_world.rb +$ ruby hello_world.rb TODO needs a screenshot? I have one - not sure where to put it. @@ -64,8 +64,8 @@ Action View can also be used with "Sinatra":http://www.sinatrarb.com/ in the sam Let's start by ensuring that you have the Action Pack and Sinatra gems installed: -gem install actionpack -gem install sinatra +$ gem install actionpack +$ gem install sinatra Now we'll create the same "Hello World" application in Sinatra. @@ -85,7 +85,7 @@ end Then, we can run the application: -ruby hello_world.rb +$ ruby hello_world.rb Once the application is running, you can see Sinatra and Action View working together by visiting +http://localhost:4567/+ diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 526e62a97a..5dc6ef3774 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -1112,7 +1112,7 @@ h4. Creating Observers For example, imagine a +User+ model where we want to send an email every time a new user is created. Because sending emails is not directly related to our model's purpose, we could create an observer to contain this functionality. -rails generate observer User +$ rails generate observer User diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index 81d181fe02..581fece1ab 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -539,7 +539,7 @@ Rake is a standalone Ruby utility that replaces the Unix utility 'make', and use You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing +rake --tasks+. Each task has a description, and should help you find the thing you need. - rake --tasks +$ rake --tasks (in /home/foobar/commandsapp) rake db:abort_if_pending_migrations # Raises an error if there are pending migrations rake db:charset # Retrieves the charset for the current environment's database diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 4f51c0f859..1977f8d0ce 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -56,8 +56,8 @@ h4. Clone the Ruby on Rails Repository Navigate to the folder where you want the Ruby on Rails source code (it will create its own +rails+ subdirectory) and run: -git clone git://github.com/rails/rails.git -cd rails +$ git clone git://github.com/rails/rails.git +$ cd rails h4. Set up and Run the Tests @@ -67,38 +67,38 @@ The test suite must pass with any submitted code. No matter whether you are writ Install first libxml2 and libxslt together with their development files for Nokogiri. In Ubuntu that's -sudo apt-get install libxml2 libxml2-dev libxslt1-dev +$ sudo apt-get install libxml2 libxml2-dev libxslt1-dev Also, SQLite3 and its development files for the +sqlite3-ruby+ gem, in Ubuntu you're done with -sudo apt-get install sqlite3 libsqlite3-dev +$ sudo apt-get install sqlite3 libsqlite3-dev Get a recent version of "Bundler":http://gembundler.com/: -gem install bundler +$ gem install bundler and run: -bundle install --without db +$ bundle install --without db This command will install all dependencies except the MySQL and PostgreSQL Ruby drivers. We will come back at these soon. With dependencies installed, you can run the test suite with: -rake test +$ rake test You can also run tests for an specific framework, like Action Pack, by going into its directory and executing the same command: -cd actionpack -rake test +$ cd actionpack +$ rake test h4. Warnings @@ -108,7 +108,7 @@ The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no As of this writing they are specially noisy with Ruby 1.9. If you are sure about what you are doing and would like to have a more clear output, there's a way to override the flag: -RUBYOPT=-W0 rake test +$ RUBYOPT=-W0 rake test h4. Testing Active Record @@ -122,8 +122,8 @@ h5. SQLite3 The gem +sqlite3-ruby+ does not belong to the "db" group indeed, if you followed the instructions above you're ready. This is how you run the Active Record test suite only for SQLite3: -cd activerecord -rake test_sqlite3 +$ cd activerecord +$ rake test_sqlite3 h5. MySQL and PostgreSQL @@ -131,15 +131,15 @@ h5. MySQL and PostgreSQL To be able to run the suite for MySQL and PostgreSQL we need their gems. Install first the servers, their client libraries, and their development files. In Ubuntu just run -sudo apt-get install mysql-server libmysqlclient15-dev -sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev +$ sudo apt-get install mysql-server libmysqlclient15-dev +$ sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev After that run: -rm .bundle/config -bundle install +$ rm .bundle/config +$ bundle install We need first to delete +.bundle/config+ because Bundler remembers in that file that we didn't want to install the "db" group (alternatively you can edit the file). @@ -156,21 +156,21 @@ mysql> GRANT ALL PRIVILEGES ON activerecord_unittest2.* and create the test databases: -cd activerecord -rake mysql:build_databases +$ cd activerecord +$ rake mysql:build_databases PostgreSQL's authentication works differently. A simple way to setup the development environment for example is to run with your development account -sudo -u postgres createuser --superuser $USER +$ sudo -u postgres createuser --superuser $USER and after that create the test databases with -cd activerecord -rake postgresql:build_databases +$ cd activerecord +$ rake postgresql:build_databases NOTE: Using the rake task to create the test databases ensures they have the correct character set and collation. @@ -188,7 +188,7 @@ test_postgresql respectively. As we mentioned before -rake test +$ rake test will now run the four of them in turn. @@ -200,8 +200,8 @@ h4. Older versions of Ruby on Rails If you want to add a fix to older versions of Ruby on Rails, you'll need to set up and switch to your own local tracking branch. Here is an example to switch to the 2-3-stable branch: -git branch --track 2-3-stable origin/2-3-stable -git checkout 2-3-stable +$ git branch --track 2-3-stable origin/2-3-stable +$ git checkout 2-3-stable TIP: You may want to "put your git branch name in your shell prompt":http://qugstart.com/blog/git-and-svn/add-colored-git-branch-name-to-your-shell-prompt/ to make it easier to remember which version of the code you're working with. @@ -225,13 +225,13 @@ h4. Testing Patches You can also help out by examining patches that have been submitted to Ruby on Rails via Lighthouse. To apply someone's changes you need to first create a dedicated branch: -git checkout -b testing_branch +$ git checkout -b testing_branch Then you can apply their patch: -git am their-patch-file.diff +$ git am their-patch-file.diff After applying a patch, test it out! Here are some things to think about: @@ -270,14 +270,14 @@ h4. Clone the Rails Repository The first thing you need to do to be able to contribute code is to clone the repository: -git clone git://github.com/rails/rails.git +$ git clone git://github.com/rails/rails.git and create a dedicated branch: -cd rails -git checkout -b my_new_branch +$ cd rails +$ git checkout -b my_new_branch It doesn’t really matter what name you use, because this branch will only exist on your local computer. @@ -311,7 +311,7 @@ h4. Commit Your Changes When you're happy with the code on your computer, you need to commit the changes to git: -git commit -a -m "Here is a commit message" +$ git commit -a -m "Here is a commit message" h4. Update master @@ -319,15 +319,15 @@ h4. Update master It’s pretty likely that other changes to master have happened while you were working. Go get them: -git checkout master -git pull +$ git checkout master +$ git pull Now reapply your patch on top of the latest changes: -git checkout my_new_branch -git rebase master +$ git checkout my_new_branch +$ git rebase master No conflicts? Tests still pass? Change still seems reasonable to you? Then move on. @@ -337,8 +337,8 @@ h4. Create a Patch Now you can create a patch file to share with other developers (and with the core team). Still in your branch, run -git commit -a -git format-patch master --stdout > my_new_patch.diff +$ git commit -a +$ git format-patch master --stdout > my_new_patch.diff Sanity check the results of this operation: open the diff file in your text editor of choice and make sure that no unintended changes crept in. diff --git a/railties/guides/source/debugging_rails_applications.textile b/railties/guides/source/debugging_rails_applications.textile index b84d7d088d..d51cdf5169 100644 --- a/railties/guides/source/debugging_rails_applications.textile +++ b/railties/guides/source/debugging_rails_applications.textile @@ -251,7 +251,7 @@ If you see the message in the console or logs: Make sure you have started your web server with the option +--debugger+: -~/PathTo/rails_project$ rails server --debugger +$ rails server --debugger => Booting WEBrick => Rails 3.0.0 application starting on http://0.0.0.0:3000 => Debugger enabled @@ -477,7 +477,7 @@ end TIP: You can use ruby-debug while using +rails console+. Just remember to +require "ruby-debug"+ before calling the +debugger+ method. -/PathTo/project $ rails console +$ rails console Loading development environment (Rails 2.1.0) >> require "ruby-debug" => [] @@ -626,7 +626,7 @@ If a Ruby object does not go out of scope, the Ruby Garbage Collector won't swee To install it run: -sudo gem install bleak_house +$ sudo gem install bleak_house Then setup your application for profiling. Then add the following at the bottom of config/environment.rb: @@ -638,7 +638,7 @@ require 'bleak_house' if ENV['BLEAK_HOUSE'] Start a server instance with BleakHouse integration: -RAILS_ENV=production BLEAK_HOUSE=1 ruby-bleak-house rails server +$ RAILS_ENV=production BLEAK_HOUSE=1 ruby-bleak-house rails server Make sure to run a couple hundred requests to get better data samples, then press +CTRL-C+. The server will stop and Bleak House will produce a dumpfile in +/tmp+: diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 3adbbfa7aa..41a96b487d 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -388,7 +388,7 @@ In the above template we specify that the application relies on the +rspec-rails Imagine that this template was in a file called +template.rb+. We can use it to modify the outcome of the +rails new+ command by using the +-m+ option and passing in the filename: - rails new thud -m template.rb +$ rails new thud -m template.rb This command will generate the +Thud+ application, and then apply the template to the generated output. @@ -396,7 +396,7 @@ This command will generate the +Thud+ application, and then apply the template t Templates don't have to be stored on the local system, the +-m+ option also supports online templates: - rails new thud -m https://gist.github.com/722911.txt +$ rails new thud -m https://gist.github.com/722911.txt Whilst the final section of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. These same methods are also available for generators. diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index 5bfbf97ea7..1548da0eb5 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -109,7 +109,7 @@ render :nothing => true If you look at the response for this using cURL, you will see the following: - $ curl -i 127.0.0.1:3000/books +$ curl -i 127.0.0.1:3000/books HTTP/1.1 200 OK Connection: close Date: Sun, 24 Jan 2010 09:25:18 GMT diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index 0d13fbc10a..21784c5ba3 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -109,7 +109,7 @@ h4. Creating a Model The model and scaffold generators will create migrations appropriate for adding a new model. This migration will already contain instructions for creating the relevant table. If you tell Rails what columns you want then statements for adding those will also be created. For example, running -rails generate model Product name:string description:text +$ rails generate model Product name:string description:text will create a migration that looks like this @@ -139,7 +139,7 @@ h4. Creating a Standalone Migration If you are creating migrations for other purposes (for example to add a column to an existing table) then you can use the migration generator: -rails generate migration AddPartNumberToProducts +$ rails generate migration AddPartNumberToProducts This will create an empty but appropriately named migration: @@ -157,7 +157,7 @@ end If the migration name is of the form "AddXXXToYYY" or "RemoveXXXFromYYY" and is followed by a list of column names and types then a migration containing the appropriate +add_column+ and +remove_column+ statements will be created. -rails generate migration AddPartNumberToProducts part_number:string +$ rails generate migration AddPartNumberToProducts part_number:string will generate @@ -177,7 +177,7 @@ end Similarly, -rails generate migration RemovePartNumberFromProducts part_number:string +$ rails generate migration RemovePartNumberFromProducts part_number:string generates @@ -197,7 +197,7 @@ end You are not limited to one magically generated column, for example -rails generate migration AddDetailsToProducts part_number:string price:decimal +$ rails generate migration AddDetailsToProducts part_number:string price:decimal generates @@ -383,7 +383,7 @@ If you specify a target version, Active Record will run the required migrations version is the numerical prefix on the migration's filename. For example to migrate to version 20080906120000 run -rake db:migrate VERSION=20080906120000 +$ rake db:migrate VERSION=20080906120000 If this is greater than the current version (i.e. it is migrating upwards) this will run the +up+ method on all migrations up to and including 20080906120000, if migrating downwards this will run the +down+ method on all the migrations down to, but not including, 20080906120000. @@ -393,13 +393,13 @@ h4. Rolling Back A common task is to rollback the last migration, for example if you made a mistake in it and wish to correct it. Rather than tracking down the version number associated with the previous migration you can run -rake db:rollback +$ rake db:rollback This will run the +down+ method from the latest migration. If you need to undo several migrations you can provide a +STEP+ parameter: -rake db:rollback STEP=3 +$ rake db:rollback STEP=3 will run the +down+ method from the last 3 migrations. @@ -407,7 +407,7 @@ will run the +down+ method from the last 3 migrations. The +db:migrate:redo+ task is a shortcut for doing a rollback and then migrating back up again. As with the +db:rollback+ task you can use the +STEP+ parameter if you need to go more than one version back, for example -rake db:migrate:redo STEP=3 +$ rake db:migrate:redo STEP=3 Neither of these Rake tasks do anything you could not do with +db:migrate+, they are simply more convenient since you do not need to explicitly specify the version to migrate to. @@ -421,7 +421,7 @@ h4. Being Specific If you need to run a specific migration up or down the +db:migrate:up+ and +db:migrate:down+ tasks will do that. Just specify the appropriate version and the corresponding migration will have its +up+ or +down+ method invoked, for example -rake db:migrate:up VERSION=20080906120000 +$ rake db:migrate:up VERSION=20080906120000 will run the +up+ method from the 20080906120000 migration. These tasks check whether the migration has already run, so for example +db:migrate:up VERSION=20080906120000+ will do nothing if Active Record believes that 20080906120000 has already been run. diff --git a/railties/guides/source/performance_testing.textile b/railties/guides/source/performance_testing.textile index cd0a8fa384..32eebe863c 100644 --- a/railties/guides/source/performance_testing.textile +++ b/railties/guides/source/performance_testing.textile @@ -37,7 +37,7 @@ h4. Generating Performance Tests Rails provides a generator called +test_unit:performance+ for creating new performance tests: -rails generate test_unit:performance homepage +$ rails generate test_unit:performance homepage This generates +homepage_test.rb+ in the +test/performance+ directory: diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile index 2135c0da4e..daca50ee9e 100644 --- a/railties/guides/source/plugins.textile +++ b/railties/guides/source/plugins.textile @@ -31,7 +31,7 @@ Rails currently ships with a generator to generate a plugin within a Rails appli how this generator works. - rails generate plugin --help +$ rails generate plugin --help This generator places the plugin into the vendor/plugins directory. @@ -214,18 +214,18 @@ We can easily generate these models in our "dummy" Rails application by running test/dummy directory: - cd test/dummy - rails generate model Hickwall last_squak:string - rails generate model Wickwall last_squak:string last_tweet:string +$ cd test/dummy +$ rails generate model Hickwall last_squak:string +$ rails generate model Wickwall last_squak:string last_tweet:string Now you can create the necessary database tables in your testing database by navigating to your dummy app and migrating the database. First - cd test/dummy - rake db:migrate - rake db:test:prepare +$ cd test/dummy +$ rake db:migrate +$ rake db:test:prepare While you are here, change the Hickwall and Wickwall models so that they know that they are supposed to act @@ -424,9 +424,9 @@ require 'yaffle' 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 of to_squawk. - cd my_app - rails console - String.instance_methods.sort +$ cd my_app +$ rails console +$ String.instance_methods.sort You can also remove the .gemspec, Gemfile and Gemfile.lock files as they will no longer be needed. @@ -447,7 +447,7 @@ Once your README is solid, go through and add rdoc comments to all of the method Once your comments are good to go, navigate to your plugin directory and run: -rake rdoc +$ rake rdoc !!!!!!!!!!!!!! Make sure these still make sense. Add any references that you see fit. !!!!!!!!!!!!!