module KeepUp::GemfileFilter
Filter to update dependency information in a Gemfile.
Public Class Methods
apply(contents, dependency)
click to toggle source
# File lib/keep_up/gemfile_filter.rb, line 6 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
dependency_matcher(dependency)
click to toggle source
# File lib/keep_up/gemfile_filter.rb, line 18 def self.dependency_matcher(dependency) / ^(\s*gem\s+['"]#{dependency.name}['"], \s+\[?['"](?:~>|=)?\ *) [^'"]* (['"]\]?[^\]]*) $ /mx end