Hi Readers,
Today we are going to learn RDoc and Option Parsing, means ruby documentation and their options. In this we are also using ruby in command line.
Hope you will get this concepts.
Share this page. Place comment on it.
Today we are going to learn RDoc and Option Parsing, means ruby documentation and their options. In this we are also using ruby in command line.
RDoc and Option Parsing:
#!/usr/bin/env ruby
# == Synopsis
# This script takes photographs living locally on my desktop or laptop
# and publishes them to my homepage at http://marklunds.com.
#
# == Usage
#
# Copy config file publish-photos.yml.template to publish-photos.yml and edit as appropriate.
# ruby publish-photos [ -h | --help ] <photo_dir1> ... <photo_dirN>
# Load the Rails environment
require File.dirname(__FILE__) + '/../config/environment'
require 'optparse'
require 'rdoc/usage'
opts = OptionParser.new
opts.on("-h", "--help") { RDoc::usage('usage') }
opts.on("-q", "--quiet") { Log::Logger.verbose = false }
opts.parse!(ARGV) rescue RDoc::usage('usage')
# == Synopsis
# This script takes photographs living locally on my desktop or laptop
# and publishes them to my homepage at http://marklunds.com.
#
# == Usage
#
# Copy config file publish-photos.yml.template to publish-photos.yml and edit as appropriate.
# ruby publish-photos [ -h | --help ] <photo_dir1> ... <photo_dirN>
# Load the Rails environment
require File.dirname(__FILE__) + '/../config/environment'
require 'optparse'
require 'rdoc/usage'
opts = OptionParser.new
opts.on("-h", "--help") { RDoc::usage('usage') }
opts.on("-q", "--quiet") { Log::Logger.verbose = false }
opts.parse!(ARGV) rescue RDoc::usage('usage')
Ruby on the Command Line:
# Query and replace
ruby -pi.bak -e "gsub(/Perl/, 'Ruby')" *.txt
# Grep
ruby -n -e "print if /Ruby/" *.txt
ruby -e "puts ARGF.grep(/Ruby/)" *.txt
ruby -pi.bak -e "gsub(/Perl/, 'Ruby')" *.txt
# Grep
ruby -n -e "print if /Ruby/" *.txt
ruby -e "puts ARGF.grep(/Ruby/)" *.txt
Hope you will get this concepts.
Share this page. Place comment on it.
No comments:
Post a Comment