Contributing To Rails By Plugin Gem
Upcoming SlideShare
Loading in...5
×
 

Contributing To Rails By Plugin Gem

on

  • 2,082 views

 

Statistics

Views

Total Views
2,082
Views on SlideShare
2,044
Embed Views
38

Actions

Likes
2
Downloads
40
Comments
0

7 Embeds 38

http://huangzhimin.com 17
http://blog.huangzhimin.com 10
http://www.huangzhimin.com 3
http://flyerhzm.github.com 3
http://luckypoem1.github.io 3
http://www.slideshare.net 1
http://www.slideee.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Contributing To Rails By Plugin Gem Contributing To Rails By Plugin Gem Presentation Transcript

  • Contributing to Rails with plugins or gems Richard Huang E kohe www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • Agenda
    • Testing
    • Plugins
    • Gems
    • Contribute
    www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • Why use plugins or gems
    • Component
    • Robust
    • Multiple choices
    www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • Why write a plugin or gem
    • Share your ideas
    • DRY
    • Learn a lot
    • Make your code better
    www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • Plugin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Read the guides first
      • http://guides.rubyonrails.org/plugins.html
    • Read other people’s plugins
    • Just do it
  • Plugin structure www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Executed when plugin loaded Executed when plugin installed Executed when plugin destroyed Rake task added to rails rake load path Logic codes of your plugin Test codes of your plugin Define plugin rake tasks
  • Plugin structure www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Plugin logic codes Textile README require ‘bullet’ require ‘bulletware’ reqire ‘bullet/association’ …… Rspec to test plugins
  • Testing – the more, the better www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Tests are documents
    • Tests make your code robust
    • Test s e nable good communication between you and contributors
  • Autotest www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • autotest
    • a utospec
  • Testing ActiveRecord www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Use sqlite3 (memory)
    • Create and drop table each time
    • Silence your migration
  • Adding methods www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • class methods and instance methods
  • Changing method behavior www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • alias_method
  • Hack with different rails versions www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Implementations are different in different rails versions
  • Configure your plugin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Enable or disable plugin
  • Lazy loading www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • autoload
  • Reuse logic www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Similar to writing rails app
      • Model
      • Controller
      • Helper
      • Task
  • README www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Let others know what you are doing
    • Rdoc, Textile or Markdown
    • An example is better
  • Gem www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Easier to maintain
    • Easier to upgrade
    • Includes dependencies automatically
    • Can use without rails
  • Gem tool -- Jeweler www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Defining your gem
    • Bumping gem version
    • Releasing gem
  • Adding gem rake www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Rails does not load gem rake
    • Load it yourself
  • Adding executable to gem www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Using optparse to get input
    • Defining executable in gemspec
  • Contribute www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Write down your ideas
    • Share your codes (rubyforge, github, gemcutter, etc.)
    • Tell others what you do
    • Use it and improve it
  • Contribute www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Don’t be afraid of reinventing the wheel
    • Don’t be afraid of ugly code
    • Don’t be afraid of bugs
  • To be a better contributor www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
    • Read other people’s plugins
      • http://github.com/flyerhzm/monitor
  • Q&A Thank you Website: http://www.huangzhimin.com Github: http://github.com/flyerhzm www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development