class Fucktherubyracer::Fucker

Attributes

lockfile[W]

Public Class Methods

new() click to toggle source
# File lib/fucktherubyracer/fucker.rb, line 7
def initialize
end

Public Instance Methods

fuck(gem_name, version = nil) click to toggle source
# File lib/fucktherubyracer/fucker.rb, line 10
def fuck(gem_name, version = nil)
  spec = if version
           Gem::Specification.new(gem_name, version)
         else
           lockfile_parser.specs.find { |spec| spec.name == gem_name }
         end

  generate(spec)
end
generate(spec) click to toggle source
# File lib/fucktherubyracer/fucker.rb, line 20
def generate(spec)
  input = File.read(File.join(File.expand_path('../../../', __FILE__), 'data/template.gemspec.erb'))
  eruby = Erubis::Eruby.new(input)

  result = eruby.result(binding)

  file = Tempfile.create("#{spec.name}.gemspec")
  file.write(result)
  file.close
  system "gem build #{file.path}"
  gem = "#{spec.name}-#{spec.version}.gem"
  system "gem install #{gem} && rm #{gem}; rm #{file.path}"
end
lockfile() click to toggle source

@return [String]

# File lib/fucktherubyracer/fucker.rb, line 37
def lockfile
  @lockfile ||= Bundler.default_lockfile
end

Private Instance Methods

lockfile_parser() click to toggle source

@return [Bundler::LockfileParser]

# File lib/fucktherubyracer/fucker.rb, line 44
def lockfile_parser
  @lockfile_parser ||=
    begin
      lock = Bundler.read_file(lockfile)
      Bundler::LockfileParser.new(lock)
    end
end