Class: Packs::Pack

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packs/pack.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from(package_yml_absolute_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/packs/pack.rb', line 13

def self.from(package_yml_absolute_path)
  package_loaded_yml = YAML.load_file(package_yml_absolute_path)
  path = package_yml_absolute_path.dirname
  relative_path = path.relative_path_from(Specification.root)
  package_name = relative_path.cleanpath.to_s

  Pack.new(
    name: package_name,
    path: path,
    relative_path: relative_path,
    raw_hash: package_loaded_yml || {}
  )
end

Instance Method Details

#is_gem?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


39
40
41
# File 'lib/packs/pack.rb', line 39

def is_gem? # rubocop:disable Naming/PredicateName
  @is_gem ||= T.let(relative_path.glob('*.gemspec').any?, T.nilable(T::Boolean))
end

#last_nameObject



34
35
36
# File 'lib/packs/pack.rb', line 34

def last_name
  relative_path.basename.to_s
end

#metadataObject



44
45
46
# File 'lib/packs/pack.rb', line 44

def 
  raw_hash['metadata'] || {}
end

#yml(relative: true) ⇒ Object



28
29
30
31
# File 'lib/packs/pack.rb', line 28

def yml(relative: true)
  path_to_use = relative ? relative_path : path
  path_to_use.join(PACKAGE_FILE).cleanpath
end