Class: Rwm::Package
- Inherits:
-
Object
- Object
- Rwm::Package
- Defined in:
- lib/rwm/package.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #app? ⇒ Boolean
- #gemfile_path ⇒ Object
- #has_rakefile? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name:, path:, type:) ⇒ Package
constructor
A new instance of Package.
- #lib? ⇒ Boolean
- #relative_path(workspace_root) ⇒ Object
Constructor Details
#initialize(name:, path:, type:) ⇒ Package
Returns a new instance of Package.
9 10 11 12 13 |
# File 'lib/rwm/package.rb', line 9 def initialize(name:, path:, type:) @name = name @path = File.(path) @type = type.to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rwm/package.rb', line 7 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/rwm/package.rb', line 7 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/rwm/package.rb', line 7 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
35 36 37 |
# File 'lib/rwm/package.rb', line 35 def ==(other) other.is_a?(Package) && name == other.name && path == other.path end |
#app? ⇒ Boolean
19 20 21 |
# File 'lib/rwm/package.rb', line 19 def app? type == :app end |
#gemfile_path ⇒ Object
27 28 29 |
# File 'lib/rwm/package.rb', line 27 def gemfile_path File.join(path, "Gemfile") end |
#has_rakefile? ⇒ Boolean
23 24 25 |
# File 'lib/rwm/package.rb', line 23 def has_rakefile? File.exist?(File.join(path, "Rakefile")) end |
#hash ⇒ Object
40 41 42 |
# File 'lib/rwm/package.rb', line 40 def hash [name, path].hash end |
#lib? ⇒ Boolean
15 16 17 |
# File 'lib/rwm/package.rb', line 15 def lib? type == :lib end |
#relative_path(workspace_root) ⇒ Object
31 32 33 |
# File 'lib/rwm/package.rb', line 31 def relative_path(workspace_root) Pathname.new(path).relative_path_from(Pathname.new(workspace_root)).to_s end |