class Perpetuus::Build

Attributes

client[R]
repository[RW]
username[RW]

Public Class Methods

new() click to toggle source
# File lib/perpetuus/build.rb, line 9
def initialize
  @username = extract_user_from_git_url
  @repository = extract_repo_name_from_git_url
  @client = Travis::Client.new
end

Public Instance Methods

builded_with_success?() click to toggle source
# File lib/perpetuus/build.rb, line 15
def builded_with_success?
  self.is_valid? ? git_repo.green? : false 
end
is_valid?() click to toggle source
# File lib/perpetuus/build.rb, line 19
def is_valid?
  git_repo ? true : false
end

Private Instance Methods

extract_repo_name_from_git_url() click to toggle source
# File lib/perpetuus/build.rb, line 32
def extract_repo_name_from_git_url
  git_remote_url.split("/").last.sub(".git", "")
end
extract_user_from_git_url() click to toggle source
# File lib/perpetuus/build.rb, line 25
def extract_user_from_git_url
  remote_url = git_remote_url
  begin_of_user = "https://github.com/"
  end_of_user = "/"
  remote_url[/#{begin_of_user}(.*?)#{end_of_user}/m, 1]
end
git_remote_url() click to toggle source
# File lib/perpetuus/build.rb, line 36
def git_remote_url
  remote = `git remote -v`
  begin_of_url = "origin\t"
  end_of_url = " "
  remote[/#{begin_of_url}(.*?)#{end_of_url}/m, 1]
end
git_repo() click to toggle source
# File lib/perpetuus/build.rb, line 43
def git_repo
  begin
    @client.repo("#{@username}/#{@repository}")
  rescue Travis::Client::NotFound
    puts "Username or repository doesn't exist!"
  end
end