Another li'l round of touchups

main
Dan Buch 8 years ago
parent 4d33de8154
commit 5e95ecd3f5
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC

@ -1,16 +1,7 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-08-30 10:56:44 -0400 using RuboCop version 0.42.0.
# on 2016-08-30 11:24:51 -0400 using RuboCop version 0.42.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Metrics/AbcSize:
Max: 17
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 14

@ -0,0 +1,2 @@
language: ruby
script: bundle exec rubocop

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 Dan Buch
Copyright © 2016 Dan Buch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

@ -1,12 +1,19 @@
require 'aws-sdk'
def main
bucket = ENV.fetch('CPI_FEED_AWS_BUCKET')
key = ARGV.first || ENV.fetch('CPI_FEED_AWS_KEY')
class MiniS3put
def initialize(key: nil, instream: $stdin)
@bucket = ENV.fetch('CPI_FEED_AWS_BUCKET')
@key = key || ENV.fetch('CPI_FEED_AWS_KEY')
@instream = instream
end
def put
Aws::S3::Resource.new.bucket(bucket).object(key).put(
body: instream.read
).on_success(&method(:on_put_success))
end
Aws::S3::Resource.new.bucket(bucket).object(key).put(
body: $stdin.read
).on_success do |response|
def on_put_success(response)
puts response.data
Aws::S3::Client.new.put_object_acl(
@ -15,10 +22,12 @@ def main
puts acl_response.data
end
return 0
0
end
1
private
attr_reader :bucket, :key, :instream
end
exit(main) if $PROGRAM_NAME == __FILE__
exit(MiniS3put.new(ARGV.first).put) if $PROGRAM_NAME == __FILE__

Loading…
Cancel
Save