Class: Bukelatta::Exporter
- Inherits:
-
Object
- Object
- Bukelatta::Exporter
- Includes:
- Utils::Helper
- Defined in:
- lib/bukelatta/exporter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
- #export_bucket_policy(bucket) ⇒ Object
- #export_buckets ⇒ Object
-
#initialize(client, options = {}) ⇒ Exporter
constructor
A new instance of Exporter.
Methods included from Utils::Helper
Constructor Details
#initialize(client, options = {}) ⇒ Exporter
8 9 10 11 12 |
# File 'lib/bukelatta/exporter.rb', line 8 def initialize(client, = {}) @client = client = @resource = Aws::S3::Resource.new(client: @client) end |
Class Method Details
.export(client, options = {}) ⇒ Object
4 5 6 |
# File 'lib/bukelatta/exporter.rb', line 4 def self.export(client, = {}) self.new(client, ).export end |
Instance Method Details
#export ⇒ Object
14 15 16 |
# File 'lib/bukelatta/exporter.rb', line 14 def export export_buckets end |
#export_bucket_policy(bucket) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/bukelatta/exporter.rb', line 33 def export_bucket_policy(bucket) bucket.auto_redirect do |b| JSON.parse(b.policy.policy.string) end rescue Aws::S3::Errors::NoSuchBucketPolicy nil end |
#export_buckets ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bukelatta/exporter.rb', line 18 def export_buckets result = {} buckets = @resource.buckets concurrency = [:request_concurrency] Parallel.each(buckets, in_threads: concurrency) do |bucket| next unless matched?(bucket.name) policy = export_bucket_policy(bucket) result[bucket.name] = policy end result.sort_array! end |