Sha256: a81a477724b1c841177b4bbe2440c2bb590dec1d02c4d009b4373c98054941d9

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

module DRG
  module Tasks
    class Gemfile
      attr_accessor :file

      def initialize
        @file = ::Bundler.default_gemfile
      end

      # @param [GemfileLine] gem
      # @param [String] version to update the gem line with
      def update(gem, version)
        lines[gem] = gem.update version
      end

      def find_by_name(name)
        lines.each_with_index.each do |line, index|
          next if line =~ /:?path:?\s*(=>)?\s*/
          next if line =~ /:?git(hub)?:?\s*(=>)?\s*/
          return GemfileLine.new line, index if line =~ /gem\s*['"]#{name}["']/
        end
        nil
      end

      def lines
        @lines ||= File.readlines file
      end

      def write
        File.open file, 'wb' do |f|
          lines.each do |line|
            f << line
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drg-0.4.1 lib/drg/tasks/gemfile.rb
drg-0.4.0 lib/drg/tasks/gemfile.rb