Class: Pipely::Build::Definition

Inherits:
Struct
  • Object
show all
Defined in:
lib/pipely/build/definition.rb

Overview

Represent a pipeline definition, built from a Template and some config.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



6
7
8
# File 'lib/pipely/build/definition.rb', line 6

def config
  @config
end

#envObject

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



6
7
8
# File 'lib/pipely/build/definition.rb', line 6

def env
  @env
end

#templateObject

Returns the value of attribute template

Returns:

  • (Object)

    the current value of template



6
7
8
# File 'lib/pipely/build/definition.rb', line 6

def template
  @template
end

Instance Method Details

#base_filenameObject



11
12
13
# File 'lib/pipely/build/definition.rb', line 11

def base_filename
  config[:namespace]
end

#pipeline_nameObject



7
8
9
# File 'lib/pipely/build/definition.rb', line 7

def pipeline_name
  config[:name]
end

#s3_path_builderObject



24
25
26
# File 'lib/pipely/build/definition.rb', line 24

def s3_path_builder
  S3PathBuilder.new(config[:s3].merge(prefix: s3_prefix))
end

#s3_prefixObject



15
16
17
18
19
20
21
22
# File 'lib/pipely/build/definition.rb', line 15

def s3_prefix
  if config[:s3_prefix]
    template = Pathology.template(config[:s3_prefix])
    template.interpolate(interpolation_context)
  else
    fail('unspecified s3_prefix')
  end
end

#schedulerObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/pipely/build/definition.rb', line 37

def scheduler
  case config[:scheduler]
  when 'daily'
    DailyScheduler.new(config[:start_time])
  when 'now'
    RightNowScheduler.new
  else
    fail('unspecified scheduler')
  end
end

#to_jsonObject



28
29
30
31
32
33
34
35
# File 'lib/pipely/build/definition.rb', line 28

def to_json
  template.apply_config(:environment => env)
  template.apply_config(config)
  template.apply_config(s3_path_builder.to_hash)
  template.apply_config(scheduler.to_hash)

  template.to_json
end