Class: Nanoc::Int::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/base/services/compiler.rb

Defined Under Namespace

Modules: Phases, Stages

Instance Method Summary collapse

Constructor Details

#initialize(site, compiled_content_cache:, checksum_store:, action_sequence_store:, action_provider:, dependency_store:, reps:, outdatedness_store:) ⇒ Compiler

Returns a new instance of Compiler



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/nanoc/base/services/compiler.rb', line 34

def initialize(site, compiled_content_cache:, checksum_store:, action_sequence_store:, action_provider:, dependency_store:, reps:, outdatedness_store:)
  @site = site

  @compiled_content_cache = compiled_content_cache
  @checksum_store         = checksum_store
  @action_sequence_store  = action_sequence_store
  @dependency_store       = dependency_store
  @reps                   = reps
  @action_provider        = action_provider
  @outdatedness_store     = outdatedness_store

  # TODO: inject
  @snapshot_repo = Nanoc::Int::SnapshotRepo.new
end

Instance Method Details

#build_repsObject

TODO: remove



100
101
102
# File 'lib/nanoc/base/services/compiler.rb', line 100

def build_reps
  @action_sequences = build_reps_stage.run
end

#calculate_checksumsObject

TODO: remove



105
106
107
# File 'lib/nanoc/base/services/compiler.rb', line 105

def calculate_checksums
  @checksums = run_stage(calculate_checksums_stage)
end

#compilation_contextObject



84
85
86
87
88
89
90
91
92
# File 'lib/nanoc/base/services/compiler.rb', line 84

def compilation_context
  @_compilation_context ||= Nanoc::Int::CompilationContext.new(
    action_provider: action_provider,
    reps: @reps,
    site: @site,
    compiled_content_cache: compiled_content_cache,
    snapshot_repo: snapshot_repo,
  )
end

#create_outdatedness_checkerObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nanoc/base/services/compiler.rb', line 49

def create_outdatedness_checker
  Nanoc::Int::OutdatednessChecker.new(
    site: @site,
    checksum_store: @checksum_store,
    dependency_store: @dependency_store,
    action_sequence_store: @action_sequence_store,
    action_sequences: @action_sequences,
    checksums: @checksums,
    reps: reps,
  )
end

#load_storesObject

TODO: remove



95
96
97
# File 'lib/nanoc/base/services/compiler.rb', line 95

def load_stores
  load_stores_stage.run
end

#prepareObject



74
75
76
77
78
79
80
81
82
# File 'lib/nanoc/base/services/compiler.rb', line 74

def prepare
  # FIXME: State is ugly

  run_stage(preprocess_stage)
  @action_sequences = run_stage(build_reps_stage)
  run_stage(load_stores_stage)
  @checksums = run_stage(calculate_checksums_stage)
  @outdated_items = run_stage(determine_outdatedness_stage)
end

#run_allObject



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/nanoc/base/services/compiler.rb', line 61

def run_all
  prepare

  run_stage(forget_outdated_dependencies_stage, @outdated_items)
  run_stage(store_pre_compilation_state_stage(@action_sequences), @checksums)
  run_stage(prune_stage)
  run_stage(compile_reps_stage(@action_sequences))
  run_stage(store_post_compilation_state_stage)
  run_stage(postprocess_stage)
ensure
  run_stage(cleanup_stage)
end