cynq 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/cynq/command.rb +30 -17
- data/lib/cynq/directory.rb +7 -3
- data/lib/cynq/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -48,7 +48,7 @@ remotes:
|
|
48
48
|
```
|
49
49
|
|
50
50
|
This would instruct cynq to upload the contents of the ```build``` directory.
|
51
|
-
The ```build``` directory itself is not uploaded, making your ```index.
|
51
|
+
The ```build``` directory itself is not uploaded, making your ```index.html```
|
52
52
|
file at the 'top-level' of your bucket.
|
53
53
|
|
54
54
|
You also need AWS key information in your environment. Make sure to do something
|
data/lib/cynq/command.rb
CHANGED
@@ -9,6 +9,10 @@ module Cynq
|
|
9
9
|
desc "deploy REMOTE", "Upload files to REMOTE"
|
10
10
|
method_option :dry_run, :type => :boolean, :aliases => "-n",
|
11
11
|
:default => false, :desc => 'Do not do anything.'
|
12
|
+
|
13
|
+
attr_reader :local_dir, :remote_dir
|
14
|
+
|
15
|
+
|
12
16
|
def deploy(remote)
|
13
17
|
load_config(remote)
|
14
18
|
|
@@ -16,24 +20,22 @@ module Cynq
|
|
16
20
|
puts " Dry run executing...".green
|
17
21
|
end
|
18
22
|
|
19
|
-
|
20
|
-
remote = Remote.new(@remote['directory'])
|
23
|
+
establish_roots
|
21
24
|
|
22
|
-
|
23
|
-
p remote
|
24
|
-
|
25
|
-
keys = (local.keys + remote.keys).sort
|
26
|
-
keys.each do |key|
|
25
|
+
all_keys.each do |key|
|
27
26
|
case
|
28
|
-
when
|
27
|
+
when local_dir.missing?(key)
|
29
28
|
puts " deleting #{key}".red
|
30
|
-
|
31
|
-
when
|
32
|
-
puts " adding #{key}".green
|
33
|
-
|
34
|
-
when
|
29
|
+
remote_dir.delete(key) unless options.dry_run?
|
30
|
+
when remote_dir.missing?(key)
|
31
|
+
puts " adding #{key} #{local_dir[key].content_type}".green
|
32
|
+
remote_dir << local_dir[key] unless options.dry_run?
|
33
|
+
when remote_dir.modified?(local_dir[key])
|
35
34
|
puts " modified #{key}".magenta
|
36
|
-
|
35
|
+
remote_dir << local_dir[key] unless options.dry_run?
|
36
|
+
when !remote_dir.meta_equal?(local_dir[key])
|
37
|
+
puts " meta #{key} #{local_dir[key].content_type}".white.on_magenta
|
38
|
+
remote_dir << local_dir[key] unless options.dry_run?
|
37
39
|
else
|
38
40
|
puts " unchanged #{key}" unless options.dry_run?
|
39
41
|
end
|
@@ -41,9 +43,20 @@ module Cynq
|
|
41
43
|
end
|
42
44
|
|
43
45
|
no_tasks do
|
46
|
+
|
47
|
+
def establish_roots
|
48
|
+
p (@local_dir = Local.new(@local_root))
|
49
|
+
p (@remote_dir = Remote.new(@remote_root['directory']))
|
50
|
+
end
|
51
|
+
|
52
|
+
def all_keys
|
53
|
+
(local_dir.keys + remote_dir.keys).sort
|
54
|
+
end
|
55
|
+
|
56
|
+
|
44
57
|
def load_config(remote)
|
45
58
|
conf_file = File.expand_path('cynq.yml')
|
46
|
-
|
59
|
+
|
47
60
|
unless File.exist?(conf_file)
|
48
61
|
$stderr.puts "Missing configuration file at #{conf_file}"
|
49
62
|
raise "Configuration not found"
|
@@ -57,8 +70,8 @@ module Cynq
|
|
57
70
|
raise "Configuration is invalid"
|
58
71
|
end
|
59
72
|
|
60
|
-
@
|
61
|
-
unless @
|
73
|
+
@remote_root = @config['remotes'][remote]
|
74
|
+
unless @remote_root
|
62
75
|
$stderr.puts("No environment matching '#{remote}' can be found.")
|
63
76
|
raise "Configuration is invalid"
|
64
77
|
end
|
data/lib/cynq/directory.rb
CHANGED
@@ -31,9 +31,9 @@ module Cynq
|
|
31
31
|
:key => other_file.key,
|
32
32
|
:body => other_file.body
|
33
33
|
})
|
34
|
-
ct = content_type_for_key(other_file.key)
|
35
|
-
file.content_type = ct if ct
|
36
34
|
end
|
35
|
+
ct = content_type_for_key(other_file.key)
|
36
|
+
file.content_type = ct if ct
|
37
37
|
file.public = true
|
38
38
|
file.save
|
39
39
|
end
|
@@ -48,6 +48,10 @@ module Cynq
|
|
48
48
|
other_file.etag != self[other_file.key].etag
|
49
49
|
end
|
50
50
|
|
51
|
+
def meta_equal?(other_file)
|
52
|
+
self[other_file.key].content_type == other_file.content_type
|
53
|
+
end
|
54
|
+
|
51
55
|
def inspect
|
52
56
|
"#{self.class.name}: #{@bucket.key} (#{keys.size} files, #{size} bytes)"
|
53
57
|
end
|
@@ -69,7 +73,7 @@ module Cynq
|
|
69
73
|
|
70
74
|
def read_current_files
|
71
75
|
@current_files = @bucket.files.inject({}) do |hsh, file|
|
72
|
-
hsh[file.key] = file
|
76
|
+
hsh[file.key] = @bucket.files.head(file.key)
|
73
77
|
hsh
|
74
78
|
end
|
75
79
|
@keys = Set.new(@current_files.keys)
|
data/lib/cynq/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cynq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &70197370073900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70197370073900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &70197370073400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70197370073400
|
36
36
|
description: Easy synchronization of local files to cloud based storage.
|
37
37
|
email:
|
38
38
|
- dboyd@realgravity.com
|