Class: S3Wrapper::Profile
- Inherits:
-
Object
- Object
- S3Wrapper::Profile
- Defined in:
- lib/s3-wrapper/profile.rb
Constant Summary collapse
- CONFIG_FILE =
'.s3-wrapper.rc'
Instance Attribute Summary collapse
-
#aws_access_key ⇒ Object
Returns the value of attribute aws_access_key.
-
#aws_secret_key ⇒ Object
Returns the value of attribute aws_secret_key.
-
#bucket_name ⇒ Object
Returns the value of attribute bucket_name.
-
#host_name ⇒ Object
Returns the value of attribute host_name.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .config_default(params) ⇒ Object
- .create(name, params) ⇒ Object
- .delete(name) ⇒ Object
- .get(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(name, params = {}) ⇒ Profile
constructor
A new instance of Profile.
- #to_hash ⇒ Object
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_key ⇒ Object
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_key ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
Returns the value of attribute host_name.
5 6 7 |
# File 'lib/s3-wrapper/profile.rb', line 5 def host_name @host_name end |
#name ⇒ Object
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 |
Instance Method Details
#to_hash ⇒ Object
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 |