Sha256: 5e561b2bb6ff29471d7a58af8ec6bd51e2a950688b0c0d1203ee2e09a1e042ea
Contents?: true
Size: 988 Bytes
Versions: 1
Compression:
Stored size: 988 Bytes
Contents
module LockfilePreserver class RubyVersion def initialize(original, updated) @original = original @updated = updated end def keep if original.include? RUBY_VERSION keep_ruby_version else remove_ruby_version end end private attr_reader :original, :updated RUBY_VERSION = "RUBY VERSION".freeze VERSION_PATTERN = %r{.+} REGEXP = %r{\n\nRUBY VERSION\n\s+(?<version>#{VERSION_PATTERN})\n*} NEW_LINE = "\n".freeze private_constant :RUBY_VERSION private_constant :REGEXP private_constant :NEW_LINE def keep_ruby_version updated.sub(REGEXP, ruby_version_section) end def remove_ruby_version updated.sub(REGEXP, NEW_LINE) end def ruby_version_section "\n\nRUBY VERSION\n" \ " #{ruby_version}\n" end def ruby_version @_ruby_version ||= original.match(REGEXP)[:version] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lockfile_preserver-1.0.1 | lib/lockfile_preserver/ruby_version.rb |