Sha256: b7faf439a1b3fcc4b0d1a0b7a6a9876cee7cbc83dba04b631ee28cea043f127c
Contents?: true
Size: 1.07 KB
Versions: 67
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' module Avm module EacRubyBase1 module Rubygems class VersionFile common_constructor :path VERSION_LINE_PATTERN = /\A(\s*)VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"](\s*)\z/.freeze def value return nil unless path.file? path.read.each_line.lazy.map { |line| line_value(line) }.find { |v| v } end def value=(new_value) path.write(new_value_content(new_value)) end private # @return Version found in line, nil otherwise. def line_value(line) VERSION_LINE_PATTERN.if_match(line.rstrip, false) { |m| ::Gem::Version.new(m[2]) } end def new_value_content(new_value) path.read.each_line .map { |line| new_value_line(line, new_value) } .join end def new_value_line(line, new_value) m = VERSION_LINE_PATTERN.match(line) return line unless m "#{m[1]}VERSION = '#{new_value}'#{m[3]}" end end end end end
Version data entries
67 entries across 67 versions & 2 rubygems