Lets Understand the Ruby programming world in 5 mins!!!

Lets Understand the Ruby programming world in 5 mins?

Ruby is a dynamic, interpreted, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro “Matz” Matsumoto in Japan. The Currnet most latest stable release is Ruby 2.5.

Gem – A Ruby Package
A Gem is a Ruby application package which can contain anything from a collection of code to libraries, and/or list of dependencies that the packaged code actually needs to run.

Gems are formed of a structure similar to the following:

/[package_name] # The main root directory of the Gem package.
|__ /bin # Location of the executable binaries if the package has any.
|__ /lib # Directory containing the main Ruby application code (inc. modules).
|__ /test # Location of test files.
|__ README #
|__ Rakefile # The Rake-file for libraries which use Rake for builds.
|__ [name].gemspec # *.gemspec file, which has the name of the main directory, contains all package meta-data, e.g. name, version, directories etc.

One of the tools we will be using for creating Gems is Bundler.

Bundler a gem to bundle gems. Bundler makes sure Ruby applications run the same code on every machine.

It does this by managing the gems that the application depends on. Given a list of gems, it can automatically download and install those gems, as well as any other gems needed by the gems that are listed. Before installing gems, it checks the versions of every gem to make sure that they are compatible, and can all be loaded at the same time. After the gems have been installed, Bundler can help you update some or all of them when new versions become available. Finally, it records the exact versions that have been installed, so that others can install the exact same gems.

RubyGems – A Package Manager
RubyGems is the default package manager for Ruby. It helps with all application package lifecycle from downloading to distributing Ruby applications and relevant binaries or libraries. RubyGems is a powerful package management tool which provides the developers a standardised structure for packing application in archives called Ruby Gem. The webiste is https://rubygems.org/

Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax. you must write a “Rakefile” file which contains the build rules.

Rails is a web application development framework written in the Ruby programming language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more than many other languages and frameworks. Experienced Rails developers also report that it makes web application development more fun.

Web sites are made of lots of things — frameworks, libraries, assets, and utilities. Bower manages all these things for you. Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower doesn’t concatenate or minify code or do anything else – it just installs the right versions of the packages you need and their dependencies.

Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.

If i have missed any tools which is important of Rudy ecospace, please mentioned in the comments sections.

Tagged : / / / / / / /

A simple Ruby method to send email

scmuser created the topic: A simple Ruby method to send email

A simple Ruby method to send email

require 'net/smtp'
def send_email(to,opts={})
  opts[:server]      ||= 'localhost'
  opts[:from]        ||= 'email@example.com'
  opts[:from_alias]  ||= 'Example Emailer'
  opts[:subject]     ||= "You need to see this"
  opts[:body]        ||= "Important stuff!"
  msg = <<END_OF_MESSAGE
From: #{opts[:from_alias]} <#{opts[:from]}>
To: <#{to}>
Subject: #{opts[:subject]}
  Net::SMTP.start(opts[:server]) do |smtp|
    smtp.send_message msg, opts[:from], to

send_email “admnistrator@example.com”, :body => “This was easy to send”

Source – jerodsanto.net/2009/02/a-simple-ruby-method-to-send-email/

Tagged :

Add each array element to the lines of a file in ruby

scmuser created the topic: Add each array element to the lines of a file in ruby

Add each array element to the lines of a file in ruby

Either use Array#each to iterate over your array and call IO#puts to write each element to the file (puts adds a record separator, typically a newline character):

File.open("test.txt", "w+") do |f|
a.each { |element| f.puts(element) }

Or pass the whole array to puts:

File.open("test.txt", "w+") do |f|

Source –http://stackoverflow.com/questions/18900474/add-each-array-element-to-the-lines-of-a-file-in-ruby

Tagged :

What is the way to iterate through an array in Ruby?

scmuser created the topic: What is the way to iterate through an array in Ruby?

What is the way to iterate through an array in Ruby?

This will iterate through all the elements:

array = [1, 2, 3, 4, 5, 6]
array.each { |x| puts x }


This will iterate through all the elements giving you the value and the index:

array = ["A", "B", "C"]
array.each_with_index {|val, index| puts "#{val} => #{index}" }


A => 0
B => 1
C => 2

Source – stackoverflow.com/questions/310634/what-…ugh-an-array-in-ruby

Tagged :

