Class: Chekku::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/chekku/fetcher.rb

Constant Summary collapse

CHEKKU_PATH =
"#{Dir.home}/.chekku"
CHEKKU_EXPORT_URL =
"http://chekku.co/definitions/export"
CHEKKU_DEFINITION_FILE =
"#{CHEKKU_PATH}/def.yml"
MAX_DAYS =
7

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dependenciesObject

Returns the value of attribute dependencies.



13
14
15
# File 'lib/chekku/fetcher.rb', line 13

def dependencies
  @dependencies
end

Class Method Details

.fetch_for_chekkufile(file_path) ⇒ Array

Fetch the Definitions from the file

Parameters:

  • file_path (String)

    Path to Chekkufile

Returns:

  • (Array)

    a list of Definition instances



19
20
21
22
# File 'lib/chekku/fetcher.rb', line 19

def self.fetch_for_chekkufile(file_path)
  fetcher = new
  fetcher.dependencies_from_file
end

Instance Method Details

#definitions_hashObject



28
29
30
31
32
33
34
35
36
# File 'lib/chekku/fetcher.rb', line 28

def definitions_hash
  begin
    definitions_yaml = load_definitions_file
  rescue
  ensure
    definitions_yaml ||= {}
  end
  ensure_definitions_are_up_to_date(definitions_yaml)
end

#dependencies_from_fileObject



24
25
26
# File 'lib/chekku/fetcher.rb', line 24

def dependencies_from_file
  @dependencies = Chekku::Definition.load(definitions_hash)
end