Class: Shakapacker::VersionChecker::NodePackageVersion
- Inherits:
-
Object
- Object
- Shakapacker::VersionChecker::NodePackageVersion
- Defined in:
- lib/shakapacker/version_checker.rb
Overview
TODO: this might as well use package_json
Instance Attribute Summary collapse
-
#package_json ⇒ Object
readonly
Returns the value of attribute package_json.
Class Method Summary collapse
- .build ⇒ Object
- .package_json_path ⇒ Object
- .package_lock_path ⇒ Object
- .pnpm_lock_path ⇒ Object
- .yarn_lock_path ⇒ Object
Instance Method Summary collapse
-
#initialize(package_json, yarn_lock, package_lock, pnpm_lock) ⇒ NodePackageVersion
constructor
A new instance of NodePackageVersion.
- #major_minor_patch ⇒ Object
- #raw ⇒ Object
- #semver_wildcard? ⇒ Boolean
- #skip_processing? ⇒ Boolean
Constructor Details
#initialize(package_json, yarn_lock, package_lock, pnpm_lock) ⇒ NodePackageVersion
Returns a new instance of NodePackageVersion.
92 93 94 95 96 97 |
# File 'lib/shakapacker/version_checker.rb', line 92 def initialize(package_json, yarn_lock, package_lock, pnpm_lock) @package_json = package_json @yarn_lock = yarn_lock @package_lock = package_lock @pnpm_lock = pnpm_lock end |
Instance Attribute Details
#package_json ⇒ Object (readonly)
Returns the value of attribute package_json.
70 71 72 |
# File 'lib/shakapacker/version_checker.rb', line 70 def package_json @package_json end |
Class Method Details
.build ⇒ Object
72 73 74 |
# File 'lib/shakapacker/version_checker.rb', line 72 def self.build new(package_json_path, yarn_lock_path, package_lock_path, pnpm_lock_path) end |
.package_json_path ⇒ Object
76 77 78 |
# File 'lib/shakapacker/version_checker.rb', line 76 def self.package_json_path Rails.root.join("package.json") end |
.package_lock_path ⇒ Object
84 85 86 |
# File 'lib/shakapacker/version_checker.rb', line 84 def self.package_lock_path Rails.root.join("package-lock.json") end |
.pnpm_lock_path ⇒ Object
88 89 90 |
# File 'lib/shakapacker/version_checker.rb', line 88 def self.pnpm_lock_path Rails.root.join("pnpm-lock.yaml") end |
.yarn_lock_path ⇒ Object
80 81 82 |
# File 'lib/shakapacker/version_checker.rb', line 80 def self.yarn_lock_path Rails.root.join("yarn.lock") end |
Instance Method Details
#major_minor_patch ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/shakapacker/version_checker.rb', line 111 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
99 100 101 |
# File 'lib/shakapacker/version_checker.rb', line 99 def raw @raw ||= find_version end |
#semver_wildcard? ⇒ Boolean
103 104 105 |
# File 'lib/shakapacker/version_checker.rb', line 103 def semver_wildcard? raw.match(/[~^]/).present? end |
#skip_processing? ⇒ Boolean
107 108 109 |
# File 'lib/shakapacker/version_checker.rb', line 107 def skip_processing? !package_specified? || relative_path? || git_url? || github_url? end |