Class: DiscourseSubscriptionClient::S3Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/discourse_subscription_client/s3_gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ S3Gem

Returns a new instance of S3Gem.



9
10
11
12
13
14
15
# File 'lib/discourse_subscription_client/s3_gem.rb', line 9

def initialize(opts = {})
  @plugin_name = opts[:plugin_name]
  @access_key_id = opts[:access_key_id]
  @secret_access_key = opts[:secret_access_key]
  @region = opts[:region]
  @bucket = opts[:bucket]
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



7
8
9
# File 'lib/discourse_subscription_client/s3_gem.rb', line 7

def access_key_id
  @access_key_id
end

#bucketObject (readonly)

Returns the value of attribute bucket.



7
8
9
# File 'lib/discourse_subscription_client/s3_gem.rb', line 7

def bucket
  @bucket
end

#plugin_nameObject (readonly)

Returns the value of attribute plugin_name.



7
8
9
# File 'lib/discourse_subscription_client/s3_gem.rb', line 7

def plugin_name
  @plugin_name
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/discourse_subscription_client/s3_gem.rb', line 7

def region
  @region
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



7
8
9
# File 'lib/discourse_subscription_client/s3_gem.rb', line 7

def secret_access_key
  @secret_access_key
end

Instance Method Details

#install(gems) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/discourse_subscription_client/s3_gem.rb', line 21

def install(gems)
  return unless ready?

  write_gemrc

  gems.each do |gem_slug, version|
    klass = gem_slug.to_s.underscore.classify
    gem_name = gem_slug.to_s.dasherize
    opts = { require_name: gem_slug.to_s.gsub(/_/, "/"), config: gemrc_path }
    load(plugin_path, gem_name, version, opts)
  end
ensure
  remove_gemrc
end

#ready?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/discourse_subscription_client/s3_gem.rb', line 17

def ready?
  plugin_name && access_key_id && secret_access_key && region && bucket && can_access_bucket?
end