Class: Hookworm::TravisPayloadBuildIndexer

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/hookworm/build_index_handler.rb

Constant Summary collapse

InvalidPayload =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cfg, log) ⇒ TravisPayloadBuildIndexer

Returns a new instance of TravisPayloadBuildIndexer.



35
36
37
38
# File 'lib/hookworm/build_index_handler.rb', line 35

def initialize(cfg, log)
  @cfg = cfg
  @log = log
end

Instance Attribute Details

#cfgObject (readonly)

Returns the value of attribute cfg.



31
32
33
# File 'lib/hookworm/build_index_handler.rb', line 31

def cfg
  @cfg
end

#logObject (readonly)

Returns the value of attribute log.



31
32
33
# File 'lib/hookworm/build_index_handler.rb', line 31

def log
  @log
end

Instance Method Details

#index(payload) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hookworm/build_index_handler.rb', line 40

def index(payload)
  mkdir_p(index_prefix)
  repo_slug = (payload[:repository] || {})[:slug]
  unless repo_slug
    fail InvalidPayload, "Invalid repo slug #{repo_slug.inspect}"
  end
  build_id_path = payload_build_id_path(repo_slug, payload)
  mkdir_p(File.dirname(build_id_path))
  write_payload(payload, build_id_path)
  link_all_category_paths(payload, repo_slug, build_id_path)
  update_all_directory_indexes(repo_slug)
end