class ReactOnRails::VersionChecker::NodePackageVersion
Attributes
package_json[R]
Public Class Methods
build()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 72 def self.build new(package_json_path) end
new(package_json)
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 80 def initialize(package_json) @package_json = package_json end
package_json_path()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 76 def self.package_json_path Rails.root.join("client", "package.json") end
Public Instance Methods
major_minor_patch()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 102 def major_minor_patch return if relative_path? match = raw.match(MAJOR_MINOR_PATCH_VERSION_REGEX) unless match raise ReactOnRails::Error, "Cannot parse version number '#{raw}' (wildcard versions are not supported)" end [match[1], match[2], match[3]] end
raw()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 84 def raw parsed_package_contents = JSON.parse(package_json_contents) if parsed_package_contents.key?("dependencies") && parsed_package_contents["dependencies"].key?("react-on-rails") parsed_package_contents["dependencies"]["react-on-rails"] else raise ReactOnRails::Error, "No 'react-on-rails' entry in package.json dependencies" end end
relative_path?()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 98 def relative_path? raw.match(%r{(\.\.|\Afile:///)}).present? end
semver_wildcard?()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 94 def semver_wildcard? raw.match(/[~^]/).present? end
Private Instance Methods
package_json_contents()
click to toggle source
# File lib/react_on_rails/version_checker.rb, line 115 def package_json_contents @package_json_contents ||= File.read(package_json) end