Your SlideShare is downloading. ×
0
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Extracting ruby gem
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Extracting ruby gem

2,084

Published on

Create ruby gem step by step with bundler

Create ruby gem step by step with bundler

Published in: Self Improvement, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,084
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Yura TolstikRuby/Rails developer at Altoros Development t witter: @yltsrc email: yltsrc@gmail.com
  • 2. Extracting ruby gem Why? Reusable code Easy to install Easy to share
  • 3. Lets start Find code duplicationsWrite tests if not exists Ready?
  • 4. How to create creating a gemspecification file(mygem.gemspec) bundle gem mygem and do all things by hand...
  • 5. By hand?
  • 6. mygem.gemspecGem::Specification.new do |s| s.name = "mygem" s.version = Mygem::VERSION s.authors = ["Yura Tolstik"] s.email = ["yltsrc@gmail.com"] s.homepage = "http://github.com/yltsrc/mygem" s.summary = %q{My first gem} s.description = %q{Create ruby gem step by step with bundler} s.license = "MIT" s.files = `git ls-files`.split("n") s.test_files = `git ls-files -- spec/*`.split("n") s.require_paths = ["lib"] s.add_development_dependency "rake" s.add_development_dependency "rspec"end
  • 7. spec_helper.rb$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), .., lib))$LOAD_PATH.unshift(File.dirname(__FILE__))require rspecrequire newgemRSpec.configure do |config| # if neededend
  • 8. Extract testsdescribe "Mygem" do describe "#hello" do it "should return Hello world!" do @base = "" @base.extend(Mygem::Base) @base.hello.should eql("Hello world!") end endend
  • 9. Extract methodsmodule Mygem module Base def hello "Hello #{self.empty? ? world : self}!" end endend
  • 10. Rakefilerequire "bundler/gem_tasks"require rspec/corerequire rspec/core/rake_taskRSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = FileList[spec/**/*_spec.rb]endtask :default => :spec
  • 11. Testrake spec
  • 12. Build rake build orgem build mygem.gemspec
  • 13. Publish rake release orgem push mygem-0.0.1.gem
  • 14. My own gem server gem help generate_index gem help server
  • 15. Questions http://gembundler.com/rubygems.htmlhttp://docs.rubygems.org/read/chapter/20

×