Class: Makitzo::Migrations::Migration

Inherits:
SSH::Context show all
Defined in:
lib/makitzo/migrations/migration.rb

Instance Attribute Summary

Attributes inherited from SSH::Context

#connection, #connection_error, #host

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SSH::Context

#exec, #exec!, #initialize, #logger, #quote, #sudo, #x

Methods included from Commands

#upload_migration_file

Methods included from SSH::Commands::Unix

#killall

Methods included from SSH::Commands::Ruby

#require_ruby!, #ruby_version

Methods included from SSH::Commands::HTTP

#download, #download!, #download_with_curl, #download_with_wget

Methods included from SSH::Commands::FileTransfer

#scp_upload

Methods included from SSH::Commands::FileSystem

#cd, #dir_exists?, #find_or_create_dir!, #mv, #require_dir!, #rm_rf!, #which?

Methods included from SSH::Commands::Apple

#daily_shutdown, #install_app, #install_pkg, #mount_dmg, #reboot, #serial_number, #shutdown, #shutdown_at, #unmount_dmg, #use_network_time_server

Constructor Details

This class inherits a constructor from Makitzo::SSH::Context

Class Method Details

.directoryObject



7
# File 'lib/makitzo/migrations/migration.rb', line 7

def directory;      @directory;       end

.directory=(d) ⇒ Object



8
# File 'lib/makitzo/migrations/migration.rb', line 8

def directory=(d);  @directory = d;   end

.hosts(*hosts) ⇒ Object Also known as: host



16
17
18
19
20
# File 'lib/makitzo/migrations/migration.rb', line 16

def hosts(*hosts)
  @hosts ||= []
  @hosts.concat([hosts].flatten) unless hosts.empty?
  @hosts
end

.protected_context_methodsObject

Returns an array of methods which are required by migrations. Used to prevent helpers from defining conflicting methods.



36
37
38
# File 'lib/makitzo/migrations/migration.rb', line 36

def protected_context_methods
  %w(up down local_directory local_migration_file remote_directory remote_migration_file)
end

.queryObject



22
23
24
25
26
27
28
29
# File 'lib/makitzo/migrations/migration.rb', line 22

def query
  unless @query
    @query = World::Query.new
    roles.each { |r| @query.roles << r }
    hosts.each { |h| @query.hosts << h }
  end
  @query
end

.roles(*roles) ⇒ Object Also known as: role



10
11
12
13
14
# File 'lib/makitzo/migrations/migration.rb', line 10

def roles(*roles)
  @roles ||= []
  @roles.concat([roles].flatten) unless roles.empty?
  @roles
end

.timestampObject



4
# File 'lib/makitzo/migrations/migration.rb', line 4

def timestamp;      @timestamp;       end

.timestamp=(ts) ⇒ Object



5
# File 'lib/makitzo/migrations/migration.rb', line 5

def timestamp=(ts); @timestamp = ts;  end

Instance Method Details

#downObject



61
62
63
# File 'lib/makitzo/migrations/migration.rb', line 61

def down
  raise UnsupportedMigrationError, "down direction is not defined!"
end

#local_directoryObject



41
42
43
# File 'lib/makitzo/migrations/migration.rb', line 41

def local_directory
  self.class.directory
end

#local_migration_file(file) ⇒ Object



45
46
47
# File 'lib/makitzo/migrations/migration.rb', line 45

def local_migration_file(file)
  File.join(local_directory, file)
end

#remote_directoryObject



49
50
51
# File 'lib/makitzo/migrations/migration.rb', line 49

def remote_directory
  File.join(host.migration_history_dir, self.class.timestamp.to_s)
end

#remote_migration_file(file) ⇒ Object



53
54
55
# File 'lib/makitzo/migrations/migration.rb', line 53

def remote_migration_file(file)
  File.join(remote_directory, file)
end

#to_iObject



65
66
67
# File 'lib/makitzo/migrations/migration.rb', line 65

def to_i
  self.class.timestamp
end

#upObject



57
58
59
# File 'lib/makitzo/migrations/migration.rb', line 57

def up
  raise UnsupportedMigrationError, "up direction is not defined!"
end