Class: BeginningOpenSource::CLI
- Inherits:
-
Object
- Object
- BeginningOpenSource::CLI
- Defined in:
- lib/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #get_and_print(input_string) ⇒ Object
- #goodbye ⇒ Object
-
#list_beginner_issues ⇒ Object
by default, it will return issues in github repos with 1 star or more.
- #print_issues(issue) ⇒ Object
- #search_issues ⇒ Object
- #welcome ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 |
# File 'lib/cli.rb', line 3 def call welcome list_beginner_issues search_issues goodbye end |
#get_and_print(input_string) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cli.rb', line 32 def get_and_print(input_string) issues_array = BeginningOpenSource::GithubApi.get_issues(input_string) BeginningOpenSource::Issues.create_from_collection(issues_array) if BeginningOpenSource::Issues.starred.empty? BeginningOpenSource::Issues.all.each do |issue| print_issues(issue) end else BeginningOpenSource::Issues.starred.each do |issue| print_issues(issue) end end end |
#goodbye ⇒ Object
60 61 62 |
# File 'lib/cli.rb', line 60 def goodbye puts "Happy learning!" end |
#list_beginner_issues ⇒ Object
by default, it will return issues in github repos with 1 star or more
17 18 19 |
# File 'lib/cli.rb', line 17 def list_beginner_issues #by default, it will return issues in github repos with 1 star or more get_and_print('beginner') end |
#print_issues(issue) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cli.rb', line 47 def print_issues(issue) length = "Repository Url: #{issue.repo_url}".length puts " " puts "Issue Title: #{issue.title}".blue puts "Repository Name: #{issue.repo_name}" puts "Repository Description: #{issue.repo_description}" puts "Stars: #{issue.stars}" puts "Labels: #{issue.labels}" puts "Issue Url: #{issue.html_url}" puts "Repository Url: #{issue.repo_url}" length.times {print "*"} end |
#search_issues ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cli.rb', line 21 def search_issues input = nil while input != "exit" puts "\n" + "Enter the issue label you would like to search for or type 'exit'".green input = gets.chomp.scan(/[a-z\s]/).join unless input == 'exit' get_and_print(input) end end end |
#welcome ⇒ Object
10 11 12 13 14 15 |
# File 'lib/cli.rb', line 10 def welcome puts "Welcome to beginning open source!".blue puts "Viewing open github issues labeled 'beginner' within the ruby language".blue puts " " puts "With this tool, you can find issues on github by label".blue end |