Class: ReactOnRails::VersionChecker
- Inherits:
-
Object
- Object
- ReactOnRails::VersionChecker
- Defined in:
- lib/react_on_rails/version_checker.rb
Overview
Responsible for checking versions of rubygem versus yarn node package against each otherat runtime.
Defined Under Namespace
Classes: NodePackageVersion
Constant Summary collapse
- MAJOR_MINOR_PATCH_VERSION_REGEX =
/(\d+)\.(\d+)\.(\d+)/
Instance Attribute Summary collapse
-
#node_package_version ⇒ Object
readonly
Returns the value of attribute node_package_version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node_package_version) ⇒ VersionChecker
constructor
A new instance of VersionChecker.
-
#raise_if_gem_and_node_package_versions_differ ⇒ Object
For compatibility, the gem and the node package versions should always match, unless the user really knows what they’re doing.
Constructor Details
#initialize(node_package_version) ⇒ VersionChecker
Returns a new instance of VersionChecker.
15 16 17 |
# File 'lib/react_on_rails/version_checker.rb', line 15 def initialize(node_package_version) @node_package_version = node_package_version end |
Instance Attribute Details
#node_package_version ⇒ Object (readonly)
Returns the value of attribute node_package_version.
7 8 9 |
# File 'lib/react_on_rails/version_checker.rb', line 7 def node_package_version @node_package_version end |
Class Method Details
.build ⇒ Object
11 12 13 |
# File 'lib/react_on_rails/version_checker.rb', line 11 def self.build new(NodePackageVersion.build) end |
Instance Method Details
#raise_if_gem_and_node_package_versions_differ ⇒ Object
For compatibility, the gem and the node package versions should always match, unless the user really knows what they’re doing. So we will give a warning if they do not.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/react_on_rails/version_checker.rb', line 22 def raise_if_gem_and_node_package_versions_differ return if node_package_version.relative_path? node_major_minor_patch = node_package_version.major_minor_patch gem_major_minor_patch = gem_major_minor_patch_version versions_match = 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_differing_versions_warning unless versions_match raise_node_semver_version_warning if node_package_version.semver_wildcard? end |