Octokit で GitHub の Issue をタイトルで検索します。
※この記事は個人メモです。既出情報のため、元から知っている人は特に得るものがありません
サンプル
環境変数の取得に dotenv を使っています。
dotenv については以下を参照ください。
Gemfile
source "https://rubygems.org" gem "dotenv" gem "octokit"
$ bundle install
コード
require 'octokit' require 'dotenv' require 'pp' Dotenv.load client = Octokit::Client.new(:access_token => ENV['GITHUB_TOKEN']) result = client.search_issues("repo:tbpgr/vup in:'Add dry-run mode'") pp result
- 出力
$ ruby issue_find_by_title.rb {:total_count=>1, :incomplete_results=>false, :items=> [{:url=>"https://api.github.com/repos/tbpgr/vup/issues/6", :repository_url=>"https://api.github.com/repos/tbpgr/vup", :labels_url=> "https://api.github.com/repos/tbpgr/vup/issues/6/labels{/name}", :comments_url=>"https://api.github.com/repos/tbpgr/vup/issues/6/comments", :events_url=>"https://api.github.com/repos/tbpgr/vup/issues/6/events", :html_url=>"https://github.com/tbpgr/vup/issues/6", :id=>169369442, :number=>6, :title=>"Add dry-run mode", :user=> {:login=>"tbpgr", :id=>4787509, :avatar_url=>"https://avatars.githubusercontent.com/u/4787509?v=3", :gravatar_id=>"", :url=>"https://api.github.com/users/tbpgr", :html_url=>"https://github.com/tbpgr", :followers_url=>"https://api.github.com/users/tbpgr/followers", :following_url=> "https://api.github.com/users/tbpgr/following{/other_user}", :gists_url=>"https://api.github.com/users/tbpgr/gists{/gist_id}", :starred_url=> "https://api.github.com/users/tbpgr/starred{/owner}{/repo}", :subscriptions_url=>"https://api.github.com/users/tbpgr/subscriptions", :organizations_url=>"https://api.github.com/users/tbpgr/orgs", :repos_url=>"https://api.github.com/users/tbpgr/repos", :events_url=>"https://api.github.com/users/tbpgr/events{/privacy}", :received_events_url=> "https://api.github.com/users/tbpgr/received_events", :type=>"User", :site_admin=>false}, :labels=>[], :state=>"closed", :locked=>false, :assignee=>nil, :assignees=>[], :milestone=>nil, :comments=>0, :created_at=>2016-08-04 13:05:25 UTC, :updated_at=>2016-08-06 21:01:39 UTC, :closed_at=>2016-08-06 21:01:39 UTC, :body=> "```\n$ cat version.cr\nmodule Vup\n VERSION = \"0.1.0\"\nend\n$ vup --patch --dry-run\n0.2.0\n$ cat version.cr\nmodule Vup\n VERSION = \"0.1.0\"\nend\n```\n", :score=>3.0223746}]}
このIssueを結果として取得できました。