Short Notes – Ruby Arrays- Insert, Append, length, Index, Removed

scmuser created the topic: Short Notes – Ruby Arrays- Insert, Append, length, Index, Removed

Short Notes – Ruby Arrays- Insert, Append, length, Index, Removed

Create a Ruby Array

letters = Array.new
letters = []
letters = Array.new()
letters =
letters = Array.new(3) ( Define how many elements you array would be)
letters = Array.new(3, 'me rocks') (Define each element with default values)

Accessing Elements

letters[0] - accessing First element
letters[-1] - Accessing last element

Inserting/Adding elements

letters = Array.new() OUTPUT = ["a", "b", "c"]
letters.insert(0, 1) OUTPUT [1, "a", "b", "c", "d"]
letters.insert(-1, 'd') OUTPUT [1, "a", "b", "c", "d"]
letters << 'e' OUTPUT [1, "a", "b", "c", "d", "e"]
letters.push('f') OUTPUT [1, "a", "b", "c", "d", "e", "f"]

Removing Elements

letters.pop - Remove the last elements
letters.delete_at(2) - Delete the element of particular index
Tagged :

Common ways to read a file in Ruby?

scmuser created the topic: Common ways to read a file in Ruby?

File.open("my/file/path", "r") do |f|
f.each_line do |line|
puts line
# File is closed automatically at end of block

It is also possible to explicitly close file after as above (pass a block to open closes it for you):

f = File.open("my/file/path", "r")
f.each_line do |line|
puts line

Source – stackoverflow.com/questions/5545068/what…-read-a-file-in-ruby

Tagged :

How to process every line in a text file with Ruby

scmuser created the topic: How to process every line in a text file with Ruby

Example 1

# ruby sample code.
# process every line in a text file with ruby (version 1).
File.readlines(file).each do |line|
puts line

Example 2

