RubyConfBD 2013 decouple, bundle and share with ruby gems

Post on 31-Aug-2014

1127 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

This presentation is about explaining what is decoupling

Transcript

Decouple, Bundle and Share with Ruby Gems

Nhm Tanveer Hossain Khan (Hasan)

Things on the table

• What is decoupling ?• What is Gem ?• Create RubyConf2013_Hello Gem.• Publish on RubyGems Repository.• And share with fellow ruby developers

About me!

• Working with Ruby for last 6 years.• Currently working with “Genweb2 Ltd.” as

“Systems Architect”• Passionate about Ruby, Java, Nodejs, Creative

idea and FOOD!• Built http://www.khadok.com• My Github profile - https://github.com/

we4tech

Decoupling!

What is decoupling Coupling?

What is decoupling ?

Direct benefits!

Benefits (contd.)

• Creates reusable code• Modularizes structure• Responds to polymorphic behavior• Possible to integrate with other projects

Trade-offs

• Requires common sense • Requires expertise on understanding “What’s

enough?”• It should be derived from a real project.• Requires tune up and adjustment based on

real requirements.

Ruby Gems!

What is Ruby Gems ?

Or This!

Real Ruby Stone!Collected from wikipedia - http://en.wikipedia.org/wiki/File:Ruby_-_Winza,_Tanzania.jpg

Ruby Gem/Gemstone!Collected from wikipedia - http://en.wikipedia.org/wiki/File:Cardinal_gems.png

Finally a complete Necklace!

Ruby Gems Repository

A complete ruby application

Create RubyConf2013_hello gem!

$ gem install bundle$ bundle gem rubyconfbd2013_hello

Generated files

Code it!# File: lib/rubyconfbd2013_hello.rbrequire "rubyconfbd2013_hello/version"

module Rubyconfbd2013Hello def rubyconfbd_year 2013 end

def rubyconfbd_location 'Bangladesh' endend

Object.send(:extend, Rubyconfbd2013Hello)Object.send(:include, Rubyconfbd2013Hello)

Add Gem information# File: rubyconfbd2013_hello.gemspec

# Other codes …… gem.authors = ["nhm tanveer hossain khan"] gem.email = ["hasan83bd@gmail.com"] gem.description = %q{A very basic gem demonstration for RubyConfBD 2013} gem.summary = %q{A very basic gem demonstration for RubyConfBD 2013} gem.homepage = "https://github.com/we4tech/rubyconfbd2013_hello"

$ rake release

Result!

Usages!

• $ gem install rubyconfbd2013_hello• $ irb• require “rubyconfbd2013_hello”• Object.rubyconfbd_year• => 2013• Object.rubyconfbd_location• => „Bangladesh”

You can check it yourself!

• Rubygems link - https://rubygems.org/gems/rubyconfbd2013_hello

• Github link - https://github.com/we4tech/rubyconfbd2013_hello

That’s It! ( Question.any? )

top related