Class: Stove::Plugin::GitHub
- Inherits:
-
Base
- Object
- Base
- Stove::Plugin::GitHub
show all
- Defined in:
- lib/stove/plugins/github.rb
Instance Attribute Summary
Attributes inherited from Base
#cookbook, #options
Instance Method Summary
collapse
Methods inherited from Base
#initialize, onload
#after, #before
extended, included
#validate
Instance Method Details
#changeset ⇒ Object
52
53
54
|
# File 'lib/stove/plugins/github.rb', line 52
def changeset
@changeset ||= cookbook.changeset.split("\n")[2..-1].join("\n").strip
end
|
#client ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/stove/plugins/github.rb', line 39
def client
return @client if @client
config = {}.tap do |h|
h[:middleware] = middleware
h[:access_token] = Config[:github][:access_token]
h[:api_endpoint] = Config[:github][:api_endpoint] if Config[:github][:api_endpoint]
end
@client = Octokit::Client.new(config)
@client
end
|
#filename ⇒ Object
60
61
62
|
# File 'lib/stove/plugins/github.rb', line 60
def filename
@filename ||= "#{cookbook.name}-#{cookbook.version}.tar.gz"
end
|
#middleware ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/stove/plugins/github.rb', line 64
def middleware
Faraday::Builder.new do |builder|
builder.use Stove::Middleware::Exceptions
builder.use Octokit::Response::RaiseError
builder.response :logger, log
builder.response :raise_error
builder.adapter :net_http
end
end
|
#repo_url ⇒ String
The URL for this repository on GitHub. This method automatically translates SSH and git:// URLs to https:// URLs.
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/stove/plugins/github.rb', line 87
def repo_url
return @repo_url if @repo_url
path = File.join('.git', 'config')
log.debug("Calculating repo_url from `#{path}'")
config = File.read(path)
log.debug("Config contents:\n#{config}")
config =~ /\[remote "#{options[:remote]}"\]\n\s+url = (.+)$/
log.debug("Match: #{$1.inspect}")
@repo_url = $1.to_s
.strip
.gsub(/\.git$/, '')
.gsub(/^\S+@(\S+):/, 'https://\1/')
.gsub('git://', 'https://')
@repo_url
end
|
#repository ⇒ Object
56
57
58
|
# File 'lib/stove/plugins/github.rb', line 56
def repository
@repository ||= Octokit::Repository.from_url(repo_url)
end
|