class Binford::GemfileStats

Attributes

file_path[R]

Public Class Methods

new(file_path) click to toggle source
# File lib/binford/gemfile_stats.rb, line 5
def initialize(file_path)
  @file_path = file_path
end

Public Instance Methods

gems() click to toggle source
# File lib/binford/gemfile_stats.rb, line 15
def gems
  @gems ||= parse_gems
end
stats() click to toggle source
# File lib/binford/gemfile_stats.rb, line 9
def stats
  gems.map do |gem, version|
    Thread.new { analyze(gem, version) }
  end.map(&:value)
end

Private Instance Methods

analyze(gem, version) click to toggle source
# File lib/binford/gemfile_stats.rb, line 31
def analyze(gem, version)
  fibers = []
  fibers << Fiber.new { ruby_toolbox_data(gem) }
  fibers << Fiber.new { rubygems_data(gem, version) }
  fibers.map(&:resume).inject({}, &:merge!)
end
parse_gems() click to toggle source
# File lib/binford/gemfile_stats.rb, line 23
def parse_gems
  out = {}
  File.open(file_path).each do |line|
    out[Regexp.last_match(1).tr(" ", "")] = Regexp.last_match(2) if line =~ /(.*)\s\(([\d.]*)\)/
  end
  out
end
ruby_toolbox_data(gem) click to toggle source
# File lib/binford/gemfile_stats.rb, line 38
def ruby_toolbox_data(gem)
  RubyToolbox.new(gem).data
end
rubygems_data(gem, version) click to toggle source
# File lib/binford/gemfile_stats.rb, line 42
def rubygems_data(gem, version)
  rubygems = RubyGems.new(gem)
  rubygems.data.merge(current: rubygems.current(version))
end