Class: Mrwolf::Transporter
- Inherits:
-
Object
- Object
- Mrwolf::Transporter
- Defined in:
- lib/mrwolf/transporter_to_s3.rb
Instance Method Summary collapse
-
#initialize(project, version) ⇒ Transporter
constructor
A new instance of Transporter.
- #publish ⇒ Object
Constructor Details
#initialize(project, version) ⇒ Transporter
Returns a new instance of Transporter.
2 3 4 5 6 7 8 9 |
# File 'lib/mrwolf/transporter_to_s3.rb', line 2 def initialize(project,version) @PROJECT = project @AWS_ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] @AWS_SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY'] @S3_BUCKET = ENV['S3_BUCKET'] @version = version end |
Instance Method Details
#publish ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mrwolf/transporter_to_s3.rb', line 11 def publish require 'rubygems' require 'fog' connection = Fog::Storage.new( provider: :AWS, aws_access_key_id: @AWS_ACCESS_KEY_ID, aws_secret_access_key: @AWS_SECRET_ACCESS_KEY) directory = connection.directories.new( key: @S3_BUCKET ) artifact = "#{@PROJECT}/#{@PROJECT}-#{@version}.noarch.rpm" artifact_path = "#{@PROJECT}-#{@version}.noarch.rpm" directory.files.create(key: artifact, body: File.open(artifact_path), public: false) if directory.files.head("#{@PROJECT}/#{@PROJECT}-#{@version}.noarch.rpm") "success" else "failure" end end |