Class: KeepUp::GemspecFilter
- Inherits:
-
FileFilter
- Object
- FileFilter
- KeepUp::GemspecFilter
- Defined in:
- lib/keep_up/gemspec_filter.rb
Overview
Filter to update dependency information in a Gemspec.
Class Method Summary collapse
Methods inherited from FileFilter
Class Method Details
.apply(contents, dependency) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/keep_up/gemspec_filter.rb', line 8 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
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/keep_up/gemspec_filter.rb', line 20 def self.dependency_matcher(dependency) / ^(.*_dependency \s*(?:\(\s*)? (?:['"]|%q.)#{dependency.name}.(?:\.freeze)?, \s+\[?['"](?:~>|=)?\ *) [^'"]* (['"]\]?[^'"]*)$ /mx end |