Class: BeginningOpenSource::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



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

#goodbyeObject



60
61
62
# File 'lib/cli.rb', line 60

def goodbye 
  puts "Happy learning!"
end

#list_beginner_issuesObject

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


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_issuesObject



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

#welcomeObject



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