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 other at runtime.
Defined Under Namespace
Classes: NodePackageVersion
Constant Summary collapse
- VERSION_PARTS_REGEX =
Semver uses - to separate pre-release, but RubyGems use .
/(\d+)\.(\d+)\.(\d+)(?:[-.]([0-9A-Za-z.-]+))?/
Instance Attribute Summary collapse
-
#node_package_version ⇒ Object
readonly
rubocop:disable Metrics/ClassLength.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node_package_version) ⇒ VersionChecker
constructor
A new instance of VersionChecker.
-
#validate_version_and_package_compatibility! ⇒ Object
Validates version and package compatibility.
Constructor Details
#initialize(node_package_version) ⇒ VersionChecker
Returns a new instance of VersionChecker.
18 19 20 |
# File 'lib/react_on_rails/version_checker.rb', line 18 def initialize(node_package_version) @node_package_version = node_package_version end |
Instance Attribute Details
#node_package_version ⇒ Object (readonly)
rubocop:disable Metrics/ClassLength
9 10 11 |
# File 'lib/react_on_rails/version_checker.rb', line 9 def node_package_version @node_package_version end |
Class Method Details
.build ⇒ Object
14 15 16 |
# File 'lib/react_on_rails/version_checker.rb', line 14 def self.build new(NodePackageVersion.build) end |
Instance Method Details
#validate_version_and_package_compatibility! ⇒ Object
Validates version and package compatibility. Raises ReactOnRails::Error if:
-
package.json file is not found
-
Both react-on-rails and react-on-rails-pro packages are installed
-
Pro gem is installed but using react-on-rails package
-
Pro package is installed but Pro gem is not installed
-
Non-exact version is used
-
Versions don’t match
30 31 32 33 34 35 |
# File 'lib/react_on_rails/version_checker.rb', line 30 def validate_version_and_package_compatibility! validate_package_json_exists! validate_package_gem_compatibility! validate_exact_version! validate_version_match! end |