Class: CloudStorageSync::Config
- Inherits:
-
Object
- Object
- CloudStorageSync::Config
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/cloud-storage-sync/config.rb
Defined Under Namespace
Classes: Invalid
Constant Summary collapse
- DYNAMIC_SERVICES =
[:provider, :google_storage_secret_access_key, :google_storage_access_key_id, :aws_secret_access_key, :aws_access_key_id, :rackspace_username, :rackspace_api_key, :rackspace_european_cloud, :rackspace_auth_url, :rackspace_servicenet, :rackspace_cdn_ssl, :ninefold_storage_token,:ninefold_storage_secret, :endpoint, :region, :host, :path, :port, :scheme, :persistent]
Instance Attribute Summary collapse
-
#assets_directory ⇒ Object
Returns the value of attribute assets_directory.
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#force_deletion_sync ⇒ Object
Returns the value of attribute force_deletion_sync.
-
#provider ⇒ Object
Returns the value of attribute provider.
Instance Method Summary collapse
- #force_deletion_sync? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #initializer_exists? ⇒ Boolean
- #options ⇒ Object
- #requires(*attrs) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19 20 21 22 |
# File 'lib/cloud-storage-sync/config.rb', line 19 def initialize self.force_deletion_sync = false self.credentials = {} end |
Instance Attribute Details
#assets_directory ⇒ Object
Returns the value of attribute assets_directory.
14 15 16 |
# File 'lib/cloud-storage-sync/config.rb', line 14 def assets_directory @assets_directory end |
#config_path ⇒ Object
Returns the value of attribute config_path.
14 15 16 |
# File 'lib/cloud-storage-sync/config.rb', line 14 def config_path @config_path end |
#credentials ⇒ Object
Returns the value of attribute credentials.
14 15 16 |
# File 'lib/cloud-storage-sync/config.rb', line 14 def credentials @credentials end |
#force_deletion_sync ⇒ Object
Returns the value of attribute force_deletion_sync.
14 15 16 |
# File 'lib/cloud-storage-sync/config.rb', line 14 def force_deletion_sync @force_deletion_sync end |
#provider ⇒ Object
Returns the value of attribute provider.
14 15 16 |
# File 'lib/cloud-storage-sync/config.rb', line 14 def provider @provider end |
Instance Method Details
#force_deletion_sync? ⇒ Boolean
24 25 26 |
# File 'lib/cloud-storage-sync/config.rb', line 24 def force_deletion_sync? self.force_deletion_sync == true end |
#initializer_exists? ⇒ Boolean
28 29 30 31 |
# File 'lib/cloud-storage-sync/config.rb', line 28 def initializer_exists? path = File.join(config_path, "initializers", "cloud_storage_sync.rb") File.exists? path end |
#options ⇒ Object
54 55 56 |
# File 'lib/cloud-storage-sync/config.rb', line 54 def { :assets_directory => assets_directory, :force_deletion_sync => force_deletion_sync } end |
#requires(*attrs) ⇒ Object
48 49 50 51 52 |
# File 'lib/cloud-storage-sync/config.rb', line 48 def requires(*attrs) attrs.each do |key| raise ArgumentError.new("#{provider.capitalize} requires #{attrs.join(', ')} in configuration files") if self.send(key).nil? end end |
#validate ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cloud-storage-sync/config.rb', line 33 def validate case provider when "aws" requires :aws_access_key_id, :aws_secret_access_key when "rackspace" requires :rackspace_api_key, :rackspace_username when "google" requires :google_storage_access_key_id, :google_storage_secret_access_key when "ninefold" requires :ninefold_storage_token, :ninefold_storage_secret else raise ArgumentError.new("#{provider} is not a recognized storage provider") end end |