class Trendhub::Commands::Repo

Attributes

options[R]

Public Class Methods

new(options) click to toggle source
# File lib/trendhub/commands/repo.rb, line 9
def initialize(options)
  @options = options
end

Public Instance Methods

execute() click to toggle source
# File lib/trendhub/commands/repo.rb, line 13
def execute
  repositories = Trendhub::Repositories.new.fetch(options[:for], options[:language])
  repositories.each do |repo|
    $stdout.puts "-" * 100
    $stdout.puts "#{colorizer.decorate(repo.name, :bold)} has #{colorizer.decorate(repo.added_stars, :bold, :red)} stars added #{repo.time_period}"
    $stdout.puts repo.desc
    repo_info = blank?(repo.language) ? "" : "#{repo.language}          "
    repo_info += "★  #{repo.stars}          "
    repo_info += "#{repo.forks} forks"
    $stdout.puts repo_info
    $stdout.puts "URL: #{repo.url}"
  end
end

Private Instance Methods

blank?(str) click to toggle source
# File lib/trendhub/commands/repo.rb, line 31
def blank?(str)
  str.nil? || str.empty? || str.match?(/^\s+$/)
end
colorizer() click to toggle source
# File lib/trendhub/commands/repo.rb, line 35
def colorizer
  @colorizer ||= Trendhub::Utils::Color.new
end