Monday, 4 February 2013

Hacking on JRuby on Rails




With RVM installed,
STEP 0 Check rvm is installed
prayag@Prayag:~/workspace_rails$ rvm --version

rvm 1.18.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]


STEP 1 Install jruby 1.7.2
prayag@Prayag:~$ rvm install jruby
Searching for binary rubies, this might take some time.
jruby-1.7.2 - #configure
jruby-1.7.2 - #download
######################################################################## 100.0%
jruby-1.7.2 - #validate archive
jruby-1.7.2 - #extract
jruby-1.7.2 - #validate binary
jruby-1.7.2 - #setup
mkdir: cannot create directory `': No such file or directory
mkdir: cannot create directory `': No such file or directory
Saving wrappers to '/home/prayag/.rvm/bin'.
jruby-1.7.2 - #importing default gemsets, this may take time ...


Check in .rvm/bin
prayag@Prayag:~/workspace_rails$ ls -l /home/prayag/.rvm/bin/
total 76
-rwxrwxr-x 1 prayag prayag   578 Jan 25 11:20 bundle
lrwxrwxrwx 1 prayag prayag    42 Jan 25 11:54 default_gem -> /home/prayag/.rvm/wrappers/jruby-1.7.2/gem
lrwxrwxrwx 1 prayag prayag    42 Jan 25 11:54 default_irb -> /home/prayag/.rvm/wrappers/jruby-1.7.2/irb
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:54 default_rake -> /home/prayag/.rvm/wrappers/jruby-1.7.2/rake
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:54 default_rdoc -> /home/prayag/.rvm/wrappers/jruby-1.7.2/rdoc
lrwxrwxrwx 1 prayag prayag    41 Jan 25 11:54 default_ri -> /home/prayag/.rvm/wrappers/jruby-1.7.2/ri
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:54 default_ruby -> /home/prayag/.rvm/wrappers/jruby-1.7.2/ruby
lrwxrwxrwx 1 prayag prayag    45 Jan 25 11:54 default_testrb -> /home/prayag/.rvm/wrappers/jruby-1.7.2/testrb
-rwxrwxr-x 1 prayag prayag   265 Jan 25 11:54 erb
lrwxrwxrwx 1 prayag prayag    42 Jan 25 11:52 erb-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/erb
lrwxrwxrwx 1 prayag prayag    49 Jan 25 11:52 erb-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/erb
-rwxrwxr-x 1 prayag prayag   265 Jan 25 11:54 gem
lrwxrwxrwx 1 prayag prayag    42 Jan 25 11:52 gem-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/gem
lrwxrwxrwx 1 prayag prayag    49 Jan 25 11:52 gem-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/gem
-rwxrwxr-x 1 prayag prayag   265 Jan 25 11:54 irb
lrwxrwxrwx 1 prayag prayag    42 Jan 25 11:52 irb-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/irb
lrwxrwxrwx 1 prayag prayag    49 Jan 25 11:52 irb-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/irb
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:52 jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/ruby
lrwxrwxrwx 1 prayag prayag    50 Jan 25 11:52 jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/ruby
-rwxrwxr-x 1 prayag prayag   266 Jan 25 11:54 rake
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:52 rake-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/rake
lrwxrwxrwx 1 prayag prayag    50 Jan 25 11:52 rake-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/rake
-rwxrwxr-x 1 prayag prayag   266 Jan 25 11:54 rdoc
lrwxrwxrwx 1 prayag prayag    43 Jan 25 11:52 rdoc-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/rdoc
lrwxrwxrwx 1 prayag prayag    50 Jan 25 11:52 rdoc-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/rdoc
-rwxrwxr-x 1 prayag prayag   264 Jan 25 11:54 ri
lrwxrwxrwx 1 prayag prayag    41 Jan 25 11:52 ri-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/ri
lrwxrwxrwx 1 prayag prayag    48 Jan 25 11:52 ri-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/ri
-rwxrwxr-x 1 prayag prayag   266 Jan 25 11:54 ruby
-rwxrwxr-x 1 prayag prayag  1272 Jan 25 11:20 rvm
-rwxrwxr-x 1 prayag prayag  1512 Jan 25 11:20 rvm-auto-ruby
-rwxrwxr-x 1 prayag prayag  1803 Jan 25 11:20 rvm-exec
-rwxrwxr-x 1 prayag prayag 10648 Jan 25 11:20 rvm-installer
-rwxrwxr-x 1 prayag prayag  3816 Jan 25 11:20 rvm-prompt
-rwxrwxr-x 1 prayag prayag  2263 Jan 25 11:20 rvm-shell
-rwxrwxr-x 1 prayag prayag   648 Jan 25 11:20 rvm-smile
-rwxrwxr-x 1 prayag prayag  2228 Jan 25 11:20 rvmsudo
-rwxrwxr-x 1 prayag prayag   268 Jan 25 11:54 testrb
lrwxrwxrwx 1 prayag prayag    45 Jan 25 11:52 testrb-jruby-1.7.2 -> /home/prayag/.rvm/wrappers/jruby-1.7.2/testrb
lrwxrwxrwx 1 prayag prayag    52 Jan 25 11:52 testrb-jruby-1.7.2@global -> /home/prayag/.rvm/wrappers/jruby-1.7.2@global/testrb


