class Semverve::VersionCodeReferences
Finds and updates safe version literals in configured code files.
Constants
- IGNORE_MARKER
-
Marker that suppresses version-reference findings.
@return [String]
- RUBY_ASSIGNMENT_PATTERN
-
Ruby assignments that are safe enough to rewrite automatically.
@return [Regexp]
Public Class Methods
# File lib/semverve/version_code_references.rb, line 102 def initialize(configuration, current_version, include_ignored: false) @configuration = configuration @current_version = current_version @include_ignored = include_ignored end
Initializes code version literal scanning.
@param [Semverve::ResolvedConfiguration] configuration @param [Semverve::SemanticVersion] current_version
@return [Semverve::VersionCodeReferences]
Public Instance Methods
Source
# File lib/semverve/version_code_references.rb, line 112 def findings files.flat_map { |path| findings_for_file(path) } end
Code version literal findings in configured files.
@return [Array<Semverve::VersionCodeReferences::Finding>]
Source
# File lib/semverve/version_code_references.rb, line 120 def fix changed_files = [] replacement_count = 0 files.each do |path| content = File.read(path) fixed, count = fixed_content(content) next if count.zero? File.write(path, fixed) changed_files << relative_path(path) replacement_count += count end FixResult.new(changed_files: changed_files, replacement_count: replacement_count) end
Replaces found code version literals with the current version.
@return [Semverve::VersionCodeReferences::FixResult]