RubyConfBD 2013 decouple, bundle and share with ruby gems

28
Decouple, Bundle and Share with Ruby Gems Nhm Tanveer Hossain Khan (Hasan)

description

This presentation is about explaining what is decoupling

Transcript of RubyConfBD 2013 decouple, bundle and share with ruby gems

Page 1: RubyConfBD 2013   decouple, bundle and share with ruby gems

Decouple, Bundle and Share with Ruby Gems

Nhm Tanveer Hossain Khan (Hasan)

Page 2: RubyConfBD 2013   decouple, bundle and share with ruby gems

Things on the table

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

Page 3: RubyConfBD 2013   decouple, bundle and share with ruby gems

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

Page 4: RubyConfBD 2013   decouple, bundle and share with ruby gems

Decoupling!

Page 5: RubyConfBD 2013   decouple, bundle and share with ruby gems

What is decoupling Coupling?

Page 6: RubyConfBD 2013   decouple, bundle and share with ruby gems

What is decoupling ?

Page 7: RubyConfBD 2013   decouple, bundle and share with ruby gems

Direct benefits!

Page 8: RubyConfBD 2013   decouple, bundle and share with ruby gems

Benefits (contd.)

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

Page 9: RubyConfBD 2013   decouple, bundle and share with ruby gems

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.

Page 10: RubyConfBD 2013   decouple, bundle and share with ruby gems

Ruby Gems!

Page 11: RubyConfBD 2013   decouple, bundle and share with ruby gems

What is Ruby Gems ?

Page 12: RubyConfBD 2013   decouple, bundle and share with ruby gems

Or This!

Page 13: RubyConfBD 2013   decouple, bundle and share with ruby gems

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

Page 14: RubyConfBD 2013   decouple, bundle and share with ruby gems

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

Page 15: RubyConfBD 2013   decouple, bundle and share with ruby gems

Finally a complete Necklace!

Page 16: RubyConfBD 2013   decouple, bundle and share with ruby gems

Ruby Gems Repository

Page 17: RubyConfBD 2013   decouple, bundle and share with ruby gems

A complete ruby application

Page 18: RubyConfBD 2013   decouple, bundle and share with ruby gems

Create RubyConf2013_hello gem!

Page 19: RubyConfBD 2013   decouple, bundle and share with ruby gems

$ gem install bundle$ bundle gem rubyconfbd2013_hello

Page 20: RubyConfBD 2013   decouple, bundle and share with ruby gems

Generated files

Page 21: RubyConfBD 2013   decouple, bundle and share with ruby gems

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)

Page 22: RubyConfBD 2013   decouple, bundle and share with ruby gems

Add Gem information# File: rubyconfbd2013_hello.gemspec

# Other codes …… gem.authors = ["nhm tanveer hossain khan"] gem.email = ["[email protected]"] 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"

Page 23: RubyConfBD 2013   decouple, bundle and share with ruby gems

$ rake release

Page 24: RubyConfBD 2013   decouple, bundle and share with ruby gems

Result!

Page 25: RubyConfBD 2013   decouple, bundle and share with ruby gems
Page 26: RubyConfBD 2013   decouple, bundle and share with ruby gems

Usages!

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

Page 27: RubyConfBD 2013   decouple, bundle and share with ruby gems

You can check it yourself!

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

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

Page 28: RubyConfBD 2013   decouple, bundle and share with ruby gems

That’s It! ( Question.any? )