Class: AssetSync::Config
- Inherits:
-
Object
- Object
- AssetSync::Config
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/asset_sync/config.rb
Defined Under Namespace
Classes: Invalid
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
-
#existing_remote_files ⇒ Object
Returns the value of attribute existing_remote_files.
-
#fog_directory ⇒ Object
Returns the value of attribute fog_directory.
-
#fog_provider ⇒ Object
Returns the value of attribute fog_provider.
-
#fog_region ⇒ Object
Returns the value of attribute fog_region.
-
#rackspace_api_key ⇒ Object
Returns the value of attribute rackspace_api_key.
-
#rackspace_username ⇒ Object
Returns the value of attribute rackspace_username.
Instance Method Summary collapse
- #existing_remote_files? ⇒ Boolean
- #fog_options ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_yml! ⇒ Object
- #yml ⇒ Object
- #yml_exists? ⇒ Boolean
- #yml_path ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 |
# File 'lib/asset_sync/config.rb', line 16 def initialize self.fog_provider = "AWS" self.existing_remote_files = "keep" load_yml! if yml_exists? end |
Instance Attribute Details
#aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
8 9 10 |
# File 'lib/asset_sync/config.rb', line 8 def aws_access_key_id @aws_access_key_id end |
#aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
8 9 10 |
# File 'lib/asset_sync/config.rb', line 8 def aws_secret_access_key @aws_secret_access_key end |
#existing_remote_files ⇒ Object
Returns the value of attribute existing_remote_files.
10 11 12 |
# File 'lib/asset_sync/config.rb', line 10 def existing_remote_files @existing_remote_files end |
#fog_directory ⇒ Object
Returns the value of attribute fog_directory.
7 8 9 |
# File 'lib/asset_sync/config.rb', line 7 def fog_directory @fog_directory end |
#fog_provider ⇒ Object
Returns the value of attribute fog_provider.
7 8 9 |
# File 'lib/asset_sync/config.rb', line 7 def fog_provider @fog_provider end |
#fog_region ⇒ Object
Returns the value of attribute fog_region.
7 8 9 |
# File 'lib/asset_sync/config.rb', line 7 def fog_region @fog_region end |
#rackspace_api_key ⇒ Object
Returns the value of attribute rackspace_api_key.
9 10 11 |
# File 'lib/asset_sync/config.rb', line 9 def rackspace_api_key @rackspace_api_key end |
#rackspace_username ⇒ Object
Returns the value of attribute rackspace_username.
9 10 11 |
# File 'lib/asset_sync/config.rb', line 9 def rackspace_username @rackspace_username end |
Instance Method Details
#existing_remote_files? ⇒ Boolean
22 23 24 |
# File 'lib/asset_sync/config.rb', line 22 def existing_remote_files? (self.existing_remote_files == "keep") end |
#fog_options ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/asset_sync/config.rb', line 49 def if fog_provider == "AWS" = { :provider => fog_provider, :aws_access_key_id => aws_access_key_id, :aws_secret_access_key => aws_secret_access_key, } elsif fog_provider == "Rackspace" = { :provider => fog_provider, :rackspace_username => rackspace_username, :rackspace_api_key => rackspace_api_key } else raise ArgumentError, "Unknown provider: #{fog_provider}" end .merge!({:region => fog_region}) if fog_region return end |
#load_yml! ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/asset_sync/config.rb', line 38 def load_yml! self.fog_provider = yml["fog_provider"] self.fog_directory = yml["fog_directory"] self.fog_region = yml["fog_region"] self.aws_access_key_id = yml["aws_access_key_id"] self.aws_secret_access_key = yml["aws_secret_access_key"] self.rackspace_username = yml["rackspace_username"] self.rackspace_api_key = yml["rackspace_api_key"] self.existing_remote_files = yml["existing_remote_files"] end |
#yml ⇒ Object
30 31 32 |
# File 'lib/asset_sync/config.rb', line 30 def yml y ||= YAML.load(ERB.new(IO.read(yml_path)).result)[Rails.env] rescue nil || {} end |
#yml_exists? ⇒ Boolean
26 27 28 |
# File 'lib/asset_sync/config.rb', line 26 def yml_exists? File.exists?(self.yml_path) end |
#yml_path ⇒ Object
34 35 36 |
# File 'lib/asset_sync/config.rb', line 34 def yml_path File.join(Rails.root, "config/asset_sync.yml") end |