Class: RubySlime::Rake::DevelopmentSync

Inherits:
Object
  • Object
show all
Includes:
Context
Defined in:
lib/ruby_slime/rake/development_sync.rb

Instance Method Summary collapse

Methods included from Context

#initialize_context

Constructor Details

#initialize(rake_context:, path_prefix: '', path_namespace:, rclone_conf: 'sync.rclone.conf', rclone_remote: 'sync', process_paths: lambda(&:itself), chdir: nil) ⇒ DevelopmentSync

Returns a new instance of DevelopmentSync.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruby_slime/rake/development_sync.rb', line 8

def initialize(
  rake_context:,
  path_prefix: '',
  path_namespace:,
  rclone_conf: 'sync.rclone.conf',
  rclone_remote: 'sync',
  process_paths: lambda(&:itself),
  chdir: nil
)
  initialize_context(rake_context)
  @rclone_conf = rclone_conf
  @rclone_remote = rclone_remote
  @path_namespace = [path_prefix, path_namespace].select(&:present?).then do |path_sections|
    ::File.join(*path_sections)
  end
  @check_rclone_conf = lambda do
    ::File.expand_path(@rclone_conf).tap do |full_path|
      raise "\"#{@rclone_conf}\" not found!" unless ::File.file?(full_path)
    end
  end
  @process_paths = process_paths
  @chdir = chdir
end

Instance Method Details

#declareObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ruby_slime/rake/development_sync.rb', line 32

def declare
  desc('rclone sync up')
  task('sync-up') { sync_up('copy') }

  desc('rclone sync up preview')
  task('sync-up-preview') { sync_up('copy', echo: true) }

  desc('rclone sync up but also delete files on remote to match local')
  task('sync-up-unsafe') { sync_up('sync') }

  desc('rclone sync down')
  task('sync-down', &method(:sync_down))
end