forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.rb
More file actions
85 lines (75 loc) · 2.06 KB
/
search.rb
File metadata and controls
85 lines (75 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# encoding: utf-8
module Github
class Search < API
include Github::Utils::Url
# Search issues
#
# Find issues by state and keyword.
#
# = Parameters
# <tt>:state</tt> - open or closed.
# <tt>:keyword</tt> - search term
#
# = Examples
# github = Github.new
# github.search.issues 'owner', 'repo-name', 'open','api'
# github.search.issues owner: 'owner', repo: 'repo-name', state: 'open', keyword: 'api'
#
def issues(*args)
required = ['owner', 'repo', 'state', 'keyword']
arguments(args, :required => required)
get_request("/legacy/issues/search/#{owner}/#{repo}/#{state}/#{escape_uri(keyword)}", arguments.params)
end
# Search repositories
#
# Find repositories by keyword.
#
# = Parameters
# <tt>:keyword</tt> - search term
#
# = Examples
# github = Github.new
# github.search.repos 'api'
# github.search.repos keyword: 'api'
#
def repos(*args)
arguments(args, :required => [:keyword])
get_request("/legacy/repos/search/#{escape_uri(keyword)}", arguments.params)
end
alias :repositories :repos
# Search users
#
# Find users by keyword.
#
# = Parameters
# <tt>:keyword</tt> - search term
#
# = Examples
# github = Github.new
# github.search.users keyword: 'wycats'
#
def users(*args)
arguments(args, :required => [:keyword])
get_request("/legacy/user/search/#{escape_uri(keyword)}", arguments.params)
end
# Search email
#
# This API call is added for compatibility reasons only. There’s no
# guarantee that full email searches will always be available.
#
# = Parameters
# <tt>:keyword</tt> - search term
#
# = Examples
# github = Github.new
# github.search.email email: 'wycats'
#
def email(*args)
arguments(args) do
assert_required %w[ email ]
end
params = arguments.params
get_request("/legacy/user/email/#{params.delete('email')}", params)
end
end # Search
end # Github