Monday, September 30, 2013

bundlerを使ったgemの作り方、公開方法

Rubyのgemパッケージを作成する手順について。bundlerにgem作成を助ける機能がいくつかあるので利用する。

ひな形の作成

bundle gemでひな形を生成する。

$ bundle gem mylib

gemspecは各gemごとに適当に修正する。ひな形を見ればすぐに内容はわかる。

依存ライブラリ

依存ライブラリはGemfileではなくgemspecファイルに記述して、Gemfileからはgemspecを参照するだけにする。

Gemfile

source 'https://rubygems.org'

gemspec

mylib.gemspec

Gem::Specification.new do |spec|
  ...
  spec.add_runtime_dependency "hashie"
  spec.add_runtime_dependency "json"
  spec.add_development_dependency "bundler"
  spec.add_development_dependency "rake"
end

ビルド

gem buildコマンドでビルド。

$ gem build mylib.gemspec

bundleでひな形を作っている場合は、rake buildでpkgフォルダにgemパッケージが作成される。

$ rake build

公開

gem pushコマンドで公開。このとき、rubygems.orgのアカウントが必要。

$ gem push mylib-x.x.x.gem

同様にbundleでひな形を作っている場合は、rake releaseリリースできる

$ rake release

1 comment:

Unknown said...

Any generation on the power follow has become a prospect caused by your miniaturization of digital elements and the benefits associated with compact power packs. Wristwatches equally attemptedto really do the initially showcase. Typically the check out introduced the 1st a particular during fresh design and style. However it has been in a rush to promote thanks to phobias about wrist watches liberating one preceding these products. Because of this, it absolutely was overwhelmed utilizing excellence troubles from the start replica watches, which usually harmed a popularity. The source had been together with the electric liaisons which unfortunately rapidly painted away and ended up being difficult vehicle repairs. Any view got plenty of story features which manufactured these folks attractive to the public. For the reason that were derived utilizing a tuning derive, people hummed rather than ticked as well as were definitely the first to experience sweeping just a few seconds possession. Watches editions demonstrated to the greatly different and also unconventional tuning derive resource interior. Still needless to say, being in position to claim for being the foremost specific watch readily available, appeared to be an immense marketing benefits for him or her. By way of 1970 however, your publishing was basically in the walls for the designer watches. The particular running watches would try and embrace even on a little bit of extended together with the progression in the unit which usually combined tuning hand technologies along with quartz manipulate. All these breakthroughs affected exactly how quartz wristwatches advanced and then the development for accurate products. The main observe has been not cheap, being a comparable being a view right at that moment, and also are not notably trustworthy using quite a few being forced to come to be recalled. But the quartz genie had been out from the product, and even there seems to be simply no returning. These days, nearly all watches can be quartz and are also one of the most budget friendly in addition to specific designer watches available.