class RubyCat::Card

Attributes

categories[R]
deps[R]
desc[R]
downloads[R]
gem_url[R]
github_url[R]
latest_version[R]
latest_version_downloads[R]
name[R]

read only

Public Class Methods

new( card ) click to toggle source
# File lib/rubycat/card.rb, line 35
def initialize( card )
  @categories = card.categories
  @name = nil


  github_link = card.links.find {|it| it[0].include?( ':octocat:') }
  
  if github_link
    @github_url = github_link[1]
    
    ## check if org (shortcut)
    uri = URI.parse( @github_url )
      puts "  uri.path: #{uri.path}"
      ##
      names = uri.path[1..-1].split('/')  ## cut off leading / and split
      pp names

      ## if single name (duplicate - downcased! e.g. Ramaze => Ramaze/ramaze)
      if names.size == 1
        @github_url += "/#{names[0].downcase}"
        @name = names[0].downcase
      else
        @name = names[1]
      end
      puts "github_url: #{@github_url}"
  else
      puts "*** no github_url found"
      pp card
  end

  gem_link  = card.links.find {|it| it[0] == ':gem:' }
  if gem_link
    @gem_url = gem_link[1]
    puts "gem_url: #{@gem_url}"

    uri = URI.parse( @gem_url )
    names = uri.path[1..-1].split('/')  ## cut off leading / and split
    pp names
    ## assume last name entry is name of gem
    @name = names[-1]
  else
    puts "*** no gem_url found"
    pp card
  end
end

Public Instance Methods

sync_gems_info( json ) click to toggle source
# File lib/rubycat/card.rb, line 82
def sync_gems_info( json )
  @desc                      = json['info']
  @latest_version            = json['version']
  @latest_version_downloads  = json['version_downloads']
  @downloads                 = json['downloads']

  deps_runtime = json['dependencies']['runtime']
  if deps_runtime && deps_runtime.size > 0
    deps = []
    deps_runtime.each do |dep|
      deps << dep['name']
    end
    @deps = deps.join(', ')
  else
    @deps = nil
  end
end
to_hash() click to toggle source
# File lib/rubycat/card.rb, line 21
def to_hash
  { name:           @name,
    gem_url:        @gem_url,
    github_url:     @github_url,
    categories:     @categories,
    desc:           @desc,
    latest_version: @latest_version,
    latest_version_downloads: @latest_version_downloads,
    downloads:      @downloads,
    deps:           @deps }
end