Vinova tuyển lập trình viên Mobile & Web ở Hà Nội, lương $300-1000

Article: Xuất bản gem 1496

ngocdaothanh.myopenid.com 172
Updated over 2 years ago

Nếu như Perl có CPAN, PHP có PEAR, thì Ruby có RubyGem. Nếu project bạn đăng kí trên RubyForge thuộc dạng tiện ích command line hoặc thư viện, thì nên xuất bản theo dạng gem để có thể install dễ dàng bằng lệnh gem install <project_name>.

Để cụ thể dễ hiểu, xin trình bày qui trình dùng để xuất bản Revent.

Trong thư mục trunk, tạo tập tin revent.gemspec có nội dung sau:

Gem::Specification.new do |spec|
spec.name = 'revent'
spec.rubyforge_project = 'revent'
spec.version = '0.1'
spec.summary = 'RPC based on EventMachine'
spec.author = 'Ngoc DAO Thanh'
spec.email = 'ngocdaothanh@gmail.com'
spec.homepage = 'http://revent.rubyforge.org'
files = Dir.glob('**/*')
files.delete('revent.gemspec')
spec.files = files
spec.has_rdoc = false
end

Rồi chạy lệnh gem build revent.gemspec để tạo revent-0.1.gem. Kết quả lệnh trên như sau:

WARNING:  RDoc will not be generated (has_rdoc == false)
Successfully built RubyGem
Name: revent
Version: 0.1
File: revent-0.1.gem

Trước hết ta thử install trên máy của chính mình bằng lệnh gem install revent-0.1.gem.

Nếu suôn sẻ thì ta upload revent-0.1.gem lên RubyForge, phải chọn kiểu tập tin là .gem để RubyForge tự động đăng kí với gem server.

Chờ vài tiếng, kiểm tra xem đã đăng kí xong chưa bằng lệnh gem search -r revent.

Revent chỉ gồm ít tập tin, nên qui trình xuất bản đơn giản. Với các project phức tạp hơn, nên dùng những tiện ích như New Gem.

Từ giữa tháng 11 năm 2009, RubyForge đã chuyển sang Gemcutter:

A few days ago we repointed gems.rubyforge.org to the gemcutter.org box. This means that Nick Quaranto's excellent gemcutter app is now indexing and serving all the gems - so rather than having two gem indexes, we now have one. As a consequence of this, when you release files to RubyForge you will probably also want to do a "gem push" to get them onto gemcutter and into the main gem index.

Note that you can continue to release gems (and other files) at RubyForge; it's just that gems won't automatically make it into the main gem index.

Comments

nguoitapdich.myopenid.com 35
over 4 years ago

Em nghe nói JavaScript có JSAN, Java có CJAN nhưng chưa dùng thử lần nào, ko biết thế nào{#emotions_dlg.foot_in_mouth}

ngocdaothanh.myopenid.com 172
over 4 years ago

Để đọc tài liệu về các gem có trên máy, dùng lệnh gem server (hoặc gem_server), rồi dùng trình duyệt để đọc.

You must login to be able to comment

Uploaded files

No file uploaded yet

You must login to be able to upload

Nhà tài trợ:

Mọi người đều tự do viết bài, sửa bài của người khác, và bình luận ở trang web này. Bạn muốn chủ động tạo bài mới để chia sẻ kinh nghiệm với mọi người? Xin click link ở dưới.

Create new content