Module: CfnDsl

Defined in:
lib/cfndsl.rb,
lib/cfndsl/names.rb,
lib/cfndsl/rules.rb,
lib/cfndsl/types.rb,
lib/cfndsl/errors.rb,
lib/cfndsl/globals.rb,
lib/cfndsl/outputs.rb,
lib/cfndsl/patches.rb,
lib/cfndsl/plurals.rb,
lib/cfndsl/version.rb,
lib/cfndsl/jsonable.rb,
lib/cfndsl/mappings.rb,
lib/cfndsl/os/types.rb,
lib/cfndsl/aws/types.rb,
lib/cfndsl/rake_task.rb,
lib/cfndsl/resources.rb,
lib/cfndsl/conditions.rb,
lib/cfndsl/parameters.rb,
lib/cfndsl/properties.rb,
lib/cfndsl/specification.rb,
lib/cfndsl/update_policy.rb,
lib/cfndsl/creation_policy.rb,
lib/cfndsl/os/heat_template.rb,
lib/cfndsl/external_parameters.rb,
lib/cfndsl/orchestration_template.rb,
lib/cfndsl/json_serialisable_object.rb,
lib/cfndsl/aws/cloud_formation_template.rb

Overview

Global variables to adjust CfnDsl behavior

Defined Under Namespace

Modules: AWS, Errors, Functions, JSONSerialisableObject, OS, Patches, Plurals, Specification, Types Classes: CloudFormationTemplate, ConditionDefinition, CreationPolicyDefinition, ExternalParameters, Fn, HeatTemplate, JSONable, MappingDefinition, OrchestrationTemplate, OutputDefinition, ParameterDefinition, PropertyDefinition, RakeTask, RefDefinition, ResourceDefinition, RuleDefinition, UpdatePolicyDefinition

Constant Summary collapse

VERSION =
'0.17.2'

Class Method Summary collapse

Class Method Details

.disable_bindingObject



7
8
9
# File 'lib/cfndsl/globals.rb', line 7

def disable_binding
  @disable_binding = true
end

.disable_binding?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cfndsl/globals.rb', line 11

def disable_binding?
  @disable_binding
end

.disable_deep_mergeObject



15
16
17
# File 'lib/cfndsl/globals.rb', line 15

def disable_deep_merge
  @disable_deep_merge = true
end

.disable_deep_merge?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cfndsl/globals.rb', line 19

def disable_deep_merge?
  @disable_deep_merge
end

.eval_file_with_extras(filename, extras = [], logstream = nil) ⇒ Object

rubocop:disable all



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cfndsl.rb', line 62

def self.eval_file_with_extras(filename, extras = [], logstream = nil)
  b = binding
  params = CfnDsl::ExternalParameters.refresh!
  extras.each do |type, file|
    case type
    when :yaml, :json
      klass_name = type.to_s.upcase
      logstream.puts("Loading #{klass_name} file #{file}") if logstream
      params.load_file file
      params.add_to_binding(b, logstream) unless disable_binding?
    when :ruby
      if disable_binding?
        logstream.puts("Interpreting Ruby files was disabled. #{file} will not be read") if logstream
      else
        logstream.puts("Running ruby file #{file}") if logstream
        b.eval(File.read(file), file)
      end
    when :raw
      file_parts = file.split("=")
      params.set_param(file_parts[0],file_parts[1..-1].join("="))
      unless disable_binding?
        logstream.puts("Running raw ruby code #{file}") if logstream
        b.eval(file, 'raw code')
      end
    end
  end

  logstream.puts("Loading template file #{filename}") if logstream
  b.eval(File.read(filename), filename)
end

.method_names(name) ⇒ Object

iterates through the the valid case-insensitive names for “name”



9
10
11
12
13
# File 'lib/cfndsl/names.rb', line 9

def method_names(name)
  name_str = name.to_s.dup
  names = [name_str, name_str.gsub(/^\w/, &:swapcase)]
  block_given? ? names.each { |n| yield n.to_sym } : names
end

.reserved_itemsObject



29
30
31
# File 'lib/cfndsl/globals.rb', line 29

def reserved_items
  %w[Resource Rule Parameter Output].freeze
end

.specification_file(file = nil) ⇒ Object



23
24
25
26
27
# File 'lib/cfndsl/globals.rb', line 23

def specification_file(file = nil)
  @specification_file = file if file
  @specification_file ||= File.join(ENV['HOME'], '.cfndsl/resource_specification.json')
  @specification_file
end