# ruby sample code.
# process every line in a text file with ruby (version 2).
f = File.open(file, "r")
f.each_line { |line|
puts line

Source –

Tagged :

Any Possible Software/Plugin FoR SCM Workflow

pankaj2252369@gmail.com created the topic: Any possible Software/plugin for SCM workflow?
Hey Team, Thanks for lot of information on the site. wonderful work.

Any idea on SCM workflow software/framework ? which would help me to complete the SDLC lifecycle.

For E.g: When ever developers are done with their changes/check-ins, they would request CM team to build (via Email), And when CM builds and deploy , they will email to Testing Team, finally when its been tested they will let CM/RM team inform about the bugs, etc. finally product will be released.

All this was happening manually(via emails). If we have a workflow software, so that we can have everything in process oriented and SCM would be very easy.

Any Suggestion are welcome.

If know of any plug-ins , we can extend our programs to make it work to our systems.

Thanks in Advance!

rajeshkumar replied the topic: Re: Any possible Software/plugin for SCM workflow?
I would suggest following in Commercial | Opensource:-
SCM Workflow consisit of following..
SCM Tools |Scripting |Build / WorkFlow Mgmt Tools |
| Release / Dep Tools | Security | Testing Tools |
Test Coverage | Source-code Analysis | Issue Tracking Tools | IDEs Integration |Virtualization |

Please find list of tools and find you combination based in your project requirement and budget

Build / WorkFlow Mgmt Tools

Apache Continuum
OpenMake Meister
Team Foundation Server
Electric Cloud

SCM Tools

CA Harvest
MKS Source Integrity
Team Foundation Server


Shell Scripts
Perl Scripts
Visual Studio

Release / Dep Tools
Rational Team Concert


Active Directory
Single Sign-on

Testing Tools

Source-code Analysis


Issue Tracking Tools

HP Quality Center
PVCS Tracker
Team Foundation Server

IDEs Integration

Visual Studio


VMWare Lab Manager
Amazon (Elastic Cloud)
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

pankaj2252369@gmail.com replied the topic: Re: Any possible Software/plugin for SCM workflow?
Thanks for the response. But this i snot actually i am looking for.. I have idea on the mentioned tools. But wanted to create one separate tool for our internal purpose. So i am just checking, if there are any SCM related plugins /frame works in market, So that i do not spend more time on the things that are available.

Anyways.. Thank you so much!

rajeshkumar replied the topic: Re: Any possible Software/plugin for SCM workflow?
Hi John,

May be i am getting confused from you questions. Framework which can help you to develop your internal tools????

You mean you would like to develop your own tools, Then you might want to identify the technology first using which you want your development work get started. There are plenty of framework in Java| C++ | Perl | Pythin| Php | Ruby on rails etc
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged : / / / / /

Top 10 Scripting Languages in DevOps | List of Best Scripting Languages

This is the time of DevOps in software industry and DevOps uses different different languages for deployment automation and for software development. This is the reason if you are a DevOps professional and want to be succeed in DevOps role than command on scripting languages is must. But, one can not be a master of all. Right? Therefore, In this article I am going to share a list of top 10 scripting languages which will be useful for your DevOps journey.
But before that let’s have a quick look on Scripting language.
Scripting languages are programming languages that communicate and integrate with other programming languages. In other words, scripting languages controlls interactive programs operations by giving it sequence of work to execute by one command at a time.
Now, let’s look on to the list of top 10 scripting languages

1. Microsoft PowerShell

Microsoft PowerShell

Microsoft powershell or powershell is belongs to Microsoft and an open source cross platform scripting language. If you have application infrastructure with windows than powershell is must for you. This scripting language is designed for system admins.
2. Puppet


Puppet is a configuration management tool and it has it’s own declarative language to describe system configuration. It runs on Linux, Unix-like and also on Windows. This one is available under Apache 2.7.0 and General Pubic license.  Puppet uses a custom declarative language, it just needs to specify ‘what’ action needs to be performed on the resources.
3. Chef


Chef is basically known as configuration management which belongs to chef is also a scripting language which is designed by David Morgan. It makes programs look like cooking any food.
4. Bash


Bash is basically a command language which is available in open source and written by Brian Fox in the year 1989. It can read scripts and Bash is the most commonly used Unix shell. Bash supports Linux, Windows and Mac OS.
5. Ruby


Ruby is amongst one of the best programming language but it is also a scripting language which is written by Yukihiro Matsumoto in the year 1995. Ruby supports cross platforms and it is available under GPL and BSD license. It supports multiple programming paradigms, including functional, object-oriented, and imperative.
6. Ansible


Ansible is known as configuration management and application deployment tool but it is also amongst top scripting languages. This language is belongs to Ansible Inc. and written by their community members. It supports Linux, Unix-like and Windows operating system.
7. Perl


Perl is a scripting language which is used for advanced web applications development. Perl is written by Larry Wall and first released in the year 1987. Perl supports cross platforms. Perl is available under general public license.
8. Python


Python is also amongst the top scripting languages which is used for high level of programming. It was first released in the year 1991 by Guido van Rossum. python is available under Python Software Foundation License. It’s supports Cross-platform.
9. Go language

Go language

Go scripting language belongs to the Internet giant Google. This scripting language is written by Robert Griesemer, Rob Pike and Ken Thompson and it was released in the year 2009. It supports  Linux, macOS, FreeBSD, NetBSD, OpenBSD, Windows, Plan 9, DragonFly BSD and Solaris operating systems. It is available in open source.
10. Groovy


Groovy can be used as a scripting language and it is also consider as a top scripting languages for DevOps professionals. It was designed by James Strachan and developed by Guillaume Laforge, Jochen Theodorou, Paul King and Cedric Champeau. It was first released in the year 2003 and available under Apache license. It supports Java platform.
Do you agree with this list? If not than feel free to respond in the comment box with your own take on the most essential scripting languages. One more thing, I would like to add here, if you need help to learn all these scripting languages and DevOps courses than scmGalaxy can help you in this. scmGalaxy is a community of DevOps professionals who are well experienced in this domain.
Tagged : / / / / / / / / / / / / / / / / / / /

A script to find all users who have not set passwords


Write a script to find all users who have not set passwords.

require “P4”
p4 = P4.new
p4.run_users.each do
user = p4.fetch_user( u[ “User” ] )
puts( user[ “User” ] ) unless user.has_key?( “Password” )


use P4;
my $p4 = new P4;
$p4->Init() or die( “Can’t connect to Perforce” );
foreach my $u ( $p4->Users() )
my $user = $p4->FetchUser( $u->{ “User” } );
print( $user->{ “User” }, “\n” ) unless defined ( $user->{ “Password” }

Tagged : / / / / / / / /