Sha256: 04d9594bdd4d4e57b40ea0708bf40290d9ac1008099ed3bfb1482b430bb386c1

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

require_relative 'exceptions'

module Rocktumbler
  class Gemfile
    attr_accessor :ruby, :source

    def initialize(gemfile_location)
      @gemfile_location = gemfile_location
      @gemfile_contents = read_contents
      @ruby = parse_ruby
      @source = parse_source
    end

    def read_contents
      gemfile = File.open(@gemfile_location,'r')
      str = gemfile.read
      gemfile.close
      str
    end

    def print_source_and_ruby
      str = ""
      str += "#{@source.gsub(/"/,'\'')}\n\n" if @source
      str += "#{@ruby.gsub(/"/,'\'')}\n\n" if @ruby
      str
    end

    def parse_ruby
      /^(ruby.*)/.match(@gemfile_contents)
      $1
    end

    def parse_source
      /^(source.*)/.match(@gemfile_contents)
      $1
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rocktumbler-0.1.2 lib/rocktumbler/gemfile.rb
rocktumbler-0.1.1 lib/rocktumbler/gemfile.rb