Check jruby version
prayag@Prayag:~$ jruby --version
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.6.0_23-b05 [linux-i386]


STEP 2 List Local gem
-S parameter tells JRuby to use its version of the installed binary.
prayag@Prayag:~/workspace_rails$ jruby -S gem list --local

*** LOCAL GEMS ***


bouncy-castle-java (1.5.0146.1)

bundler (1.2.3)
jruby-openssl (0.8.2)
rake (10.0.3)
rubygems-bundler (1.1.0)
rvm (1.11.3.6)


gem install rails
prayag@Prayag:~/workspace_rails$ jruby -S gem install rails mongrel jdbc-mysql activerecord-jdbcmysql-adapter
Fetching: railties-3.2.11.gem (100%)
Fetching: rails-3.2.11.gem (100%)
Successfully installed railties-3.2.11
Successfully installed rails-3.2.11
Fetching: gem_plugin-0.2.3.gem (100%)
Fetching: mongrel-1.1.5-java.gem (100%)
Successfully installed gem_plugin-0.2.3
Successfully installed mongrel-1.1.5-java
Fetching: jdbc-mysql-5.1.22.1.gem (100%)
Successfully installed jdbc-mysql-5.1.22.1
Fetching: activerecord-jdbc-adapter-1.2.5.gem (100%)
Fetching: activerecord-jdbcmysql-adapter-1.2.5.gem (100%)
Successfully installed activerecord-jdbc-adapter-1.2.5
Successfully installed activerecord-jdbcmysql-adapter-1.2.5
7 gems installed


STEP 3 create a rails app
prayag@Prayag:~/workspace_rails$ jruby -S rails new justice-for-gyanendra
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/.
Error Bundler::HTTPError during request to dependency API
Fetching full source index from https://rubygems.org/
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.4)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.11)
Installing mime-types (1.20.1)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.11)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.11)
Installing activerecord-jdbc-adapter (1.2.6)
Installing jdbc-sqlite3 (3.7.2.1)
Installing activerecord-jdbcsqlite3-adapter (1.2.6)
Using activeresource (3.2.11)
Using bouncy-castle-java (1.5.0146.1)
Using bundler (1.2.3)
Installing coffee-script-source (1.4.0)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Installing rack-ssl (1.3.3)
Using json (1.7.6)
Using rdoc (3.12)
Using thor (0.17.0)
Using railties (3.2.11)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.2.0)
Using jruby-openssl (0.8.2)
Using rails (3.2.11)
Installing sass (3.2.5)
Installing sass-rails (3.2.6)
Installing therubyrhino_jar (1.7.4)
Installing therubyrhino (2.0.2)
Installing uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.


STEP 4 build a rails app
Rake is a build tool, written in Ruby, using Ruby as a build language.

prayag@Prayag:~/workspace_rails/justice-for-gyanendra$ jruby -S rake -T
rake about              # List versions of all Rails frameworks and the env...
rake assets:clean       # Remove compiled assets
rake assets:precompile  # Compile all the assets named in config.assets.pre...
rake db:create          # Create the database from DATABASE_URL or config/d...
rake db:drop            # Drops the database using DATABASE_URL or the curr...
rake db:fixtures:load   # Load fixtures into the current environment's data...
rake db:migrate         # Migrate the database (options: VERSION=x, VERBOSE...
rake db:migrate:status  # Display status of migrations
rake db:rollback        # Rolls the schema back to the previous version (sp...
rake db:schema:dump     # Create a db/schema.rb file that can be portably u...
rake db:schema:load     # Load a schema.rb file into the database
rake db:seed            # Load the seed data from db/seeds.rb
rake db:setup           # Create the database, load the schema, and initial...
rake db:structure:dump  # Dump the database structure to db/structure.sql. ...
rake db:version         # Retrieves the current schema version number
rake doc:app            # Generate docs for the app -- also available doc:r...
rake log:clear          # Truncates all *.log files in log/ to zero bytes
rake middleware         # Prints out your Rack middleware stack
rake notes              # Enumerate all annotations (use notes:optimize, :f...
rake notes:custom       # Enumerate a custom annotation, specify with ANNOT...
rake rails:template     # Applies the template supplied by LOCATION=(/path/...
rake rails:update       # Update configs and some other initially generated...
rake routes             # Print out all defined routes in match order, with...
rake secret             # Generate a cryptographically secure secret key (t...
rake stats              # Report code statistics (KLOCs, etc) from the appl...
rake test               # Runs test:units, test:functionals, test:integrati...
rake test:recent        # Run tests for {:recent=>"test:prepare"} / Test re...
rake test:single        # Run tests for {:single=>"test:prepare"}
rake test:uncommitted   # Run tests for {:uncommitted=>"test:prepare"} / Te...
rake time:zones:all     # Displays all time zones, also available: time:zon...
rake tmp:clear          # Clear session, cache, and socket files from tmp/ ...
rake tmp:create         # Creates tmp directories for sessions, cache, sock...


No comments:

Post a Comment