class Bundler::Star

Attributes

installer[R]

Public Class Methods

new(installer) click to toggle source
# File bin/bundle-star, line 36
def initialize(installer)
  @installer = installer
end

Public Instance Methods

star() click to toggle source
# File bin/bundle-star, line 40
def star
  if repo = repository
    begin
      client = Octokit::Client.new netrc: true
      client.star repo
      message = "\e[33m"
      message << (macos_higher_lion? ? "\xe2\xad\x90  " : "\xe2\x98\x85  ")
      puts message + "starred #{repo} (^_^)b\e[0m"
    rescue => e
      puts "\e[31mfailed putting a star #{repo}, reason #{e}\e[0m"
      puts e.backtrace if ENV['DEBUG']
    end
  end
end

Private Instance Methods

macos_higher_lion?() click to toggle source
# File bin/bundle-star, line 71
def macos_higher_lion?
  unless RUBY_PLATFORM =~ /darwin/
    return false
  end
  macos_version = `/usr/bin/sw_vers -productVersion`.chomp.slice(/\d+\.\d+/).to_f
  macos_version >= 10.7
end
repository() click to toggle source
# File bin/bundle-star, line 57
def repository
  url = installer.spec.homepage.dup
  url.sub!(/\/$/, '') if url # some gems contain trailing slash
  if url =~ /\Ahttps?:\/\/([^.]+)?\.?github.com\/(.+)/
    if $1 == nil
      $2
    elsif $1 == 'www'
      $2
    else
      "#{$1}/#{$2}"
    end
  end
end