Class: Devpack::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/devpack/config.rb

Overview

Locates and parses .devpack config file

Constant Summary collapse

FILENAME =
'.devpack'
INITIALIZERS_DIRECTORY_NAME =
'.devpack_initializers'
MAX_PARENTS =

Avoid infinite loops (symlinks/weird file systems)

100

Instance Method Summary collapse

Constructor Details

#initialize(pwd) ⇒ Config

Returns a new instance of Config.



10
11
12
# File 'lib/devpack/config.rb', line 10

def initialize(pwd)
  @pwd = Pathname.new(pwd)
end

Instance Method Details

#devpack_initializer_pathsObject



31
32
33
# File 'lib/devpack/config.rb', line 31

def devpack_initializer_paths
  devpack_initializers_path&.glob(File.join('**', '*.rb'))&.map(&:to_s)&.sort || []
end

#devpack_initializers_pathObject



27
28
29
# File 'lib/devpack/config.rb', line 27

def devpack_initializers_path
  @devpack_initializers_path ||= located_path(@pwd, INITIALIZERS_DIRECTORY_NAME, :directory)
end

#devpack_pathObject



23
24
25
# File 'lib/devpack/config.rb', line 23

def devpack_path
  @devpack_path ||= located_path(@pwd, FILENAME, :file)
end

#requested_gemsObject



14
15
16
17
18
19
20
21
# File 'lib/devpack/config.rb', line 14

def requested_gems
  return nil if devpack_path.nil?

  File.readlines(devpack_path)
      .map(&filter_comments)
      .compact
      .map { |line| GemRef.parse(line) }
end