Module: Configature

Defined in:
lib/configature.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
File.readlines(File.expand_path('../VERSION', __dir__)).first.chomp.freeze

Class Method Summary collapse

Class Method Details

.config_dirObject



25
26
27
28
29
30
31
# File 'lib/configature.rb', line 25

def self.config_dir
  dir_plus_parents(Dir.pwd).lazy.map do |dir|
    File.expand_path('config', dir)
  end.find do |dir|
    File.directory?(dir)
  end
end

.configable_examples(dir) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/configature.rb', line 33

def self.configable_examples(dir)
  map = Dir.glob(File.expand_path('*.example', dir)).map do |source|
    [ source, source.delete_suffix('.example') ]
  end.to_h

  if (block_given?)
    map.each do |k,v|
      yield(k, v)
    end
  end

  map
end

.dir_plus_parents(dir) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/configature.rb', line 11

def self.dir_plus_parents(dir)
  Enumerator.new do |y|
    y << dir

    loop do
      last, dir = dir, File.expand_path('../', dir)

      break if (last == dir)

      y << dir
    end
  end
end

.versionObject

Your code goes here…



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

def self.version
  VERSION
end