Ruby | gems gem で rubygems.org の gem の情報を取得する #ruby

# Ruby | gems gem で rubygems.org の gem の情報を取得する #ruby
## <i class="fa fa-cubes" style="font-size:1em;"></i> 概要
gems gem で rubygems.org の gem の情報を取得します。
## <i class="fa fa-cube" style="font-size:1em;"></i> インストール
~~~bash
gem install gems
~~~
## <i class="fa cube" style="font-size:1em;"></i> Commands

|command|処理内容|
|:--|:--|
|[info(&lt;gem_name&gt;)](#-gemsinfo)|1件の gem の情報を取得|
|[search(&lt;gem_name&gt;)](#-gemssearch)|一致する gem のリストを取得|
|[gems(&lt;user_name&gt;)](#-gemsgems)|任意のユーザーの gem のリストを取得|
|[push(&lt;gem_name&gt;)](#-gemspush)|Rubygems.org に push する|
|[yank(&lt;gem_name&gt;)](#-gemsyank)|Rubygems.org の gem を削除する|
|[unyank](#-gemsunyank)|Rubygems.org で最後に削除した gem を元にもどす|
|[versions(&lt;gem_name&gt;)](#-gemsversions)|特定の gem の全バージョンのリストを取得|
|[total_downloads(&lt;gem_name&gt;)](#-gemstotal_downloads)|対象 gem のダウンロード数を取得|
|[most_downloaded_today](#-gemsmost_downloaded_today)|本日のダウンロード数トップ 50 の gem を取得|
|[most_downloaded](#-gemsmost_downloaded)|ダウンロード数トップ 50 の gem を取得|
|[downloads](#-gemsdownloads)|Gem のバージョンごとのダウンロード数を配列で取得する|
|[owners](#-gemsowners)|Gem のオーナーの メールアドレスをリスト取得する|
|[add_owner](#-gemsadd_owner)|対象 gem にオーナーを追加する|
|[remove_owner](#-gemsremove_owner)|対象 gem のオーナーを削除する|
|[web_hooks](#-gemsweb_hooks)|あなたのアカウントの全ての WebHook を返却する|
|[add_web_hook](#-gemsadd_web_hook)|webhook を追加する.|
|[remove_web_hook](#-gemsremove_web_hook)|webhook を削除する.|
|[fire_web_hook](#-gemsfire_web_hook)|webhook をテスト用に発火する|
|[latest](#-gemslatest)|最近追加された gem を 50件取得|
|[just_updated](#-gemsjust_updated)|最近更新された gem を 50件取得|
|[configure](#-gemsconfigure)|Retrieve your API key using HTTP basic authentication.|
|[dependencies](#-gemsdependencies)|Return an array of gem dependency details for all versions of all the given gems.|

## <i class="fa fa-file-o" style="font-size:1em;"></i> 利用方法
※認証不要の機能のみ例示

### <i class="fa fa-file-text-o" style="font-size:1em;"></i> Gems.info

~~~ruby
require 'pp'
require 'gems'

# Return some basic information about rails.
pp Gems.info 'ruboty-megen'
~~~

* 出力

~~~ruby
{"name"=>"ruboty-megen",
 "downloads"=>364,
 "version"=>"1.0.1",
 "version_downloads"=>121,
 "platform"=>"ruby",
 "authors"=>"tbpgr",
 "info"=>"ruboty-megen generate ruboty README.md template.",
 "licenses"=>["MIT"],
 "project_uri"=>"http://rubygems.org/gems/ruboty-megen",
 "gem_uri"=>"http://rubygems.org/gems/ruboty-megen-1.0.1.gem",
 "homepage_uri"=>"https://github.com/tbpgr/ruboty-megen",
 "wiki_uri"=>nil,
 "documentation_uri"=>nil,
 "mailing_list_uri"=>nil,
 "source_code_uri"=>nil,
 "bug_tracker_uri"=>nil,
 "dependencies"=>
  {"development"=>
    [{"name"=>"bundler", "requirements"=>"~> 1.6"},
     {"name"=>"rake", "requirements"=>"~> 10.0"},
     {"name"=>"rspec", "requirements"=>">= 0"},
     {"name"=>"simplecov", "requirements"=>">= 0"}],
   "runtime"=>[{"name"=>"thor", "requirements"=>"~> 0.18.1"}]}}
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-search-plus" style="font-size:1em;"></i> Gems.search

~~~ruby
require 'pp'
require 'gems'

# Return some basic information about rails.
pp Gems.search('ruboty-').map { |e|e['name'] }
~~~

* 出力

~~~ruby
["ruboty-redis",
 "ruboty-twitter",
 "ruboty-lgtm",
 "ruboty-japan_weather",
 "ruboty-echo",
 "ruboty-scorekeeper",
 "ruboty-attendance",
 "ruboty-slot",
 "ruboty-yasy",
 "ruboty-hubot",
 "ruboty-ss",
 "ruboty-heroku_status",
 "ruboty-seppuku",
 "ruboty-sudden_death",
 "ruboty-kintai",
 "ruboty-replica",
 "ruboty-mstr",
 "ruboty-nullpo",
 "ruboty-free_image",
 "ruboty-qiita_scouter",
 "ruboty-deadline",
 "ruboty-yes",
 "ruboty-minecraft_status",
 "ruboty-trust_me",
 "ruboty-gcal",
 "ruboty-megen",
 "ruboty-reminder",
 "ruboty-response",
 "ruboty-tweetstream",
 "ruboty-evaluate"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-user" style="font-size:1em;"></i><i class="fa fa-search-plus" style="font-size:1em;"></i> Gems.gems

~~~ruby
require 'pp'
require 'gems'

pp Gems.gems('tbpgr').take(2).map { |e|e['name']}
~~~

* 出力

~~~ruby
["ruboty-wareki", "ruboty-eto"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-cloud-upload" style="font-size:1em;"></i> Gems.push

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-trash" style="font-size:1em;"></i> Gems.yank

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-reply" style="font-size:1em;"></i><i class="fa fa-trash" style="font-size:1em;"></i> Gems.unyank

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-sort-numeric-asc" style="font-size:1em;"></i> Gems.versions

~~~ruby
require 'pp'
require 'gems'

pp Gems.gems('tbpgr').take(2).map { |e|e['name']}
~~~

* 出力

~~~bash
["rspec_piccolo:0.0.8",
 "rspec_piccolo:0.0.7",
 "rspec_piccolo:0.0.6",
 "rspec_piccolo:0.0.5",
 "rspec_piccolo:0.0.4"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-cloud-download" style="font-size:1em;"></i> Gems.total_downloads

~~~ruby
require 'pp'
require 'gems'

pp Gems.total_downloads('rspec_piccolo')
~~~

* 出力

~~~bash
{:total_downloads=>3071, :version_downloads=>399}
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-trophy" style="font-size:1em;"></i><i class="fa fa-cloud-download" style="font-size:1em;"></i> Gems.most_downloaded_today

~~~ruby
require 'pp'
require 'gems'

pp Gems.most_downloaded_today.take(2).map { |e|"gem_id #{e[0]['rubygem_id']}:downloads #{e.last}"}
~~~

* 出力

~~~bash
["gem_id 29916:downloads 6579", "gem_id 15055:downloads 5945"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-trophy" style="font-size:1em;"></i><i class="fa fa-cloud-download" style="font-size:1em;"></i> Gems.most_downloaded

~~~ruby
require 'pp'
require 'gems'

pp Gems.most_downloaded.take(2).map { |e|"gem_id #{e[0]['rubygem_id']}:downloads #{e.last}"}
~~~

* 出力

~~~bash
["gem_id 15055:downloads 20852350", "gem_id 15558:downloads 16982527"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-cloud-download" style="font-size:1em;"></i> Gems.downloads

~~~ruby
require 'pp'
require 'gems'

pp Gems.downloads('rspec_piccolo').take(4)
~~~

* 出力

~~~bash
[["2014-09-03", 0], ["2014-09-04", 0], ["2014-09-05", 5], ["2014-09-06", 3]]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-users" style="font-size:1em;"></i> Gems.owners

~~~ruby
require 'pp'
require 'gems'

pp Gems.owners('rails')
~~~

* 出力

~~~bash
[{"email"=>"yves.senn@gmail.com"},
 {"email"=>"godfreykfc@gmail.com"},
 {"email"=>"andyw@pixeltrix.co.uk"},
 {"email"=>"jeremy@bitsweat.net"},
 {"email"=>"david@loudthinking.com"},
 {"email"=>"michael@koziarski.com"},
 {"email"=>"fxn@hashref.com"},
 {"email"=>"jose.valim@gmail.com"},
 {"email"=>"aaron.patterson@gmail.com"},
 {"email"=>"santiago@wyeworks.com"},
 {"email"=>"carlosantoniodasilva@gmail.com"},
 {"email"=>"guilleiguaran@gmail.com"},
 {"email"=>"rafaelmfranca@gmail.com", "gittip_username"=>""}]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-plus-square" style="font-size:1em;"></i><i class="fa fa-user" style="font-size:1em;"></i> Gems.add_owner

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-trash" style="font-size:1em;"></i><i class="fa fa-user" style="font-size:1em;"></i> Gems.remove_owner

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-external-link" style="font-size:1em;"></i> Gems.web_hooks

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-plus-square-o" style="font-size:1em;"></i><i class="fa fa-external-link" style="font-size:1em;"></i> Gems.add_web_hook

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-trash" style="font-size:1em;"></i><i class="fa fa-external-link" style="font-size:1em;"></i> Gems.remove_web_hook

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-fire" style="font-size:1em;"></i><i class="fa fa-external-link" style="font-size:1em;"></i> Gems.fire_web_hook

no sample

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-plus-square-o" style="font-size:1em;"></i> Gems.latest

~~~ruby
require 'pp'
require 'gems'

pp Gems.latest.take(2).map { |e|e['name'] }
~~~

* 出力

~~~bash
["nifty-variants", "sass-material-colors"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-refresh" style="font-size:1em;"></i> Gems.just_updated

~~~ruby
require 'pp'
require 'gems'

pp Gems.just_updated.take(2).map { |e|e['name'] }
~~~

* 出力

~~~bash
["my_plugin", "my_plugin"]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-gear" style="font-size:1em;"></i> Gems.configure

~~~ruby
require 'pp'
require 'gems'

# Retrieve your API key using HTTP basic authentication.
Gems.configure do |config|
  config.username = 'your email'
  config.password = 'your password'
end
pp Gems.api_key # => your api token
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

### <i class="fa fa-cube" style="font-size:1em;"></i> Gems.dependencies

~~~ruby
require 'pp'
require 'gems'

pp Gems.dependencies ['rspec_piccolo', 'ruboty-megen']
~~~

* 出力

~~~ruby
[{:name=>"rspec_piccolo",
  :number=>"0.0.1",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.2",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.3",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.4",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.5",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.6",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.7",
  :platform=>"ruby",
  :dependencies=>[["activesupport", "~> 4.0.1"], ["thor", "~> 0.18.1"]]},
 {:name=>"rspec_piccolo",
  :number=>"0.0.8",
  :platform=>"ruby",
  :dependencies=>
   [["activesupport", "~> 4.0.1"],
    ["thor", "~> 0.18.1"],
    ["tbpgr_utils", "~> 0.0.4"]]},
 {:name=>"ruboty-megen",
  :number=>"1.0.1",
  :platform=>"ruby",
  :dependencies=>[["thor", "~> 0.18.1"]]},
 {:name=>"ruboty-megen",
  :number=>"1.0.0",
  :platform=>"ruby",
  :dependencies=>[["thor", "~> 0.18.1"]]},
 {:name=>"ruboty-megen",
  :number=>"0.0.1",
  :platform=>"ruby",
  :dependencies=>[["thor", "~> 0.18.1"]]}]
~~~

<i class="fa fa-step-backward" style="font-size:1em;"></i> [back to commands](#-commands)

## <i class="fa fa-arrow-circle-right" style="font-size:1em;"></i> 参照
<i class="fa fa-github" style="font-size:1em;"></i> [gems GitHub](https://github.com/rubygems/gems)
<i class="fa fa-external-link" style="font-size:1em;"></i> [gems RubyGems](http://rubygems.org/gems/gems)
<i class="fa fa-external-link" style="font-size:1em;"></i> [gems source](https://github.com/rubygems/gems/blob/master/lib/gems/client.rb)