Sha256: b2dfe465ba0feb132fee6aced98cf170111488a328afa142b29edd1dcb069e13

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module KeepUp
  # Filter to update dependency information in a Gemspec.
  module GemspecFilter
    def self.apply(contents, dependency)
      matcher = dependency_matcher(dependency)
      contents.each_line.map do |line|
        if line =~ matcher
          match = Regexp.last_match
          "#{match[1]}#{dependency.version}#{match[2]}"
        else
          line
        end
      end.join
    end

    def self.dependency_matcher(dependency)
      /
        ^(.*_dependency
        [\ (](?:['"]|%q.)#{dependency.name}.(?:\.freeze)?,
        \ \[?['"](?:~>|=)?\ *)[^'"]*(['"].*)
      /mx
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keep_up-0.5.0 lib/keep_up/gemspec_filter.rb