cloudify 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +18 -1
- data/lib/cloudify/storage.rb +7 -6
- data/lib/cloudify/version.rb +1 -1
- data/spec/cloudify_spec.rb +14 -0
- data/test/install_generator_test.rb +4 -3
- data/test/test_helper.rb +2 -3
- metadata +12 -12
data/Rakefile
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'rspec/core/rake_task'
|
1
3
|
# Use Rakefile for tasks that operate on the plugin’s source files, such as special testing or documentation.
|
2
4
|
# These must be run from the plugin’s directory.
|
3
5
|
|
4
6
|
# rakes = Dir["#{File.dirname(__FILE__)}/lib/tasks/*.rake"]
|
5
7
|
# rakes.sort.each { |ext| load ext; puts ext }
|
6
|
-
Bundler::GemHelper.install_tasks
|
8
|
+
Bundler::GemHelper.install_tasks
|
9
|
+
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc 'Run ALL OF the specs'
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
14
|
+
|
15
|
+
desc "Run Cloudify generator tests."
|
16
|
+
Rake::TestTask.new(:test_unit)do |t|
|
17
|
+
t.libs << 'lib'
|
18
|
+
t.libs << 'test'
|
19
|
+
t.pattern = 'test/**/*_test.rb'
|
20
|
+
t.verbose = true
|
21
|
+
end
|
22
|
+
|
23
|
+
task :test => [ :test_unit, :spec ]
|
data/lib/cloudify/storage.rb
CHANGED
@@ -25,14 +25,17 @@ module Cloudify
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def local_files
|
28
|
-
@local_files ||= Dir.glob("#{Rails.root.to_s}/public/**/*").map do |f|
|
29
|
-
|
30
|
-
Digest::MD5.hexdigest(File.read(f))
|
28
|
+
@local_files ||= Dir.glob("#{Rails.root.to_s}/public/**/*").map do |f|
|
29
|
+
Digest::MD5.hexdigest(File.read(f)) unless File.directory?(f)
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
33
|
def remote_files
|
35
|
-
@remote_files ||= bucket.files.map{ |f| f.etag }
|
34
|
+
@remote_files ||= bucket.files.reload.map{ |f| f.etag }
|
35
|
+
end
|
36
|
+
|
37
|
+
def files_to_delete
|
38
|
+
@files_to_delete ||= (local_files | remote_files) - (local_files & remote_files)
|
36
39
|
end
|
37
40
|
|
38
41
|
def upload_new_and_changed_files
|
@@ -53,7 +56,6 @@ module Cloudify
|
|
53
56
|
|
54
57
|
def delete_unsynced_remote_files
|
55
58
|
STDERR.puts "Deleting remote files that no longer exist locally"
|
56
|
-
files_to_delete = (local_files | remote_files) - (local_files & remote_files)
|
57
59
|
bucket.files.each do |f|
|
58
60
|
if files_to_delete.include?(f.etag)
|
59
61
|
STDERR.puts "D #{f.key}"
|
@@ -67,6 +69,5 @@ module Cloudify
|
|
67
69
|
delete_unsynced_remote_files if options[:force_deletion_sync] == true
|
68
70
|
STDERR.puts "Done"
|
69
71
|
end
|
70
|
-
|
71
72
|
end
|
72
73
|
end
|
data/lib/cloudify/version.rb
CHANGED
data/spec/cloudify_spec.rb
CHANGED
@@ -178,6 +178,20 @@ describe Cloudify::Storage do
|
|
178
178
|
@storage = Cloudify::Storage.new(@config.credentials, @config.options)
|
179
179
|
end
|
180
180
|
|
181
|
+
it "Uploads a collection of files for the 1st time and doesn't delete them" do
|
182
|
+
this_file = File.read(__FILE__)
|
183
|
+
this_file_digest = Digest::MD5.hexdigest(this_file)
|
184
|
+
this_file_path = __FILE__
|
185
|
+
files = @storage.stub(:local_files).and_return([YML_DIGEST, this_file_digest])
|
186
|
+
Dir.stub(:glob).and_return([YML_FILE_PATH, this_file_path])
|
187
|
+
@storage.local_files.length.should == 2
|
188
|
+
@storage.options[:force_deletion_sync] = true
|
189
|
+
Fog::Storage::AWS::File.any_instance.stub(:etag).and_return(YML_DIGEST)
|
190
|
+
@storage.sync
|
191
|
+
@storage.bucket.files.reload.length.should == 2
|
192
|
+
@storage.bucket.files.each { |k| k.destroy }
|
193
|
+
end
|
194
|
+
|
181
195
|
it "Uploads a new file and then deletes it" do
|
182
196
|
@storage.stub(:local_files).and_return([YML_DIGEST])
|
183
197
|
Dir.stub(:glob).and_return([YML_FILE_PATH])
|
@@ -1,13 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class InstallGeneratorTest < Rails::Generators::TestCase
|
4
4
|
tests Cloudify::InstallGenerator
|
5
|
-
destination File.expand_path("
|
5
|
+
destination File.expand_path("../../tmp", File.dirname(__FILE__))
|
6
6
|
setup :prepare_destination
|
7
7
|
setup :run_generator
|
8
8
|
|
9
9
|
test "Assert all files are properly created" do
|
10
|
-
|
10
|
+
run_generator
|
11
|
+
assert_file "config/initializers/cloudify.rb"
|
11
12
|
end
|
12
13
|
|
13
14
|
end
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-11-
|
14
|
+
date: 2011-11-25 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec-rails
|
18
|
-
requirement: &
|
18
|
+
requirement: &2152530880 !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: *
|
26
|
+
version_requirements: *2152530880
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
|
-
requirement: &
|
29
|
+
requirement: &2156896000 !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: *
|
37
|
+
version_requirements: *2156896000
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: ruby-debug19
|
40
|
-
requirement: &
|
40
|
+
requirement: &2156976420 !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: *
|
48
|
+
version_requirements: *2156976420
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: fog
|
51
|
-
requirement: &
|
51
|
+
requirement: &2157044560 !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: *
|
59
|
+
version_requirements: *2157044560
|
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:
|
106
|
+
hash: 1107229434259926300
|
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:
|
115
|
+
hash: 1107229434259926300
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project: cloudify
|
118
118
|
rubygems_version: 1.8.10
|