Class: GithubCLI::API
- Inherits:
-
Object
- Object
- GithubCLI::API
- Defined in:
- lib/github_cli/api.rb
Overview
The API class is the main entry point for creating GithubCLI APIs.
Direct Known Subclasses
Assignee, Authorization, Blob, Collaborator, Commit, Content, Download, Email, Event, Follower, Fork, Gist, Hook, Issue, Key, Label, Member, Merging, Milestone, Notification, Organization, PullRequest, Reference, Repository, Search, Starring, Status, Tag, Team, Tree, User, Watching
Defined Under Namespace
Classes: All
Constant Summary collapse
- @@api =
nil
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.configure_api ⇒ Object
this could become a command such as configure that gets class options.
- .github_api ⇒ Object
- .output(format = :table, &block) ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/github_cli/api.rb', line 12 def config @config end |
Class Method Details
.configure_api ⇒ Object
this could become a command such as configure that gets class options
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/github_cli/api.rb', line 24 def configure_api @@api = Github.new config = GithubCLI.config.data if config['user.token'] @@api.oauth_token = config['user.token'] end if config['user.login'] && config['user.password'] @@api.basic_auth = "#{config['user.login']}:#{config['user.password']}" end @@api.endpoint = GithubCLI.config['core.endpoint'] || @@api.endpoint if ENV['TEST_HOST'] @@api.endpoint = 'http://' + ENV['TEST_HOST'] end @@api end |
.github_api ⇒ Object
14 15 16 17 18 |
# File 'lib/github_cli/api.rb', line 14 def github_api @@api ||= begin @@api = configure_api end end |
.output(format = :table, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/github_cli/api.rb', line 41 def output(format=:table, &block) GithubCLI.on_error do response = block.call if response.respond_to?(:body) formatter = Formatter.new response, :format => format formatter.render_output else response end end end |