-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample-rakefile
More file actions
55 lines (40 loc) · 1.62 KB
/
sample-rakefile
File metadata and controls
55 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'based'
require 'synqa'
require 'digest/sha2'
STDOUT.sync = true
include Synqa
BASE_DIR = File.dirname(__FILE__)
SRC_DIR = File.join(BASE_DIR, "src")
UPLOAD_DIR = Based::BaseDirectory.new(SRC_DIR,
:fileExclude => lambda{|file| file.name.end_with?("~")})
SYNQA_DIR = File.join(BASE_DIR, "output", "synqa")
task :default => [:uploaddry] do |t|
end
REMOTE_HOST = SshContentHost.new("yourusername@yourhostname.example.com",
Sha256Command.new())
REMOTE_SITE = RemoteContentLocation.new(REMOTE_HOST,
"/home/username/public",
File.join(SYNQA_DIR, "nearlyContent.txt"))
LOCAL_SITE = LocalContentLocation.new(UPLOAD_DIR,
Digest::SHA256,
File.join(SYNQA_DIR, "localContent.txt"))
# Ensure that directory for cached content files exists
task :init do |t|
ensureDirectoryExists(SYNQA_DIR)
end
# Delete the cached content files
task :clean => [:init] do |t|
SyncOperation.new(LOCAL_SITE, REMOTE_SITE).clearCachedContentFiles()
end
# List the files and directories in the remote directory
task :list do |t|
REMOTE_SITE.listFiles()
end
# Dry run for uploading (i.e. syncing) files to remote site
task :uploaddry => [:init] do |t|
SyncOperation.new(LOCAL_SITE, REMOTE_SITE).doSync(:dryRun => true)
end
# Upload (i.e. sync) files to remote site
task :upload => [:init] do |t|
SyncOperation.new(LOCAL_SITE, REMOTE_SITE).doSync()
end