octokit 7.2.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/octokit.rb CHANGED
@@ -4,6 +4,7 @@ require 'octokit/default'
4
4
  require 'octokit/client'
5
5
  require 'octokit/enterprise_admin_client'
6
6
  require 'octokit/enterprise_management_console_client'
7
+ require 'octokit/manage_ghes_client'
7
8
 
8
9
  # Ruby toolkit for the GitHub API
9
10
  module Octokit
@@ -41,12 +42,24 @@ module Octokit
41
42
  @enterprise_management_console_client = Octokit::EnterpriseManagementConsoleClient.new(options)
42
43
  end
43
44
 
45
+ # ManageGHESClient client based on configured options {Configurable}
46
+ #
47
+ # @return [Octokit::ManageGHESClient] API wrapper
48
+ def manage_ghes_client
49
+ if defined?(@manage_ghes_client) && @manage_ghes_client.same_options?(options)
50
+ return @manage_ghes_client
51
+ end
52
+
53
+ @manage_ghes_client = Octokit::ManageGHESClient.new(options)
54
+ end
55
+
44
56
  private
45
57
 
46
58
  def respond_to_missing?(method_name, include_private = false)
47
59
  client.respond_to?(method_name, include_private) ||
48
60
  enterprise_admin_client.respond_to?(method_name, include_private) ||
49
- enterprise_management_console_client.respond_to?(method_name, include_private)
61
+ enterprise_management_console_client.respond_to?(method_name, include_private) ||
62
+ manage_ghes_client.respond_to?(method_name, include_private)
50
63
  end
51
64
 
52
65
  def method_missing(method_name, *args, &block)
@@ -56,6 +69,8 @@ module Octokit
56
69
  return enterprise_admin_client.send(method_name, *args, &block)
57
70
  elsif enterprise_management_console_client.respond_to?(method_name)
58
71
  return enterprise_management_console_client.send(method_name, *args, &block)
72
+ elsif manage_ghes_client.respond_to?(method_name)
73
+ return manage_ghes_client.send(method_name, *args, &block)
59
74
  end
60
75
 
61
76
  super
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.2.0
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
8
8
  - Erik Michaels-Ober
9
9
  - Clint Shryock
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-09-29 00:00:00.000000000 Z
13
+ date: 2024-10-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -104,7 +104,6 @@ files:
104
104
  - lib/octokit/client/organizations.rb
105
105
  - lib/octokit/client/pages.rb
106
106
  - lib/octokit/client/projects.rb
107
- - lib/octokit/client/pub_sub_hubbub.rb
108
107
  - lib/octokit/client/pull_requests.rb
109
108
  - lib/octokit/client/rate_limit.rb
110
109
  - lib/octokit/client/reactions.rb
@@ -135,6 +134,8 @@ files:
135
134
  - lib/octokit/enterprise_management_console_client/management_console.rb
136
135
  - lib/octokit/error.rb
137
136
  - lib/octokit/gist.rb
137
+ - lib/octokit/manage_ghes_client.rb
138
+ - lib/octokit/manage_ghes_client/manage_ghes.rb
138
139
  - lib/octokit/middleware/follow_redirects.rb
139
140
  - lib/octokit/organization.rb
140
141
  - lib/octokit/rate_limit.rb
@@ -152,7 +153,7 @@ licenses:
152
153
  - MIT
153
154
  metadata:
154
155
  rubygems_mfa_required: 'true'
155
- post_install_message:
156
+ post_install_message:
156
157
  rdoc_options: []
157
158
  require_paths:
158
159
  - lib
@@ -167,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: 1.3.5
169
170
  requirements: []
170
- rubygems_version: 3.4.20
171
- signing_key:
171
+ rubygems_version: 3.0.3.1
172
+ signing_key:
172
173
  specification_version: 4
173
174
  summary: Ruby toolkit for working with the GitHub API
174
175
  test_files: []
