Class: Webpacker::VersionChecker::NodePackageVersion
- Inherits:
-
Object
- Object
- Webpacker::VersionChecker::NodePackageVersion
- Defined in:
- lib/webpacker/version_checker.rb
Instance Attribute Summary collapse
-
#package_json ⇒ Object
readonly
Returns the value of attribute package_json.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(package_json) ⇒ NodePackageVersion
constructor
A new instance of NodePackageVersion.
- #major_minor_patch ⇒ Object
- #raw ⇒ Object
- #semver_wildcard? ⇒ Boolean
- #skip_processing? ⇒ Boolean
Constructor Details
#initialize(package_json) ⇒ NodePackageVersion
Returns a new instance of NodePackageVersion.
101 102 103 |
# File 'lib/webpacker/version_checker.rb', line 101 def initialize(package_json) @package_json = package_json end |
Instance Attribute Details
#package_json ⇒ Object (readonly)
Returns the value of attribute package_json.
91 92 93 |
# File 'lib/webpacker/version_checker.rb', line 91 def package_json @package_json end |
Class Method Details
.build ⇒ Object
93 94 95 |
# File 'lib/webpacker/version_checker.rb', line 93 def self.build new(package_json_path) end |
.package_json_path ⇒ Object
97 98 99 |
# File 'lib/webpacker/version_checker.rb', line 97 def self.package_json_path Rails.root.join("package.json") end |
Instance Method Details
#major_minor_patch ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/webpacker/version_checker.rb', line 118 def major_minor_patch return if skip_processing? match = raw.match(MAJOR_MINOR_PATCH_VERSION_REGEX) unless match raise "Cannot parse version number '#{raw}' (wildcard versions are not supported)" end [match[1], match[2], match[3]] end |
#raw ⇒ Object
105 106 107 108 |
# File 'lib/webpacker/version_checker.rb', line 105 def raw parsed_package_contents = JSON.parse(package_json_contents) parsed_package_contents.dig("dependencies", "shakapacker").to_s end |
#semver_wildcard? ⇒ Boolean
110 111 112 |
# File 'lib/webpacker/version_checker.rb', line 110 def semver_wildcard? raw.match(/[~^]/).present? end |
#skip_processing? ⇒ Boolean
114 115 116 |
# File 'lib/webpacker/version_checker.rb', line 114 def skip_processing? !package_specified? || relative_path? || git_url? || github_url? end |