Module: Dishwasher::Github
- Extended by:
- MessageFormatter
- Defined in:
- lib/dishwasher/github.rb
Class Method Summary collapse
-
.canceled_message ⇒ string
Canceled message.
-
.choices ⇒ hash
Potential choices to choose from for deletion.
-
.client ⇒ object
GitHub Client Object.
-
.confirmation_prompt ⇒ boolean
Prompt to confirm deletion of repos.
-
.confirmed_selections ⇒ array
Selected forks for deletion.
-
.delete_repo(r) ⇒ Boolean
Delete passed in repository ID.
-
.forks ⇒ object
All forked repositories for the client.
-
.no_selections ⇒ string
No selection message.
-
.prompt ⇒ object
Initialize new TTY Prompt.
-
.repos ⇒ object
Repositories for the client object.
-
.selection(c) ⇒ array
Array of selected id’s.
-
.token ⇒ string
Get GitHub Access Token so we can authenticate with GitHub’s API.
Methods included from MessageFormatter
abort_message, body_message, title_message
Class Method Details
.canceled_message ⇒ string
Canceled message
114 115 116 |
# File 'lib/dishwasher/github.rb', line 114 def ("Operation canceled by user.") end |
.choices ⇒ hash
Potential choices to choose from for deletion
66 67 68 |
# File 'lib/dishwasher/github.rb', line 66 def choices forks.map { |f| [f[:full_name], f[:id]] }.to_h end |
.client ⇒ object
GitHub Client Object
28 29 30 |
# File 'lib/dishwasher/github.rb', line 28 def client @client ||= Octokit::Client.new(access_token: token, per_page: 1000) end |
.confirmation_prompt ⇒ boolean
Prompt to confirm deletion of repos
86 87 88 89 |
# File 'lib/dishwasher/github.rb', line 86 def confirmation_prompt ("Are you sure you want to delete these forked repos?") prompt.yes?("→") end |
.confirmed_selections ⇒ array
Selected forks for deletion
75 76 77 78 79 |
# File 'lib/dishwasher/github.rb', line 75 def confirmed_selections selections = selection(choices) no_selections if selections.empty? confirmation_prompt ? selections : end |
.delete_repo(r) ⇒ Boolean
Delete passed in repository ID
39 40 41 |
# File 'lib/dishwasher/github.rb', line 39 def delete_repo(r) client.delete_repository(r) end |
.forks ⇒ object
All forked repositories for the client
57 58 59 |
# File 'lib/dishwasher/github.rb', line 57 def forks repos.select { |hash| hash[:fork] == true } end |
.no_selections ⇒ string
No selection message
105 106 107 |
# File 'lib/dishwasher/github.rb', line 105 def no_selections ("No selections were made.") end |
.prompt ⇒ object
Initialize new TTY Prompt
10 11 12 |
# File 'lib/dishwasher/github.rb', line 10 def prompt @prompt ||= TTY::Prompt.new end |
.repos ⇒ object
Repositories for the client object
48 49 50 |
# File 'lib/dishwasher/github.rb', line 48 def repos client.repos(user: client.user, query: {type: "owner", sort: "asc"}) end |
.selection(c) ⇒ array
Array of selected id’s
96 97 98 |
# File 'lib/dishwasher/github.rb', line 96 def selection(c) prompt.multi_select(("Select forks to delete"), c) end |
.token ⇒ string
Get GitHub Access Token so we can authenticate with GitHub’s API
19 20 21 |
# File 'lib/dishwasher/github.rb', line 19 def token @token ||= prompt.mask(("What is your GitHub Personal Access Token?"), default: ENV["GITHUB_ACCESS_TOKEN"]) end |