horn_of_plenty 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE.txt +19 -0
- data/README.md +36 -0
- data/lib/horn_of_plenty.rb +22 -0
- data/lib/horn_of_plenty/adapters/github/client.rb +82 -0
- data/lib/horn_of_plenty/adapters/github/collections/card.rb +46 -0
- data/lib/horn_of_plenty/adapters/github/configuration.rb +38 -0
- data/lib/horn_of_plenty/adapters/github/error.rb +44 -0
- data/lib/horn_of_plenty/adapters/github/parsers/board.rb +52 -0
- data/lib/horn_of_plenty/adapters/github/parsers/card.rb +91 -0
- data/lib/horn_of_plenty/adapters/github/parsers/issue.rb +95 -0
- data/lib/horn_of_plenty/adapters/github/parsers/lane.rb +50 -0
- data/lib/horn_of_plenty/adapters/github/parsers/pull_request.rb +38 -0
- data/lib/horn_of_plenty/adapters/github/queries/list_boards.rb +18 -0
- data/lib/horn_of_plenty/adapters/github/queries/list_cards.rb +19 -0
- data/lib/horn_of_plenty/adapters/github/queries/list_issues.rb +22 -0
- data/lib/horn_of_plenty/adapters/github/queries/list_lanes.rb +19 -0
- data/lib/horn_of_plenty/adapters/github/queries/list_pull_requests.rb +22 -0
- data/lib/horn_of_plenty/adapters/github/repositories/board.rb +24 -0
- data/lib/horn_of_plenty/adapters/github/repositories/card.rb +24 -0
- data/lib/horn_of_plenty/adapters/github/repositories/issue.rb +24 -0
- data/lib/horn_of_plenty/adapters/github/repositories/lane.rb +24 -0
- data/lib/horn_of_plenty/adapters/github/repositories/pull_request.rb +24 -0
- data/lib/horn_of_plenty/adapters/github/requests/list_boards.rb +50 -0
- data/lib/horn_of_plenty/adapters/github/requests/list_cards.rb +52 -0
- data/lib/horn_of_plenty/adapters/github/requests/list_issues.rb +50 -0
- data/lib/horn_of_plenty/adapters/github/requests/list_lanes.rb +52 -0
- data/lib/horn_of_plenty/adapters/github/requests/list_pull_requests.rb +50 -0
- data/lib/horn_of_plenty/adapters/github/response.rb +16 -0
- data/lib/horn_of_plenty/adapters/github/responses/list_boards.rb +17 -0
- data/lib/horn_of_plenty/adapters/github/responses/list_cards.rb +23 -0
- data/lib/horn_of_plenty/adapters/github/responses/list_issues.rb +18 -0
- data/lib/horn_of_plenty/adapters/github/responses/list_lanes.rb +17 -0
- data/lib/horn_of_plenty/adapters/github/responses/list_pull_requests.rb +17 -0
- data/lib/horn_of_plenty/collection.rb +60 -0
- data/lib/horn_of_plenty/core_ext/string.rb +95 -0
- data/lib/horn_of_plenty/models/board.rb +32 -0
- data/lib/horn_of_plenty/models/card.rb +51 -0
- data/lib/horn_of_plenty/models/issue.rb +46 -0
- data/lib/horn_of_plenty/models/lane.rb +30 -0
- data/lib/horn_of_plenty/models/parsable.rb +44 -0
- data/lib/horn_of_plenty/models/pull_request.rb +12 -0
- data/lib/horn_of_plenty/null_objects/board.rb +10 -0
- data/lib/horn_of_plenty/null_objects/card.rb +10 -0
- data/lib/horn_of_plenty/null_objects/issue.rb +10 -0
- data/lib/horn_of_plenty/null_objects/lane.rb +10 -0
- data/lib/horn_of_plenty/null_objects/pull_request.rb +10 -0
- data/lib/horn_of_plenty/paginator.rb +109 -0
- data/lib/horn_of_plenty/parsers/hash.rb +95 -0
- data/lib/horn_of_plenty/queries/fetch.rb +36 -0
- data/lib/horn_of_plenty/repositories/board.rb +26 -0
- data/lib/horn_of_plenty/repositories/card.rb +26 -0
- data/lib/horn_of_plenty/repositories/issue.rb +26 -0
- data/lib/horn_of_plenty/repositories/lane.rb +26 -0
- data/lib/horn_of_plenty/repositories/pull_request.rb +26 -0
- data/lib/horn_of_plenty/repository.rb +29 -0
- data/lib/horn_of_plenty/request.rb +32 -0
- data/lib/horn_of_plenty/response.rb +44 -0
- data/lib/horn_of_plenty/version.rb +4 -0
- data/spec/fixtures/responses/board_github.json +29 -0
- data/spec/fixtures/responses/card_github.json +7 -0
- data/spec/fixtures/responses/issue_github.json +163 -0
- data/spec/fixtures/responses/lane_github.json +7 -0
- data/spec/fixtures/responses/pull_request_github.json +361 -0
- data/spec/lib/horn_of_plenty/adapters/github/client_spec.rb +12 -0
- data/spec/lib/horn_of_plenty/adapters/github/collections/card_spec.rb +14 -0
- data/spec/lib/horn_of_plenty/adapters/github/configuration_spec.rb +12 -0
- data/spec/lib/horn_of_plenty/adapters/github/error_spec.rb +35 -0
- data/spec/lib/horn_of_plenty/adapters/github/parsers/board_spec.rb +39 -0
- data/spec/lib/horn_of_plenty/adapters/github/parsers/card_spec.rb +64 -0
- data/spec/lib/horn_of_plenty/adapters/github/parsers/issue_spec.rb +47 -0
- data/spec/lib/horn_of_plenty/adapters/github/parsers/lane_spec.rb +38 -0
- data/spec/lib/horn_of_plenty/adapters/github/parsers/pull_request_spec.rb +50 -0
- data/spec/lib/horn_of_plenty/adapters/github/queries/list_boards_spec.rb +19 -0
- data/spec/lib/horn_of_plenty/adapters/github/queries/list_cards_spec.rb +19 -0
- data/spec/lib/horn_of_plenty/adapters/github/queries/list_issues_spec.rb +19 -0
- data/spec/lib/horn_of_plenty/adapters/github/queries/list_lanes_spec.rb +19 -0
- data/spec/lib/horn_of_plenty/adapters/github/queries/list_pull_requests_spec.rb +19 -0
- data/spec/lib/horn_of_plenty/adapters/github/repositories/board_spec.rb +22 -0
- data/spec/lib/horn_of_plenty/adapters/github/repositories/card_spec.rb +67 -0
- data/spec/lib/horn_of_plenty/adapters/github/repositories/issue_spec.rb +22 -0
- data/spec/lib/horn_of_plenty/adapters/github/repositories/lane_spec.rb +25 -0
- data/spec/lib/horn_of_plenty/adapters/github/repositories/pull_request_spec.rb +24 -0
- data/spec/lib/horn_of_plenty/adapters/github/requests/list_boards_spec.rb +42 -0
- data/spec/lib/horn_of_plenty/adapters/github/requests/list_cards_spec.rb +51 -0
- data/spec/lib/horn_of_plenty/adapters/github/requests/list_issues_spec.rb +42 -0
- data/spec/lib/horn_of_plenty/adapters/github/requests/list_lanes_spec.rb +51 -0
- data/spec/lib/horn_of_plenty/adapters/github/requests/list_pull_requests_spec.rb +42 -0
- data/spec/lib/horn_of_plenty/adapters/github/responses/list_boards_spec.rb +78 -0
- data/spec/lib/horn_of_plenty/adapters/github/responses/list_cards_spec.rb +86 -0
- data/spec/lib/horn_of_plenty/adapters/github/responses/list_issues_spec.rb +104 -0
- data/spec/lib/horn_of_plenty/adapters/github/responses/list_lanes_spec.rb +86 -0
- data/spec/lib/horn_of_plenty/adapters/github/responses/list_pull_requests_spec.rb +109 -0
- data/spec/lib/horn_of_plenty/models/board_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/models/card_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/models/issue_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/models/lane_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/models/pull_request_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/null_objects/board_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/null_objects/card_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/null_objects/issue_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/null_objects/lane_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/null_objects/pull_request_spec.rb +10 -0
- data/spec/lib/horn_of_plenty/queries/fetch_spec.rb +15 -0
- data/spec/lib/horn_of_plenty/repositories/board_spec.rb +48 -0
- data/spec/lib/horn_of_plenty/repositories/card_spec.rb +51 -0
- data/spec/lib/horn_of_plenty/repositories/issue_spec.rb +48 -0
- data/spec/lib/horn_of_plenty/repositories/lane_spec.rb +51 -0
- data/spec/lib/horn_of_plenty/repositories/pull_request_spec.rb +50 -0
- data/spec/support/patterns.rb +1 -0
- metadata +396 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/parsers/hash'
|
3
|
+
require 'horn_of_plenty/null_objects/issue'
|
4
|
+
require 'horn_of_plenty/models/issue'
|
5
|
+
|
6
|
+
# rubocop:disable Style/SpaceAroundOperators
|
7
|
+
module HornOfPlenty
|
8
|
+
module Adapters
|
9
|
+
module Github
|
10
|
+
module Parsers
|
11
|
+
class Issue
|
12
|
+
include HornOfPlenty::Parsers::Hash
|
13
|
+
|
14
|
+
attr_accessor :raw
|
15
|
+
|
16
|
+
def initialize(raw:)
|
17
|
+
self.raw = raw
|
18
|
+
end
|
19
|
+
|
20
|
+
def id
|
21
|
+
@id ||= parse_text(raw, 'number')
|
22
|
+
end
|
23
|
+
|
24
|
+
def author_id
|
25
|
+
@author_id ||= parse_text(raw, 'user/:/login')
|
26
|
+
end
|
27
|
+
|
28
|
+
def assignee_ids
|
29
|
+
@assignee_ids ||= begin
|
30
|
+
parse_key(raw, 'assignees').map { |assignee| assignee['login'] }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def closer_id
|
35
|
+
@closer_id ||= parse_text(raw, 'closed_by/:/login')
|
36
|
+
end
|
37
|
+
|
38
|
+
def repository
|
39
|
+
@repository ||= parse_text(raw, 'url') do |url|
|
40
|
+
repo_name = url.match(%r{\A.*/repos/((?:[^/]+/){2}).*\z})[1]
|
41
|
+
|
42
|
+
repo_name && repo_name[0..-2]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def status
|
47
|
+
@status ||= parse_text(raw, 'state')
|
48
|
+
end
|
49
|
+
|
50
|
+
def title
|
51
|
+
@title ||= parse_text(raw, 'title')
|
52
|
+
end
|
53
|
+
|
54
|
+
def description
|
55
|
+
@description ||= parse_text(raw, 'body') do |description|
|
56
|
+
description.delete("\r")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def labels
|
61
|
+
@labels ||= begin
|
62
|
+
labels = parse_key(raw, 'labels').map { |label| label['name'] }
|
63
|
+
milestone = Array(parse_key(raw, 'milestone/:/title'))
|
64
|
+
|
65
|
+
labels + milestone
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def closed_at
|
70
|
+
@closed_at ||= parse_time(raw, 'closed_at')
|
71
|
+
end
|
72
|
+
|
73
|
+
def created_at
|
74
|
+
@created_at ||= parse_time(raw, 'created_at')
|
75
|
+
end
|
76
|
+
|
77
|
+
def updated_at
|
78
|
+
@updated_at ||= parse_time(raw, 'updated_at')
|
79
|
+
end
|
80
|
+
|
81
|
+
def has_pull_request?
|
82
|
+
@has_pull_request ||= parse_existance(raw, 'pull_request')
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.to_model(raw_item)
|
86
|
+
return NullObjects::Issue.instance unless raw_item
|
87
|
+
|
88
|
+
Models::Issue.from_parser(parser: new(raw: raw_item))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
# rubocop:enable Style/SpaceAroundOperators
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/parsers/hash'
|
3
|
+
require 'horn_of_plenty/null_objects/lane'
|
4
|
+
require 'horn_of_plenty/models/lane'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Parsers
|
10
|
+
class Lane
|
11
|
+
include HornOfPlenty::Parsers::Hash
|
12
|
+
|
13
|
+
attr_accessor :raw
|
14
|
+
|
15
|
+
def initialize(raw:)
|
16
|
+
self.raw = raw
|
17
|
+
end
|
18
|
+
|
19
|
+
def id
|
20
|
+
@id ||= parse_text(raw, 'id')
|
21
|
+
end
|
22
|
+
|
23
|
+
def board_id
|
24
|
+
@board_id ||= parse_text(raw, 'project_url') do |url|
|
25
|
+
url.match(%r{\A.*/(\d+)\z})[1]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def title
|
30
|
+
@title ||= parse_text(raw, 'name')
|
31
|
+
end
|
32
|
+
|
33
|
+
def created_at
|
34
|
+
@created_at ||= parse_time(raw, 'created_at')
|
35
|
+
end
|
36
|
+
|
37
|
+
def updated_at
|
38
|
+
@updated_at ||= parse_time(raw, 'updated_at')
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.to_model(raw_item)
|
42
|
+
return NullObjects::Lane.instance unless raw_item
|
43
|
+
|
44
|
+
Models::Lane.from_parser(parser: new(raw: raw_item))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/parsers/hash'
|
3
|
+
require 'horn_of_plenty/null_objects/pull_request'
|
4
|
+
require 'horn_of_plenty/adapters/github/parsers/issue'
|
5
|
+
require 'horn_of_plenty/models/pull_request'
|
6
|
+
|
7
|
+
module HornOfPlenty
|
8
|
+
module Adapters
|
9
|
+
module Github
|
10
|
+
module Parsers
|
11
|
+
class PullRequest < Parsers::Issue
|
12
|
+
def labels
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
|
16
|
+
def merger_id
|
17
|
+
@merger_id ||= parse_text(raw, 'merged_by/:/login')
|
18
|
+
end
|
19
|
+
|
20
|
+
def status
|
21
|
+
@status ||= begin
|
22
|
+
status = parse_text(raw, 'state')
|
23
|
+
merged_at = parse_text(raw, 'merged_at')
|
24
|
+
|
25
|
+
merged_at ? 'merged' : status
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.to_model(raw_item)
|
30
|
+
return NullObjects::PullRequest.instance unless raw_item
|
31
|
+
|
32
|
+
Models::PullRequest.from_parser(parser: new(raw: raw_item))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/queries/fetch'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Queries
|
8
|
+
class ListBoards < HornOfPlenty::Queries::Fetch
|
9
|
+
def translate(query)
|
10
|
+
query.delete(:id)
|
11
|
+
|
12
|
+
query
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/queries/fetch'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Queries
|
8
|
+
class ListCards < HornOfPlenty::Queries::Fetch
|
9
|
+
def translate(query)
|
10
|
+
query.delete(:id)
|
11
|
+
query.delete(:lane_id)
|
12
|
+
|
13
|
+
query
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/queries/fetch'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Queries
|
8
|
+
class ListIssues < HornOfPlenty::Queries::Fetch
|
9
|
+
def translate(query)
|
10
|
+
query.delete(:id)
|
11
|
+
|
12
|
+
rename_key(from: :author_id, to: :creator)
|
13
|
+
rename_key(from: :assignee_id, to: :assignee)
|
14
|
+
rename_key(from: :status, to: :state)
|
15
|
+
|
16
|
+
query
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/queries/fetch'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Queries
|
8
|
+
class ListLanes < HornOfPlenty::Queries::Fetch
|
9
|
+
def translate(query)
|
10
|
+
query.delete(:id)
|
11
|
+
query.delete(:board_id)
|
12
|
+
|
13
|
+
query
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/queries/fetch'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Queries
|
8
|
+
class ListPullRequests < HornOfPlenty::Queries::Fetch
|
9
|
+
def translate(query)
|
10
|
+
query.delete(:id)
|
11
|
+
|
12
|
+
rename_key(from: :author_id, to: :creator)
|
13
|
+
rename_key(from: :assignee_id, to: :assignee)
|
14
|
+
rename_key(from: :status, to: :state)
|
15
|
+
|
16
|
+
query
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/adapters/github/client'
|
3
|
+
require 'horn_of_plenty/adapters/github/requests/list_boards'
|
4
|
+
require 'horn_of_plenty/repository'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Repositories
|
10
|
+
class Board < HornOfPlenty::Repository
|
11
|
+
private
|
12
|
+
|
13
|
+
def client
|
14
|
+
@client || Github::Client.pool
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_class(_attrs)
|
18
|
+
@fetch_class ||= Requests::ListBoards
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/adapters/github/client'
|
3
|
+
require 'horn_of_plenty/adapters/github/requests/list_cards'
|
4
|
+
require 'horn_of_plenty/repository'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Repositories
|
10
|
+
class Card < HornOfPlenty::Repository
|
11
|
+
private
|
12
|
+
|
13
|
+
def client
|
14
|
+
@client || Github::Client.pool
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_class(_attrs)
|
18
|
+
@fetch_class ||= Requests::ListCards
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/adapters/github/client'
|
3
|
+
require 'horn_of_plenty/adapters/github/requests/list_issues'
|
4
|
+
require 'horn_of_plenty/repository'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Repositories
|
10
|
+
class Issue < HornOfPlenty::Repository
|
11
|
+
private
|
12
|
+
|
13
|
+
def client
|
14
|
+
@client || Github::Client.pool
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_class(_attrs)
|
18
|
+
@fetch_class ||= Requests::ListIssues
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/adapters/github/client'
|
3
|
+
require 'horn_of_plenty/adapters/github/requests/list_lanes'
|
4
|
+
require 'horn_of_plenty/repository'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Repositories
|
10
|
+
class Lane < HornOfPlenty::Repository
|
11
|
+
private
|
12
|
+
|
13
|
+
def client
|
14
|
+
@client || Github::Client.pool
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_class(_attrs)
|
18
|
+
@fetch_class ||= Requests::ListLanes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/adapters/github/client'
|
3
|
+
require 'horn_of_plenty/adapters/github/requests/list_pull_requests'
|
4
|
+
require 'horn_of_plenty/repository'
|
5
|
+
|
6
|
+
module HornOfPlenty
|
7
|
+
module Adapters
|
8
|
+
module Github
|
9
|
+
module Repositories
|
10
|
+
class PullRequest < HornOfPlenty::Repository
|
11
|
+
private
|
12
|
+
|
13
|
+
def client
|
14
|
+
@client || Github::Client.pool
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_class(_attrs)
|
18
|
+
@fetch_class ||= Requests::ListPullRequests
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'horn_of_plenty/request'
|
3
|
+
|
4
|
+
module HornOfPlenty
|
5
|
+
module Adapters
|
6
|
+
module Github
|
7
|
+
module Requests
|
8
|
+
class ListBoards < HornOfPlenty::Request
|
9
|
+
attr_accessor :format,
|
10
|
+
:pagination,
|
11
|
+
:query,
|
12
|
+
:repository
|
13
|
+
|
14
|
+
def initialize(format: 'raw',
|
15
|
+
pagination: {},
|
16
|
+
query: {},
|
17
|
+
repository:)
|
18
|
+
|
19
|
+
self.format = format
|
20
|
+
self.pagination = pagination
|
21
|
+
self.query = query
|
22
|
+
self.repository = repository
|
23
|
+
end
|
24
|
+
|
25
|
+
def method
|
26
|
+
'get'
|
27
|
+
end
|
28
|
+
|
29
|
+
def path
|
30
|
+
return "repos/#{repository}/projects" unless query[:id]
|
31
|
+
|
32
|
+
"repos/#{repository}/projects/#{query[:id]}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_h
|
36
|
+
@to_h ||= query_class.new(query).to_h.
|
37
|
+
merge(pagination_hash)
|
38
|
+
end
|
39
|
+
alias to_params to_h
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def pagination_hash
|
44
|
+
pagination.to_h
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|