static_sync 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -5
- data/lib/static_sync/config.rb +5 -0
- data/lib/static_sync/storage.rb +12 -1
- data/lib/static_sync/version.rb +1 -1
- data/spec/storage_spec.rb +22 -0
- metadata +2 -3
data/README.md
CHANGED
@@ -28,13 +28,17 @@ In your project directory create a `.static` file:
|
|
28
28
|
```
|
29
29
|
> cat .static
|
30
30
|
|
31
|
-
#
|
31
|
+
# What to upload
|
32
32
|
local:
|
33
33
|
directory: build
|
34
34
|
|
35
|
-
#
|
35
|
+
# What not to upload (ruby regular expression).
|
36
|
+
ignored: (psd,gz)$
|
37
|
+
|
38
|
+
# Where to upload
|
36
39
|
remote:
|
37
40
|
provider: AWS
|
41
|
+
region: ap-southeast-2
|
38
42
|
username: my-aws-key
|
39
43
|
password: my-aws-secret
|
40
44
|
directory: my-aws-bucket
|
@@ -45,9 +49,6 @@ cache:
|
|
45
49
|
javascript: 31536000
|
46
50
|
css: 31536000
|
47
51
|
image: 31536000
|
48
|
-
|
49
|
-
# Flag to enable / disable automatic gzip compression.
|
50
|
-
gzip: true
|
51
52
|
```
|
52
53
|
|
53
54
|
And simply run the following command any time you want to upload.
|
data/lib/static_sync/config.rb
CHANGED
@@ -21,6 +21,7 @@ module StaticSync
|
|
21
21
|
|
22
22
|
def storage
|
23
23
|
Fog::Storage.new({
|
24
|
+
:persistent => true,
|
24
25
|
:provider => self.remote['provider'],
|
25
26
|
:region => self.remote['region'],
|
26
27
|
:aws_access_key_id => self.remote['username'],
|
@@ -36,6 +37,10 @@ module StaticSync
|
|
36
37
|
self.fetch('gzip', true)
|
37
38
|
end
|
38
39
|
|
40
|
+
def ignored
|
41
|
+
self['ignored']
|
42
|
+
end
|
43
|
+
|
39
44
|
def load(path = '.static')
|
40
45
|
content = '{}'
|
41
46
|
begin
|
data/lib/static_sync/storage.rb
CHANGED
@@ -12,12 +12,13 @@ module StaticSync
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def sync
|
15
|
+
verify_remote_directory
|
15
16
|
remote_keys = []
|
16
17
|
remote_directory.files.each do |file|
|
17
18
|
remote_keys << [file.key, file.etag]
|
18
19
|
end
|
19
20
|
Dir.chdir(@config.source) do
|
20
|
-
|
21
|
+
local_filtered_files.each do |file|
|
21
22
|
current_file = @meta.for(file)
|
22
23
|
current_file_key = [current_file[:key], current_file[:etag]]
|
23
24
|
|
@@ -36,6 +37,12 @@ module StaticSync
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
40
|
+
def local_filtered_files
|
41
|
+
local_files.reject do |file|
|
42
|
+
file =~ Regexp.new(@config.ignored) if @config.ignored
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
39
46
|
def local_files
|
40
47
|
Dir.glob("**/*.*").reject do |file|
|
41
48
|
File.directory?(file)
|
@@ -46,6 +53,10 @@ module StaticSync
|
|
46
53
|
@config.storage.directories.new(:key => @config.storage_directory)
|
47
54
|
end
|
48
55
|
|
56
|
+
def verify_remote_directory
|
57
|
+
@config.storage.get_bucket(@config.storage_directory)
|
58
|
+
end
|
59
|
+
|
49
60
|
def log
|
50
61
|
@log ||= begin
|
51
62
|
logger = Logger.new(STDOUT)
|
data/lib/static_sync/version.rb
CHANGED
data/spec/storage_spec.rb
CHANGED
@@ -58,5 +58,27 @@ describe StaticSync::Storage do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
context "synching ignored files" do
|
62
|
+
|
63
|
+
describe "#sync" do
|
64
|
+
|
65
|
+
before do
|
66
|
+
config.merge!(
|
67
|
+
'ignored' => '(css|gif)$'
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "does not upload them" do
|
72
|
+
subject.sync
|
73
|
+
|
74
|
+
config.storage.directories.get(config.storage_directory).files.map(&:key).should == [
|
75
|
+
"assets/javascripts/jquery.min.js",
|
76
|
+
"cat.com/index.html",
|
77
|
+
"index.html"
|
78
|
+
]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
61
83
|
end
|
62
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -104,4 +104,3 @@ test_files:
|
|
104
104
|
- spec/meta/compression_spec.rb
|
105
105
|
- spec/meta_spec.rb
|
106
106
|
- spec/storage_spec.rb
|
107
|
-
has_rdoc: false
|