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

                                          Publish Gem
                                           "mysql"


                                                           Ruby Dev




                      Over the Internet   Publish Gem
RubyGems Repository                       "user_auth"


                                                           Ruby Dev




                                           Publish Gem
                                          "factory_girl"


                                                           Ruby Dev
A complete ruby application
Create RubyConf2013_hello
          gem!
$ gem install bundle
$ bundle gem rubyconfbd2013_hello
Generated files
Code it!
# File: lib/rubyconfbd2013_hello.rb
require "rubyconfbd2013_hello/version"

module Rubyconfbd2013Hello
  def rubyconfbd_year
    2013
  end

  def rubyconfbd_location
    'Bangladesh'
  end
end

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? )

             

RubyConfBD 2013 decouple, bundle and share with ruby gems

  • 1.
    Decouple, Bundle andShare with Ruby Gems Nhm Tanveer Hossain Khan (Hasan)
  • 2.
    Things on thetable • What is decoupling ? • What is Gem ? • Create RubyConf2013_Hello Gem. • Publish on RubyGems Repository. • And share with fellow ruby developers
  • 3.
    About me! • Workingwith 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
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
    Benefits (contd.) • Creates reusable code • Modularizes structure • Responds to polymorphic behavior • Possible to integrate with other projects
  • 9.
    Trade-offs • Requires commonsense • Requires expertise on understanding “What’s enough?” • It should be derived from a real project. • Requires tune up and adjustment based on real requirements.
  • 10.
  • 11.
  • 12.
  • 13.
    Real Ruby Stone! Collectedfrom wikipedia - http://en.wikipedia.org/wiki/File:Ruby_-_Winza,_Tanzania.jpg
  • 14.
    Ruby Gem/Gemstone! Collected fromwikipedia - http://en.wikipedia.org/wiki/File:Cardinal_gems.png
  • 15.
  • 16.
    Ruby Gems Repository Publish Gem "mysql" Ruby Dev Over the Internet Publish Gem RubyGems Repository "user_auth" Ruby Dev Publish Gem "factory_girl" Ruby Dev
  • 17.
    A complete rubyapplication
  • 18.
  • 19.
    $ gem installbundle $ bundle gem rubyconfbd2013_hello
  • 20.
  • 21.
    Code it! # File:lib/rubyconfbd2013_hello.rb require "rubyconfbd2013_hello/version" module Rubyconfbd2013Hello def rubyconfbd_year 2013 end def rubyconfbd_location 'Bangladesh' end end Object.send(:extend, Rubyconfbd2013Hello) Object.send(:include, Rubyconfbd2013Hello)
  • 22.
    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"
  • 23.
  • 24.
  • 26.
    Usages! • $ geminstall rubyconfbd2013_hello • $ irb • require “rubyconfbd2013_hello” • Object.rubyconfbd_year • => 2013 • Object.rubyconfbd_location • => „Bangladesh”
  • 27.
    You can checkit yourself! • Rubygems link - https://rubygems.org/gems/rubyconfbd2013_ hello • Github link - https://github.com/we4tech/rubyconfbd2013 _hello
  • 28.
    That’s It! (Question.any? ) 