Module: Lono::Template::Dsl::Builder::Helpers::CoreHelper

Extended by:
Memoist
Included in:
Lono::Template::Dsl::Builder::Helpers
Defined in:
lib/lono/template/dsl/builder/helpers/core_helper.rb

Instance Method Summary collapse

Instance Method Details

#content(path) ⇒ Object



35
36
37
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 35

def content(path)
  render_file(Lono.config.content_path, path)
end

#dimensions(hash, casing: :camelize) ⇒ Object



28
29
30
31
32
33
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 28

def dimensions(hash, casing: :camelize)
  tags(hash, casing: casing).map { |h|
    h[:Name] = h.delete(:Key) || h.delete(:key)
    h
  }
end

#file_s3_key(name, options = {}) ⇒ Object Also known as: s3_key



65
66
67
68
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 65

def file_s3_key(name, options={})
  Lono::AppFile::Registry.register(name, @blueprint, options)
  "file://app/files/#{name}" # placeholder for post processing
end

#render_file(folder, path) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 43

def render_file(folder, path)
  path = "#{folder}/#{path}"
  if File.exist?(path)
    render_path(path)
  else
    message = "WARNING: path #{path} not found"
    puts message.color(:yellow)
    puts "Called from:"
    puts caller[2]
    message
  end
end

#render_path(path) ⇒ Object



57
58
59
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 57

def render_path(path)
  RenderMePretty.result(path, context: self)
end

#s3_bucketObject



61
62
63
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 61

def s3_bucket
  Lono::S3::Bucket.name
end

#settingObject



71
72
73
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 71

def setting
  Lono::Setting.new
end

#tag_list(hash, casing: :camelize) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 10

def tag_list(hash, casing: :camelize)
  hash.map do |k,v|
    k = k.to_s
    k = case casing
    when :camelize
      k.camelize
    when :underscore
      k.underscore
    when :dasherize
      k.dasherize
    else # leave alone
      k
    end

    {Key: k, Value: v}
  end
end

#tags(hash, casing: :camelize) ⇒ Object



5
6
7
8
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 5

def tags(hash, casing: :camelize)
  puts "DEPRECATED: tags helper will be removed. Use tag_list instead."
  tag_list(hash, casing: casing)
end

#user_data(path) ⇒ Object



39
40
41
# File 'lib/lono/template/dsl/builder/helpers/core_helper.rb', line 39

def user_data(path)
  render_file(Lono.config.user_data_path, path)
end