Upgrade to Pro — share decks privately, control downloads, hide ads and more …

what is a gem and how do I build one

what is a gem and how do I build one

this is an account of my first ruby gem

glamouracademy

November 05, 2013
Tweet

More Decks by glamouracademy

Other Decks in Technology

Transcript

  1. em gem gem gem g gem gem gem gem gem

    gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem gem em m ge g g g
  2. what is a gem? Jem, also known as Jem and

    the Holograms, is an American animated television series that ran from 1985 to 1988 in U.S. first-run syndication. The show is about music company owner Jerrica Benton, her singer alter-ego Jem, her band the Holograms, and their adventures
  3. what is a gem? One of the most beautiful things

    about Ruby development is the ease of adding functionality through packaged libraries called gems. Gems can be used to extend or modify functionality in Ruby applications. Commonly they're used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work.
  4. gems are superpowers “Jem had special powers (through Synergy)” -The

    Discriminating Fangirl Jerrica adopts this persona (Jem) with the help of a holographic computer, known as Synergy, which was built by Jerrica's father to be "the ultimate audio-visual entertainment synthesizer" and is bequeathed to her after his death. Jerrica is able to command Synergy to project "the Jem hologram" over herself by means of the remote micro-projectors in her earrings, thus disguising her features and clothing enabling her to assume the Jem persona. While disguised as Jem, Jerrica is able to move freely without restrictions and on several occasions other people have been in direct physical contact with her without disrupting the holographic projection. Jem, through the use of her earrings, is also able to project holograms around her and uses this ability throughout the series to avoid danger and provide special effects for the performances of her group. -wikipedia
  5. python → eggs java → jars .net → nugets objective-c

    → cocoapods ruby → gems now, with m ore relevant context
  6. break everything down into bite-sized units of work choose something

    you like! consider the data get the data create gem dir create gemspec add an executable build && install the gem test it locally get a rubygem acct publish & push gem 1 2 3 4 5 7 .A 8 9 10 write your gem 6
  7. 1

  8. gem.first As of May 2013, the Bitcoin network processing power

    "exceeds the combined processing strength of the top 500 most powerful supercomputers". The Chinese Are In Love With Bitcoin And It's Driving The Digital Currency's Prices Into The Stratosphere
  9. break everything down into bite-sized units of work choose something

    you like! consider the data get the data create gem dir create gemspec add an executable build && install the gem test it locally get a rubygem acct publish & push gem 1 2 3 4 5 7 .A 8 9 10 write your gem 6
  10. create the gem directory example 1 example 2 4 •

    name your gem • Code for your package is placed within the lib directory. (The convention is to have one Ruby file with the same name as your gem, since that gets loaded when require 'bithound' is run.) • That one file is in charge of setting up your gem’s code and API.
  11. create the gemspec example 1 example 2 5 • a

    gemspec is a specification guide for your gem • information that you enter in your gemspec appears on rubygems.org, which is where people will get your gem • fyi ‘MIT’ is an open source license. other types of licenses include: GPL, CC.
  12. write your gem (if you haven’t already) example 1 example

    2 6 • this is in the .rb file you created in step 4 (which is also the name of your gem)
  13. build it && install it example 1 example 2 7

    • build the gem locally from the directory you created • install the gem locally using the version number (or else the gem manager will look for your gem on the web which isn’t there yet)
  14. test it locally example 1 example 2 7A • in

    irb, ‘require’ your gem
  15. adding an executable example 1 example 2 8 • an

    “executable” is what executes your gem • the file needs to be in the bin directory • also, the file needs a shebang #! ← (also, I like the word ‘shebang’) 1 2 3
  16. test it locally example 1 example 2 8A • you

    can run the executable from either the bin directory or you can type in the path
  17. get a rubygems account (if you don’t have one) 9

    • consider using the same handle is your github account because your gem is also in github
  18. publish && push your gem 10 your rubygems handle your

    rubygems password 1 2 ‘u’ stands for ‘username’ • want to learn more about curl? (it’s not this) ‘curl’ is the command you type
  19. after you publish && push, you can see your gem

    in rubygems.org and people can install it!