Sha256: 41a1f70cb29747f614b1de7d591182febdb354e45c677a228f0f98055cf9435c

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

module DRG
  module Tasks
    class Gemfile
      attr_accessor :file

      def initialize
        @file = ::Bundler.default_gemfile
      end

      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*/
          if line =~ /gem\s*['"]#{name}["']/
            return GemfileLine.new line, index
          end
        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

3 entries across 3 versions & 1 rubygems

Version Path
drg-0.3.0 lib/drg/tasks/gemfile.rb
drg-0.2.1 lib/drg/tasks/gemfile.rb
drg-0.2.0 lib/drg/tasks/gemfile.rb