Class: Shakapacker::VersionChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/shakapacker/version_checker.rb

Defined Under Namespace

Classes: NodePackageVersion

Constant Summary collapse

MAJOR_MINOR_PATCH_VERSION_REGEX =
/(\d+)\.(\d+)\.(\d+)/.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_package_version) ⇒ VersionChecker

Returns a new instance of VersionChecker.



14
15
16
# File 'lib/shakapacker/version_checker.rb', line 14

def initialize(node_package_version)
  @node_package_version = node_package_version
end

Instance Attribute Details

#node_package_versionObject (readonly)

Returns the value of attribute node_package_version.



6
7
8
# File 'lib/shakapacker/version_checker.rb', line 6

def node_package_version
  @node_package_version
end

Class Method Details

.buildObject



10
11
12
# File 'lib/shakapacker/version_checker.rb', line 10

def self.build
  new(NodePackageVersion.build)
end

Instance Method Details

#raise_if_gem_and_node_package_versions_differObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/shakapacker/version_checker.rb', line 18

def raise_if_gem_and_node_package_versions_differ
  # Skip check if package is not in package.json or listed from relative path, git repo or github URL
  # or if consistent version checking is not enabled
  return if node_package_version.skip_processing? || !Shakapacker.config.ensure_consistent_versioning?

  node_major_minor_patch = node_package_version.major_minor_patch
  gem_major_minor_patch = gem_major_minor_patch_version

  raise_differing_versions_warning unless (
    node_major_minor_patch[0] == gem_major_minor_patch[0] &&
    node_major_minor_patch[1] == gem_major_minor_patch[1] &&
    node_major_minor_patch[2] == gem_major_minor_patch[2]
  )

  raise_node_semver_version_warning if node_package_version.semver_wildcard?
end