Difference between revisions of "Ruby"

From BarikWiki
Jump to: navigation, search
(Introduction)
(Passenger)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Lecture-Specific ==
 
 
* My github [https://github.com/barik repository].
 
* Rails questions? Different units: fixtures, functional, integration, performance, unit.
 
* [https://docs.google.com/a/ncsu.edu/spreadsheet/viewform?formkey=dFhnRW9QcHpZSHJ4VlZXVVdsRU5PLWc6MQ Games Research Sign-Up Games Research Sign-Up: Experiments on Player Rationality through Real-Time Strategy Games]
 
 
 
== Introduction ==
 
== Introduction ==
  
* For Linux and variants, use [https://rvm.beginrescueend.com/rvm/install/ RVM].
+
* For Linux and variants, use the Ruby Version Manager, [https://rvm.beginrescueend.com/rvm/install/ RVM]. On CentOS, you'll need to the <code>automake</code> make to install Ruby. Run <code>rvm requirements</code> to see what else needs to be installed.
 
* [http://www.ruby-lang.org/ Ruby Homepage]. For Windows installations, see [http://rubyinstaller.org/ RubyInstaller]. I find that Rails Installer lags behind this, so I don't use it.
 
* [http://www.ruby-lang.org/ Ruby Homepage]. For Windows installations, see [http://rubyinstaller.org/ RubyInstaller]. I find that Rails Installer lags behind this, so I don't use it.
 
* [http://www.ruby-doc.org/ Ruby Doc].
 
* [http://www.ruby-doc.org/ Ruby Doc].
Line 14: Line 8:
 
* [http://docs.rubygems.org/ RubyGems Manuals]. See the [http://docs.rubygems.org/read/book/1 User's Guide], particularly Chapter 3.
 
* [http://docs.rubygems.org/ RubyGems Manuals]. See the [http://docs.rubygems.org/read/book/1 User's Guide], particularly Chapter 3.
 
* Try Ruby. No really, [http://tryruby.org/ tryruby].
 
* Try Ruby. No really, [http://tryruby.org/ tryruby].
 +
 +
== Installation on CentOS ==
 +
 +
I have some issues that appear to happen on my CentOS 6.2 machine:
 +
 +
  [[email protected] ~]$ gem install rails
 +
  ERROR:  Loading command: install (LoadError)
 +
    cannot load such file -- zlib
 +
  ERROR:  While executing gem ... (NameError)
 +
    uninitialized constant Gem::Commands::InstallCommand
 +
 +
Perhaps try [http://beginrescueend.com/packages/zlib/ zlib] and just do a simple reinstall, since you forgot to handle the <code>rvm requirements</code> before doing an install. Not done yet though, do <code>sudo yum install sqlite-devel</code> to get the default <code>sqlite3</code> database to work with <code>rails new</code>.
  
 
== Testing ==
 
== Testing ==
Line 38: Line 44:
 
   rm -r `gem env gemdir`/doc
 
   rm -r `gem env gemdir`/doc
  
Or to make option default, you can edit your [http://docs.rubygems.org/read/chapter/11 gemrc] file ([http://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-default-for-gem-install StackOverflow]). On Windows 7, this is <code>C:\ProgramData\gemrc</code>. Add <code>gem: --no-ri --no-rdoc</code>.
+
Or to make option default, you can edit your [http://docs.rubygems.org/read/chapter/11 gemrc] file ([http://stackoverflow.com/questions/1381725/how-to-make-no-ri-no-rdoc-default-for-gem-install StackOverflow]). On Windows 7, this is <code>C:\ProgramData\gemrc</code>. One option is to add <code>gem: --no-ri --no-rdoc</code>, but it turns out that this [https://rvm.beginrescueend.com/gemsets/basics/ probably isn't the best way to go]. Instead, do:
 +
 
 +
  install: --no-rdoc --no-ri
 +
  update: --no-rdoc --no-ri
  
 
Obligatory reference to [http://gnuwin32.sourceforge.net/ GnuWin]. See [http://docs.rubygems.org/read/chapter/3 Chapter 3] for Gem deployment.
 
Obligatory reference to [http://gnuwin32.sourceforge.net/ GnuWin]. See [http://docs.rubygems.org/read/chapter/3 Chapter 3] for Gem deployment.
Line 53: Line 62:
 
* It seems that you'll need to learn [http://git-scm.com/download Git]. And I just learned Subversion. Git for Windows isn't nearly as mature as the other platforms, unfortunately (<code>preview</code>), so use the portable version for now until it matures.
 
* It seems that you'll need to learn [http://git-scm.com/download Git]. And I just learned Subversion. Git for Windows isn't nearly as mature as the other platforms, unfortunately (<code>preview</code>), so use the portable version for now until it matures.
 
* [http://www.heroku.com/ Heroku], the Ruby Cloud as a Platform Service. Their [http://devcenter.heroku.com/articles/quickstart quick start guide] requires that you know both Ruby and Git.
 
* [http://www.heroku.com/ Heroku], the Ruby Cloud as a Platform Service. Their [http://devcenter.heroku.com/articles/quickstart quick start guide] requires that you know both Ruby and Git.
 +
 +
== Passenger ==
 +
 +
* You can deploy on Apache with [https://www.phusionpassenger.com/ Phusion Passenger]. The configuration for this is under <code>/etc/httpd/conf.d</code>. Note that this is very different from [http://modruby.net/ mod_ruby].
 +
* Still an open question (for me) on how to integrate Passenger with <code>rvm</code>, but see [https://rvm.io/integration/passenger/ Using RVM rubies with Passenger].
  
 
== Rails ==
 
== Rails ==
Line 58: Line 72:
 
* [http://guides.rubyonrails.org/ Ruby on Rails Guides].
 
* [http://guides.rubyonrails.org/ Ruby on Rails Guides].
 
* As easy as <code>gem install rails</code>, but don't forget sqlite.
 
* As easy as <code>gem install rails</code>, but don't forget sqlite.
 +
* Deploy under Apache through [http://www.modrails.com/ mod_passenger].
 
* [http://oreilly.com/ruby/archive/rails-revisited.html Rolling with Ruby on Rails Revisited]
 
* [http://oreilly.com/ruby/archive/rails-revisited.html Rolling with Ruby on Rails Revisited]
 
* A free [https://github.com/bryanbibat/rails-3_0-tutorial Rails 3.0 tutorial].
 
* A free [https://github.com/bryanbibat/rails-3_0-tutorial Rails 3.0 tutorial].
Line 68: Line 83:
 
   gem 'therubyracer'
 
   gem 'therubyracer'
 
* Cucumber requires [http://adoxa.110mb.com/ansicon/ ANSICON] on Windows.
 
* Cucumber requires [http://adoxa.110mb.com/ansicon/ ANSICON] on Windows.
 +
 +
== RVM Commands ==
  
 
== Books ==
 
== Books ==

Latest revision as of 18:50, 30 October 2012

Introduction

  • For Linux and variants, use the Ruby Version Manager, RVM. On CentOS, you'll need to the automake make to install Ruby. Run rvm requirements to see what else needs to be installed.
  • Ruby Homepage. For Windows installations, see RubyInstaller. I find that Rails Installer lags behind this, so I don't use it.
  • Ruby Doc.
  • Ruby development in Windows is doable, but I don't think it's a friendly environment. See Ruby in Twenty Minutes for a refresher.
  • If you want debugging support in Windows, such as in RubyMine or Eclipse, you'll also need DevKit to compile. Documentation. Under Step 5: Test Installation, replace the call for rubygems with ruby under 1.9.2.
  • RubyGems Manuals. See the User's Guide, particularly Chapter 3.
  • Try Ruby. No really, tryruby.

Installation on CentOS

I have some issues that appear to happen on my CentOS 6.2 machine:

 [[email protected] ~]$ gem install rails
 ERROR:  Loading command: install (LoadError)
   cannot load such file -- zlib
 ERROR:  While executing gem ... (NameError)
   uninitialized constant Gem::Commands::InstallCommand

Perhaps try zlib and just do a simple reinstall, since you forgot to handle the rvm requirements before doing an install. Not done yet though, do sudo yum install sqlite-devel to get the default sqlite3 database to work with rails new.

Testing

Too many testing frameworks (what's the testing framework of the day, these days), including: RSpec, Cucumber, Test/Unit (go directly to list of Assertions), Test/Spec and Shoulda.

Gems

Update the system itself (especially if using RubyMine and Ruby 1.9.2):

 gem update --system

Otherwise, RubyMine will throw errors.

See the RubyGems Manuals. Gem installation without RubyDoc:

 gem --no-ri --no-rdoc

If you've already installed ri and rdoc

 rm -r `gem env gemdir`/doc

Or to make option default, you can edit your gemrc file (StackOverflow). On Windows 7, this is C:\ProgramData\gemrc. One option is to add gem: --no-ri --no-rdoc, but it turns out that this probably isn't the best way to go. Instead, do:

 install: --no-rdoc --no-ri
 update: --no-rdoc --no-ri

Obligatory reference to GnuWin. See Chapter 3 for Gem deployment.

RubyMine

Deployment

  • Heroku DevCenter.
  • It seems that you'll need to learn Git. And I just learned Subversion. Git for Windows isn't nearly as mature as the other platforms, unfortunately (preview), so use the portable version for now until it matures.
  • Heroku, the Ruby Cloud as a Platform Service. Their quick start guide requires that you know both Ruby and Git.

Passenger

Rails

 gem 'execjs'
 gem 'therubyracer'
  • Cucumber requires ANSICON on Windows.

RVM Commands

Books

There are a few good books on Ruby:

Fun (Frustrating?) Stuff