Class: Capistrano::NetStorage::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/net_storage/config.rb

Instance Method Summary collapse

Instance Method Details

#archive_on_missing?Boolean

If true, create archive ONLY when it’s not found on Network Storage. Otherwise, create archive ALWAYS. Defaults to true

Returns:

  • (Boolean)


59
60
61
62
63
64
65
# File 'lib/capistrano/net_storage/config.rb', line 59

def archive_on_missing?
  @has_checked_archive_on_missing ||= begin
    @archive_on_missing = fetch(:net_storage_archive_on_missing, true)
    true
  end
  @archive_on_missing
end

#archive_pathPathname

Path of archive file to be downloaded on servers

Returns:

  • (Pathname)


129
130
131
132
133
134
135
136
# File 'lib/capistrano/net_storage/config.rb', line 129

def archive_path
  @archive_path ||= pathname(fetch(:net_storage_archive_path))
  @archive_path ||= begin
    # Set release_timestamp if not set
    fetch(:release_path, set_release_path)
    pathname("#{release_path}.#{archive_suffix}")
  end
end

#archive_suffixString

Suffix of archive file

Returns:

  • (String)


140
141
142
143
144
145
146
147
148
149
# File 'lib/capistrano/net_storage/config.rb', line 140

def archive_suffix
  case Capistrano::NetStorage.archiver
  when Capistrano::NetStorage::Archiver::Zip
    'zip'
  when Capistrano::NetStorage::Archiver::TarGzip
    'tar.gz'
  else
    'archive'
  end
end

#config_filesArray<String, Pathname>

Application configuration files to be deployed with

Returns:

  • (Array<String, Pathname>)


42
43
44
# File 'lib/capistrano/net_storage/config.rb', line 42

def config_files
  @config_files ||= fetch(:net_storage_config_files)
end

#executor_class(type) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/capistrano/net_storage/config.rb', line 9

def executor_class(type)
  @executor_classes ||= {}
  @executor_classes[type] ||= fetch(:"net_storage_#{type}")
  @executor_classes[type] ||= begin
    case type
    when :archiver
      Capistrano::NetStorage::Archiver::Zip
    when :scm
      Capistrano::NetStorage::SCM::Git
    when :cleaner
      Capistrano::NetStorage::Cleaner
    when :bundler
      Capistrano::NetStorage::Bundler
    when :transport
      msg = 'You have to set :net_storage_transport because no default transport class!'
      raise Capistrano::NetStorage::Error, msg
    else
      raise "Unknown type! #{type}"
    end
  end
end

#local_archive_pathPathname

Destination path to archive application on localhost

Returns:

  • (Pathname)


122
123
124
125
# File 'lib/capistrano/net_storage/config.rb', line 122

def local_archive_path
  @local_archive_path ||= pathname(fetch(:net_storage_local_archive_path))
  @local_archive_path ||= pathname("#{local_release_path}.#{archive_suffix}")
end

#local_base_pathPathname

Path of base directory on localhost

Returns:

  • (Pathname)


88
89
90
# File 'lib/capistrano/net_storage/config.rb', line 88

def local_base_path
  @local_base_path ||= pathname(fetch(:net_storage_local_base_path, "#{Dir.pwd}/.local_repo"))
end

#local_bundle_pathPathname

Shared directory to install gems

Returns:

  • (Pathname)


115
116
117
118
# File 'lib/capistrano/net_storage/config.rb', line 115

def local_bundle_path
  @local_bundle_path ||= pathname(fetch(:net_storage_local_bundle_path))
  @local_bundle_path ||= local_base_path.join('bundle')
end

#local_mirror_pathPathname

Path to clone repository on localhost

Returns:

  • (Pathname)


94
95
96
97
# File 'lib/capistrano/net_storage/config.rb', line 94

def local_mirror_path
  @local_mirror_path ||= pathname(fetch(:net_storage_local_mirror_path))
  @local_mirror_path ||= local_base_path.join('mirror')
end

#local_release_pathPathname

Path to take a snapshot of repository for release

Returns:

  • (Pathname)


108
109
110
111
# File 'lib/capistrano/net_storage/config.rb', line 108

def local_release_path
  @local_release_path ||= pathname(fetch(:net_storage_local_release_path))
  @local_release_path ||= local_releases_path.join(release_timestamp)
end

#local_releases_pathPathname

Path to keep release directories and archives on localhost

Returns:

  • (Pathname)


101
102
103
104
# File 'lib/capistrano/net_storage/config.rb', line 101

def local_releases_path
  @local_releases_path ||= pathname(fetch(:net_storage_local_releases_path))
  @local_releases_path ||= local_base_path.join('releases')
end

#max_parallelsObject



36
37
38
# File 'lib/capistrano/net_storage/config.rb', line 36

def max_parallels
  @max_parallels ||= fetch(:net_storage_max_parallels, servers.size)
end

#rsync_optionsObject

You can set :user, :keys, :port as ssh options for rsync command to sync configs when :net_storage_upload_files_by_rsync is set true.



78
79
80
# File 'lib/capistrano/net_storage/config.rb', line 78

def rsync_options
  @rsync_options ||= fetch(:net_storage_rsync_options, fetch(:ssh_options, {}))
end

#serversObject

Servers to deploy



32
33
34
# File 'lib/capistrano/net_storage/config.rb', line 32

def servers
  fetch(:net_storage_servers, -> { release_roles(:all) })
end

#skip_bundle?Boolean

If true, skip to bundle gems bundled with target app. Defaults to true

Returns:

  • (Boolean)


48
49
50
51
52
53
54
# File 'lib/capistrano/net_storage/config.rb', line 48

def skip_bundle?
  @has_checked_skip_bundle ||= begin
    @skip_bundle = !fetch(:net_storage_with_bundle)
    true
  end
  @skip_bundle
end

#upload_files_by_rsync?Boolean

If true, use rsync to sync config files. Otherwise, use upload! by sshkit. Defaults to false

Returns:

  • (Boolean)

See Also:



71
72
73
# File 'lib/capistrano/net_storage/config.rb', line 71

def upload_files_by_rsync?
  @upload_files_by_rsync ||= fetch(:net_storage_upload_files_by_rsync, false)
end