@@ -1,111 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Octokit
4
- class Client
5
- # Methods for the PubSubHubbub API
6
- #
7
- # @see https://developer.github.com/v3/repos/hooks/#pubsubhubbub
8
- module PubSubHubbub
9
- # Subscribe to a pubsub topic
10
- #
11
- # @param topic [String] A recoginized and supported pubsub topic
12
- # @param callback [String] A callback url to be posted to when the topic event is fired
13
- # @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
14
- # @return [Boolean] true if the subscribe was successful, otherwise an error is raised
15
- # @see https://developer.github.com/v3/repos/hooks/#subscribing
16
- # @example Subscribe to push events from one of your repositories, having an email sent when fired
17
- # client = Octokit::Client.new(:oauth_token = "token")
18
- # client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
19
- def subscribe(topic, callback, secret = nil)
20
- options = {
21
- 'hub.callback': callback,
22
- 'hub.mode': 'subscribe',
23
- 'hub.topic': topic
24
- }
25
- options.merge!('hub.secret': secret) unless secret.nil?
26
-
27
- response = pub_sub_hubbub_request(options)
28
-
29
- response.status == 204
30
- end
31
-
32
- # Unsubscribe from a pubsub topic
33
- #
34
- # @param topic [String] A recoginized pubsub topic
35
- # @param callback [String] A callback url to be unsubscribed from
36
- # @return [Boolean] true if the unsubscribe was successful, otherwise an error is raised
37
- # @see https://developer.github.com/v3/repos/hooks/#subscribing
38
- # @example Unsubscribe to push events from one of your repositories, no longer having an email sent when fired
39
- # client = Octokit::Client.new(:oauth_token = "token")
40
- # client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
41
- def unsubscribe(topic, callback)
42
- options = {
43
- 'hub.callback': callback,
44
- 'hub.mode': 'unsubscribe',
45
- 'hub.topic': topic
46
- }
47
- response = pub_sub_hubbub_request(options)
48
-
49
- response.status == 204
50
- end
51
-
52
- # Subscribe to a repository through pubsub
53
- #
54
- # @param repo [String, Repository, Hash] A GitHub repository
55
- # @param service_name [String] service name owner
56
- # @param service_arguments [Hash] params that will be passed by subscribed hook.
57
- # List of services is available @ https://github.com/github/github-services/tree/master/docs.
58
- # Please refer Data node for complete list of arguments.
59
- # @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
60
- # @return [Boolean] True if subscription successful, false otherwise
61
- # @see https://developer.github.com/v3/repos/hooks/#subscribing
62
- # @example Subscribe to push events to one of your repositories to Travis-CI
63
- # client = Octokit::Client.new(:oauth_token = "token")
64
- # client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
65
- def subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil)
66
- topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
67
- callback = "github://#{service_name}?#{service_arguments.collect { |k, v| [k, v].map { |p| URI.encode_www_form_component(p) }.join('=') }.join('&')}"
68
- subscribe(topic, callback, secret)
69
- end
70
-
71
- # Unsubscribe repository through pubsub
72
- #
73
- # @param repo [String, Repository, Hash] A GitHub repository
74
- # @param service_name [String] service name owner
75
- # List of services is available @ https://github.com/github/github-services/tree/master/docs.
76
- # @see https://developer.github.com/v3/repos/hooks/#subscribing
77
- # @example Subscribe to push events to one of your repositories to Travis-CI
78
- # client = Octokit::Client.new(:oauth_token = "token")
79
- # client.unsubscribe_service_hook('joshk/device_imapable', 'Travis')
80
- def unsubscribe_service_hook(repo, service_name)
81
- topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
82
- callback = "github://#{service_name}"
83
- unsubscribe(topic, callback)
84
- end
85
-
86
- private
87
-
88
- def pub_sub_hubbub_request(options = {})
89
- # This method is janky, bypass normal stack so we don't
90
- # serialize request as JSON
91
- conn = Faraday.new(url: @api_endpoint) do |http|
92
- http.headers[:user_agent] = user_agent
93
- if basic_authenticated?
94
- http.request(*FARADAY_BASIC_AUTH_KEYS, @login, @password)
95
- elsif token_authenticated?
96
- http.request :authorization, 'token', @access_token
97
- end
98
- http.request :url_encoded
99
- http.use Octokit::Response::RaiseError
100
- http.adapter Faraday.default_adapter
101
- end
102
-
103
- conn.post do |req|
104
- req.url 'hub'
105
- req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
106
- req.body = options
107
- end
108
- end
109
- end
110
- end
111
- end