SlideShare a Scribd company logo
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

More Related Content

PDF
Search friendly image galleries s lideshare
PDF
Distributed Transactions in Akka.NET
PDF
Akka.NET @ London.NET
PDF
Akka.NET Fundamentals — #ProgNet15
PDF
Concurrency, Without the Pain: An Intro to Akka.NET @ Bay.NET
PDF
Functional Web Apps with WebMachine Framework - Mikhail Bortnyk
PDF
Streaming ETL With Akka.NET
PDF
Scala for android
Search friendly image galleries s lideshare
Distributed Transactions in Akka.NET
Akka.NET @ London.NET
Akka.NET Fundamentals — #ProgNet15
Concurrency, Without the Pain: An Intro to Akka.NET @ Bay.NET
Functional Web Apps with WebMachine Framework - Mikhail Bortnyk
Streaming ETL With Akka.NET
Scala for android

Similar to Contributing To Rails By Plugin Gem (20)

PPT
Design Pattern From Java To Ruby
PPT
Rails bestpractices.com
PPT
Ruby application based on http
PPT
Css sprite best practices
PPT
Static Code Analysis For Ruby
PDF
Design Pattern From Java To Ruby
PPT
Ruby On Rails Seminar Basis Softexpo Feb2010
PPT
Rails Vs CakePHP
PPT
RubyonRails
PPT
Email Contacts For Invitation
PPTX
Intro to Rails
KEY
Ruby On Rails
PDF
Ror Seminar With agilebd.org on 23 Jan09
PPT
Ruby Kaigi09 China Rubyupdate20090718
PDF
Vivendo No Mundo Rails
ODP
DiUS Computing Lca Rails Final
PDF
Rails for Django developers
PDF
RoR (Ruby on Rails)
PDF
Merb For The Enterprise
PDF
Web application intro + a bit of ruby (revised)
Design Pattern From Java To Ruby
Rails bestpractices.com
Ruby application based on http
Css sprite best practices
Static Code Analysis For Ruby
Design Pattern From Java To Ruby
Ruby On Rails Seminar Basis Softexpo Feb2010
Rails Vs CakePHP
RubyonRails
Email Contacts For Invitation
Intro to Rails
Ruby On Rails
Ror Seminar With agilebd.org on 23 Jan09
Ruby Kaigi09 China Rubyupdate20090718
Vivendo No Mundo Rails
DiUS Computing Lca Rails Final
Rails for Django developers
RoR (Ruby on Rails)
Merb For The Enterprise
Web application intro + a bit of ruby (revised)
Ad

More from Daniel Lv (11)

PDF
Javascript framework and backbone
PDF
Intridea & open source
PDF
Getting start with titanium
KEY
Better framework, better life
KEY
上海的Rails社区
PDF
Kungfurails2009
PPT
Sinatra
PDF
J Ruby Kungfu Rails
PDF
Active Direct
PPT
岛根县政府的挑战
PDF
Why Ruby
Javascript framework and backbone
Intridea & open source
Getting start with titanium
Better framework, better life
上海的Rails社区
Kungfurails2009
Sinatra
J Ruby Kungfu Rails
Active Direct
岛根县政府的挑战
Why Ruby
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
A Presentation on Artificial Intelligence
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
1. Introduction to Computer Programming.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Assigned Numbers - 2025 - Bluetooth® Document
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectroscopy.pptx food analysis technology
A Presentation on Artificial Intelligence
Group 1 Presentation -Planning and Decision Making .pptx
Advanced methodologies resolving dimensionality complications for autism neur...
A comparative analysis of optical character recognition models for extracting...
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
1. Introduction to Computer Programming.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Assigned Numbers - 2025 - Bluetooth® Document

Contributing To Rails By Plugin Gem

  • 1. 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
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. Autotest www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development autotest a utospec
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. Lazy loading www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development autoload
  • 16. 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
  • 17. 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
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. 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
  • 25. 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