Skip to content

Latest commit

 

History

History
executable file
·
86 lines (50 loc) · 2.31 KB

2016-01-18-gem-npm-ruby-gems-node.js.md

File metadata and controls

executable file
·
86 lines (50 loc) · 2.31 KB
layout title cover date organiser
post
Gem Npm Packages
img/blur-background-1680x1050-spectrum-electromagnetic-4k-901-1.jpg
2015-10-18
Lucas Gatsas

RubyGems

Make your Own Gem

What is Gem? RubyGems is the official packaging system for ruby-lang.org programming language. It provides a packet format, a tool for managing packages, a repository for their distribution.

Since Ruby 1.9 RubyGems is part of the standard library of Ruby. If you want to use a RubyGem in a Ruby program, you must first load the required library:

Use

RubyGems be accessed via the command line acc.

Example :

require 'json'        # aktuelle Version
gem 'rake', '= 10.1.0' # mit Versionsangabe

Gem Installation : Rake

Download and install rake with the following. gem install rake

Example :

First, you must write a “Rakefile” file which contains the build rules. Here's a simple example:

task default: %w[test]
task :test do
ruby "test/unittest.rb"
end

This Rakefile has two tasks:

A task named “test”, which – upon invocation – will run a unit test file in Ruby.

A task named “default”. This task does nothing by itself, but it has exactly one dependency, namely the “test” task. Invoking the “default” task will cause Rake to invoke the “test” task as well.

Running the “rake” command without any options will cause it to run the “default” task in the Rakefile:

% ls
Rakefile     test/
% rake
(in /home/some_user/Projects/rake)
ruby test/unittest.rb
....unit test output here...

Type “rake –help” for all available options.

Link: rubygems.org Link: ruby-lang.org