Class: S3Secure::Summary::Items

Inherits:
CLI::Base show all
Extended by:
Memoist
Defined in:
lib/s3_secure/summary/items.rb

Instance Method Summary collapse

Methods inherited from CLI::Base

#buckets

Methods included from CLI::Say

#say

Methods included from AwsServices

#sts

Methods included from AwsServices::S3

#check_bucket!, #new_s3_regional_client, #region, #region_map, #s3, #s3_client, #s3_regional_client

Constructor Details

#initialize(options, buckets) ⇒ Items

override initialize



6
7
8
9
# File 'lib/s3_secure/summary/items.rb', line 6

def initialize(options, buckets)
  @options, @buckets = options, buckets
  @ssl, @encrypted = @options[:ssl], @options[:encrypted]
end

Instance Method Details

#all_itemsObject

Triggers loading of items



32
33
34
# File 'lib/s3_secure/summary/items.rb', line 32

def all_items
  load_items!
end

#filtered_itemsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/s3_secure/summary/items.rb', line 11

def filtered_items
  items = all_items.select do |item|
    case @ssl
    when "yes", "no"
      @ssl == item.ssl
    else # any or fallback
      true
    end
  end

  items.select do |item|
    case @encrypted
    when "yes", "no"
      @encrypted == item.encrypted
    else # any or fallback
      true
    end
  end
end

#load_items!Object



36
37
38
39
40
41
42
# File 'lib/s3_secure/summary/items.rb', line 36

def load_items!
  @buckets.map do |bucket|
    Item.new(bucket,
             ssl: ssl?(bucket) ? "yes" : "no",
             encrypted: encrypted?(bucket) ? "yes" : "no")
  end
end