Class: S3Wrapper::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/s3-wrapper/profile.rb

Constant Summary collapse

CONFIG_FILE =
'.s3-wrapper.rc'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = {}) ⇒ Profile

Returns a new instance of Profile.



32
33
34
35
36
37
# File 'lib/s3-wrapper/profile.rb', line 32

def initialize(name, params = {})
  self.name = name
  params.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#aws_access_keyObject

Returns the value of attribute aws_access_key.



5
6
7
# File 'lib/s3-wrapper/profile.rb', line 5

def aws_access_key
  @aws_access_key
end

#aws_secret_keyObject

Returns the value of attribute aws_secret_key.



5
6
7
# File 'lib/s3-wrapper/profile.rb', line 5

def aws_secret_key
  @aws_secret_key
end

#bucket_nameObject

Returns the value of attribute bucket_name.



5
6
7
# File 'lib/s3-wrapper/profile.rb', line 5

def bucket_name
  @bucket_name
end

#host_nameObject

Returns the value of attribute host_name.



5
6
7
# File 'lib/s3-wrapper/profile.rb', line 5

def host_name
  @host_name
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/s3-wrapper/profile.rb', line 5

def name
  @name
end

Class Method Details

.config_default(params) ⇒ Object



8
9
10
# File 'lib/s3-wrapper/profile.rb', line 8

def self.config_default(params)
  self::create('default', params)
end

.create(name, params) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/s3-wrapper/profile.rb', line 12

def self.create(name, params)
  config = read_config(name, false)
  params.each do |key, value|
    config[name][key] = value
  end
  self::write_config(config)
  S3Wrapper::Profile.new(name, config[name])
end

.delete(name) ⇒ Object



21
22
23
24
25
# File 'lib/s3-wrapper/profile.rb', line 21

def self.delete(name)
  config = read_config(name, false)
  config.delete(name)
  self::write_config(config)
end

.get(name) ⇒ Object



27
28
29
30
# File 'lib/s3-wrapper/profile.rb', line 27

def self.get(name)
  config = read_config(name, true)
  S3Wrapper::Profile.new(name, config[name])
end

Instance Method Details

#to_hashObject



39
40
41
42
43
# File 'lib/s3-wrapper/profile.rb', line 39

def to_hash
  Hash[*instance_variables.map { |v|
    [v.to_sym, instance_variable_get(v)]
  }.flatten]
end