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