class Simnos::DSL
Attributes
result[R]
Public Class Methods
define(source, filepath, options)
click to toggle source
# File lib/simnos/dsl.rb, line 10 def define(source, filepath, options) self.new(filepath, options) do eval(source, binding, filepath) end end
new(filepath, options, &block)
click to toggle source
# File lib/simnos/dsl.rb, line 19 def initialize(filepath, options, &block) @filepath = filepath @result = OpenStruct.new(snss: Hashie::Mash.new) @context = Hashie::Mash.new( filepath: filepath, templates: {}, options: options, ) instance_eval(&block) end
Public Instance Methods
require(file)
click to toggle source
# File lib/simnos/dsl.rb, line 32 def require(file) albfile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@filepath), file)) if File.exist?(albfile) instance_eval(File.read(albfile), albfile) elsif File.exist?("#{albfile}.rb") instance_eval(File.read("#{albfile}.rb"), "#{albfile}.rb") else Kernel.require(file) end end
sns(region = nil, &block)
click to toggle source
# File lib/simnos/dsl.rb, line 48 def sns(region = nil, &block) current_region = @context[:region] = region || ENV['AWS_DEFAULT_REGION'] || ENV.fetch('AWS_REGION') current_region_sns = @result.snss[current_region] topics = current_region_sns ? current_region_sns.topics : [] @result.snss[current_region] = SNS.new(@context, topics, &block).result end
template(name, &block)
click to toggle source
# File lib/simnos/dsl.rb, line 44 def template(name, &block) @context.templates[name.to_s] = block end