gitearb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gitea/client.rb +20 -0
- data/lib/gitea/collection.rb +5 -1
- data/lib/gitea/objects/hook.rb +4 -0
- data/lib/gitea/objects/org.rb +4 -0
- data/lib/gitea/objects/repo.rb +4 -0
- data/lib/gitea/resource.rb +6 -6
- data/lib/gitea/resources/org_hooks.rb +27 -0
- data/lib/gitea/resources/orgs.rb +26 -0
- data/lib/gitea/resources/repo_hooks.rb +31 -0
- data/lib/gitea/resources/repos.rb +22 -0
- data/lib/gitea/resources/user_repos.rb +14 -0
- data/lib/gitea/version.rb +1 -1
- data/lib/gitea.rb +8 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69d14b4480523c201fc11f1a0aa0e49cb97762f43085b1d282c7930e7c9ab72
|
4
|
+
data.tar.gz: 42ecd75e0029ddbafd8d1566cc9975ad2b34722ffdb2b827e57211380f92d7f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fa788ffb7c750c447234d57d00d37a7aa680081b7e78c6a809634fbc57087354f2fb6bd5334cba907e994113dbcef57b325c81f98161b804c2e87783d54ff5b
|
7
|
+
data.tar.gz: 853ac5731bd6d586771aafe2f366c03e71e1d4ce19a15743b4cc2c90dcc346d265422465637b5a9314b8b104b482c29ea905e1b91abc204d3180b8b918c77a40
|
data/Gemfile.lock
CHANGED
data/lib/gitea/client.rb
CHANGED
@@ -17,6 +17,26 @@ module Gitea
|
|
17
17
|
UserResource.new(self)
|
18
18
|
end
|
19
19
|
|
20
|
+
def user_repos
|
21
|
+
UserReposResource.new(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
def orgs
|
25
|
+
OrgsResource.new(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def org_hooks
|
29
|
+
OrgHooksResource.new(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
def repos
|
33
|
+
ReposResource.new(self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def repo_hooks
|
37
|
+
RepoHooksResource.new(self)
|
38
|
+
end
|
39
|
+
|
20
40
|
def connection
|
21
41
|
full_url = [url, "api/v1"].join("/")
|
22
42
|
|
data/lib/gitea/collection.rb
CHANGED
@@ -2,9 +2,13 @@ module Gitea
|
|
2
2
|
class Collection
|
3
3
|
attr_reader :data, :total
|
4
4
|
|
5
|
-
def self.from_response(response, type:)
|
5
|
+
def self.from_response(response, type:, kind: nil)
|
6
6
|
body = response.body
|
7
7
|
|
8
|
+
if kind
|
9
|
+
body = body[kind]
|
10
|
+
end
|
11
|
+
|
8
12
|
new(
|
9
13
|
data: body.map { |attrs| type.new(attrs) },
|
10
14
|
total: body.count
|
data/lib/gitea/resource.rb
CHANGED
@@ -33,21 +33,21 @@ module Gitea
|
|
33
33
|
when 400
|
34
34
|
raise Error, "Error 400: Your request was malformed. '#{response.body["message"]}'"
|
35
35
|
when 401
|
36
|
-
raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["
|
36
|
+
raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["message"]}'"
|
37
37
|
when 403
|
38
|
-
raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["
|
38
|
+
raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["message"]}'"
|
39
39
|
when 404
|
40
|
-
raise Error, "Error 404: No results were found for your request. '#{response.body["
|
40
|
+
raise Error, "Error 404: No results were found for your request. '#{response.body["message"]}'"
|
41
41
|
when 409
|
42
42
|
raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
|
43
43
|
when 422
|
44
44
|
raise Error, "Error 422: Unprocessable Entity. '#{response.body["message"]}"
|
45
45
|
when 429
|
46
|
-
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["
|
46
|
+
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["message"]}'"
|
47
47
|
when 500
|
48
|
-
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["
|
48
|
+
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["message"]}'"
|
49
49
|
when 503
|
50
|
-
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["
|
50
|
+
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["message"]}'"
|
51
51
|
when 204
|
52
52
|
# 204 is a response for success on Twitch's API
|
53
53
|
return true
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Gitea
|
2
|
+
class OrgHooksResource < Resource
|
3
|
+
|
4
|
+
def list(org:, **params)
|
5
|
+
response = get_request("orgs/#{org}/hooks", params: params)
|
6
|
+
Collection.from_response(response, type: Hook)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(org:, id:)
|
10
|
+
Hook.new get_request("orgs/#{org}/hooks/#{id}").body
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(org:, url:, type:, **args)
|
14
|
+
data = {config: {content_type: "json", url: url}, type: type}
|
15
|
+
Hook.new post_request("orgs/#{org}/hooks", body: args.merge(data)).body
|
16
|
+
end
|
17
|
+
|
18
|
+
def update(org:, id:, **args)
|
19
|
+
Hook.new patch_request("orgs/#{org}/hooks/#{id}", body: args).body
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete(org:, id:)
|
23
|
+
delete_request("orgs/#{org}/hooks/#{id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Gitea
|
2
|
+
class OrgsResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("orgs", params: params)
|
6
|
+
Collection.from_response(response, type: Org)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(name:)
|
10
|
+
Org.new get_request("orgs/#{name}").body
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(name:, **args)
|
14
|
+
Org.new post_request("orgs", body: args.merge({username: name})).body
|
15
|
+
end
|
16
|
+
|
17
|
+
def update(name:, **args)
|
18
|
+
Org.new patch_request("orgs/#{name}", body: args).body
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(name:)
|
22
|
+
delete_request("orgs/#{name}")
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Gitea
|
2
|
+
class RepoHooksResource < Resource
|
3
|
+
|
4
|
+
def list(owner:, repo:, **params)
|
5
|
+
response = get_request("repos/#{owner}/#{repo}/hooks", params: params)
|
6
|
+
Collection.from_response(response, type: Hook)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(owner:, repo:, id:)
|
10
|
+
Hook.new get_request("repos/#{owner}/#{repo}/hooks/#{id}").body
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(owner:, repo:, url:, type:, **args)
|
14
|
+
data = {config: {content_type: "json", url: url}, type: type}
|
15
|
+
Hook.new post_request("repos/#{owner}/#{repo}/hooks", body: args.merge(data)).body
|
16
|
+
end
|
17
|
+
|
18
|
+
def test(owner:, repo:, id:)
|
19
|
+
post_request("repos/#{owner}/#{repo}/hooks/#{id}/tests", body: {})
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(owner:, repo:, id:, **args)
|
23
|
+
Hook.new patch_request("repos/#{owner}/#{repo}/hooks/#{id}", body: args).body
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(owner:, repo:, id:)
|
27
|
+
delete_request("repos/#{owner}/#{repo}/hooks/#{id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Gitea
|
2
|
+
class ReposResource < Resource
|
3
|
+
|
4
|
+
def search(**params)
|
5
|
+
response = get_request("repos/search", params: params)
|
6
|
+
Collection.from_response(response, type: Repo, kind: "data")
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(owner:, repo:)
|
10
|
+
Repo.new get_request("repos/#{owner}/#{repo}").body
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(owner:, repo:, **args)
|
14
|
+
Repo.new patch_request("repos/#{owner}/#{repo}", body: args).body
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete(owner:, repo:)
|
18
|
+
delete_request("repos/#{owner}/#{repo}")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Gitea
|
2
|
+
class UserReposResource < Resource
|
3
|
+
|
4
|
+
def list(**params)
|
5
|
+
response = get_request("user/repos", params: params)
|
6
|
+
Collection.from_response(response, type: Repo)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(name:, **args)
|
10
|
+
Repo.new post_request("user/repos", body: args.merge({name: name})).body
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/gitea/version.rb
CHANGED
data/lib/gitea.rb
CHANGED
@@ -12,8 +12,16 @@ module Gitea
|
|
12
12
|
|
13
13
|
|
14
14
|
autoload :UserResource, "gitea/resources/user"
|
15
|
+
autoload :OrgsResource, "gitea/resources/orgs"
|
16
|
+
autoload :OrgHooksResource, "gitea/resources/org_hooks"
|
17
|
+
autoload :UserReposResource, "gitea/resources/user_repos"
|
18
|
+
autoload :ReposResource, "gitea/resources/repos"
|
19
|
+
autoload :RepoHooksResource, "gitea/resources/repo_hooks"
|
15
20
|
|
16
21
|
autoload :User, "gitea/objects/user"
|
17
22
|
autoload :Email, "gitea/objects/email"
|
23
|
+
autoload :Org, "gitea/objects/org"
|
24
|
+
autoload :Hook, "gitea/objects/hook"
|
25
|
+
autoload :Repo, "gitea/objects/repo"
|
18
26
|
|
19
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitearb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -49,9 +49,17 @@ files:
|
|
49
49
|
- lib/gitea/error.rb
|
50
50
|
- lib/gitea/object.rb
|
51
51
|
- lib/gitea/objects/email.rb
|
52
|
+
- lib/gitea/objects/hook.rb
|
53
|
+
- lib/gitea/objects/org.rb
|
54
|
+
- lib/gitea/objects/repo.rb
|
52
55
|
- lib/gitea/objects/user.rb
|
53
56
|
- lib/gitea/resource.rb
|
57
|
+
- lib/gitea/resources/org_hooks.rb
|
58
|
+
- lib/gitea/resources/orgs.rb
|
59
|
+
- lib/gitea/resources/repo_hooks.rb
|
60
|
+
- lib/gitea/resources/repos.rb
|
54
61
|
- lib/gitea/resources/user.rb
|
62
|
+
- lib/gitea/resources/user_repos.rb
|
55
63
|
- lib/gitea/version.rb
|
56
64
|
- lib/gitearb.rb
|
57
65
|
homepage: https://deanpcmad.com
|