Class: TelegramBot::GitHubWrapper::Repository
- Inherits:
-
Object
- Object
- TelegramBot::GitHubWrapper::Repository
- Includes:
- HTTParty
- Defined in:
- lib/telegram-bot/github_wrapper.rb
Constant Summary collapse
- @@headers =
{ 'User-Agent': 'telegram-scrum-bot' }
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#private_repo ⇒ Object
(also: #private?)
readonly
Returns the value of attribute private_repo.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.find(username:, repository:) ⇒ Object
Find a particular repository.
Instance Method Summary collapse
-
#get_issues(state: 'all', sort: "created", order_direction: 'asc') ⇒ Object
Returns the issues from a public repository.
-
#initialize(username:, repository:, description:, private_repo:) ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(username:, repository:, description:, private_repo:) ⇒ Repository
Returns a new instance of Repository.
14 15 16 17 18 19 20 |
# File 'lib/telegram-bot/github_wrapper.rb', line 14 def initialize(username:, repository:, description:, private_repo:) @username = username @repository = repository @description = description @private_repo = private_repo @issues = [] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/telegram-bot/github_wrapper.rb', line 12 def description @description end |
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
12 13 14 |
# File 'lib/telegram-bot/github_wrapper.rb', line 12 def issues @issues end |
#private_repo ⇒ Object (readonly) Also known as: private?
Returns the value of attribute private_repo.
12 13 14 |
# File 'lib/telegram-bot/github_wrapper.rb', line 12 def private_repo @private_repo end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
12 13 14 |
# File 'lib/telegram-bot/github_wrapper.rb', line 12 def repository @repository end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/telegram-bot/github_wrapper.rb', line 12 def username @username end |
Class Method Details
.find(username:, repository:) ⇒ Object
Find a particular repository
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/telegram-bot/github_wrapper.rb', line 52 def self.find(username:, repository:) response = get("/#{username}/#{repository}", headers: @@headers) if response.success? self.new(username: username, repository: repository, description: response.fetch("description", ""), private_repo: response.fetch("private", "")) else raise response.response end end |
Instance Method Details
#get_issues(state: 'all', sort: "created", order_direction: 'asc') ⇒ Object
Returns the issues from a public repository
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 |
# File 'lib/telegram-bot/github_wrapper.rb', line 25 def get_issues(state: 'all', sort: "created", order_direction: 'asc') query = { "state" => state, "sort" => sort, "direction" => order_direction } response = self.class.get("/#{@username}/#{@repository}/issues", headers: @@headers, query: query) if response.success? JSON.parse(response.body).each do |issue| @issues << Issue.new(id: issue.fetch('id', ''), number: issue.fetch('number', ''), title: issue.fetch('title', ''), body: issue.fetch('body', ''), state: issue.fetch('state', ''), url: issue.fetch('url', '')) end else raise response.response end @issues end |