forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitignore.rb
More file actions
56 lines (47 loc) · 1.39 KB
/
Copy pathgitignore.rb
File metadata and controls
56 lines (47 loc) · 1.39 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
# encoding: utf-8
module Github
# When you create a new GitHub repository via the API, you can specify a
# .gitignore template to apply to the repository upon creation.
class Gitignore < API
# Creates new Gitignore API
def initialize(options = {})
super(options)
end
# List all templates available to pass as an option when creating a repository.
#
# = Examples
# github = Github.new
# github.gitignore.list
# github.gitignore.list { |template| ... }
#
def list(*args)
params = args.extract_options!
normalize! params
response = get_request("/gitignore/templates", params)
return response unless block_given?
response.each { |el| yield el }
end
alias :all :list
# Get a single template
#
# = Examples
# github = Github.new
# github.gitignore.get "template-name"
#
# Use the raw media type to get the raw contents.
#
# = Examples
# github = Github.new
# github.gitignore.get "template-name", mime: 'applicatin/vnd.github.raw'
#
def get(name, params={})
normalize! params
assert_presence_of name
if (mime_type = params.delete('mime'))
options = { :raw => true, :headers => {'Accept' => mime_type} }
end
get_request("/gitignore/templates/#{name}", params, options || {})
end
alias :find :get
end # Gitignore
end # Github