Class: CobraCommander::Dependencies::Yarn::Package
- Inherits:
-
Object
- Object
- CobraCommander::Dependencies::Yarn::Package
- Defined in:
- lib/cobra_commander/dependencies/yarn/package.rb
Overview
Represents an Yarn package.json file
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(path) ⇒ Package
constructor
A new instance of Package.
- #name ⇒ Object
- #project_tag ⇒ Object
Constructor Details
#initialize(path) ⇒ Package
Returns a new instance of Package.
13 14 15 |
# File 'lib/cobra_commander/dependencies/yarn/package.rb', line 13 def initialize(path) @path = ::Pathname.new(File.join(path, "package.json")).realpath end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/cobra_commander/dependencies/yarn/package.rb', line 11 def path @path end |
Instance Method Details
#dependencies ⇒ Object
25 26 27 28 |
# File 'lib/cobra_commander/dependencies/yarn/package.rb', line 25 def dependencies json.fetch("dependencies", {}) .merge(json.fetch("devDependencies", {})) end |
#name ⇒ Object
21 22 23 |
# File 'lib/cobra_commander/dependencies/yarn/package.rb', line 21 def name json["name"] end |
#project_tag ⇒ Object
17 18 19 |
# File 'lib/cobra_commander/dependencies/yarn/package.rb', line 17 def project_tag name.match(%r{^@[\w-]+/}).to_s end |