Class: Squarespace::Sync::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/squarespace/sync/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



50
51
52
# File 'lib/squarespace/sync/cli.rb', line 50

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#pull(file = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/squarespace/sync/cli.rb', line 39

def pull(file=nil)
  Connection.new do |sftp, options, instance|
    if file
      local_file = File.join(Squarespace::Sync.local_path, file)
      instance.pull_file( sftp, File.join(options[:directory], file), local_file )
    else
      instance.pull_tree( sftp, options[:directory] )
    end
  end
end

#push(file = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/squarespace/sync/cli.rb', line 27

def push(file=nil)
  Connection.new do |sftp, options, instance|
    if file
      local_file = File.join(Squarespace::Sync.local_path, file)
      instance.push_file( sftp, local_file, File.join(options[:directory], file) )
    else
      instance.push_tree( sftp, options[:directory] )
    end
  end
end

#setupObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/squarespace/sync/cli.rb', line 12

def setup
  output_file = File.join(Squarespace::Sync.local_path, "squarespace.yaml")
  template_file = "squarespace.tt"
  options = {
    host: "dev.squarespace.com",
    username: "[email protected]",
    password: "\"\"",
    directory: "your-site",
    port: 2030,
    ignore: %w{.gitignore Gemfile Gemfile.lock}
  }
  template( template_file, output_file, options )
end

#versionObject



7
8
9
# File 'lib/squarespace/sync/cli.rb', line 7

def version
  say Squarespace::Sync::VERSION
end