Class: Rwm::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/rwm/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path(path)
  @type = type.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/rwm/package.rb', line 7

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/rwm/package.rb', line 7

def path
  @path
end

#typeObject (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

Returns:



19
20
21
# File 'lib/rwm/package.rb', line 19

def app?
  type == :app
end

#gemfile_pathObject



27
28
29
# File 'lib/rwm/package.rb', line 27

def gemfile_path
  File.join(path, "Gemfile")
end

#has_rakefile?Boolean

Returns:



23
24
25
# File 'lib/rwm/package.rb', line 23

def has_rakefile?
  File.exist?(File.join(path, "Rakefile"))
end

#hashObject



40
41
42
# File 'lib/rwm/package.rb', line 40

def hash
  [name, path].hash
end

#lib?Boolean

Returns:



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