class Github::Repo

Attributes

id[R]
name[R]
tags_all[W]
tags_last[W]
updated_at[R]

Public Class Methods

new(repo) click to toggle source
# File lib/knife-github/repo.rb, line 7
def initialize(repo)
# Instance variables
  @id          = repo['id']
  @name        = repo['name']
  @description = repo['description']
  @full_name   = repo['full_name']
  @private     = repo['private']
  @homapage    = repo['homepage']
  @created_at  = repo['created_at']
  @updated_at  = repo['updated_at']
  @pushed_at   = repo['pushed_at']
  @html_url    = repo['html_url']
  @ssh_url     = repo['ssh_url']
  @git_url     = repo['git_url']
  @svn_url     = repo['svn_url']
  @clone_url   = repo['clone_url']
  @tags_url    = repo['tags_url']
  @tags_all    = repo['tags_all']
  @tags_last   = repo['tags_last']
end

Public Instance Methods

get_repo_data(orgs) click to toggle source
# File lib/knife-github/repo.rb, line 69
def get_repo_data(orgs)
  orgs.each do |org| 
    get_org_data(org)
  end
end
last_tag?() click to toggle source
# File lib/knife-github/repo.rb, line 31
def last_tag?
  get_last_tag(@tags_all)
end
to_hash() click to toggle source
# File lib/knife-github/repo.rb, line 47
def to_hash
  { 
    'id'          => @id,
    'name'        => @name,
    'description' => @description,
    'full_name'   => @full_name,
    'private'     => @private,
    'homepage'    => @homepage,
    'created_at'  => @created_at,
    'updated_at'  => @updated_at,
    'pushed_at'   => @pushed_at,
    'html_url'    => @html_url,
    'ssh_url'     => @ssh_url,
    'git_url'     => @git_url,
    'svn_url'     => @svn_url,
    'clone_url'   => @clone_url,
    'tags_url'    => @tags_url,
    'tags_all'    => @tags_all,
    'tags_last'   => @tags_last 
  }
end
to_s() click to toggle source
# File lib/knife-github/repo.rb, line 35
def to_s
  @name
end
update_tags!() click to toggle source
# File lib/knife-github/repo.rb, line 39
def update_tags!
  if @tags_url
    @tags_all = get_tags(@tags_url)
    @tags_last = get_last_tag(@tags_all)
  end
  self
end

Private Instance Methods

connection() click to toggle source
# File lib/knife-github/repo.rb, line 100
def connection
  @connection ||= GithubClient::Connection.new()
end
get_last_tag(tags) click to toggle source
# File lib/knife-github/repo.rb, line 88
def get_last_tag(tags)
  return nil if tags.nil? || tags.empty?
  base, last = "0.0.0", nil
  tags.each do |tag|
    if Mixlib::Versioning.parse(tag) >= Mixlib::Versioning.parse(base)
      last = tag
      base = last
    end
  end
  last
end
get_tags(url) click to toggle source
# File lib/knife-github/repo.rb, line 77
def get_tags(url)
  tags = []
  params = {}
  params[:url] = url
  params[:action] = "GET"
  params[:token] = Chef::Config[:knife][:github_token] 
  result = connection.request(params)
  result.each { |tag| tags.push(tag['name']) if tag['name'] =~ /^(\d*)\.(\d*)\.(\d*)$/ }
  tags || nil
end