cloudify 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,11 +15,12 @@ module Cloudify
15
15
  end
16
16
 
17
17
  def sync
18
- config.validate
19
18
  if config && config.valid?
20
19
  storage.sync
20
+ elsif config && !config.valid?
21
+ STDERR.puts "Cloudify: #{config.errors.full_messages.join(', ')}"
21
22
  else
22
- "Cloudify: Something went wrong"
23
+ "Cloudify: Something went wrong."
23
24
  end
24
25
  end
25
26
  end
@@ -8,8 +8,7 @@ module Cloudify
8
8
  :rackspace_auth_url, :rackspace_servicenet, :rackspace_cdn_ssl,
9
9
  :ninefold_storage_token,:ninefold_storage_secret,
10
10
  :endpoint, :region, :host, :path, :port, :scheme, :persistent]
11
-
12
- class Invalid < StandardError; end
11
+ PROVIDERS = ["aws", "google", "rackspace", "ninefold"]
13
12
 
14
13
  attr_accessor :provider, :force_deletion_sync, :credentials, :assets_directory, :config_path
15
14
 
@@ -18,6 +17,7 @@ module Cloudify
18
17
  validates_presence_of :aws_access_key_id, :aws_secret_access_key, :if => Proc.new { |con| con.provider == "aws" }
19
18
  validates_presence_of :rackspace_api_key, :rackspace_username, :if => Proc.new { |con| con.provider == "rackspace" }
20
19
  validates_presence_of :ninefold_storage_token, :ninefold_storage_secret, :if => Proc.new { |con| con.provider == "ninefold" }
20
+ validates_inclusion_of :provider, :in => PROVIDERS, :message => "%{value} is not supported."
21
21
  validates_inclusion_of :force_deletion_sync, :in => [true, false]
22
22
 
23
23
  def initialize
@@ -33,18 +33,6 @@ module Cloudify
33
33
  path = File.join(config_path, "initializers", "cloud_storage_sync.rb")
34
34
  File.exists? path
35
35
  end
36
-
37
- def validate
38
- unless ["aws", "google", "rackspace", "ninefold"].include?(provider)
39
- raise ArgumentError.new("#{provider} is not a recognized storage provider")
40
- end
41
- end
42
-
43
- def requires(*attrs)
44
- attrs.each do |key|
45
- raise ArgumentError.new("#{provider.capitalize} requires #{attrs.join(', ')} in configuration files") if self.send(key).nil?
46
- end
47
- end
48
36
 
49
37
  def options
50
38
  { :assets_directory => assets_directory, :force_deletion_sync => force_deletion_sync }
@@ -1,3 +1,3 @@
1
1
  module Cloudify
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  Rake::Task["cloud_storage_sync:sync"].enhance do
2
- CloudStorageSync.sync
2
+ Cloudify.sync
3
3
  end
@@ -18,6 +18,7 @@ describe Cloudify do
18
18
  it "should not be valid when google" do
19
19
  @config.provider = "google"
20
20
  @config.should_not be_valid
21
+ @config.errors[:provider].should be_empty
21
22
  @config.errors[:google_storage_access_key_id].should_not be_empty
22
23
  @config.errors[:google_storage_secret_access_key].should_not be_empty
23
24
  end
@@ -25,6 +26,7 @@ describe Cloudify do
25
26
  it "should not be valid when aws" do
26
27
  @config.provider = "aws"
27
28
  @config.should_not be_valid
29
+ @config.errors[:provider].should be_empty
28
30
  @config.errors[:aws_secret_access_key].should_not be_empty
29
31
  @config.errors[:aws_access_key_id].should_not be_empty
30
32
  end
@@ -32,6 +34,7 @@ describe Cloudify do
32
34
  it "should not be valid when rackspace" do
33
35
  @config.provider = "rackspace"
34
36
  @config.should_not be_valid
37
+ @config.errors[:provider].should be_empty
35
38
  @config.errors[:rackspace_username].should_not be_empty
36
39
  @config.errors[:rackspace_api_key].should_not be_empty
37
40
  end
@@ -39,9 +42,21 @@ describe Cloudify do
39
42
  it "should not be valid when ninefold" do
40
43
  @config.provider = "ninefold"
41
44
  @config.should_not be_valid
45
+ @config.errors[:provider].should be_empty
42
46
  @config.errors[:ninefold_storage_token].should_not be_empty
43
47
  @config.errors[:ninefold_storage_secret].should_not be_empty
44
48
  end
49
+
50
+ it "should not be valid with wrong provider" do
51
+ @config.provider = "donotexist"
52
+ @config.should_not be_valid
53
+ @config.errors[:provider].should_not be_empty
54
+ end
55
+
56
+ it "should not be valid without assets_directory" do
57
+ @config.should_not be_valid
58
+ @config.errors[:assets_directory].should_not be_empty
59
+ end
45
60
  end
46
61
  end
47
62
  end
@@ -10,7 +10,7 @@
10
10
  # google_storage_access_key_id: GOOGLE_STORAGE_ACCESS_KEY_ID
11
11
  # google_storage_secret_access_key: GOOGLE_STORAGE_SECRET_ACCESS_KEY
12
12
 
13
- ## CloudStorageSync supports the following providers: aws, google, ninefold and rackspace
13
+ ## Cloudify supports the following providers: aws, google, ninefold and rackspace
14
14
  ## For more information on which parameters are required for each provider, visit http://fog.io/1.0.0/storage/
15
15
 
16
16
  defaults: &defaults
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-11-11 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec-rails
18
- requirement: &2152934620 !ruby/object:Gem::Requirement
18
+ requirement: &2153041920 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - =
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 2.7.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *2152934620
26
+ version_requirements: *2153041920
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mocha
29
- requirement: &2152934020 !ruby/object:Gem::Requirement
29
+ requirement: &2153041260 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - =
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.10.0
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *2152934020
37
+ version_requirements: *2153041260
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: ruby-debug19
40
- requirement: &2152926500 !ruby/object:Gem::Requirement
40
+ requirement: &2153040740 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2152926500
48
+ version_requirements: *2153040740
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: fog
51
- requirement: &2152925700 !ruby/object:Gem::Requirement
51
+ requirement: &2153039960 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - =
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: 1.0.0
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2152925700
59
+ version_requirements: *2153039960
60
60
  description: Sync your assets hosts to Amazon, Google & Rackspace services
61
61
  email:
62
62
  - amed@tractical.com
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  segments:
105
105
  - 0
106
- hash: 2432946652788188517
106
+ hash: -91208309299467127
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: 2432946652788188517
115
+ hash: -91208309299467127
116
116
  requirements: []
117
117
  rubyforge_project: cloudify
118
118
  rubygems_version: 1.8.10