Class: Rna::S3

Inherits:
Outputer show all
Defined in:
lib/rna/outputers.rb

Instance Attribute Summary collapse

Attributes inherited from Outputer

#options

Instance Method Summary collapse

Methods inherited from Outputer

#initialize

Constructor Details

This class inherits a constructor from Rna::Outputer

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



22
23
24
# File 'lib/rna/outputers.rb', line 22

def config
  @config
end

#s3Object (readonly)

Returns the value of attribute s3.



22
23
24
# File 'lib/rna/outputers.rb', line 22

def s3
  @s3
end

Instance Method Details

#run(jsons) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rna/outputers.rb', line 23

def run(jsons)
  # options[:config] only used for specs
  s3_config_path = options[:s3_config_path] || 'config/s3.yml'
  @config ||= YAML.load(File.read(s3_config_path))
  AWS.config(@config)
  @s3 = AWS::S3.new
  bucket = @s3.buckets[@config['bucket']]
  jsons.each do |role,json|
    puts "  #{role}.json" if options[:verbose]
    bucket.objects.create("#{@config['folder']}/#{role}.json", json)
  end
  self # return outputer object for specs
end