Class: Avm::Rspec::LauncherController

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/rspec/launcher_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#remotes_dirObject

Returns the value of attribute remotes_dir.



13
14
15
# File 'lib/avm/rspec/launcher_controller.rb', line 13

def remotes_dir
  @remotes_dir
end

Instance Method Details

#application_source_path(application_id, path) ⇒ Object

Returns void.

Parameters:

  • application_id (String)
  • path (Pathname)

Returns:

  • void



18
19
20
21
# File 'lib/avm/rspec/launcher_controller.rb', line 18

def application_source_path(application_id, path)
  EacConfig::Node.context.current.entry("#{application_id}_dev.install.path").value =
    path.to_pathname.to_path
end

#context_set(settings_path, projects_root) ⇒ Object

Parameters:

  • settings_path (Pathname)
  • projects_root (Pathname)


25
26
27
28
29
30
31
# File 'lib/avm/rspec/launcher_controller.rb', line 25

def context_set(settings_path, projects_root)
  Avm::Launcher::Context.current = Avm::Launcher::Context.new(
    settings_file: settings_path.to_pathname.to_path,
    cache_root: Dir.mktmpdir
  )
  self.projects_root = projects_root
end

#default_settings_pathPathname

Returns:

  • (Pathname)


34
35
36
# File 'lib/avm/rspec/launcher_controller.rb', line 34

def default_settings_path
  templates_directory.join('settings.yml')
end

#dummy_directoryPathname

Returns:

  • (Pathname)


39
40
41
# File 'lib/avm/rspec/launcher_controller.rb', line 39

def dummy_directory
  templates_directory.join('dummy')
end

#init_git(subdir) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/avm/rspec/launcher_controller.rb', line 55

def init_git(subdir)
  require 'avm/git/launcher/base'
  r = Avm::Git::Launcher::Base.new(File.join(projects_root, subdir))
  r.git
  r.execute!('config', 'user.email', '[email protected]')
  r.execute!('config', 'user.name', 'The User')
  r
end

#init_remote(name) ⇒ Object



48
49
50
51
52
53
# File 'lib/avm/rspec/launcher_controller.rb', line 48

def init_remote(name)
  require 'avm/git/launcher/base'
  r = Avm::Git::Launcher::Base.new(File.join(remotes_dir, name))
  r.init_bare
  r
end

#new_contextAvm::Launcher::Context



65
66
67
68
69
70
# File 'lib/avm/rspec/launcher_controller.rb', line 65

def new_context
  Avm::Launcher::Context.new(
    settings_file: default_settings_path,
    cache_root: Dir.mktmpdir
  )
end

#projects_rootObject

Parameters:

  • path (String)


73
74
75
# File 'lib/avm/rspec/launcher_controller.rb', line 73

def projects_root
  @projects_root ||= Dir.mktmpdir
end

#projects_root=(path) ⇒ Object

Parameters:

  • path (Pathname)


78
79
80
# File 'lib/avm/rspec/launcher_controller.rb', line 78

def projects_root=(path)
  @projects_root = path.to_pathname.to_path
end

#temp_context(settings_path) ⇒ Object

Parameters:

  • settings_path (Pathname)


44
45
46
# File 'lib/avm/rspec/launcher_controller.rb', line 44

def temp_context(settings_path)
  context_set(settings_path, Dir.mktmpdir)
end

#templates_directoryPathname

Returns:

  • (Pathname)


83
84
85
# File 'lib/avm/rspec/launcher_controller.rb', line 83

def templates_directory
  '../../../template/avm/rspec/launcher_controller'.to_pathname.expand_path(__dir__)
end

#touch_commit(repos, subpath) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/avm/rspec/launcher_controller.rb', line 87

def touch_commit(repos, subpath)
  require 'fileutils'
  FileUtils.mkdir_p(File.dirname(repos.subpath(subpath)))
  FileUtils.touch(repos.subpath(subpath))
  repos.execute!('add', repos.subpath(subpath))
  repos.execute!('commit', '-m', subpath)
end