Module: KeepUp::GemspecFilter
- Defined in:
- lib/keep_up/gemspec_filter.rb
Overview
Filter to update dependency information in a Gemspec.
Class Method Summary collapse
Class Method Details
.apply(contents, dependency) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/keep_up/gemspec_filter.rb', line 4 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) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/keep_up/gemspec_filter.rb', line 16 def self.dependency_matcher(dependency) / ^(.*_dependency [\ (](?:['"]|%q.)#{dependency.name}.(?:\.freeze)?, \ \[?['"](?:~>|=)?\ *)[^'"]*(['"].*) /mx end |