Class: Avm::Rspec::LauncherController
- Inherits:
-
Object
- Object
- Avm::Rspec::LauncherController
- Defined in:
- lib/avm/rspec/launcher_controller.rb
Instance Attribute Summary collapse
-
#remotes_dir ⇒ Object
Returns the value of attribute remotes_dir.
Instance Method Summary collapse
-
#application_source_path(application_id, path) ⇒ Object
Void.
- #commit_file(repos, subpath, content) ⇒ Object
- #context_set(settings_path, projects_root) ⇒ Object
- #default_settings_path ⇒ Pathname
- #dummy_directory ⇒ Pathname
- #init_git(subdir) ⇒ Object
- #init_remote(name) ⇒ Object
- #new_context ⇒ Avm::Launcher::Context
- #projects_root ⇒ Object
- #projects_root=(path) ⇒ Object
- #temp_context(settings_path) ⇒ Object
- #templates_directory ⇒ Pathname
- #touch_commit(repos, subpath) ⇒ Object
Instance Attribute Details
#remotes_dir ⇒ Object
Returns the value of attribute remotes_dir.
10 11 12 |
# File 'lib/avm/rspec/launcher_controller.rb', line 10 def remotes_dir @remotes_dir end |
Instance Method Details
#application_source_path(application_id, path) ⇒ Object
Returns void.
15 16 17 18 |
# File 'lib/avm/rspec/launcher_controller.rb', line 15 def application_source_path(application_id, path) EacConfig::Node.context.current.entry("#{application_id}_dev.install.path").value = path.to_pathname.to_path end |
#commit_file(repos, subpath, content) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/avm/rspec/launcher_controller.rb', line 23 def commit_file(repos, subpath, content) require 'fileutils' repos.subpath(subpath).then do |file_path| FileUtils.mkdir_p(File.dirname(file_path)) ::File.write(file_path, content) repos.execute!('add', file_path) repos.execute!('commit', '-m', subpath) end end |
#context_set(settings_path, projects_root) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/avm/rspec/launcher_controller.rb', line 35 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_path ⇒ Pathname
44 45 46 |
# File 'lib/avm/rspec/launcher_controller.rb', line 44 def default_settings_path templates_directory.join('settings.yml') end |
#dummy_directory ⇒ Pathname
49 50 51 |
# File 'lib/avm/rspec/launcher_controller.rb', line 49 def dummy_directory templates_directory.join('dummy') end |
#init_git(subdir) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/avm/rspec/launcher_controller.rb', line 64 def init_git(subdir) r = Avm::Git::Launcher::Base.new(File.join(projects_root, subdir)) r.git r.execute!('config', 'user.email', 'theuser@example.net') r.execute!('config', 'user.name', 'The User') r end |
#init_remote(name) ⇒ Object
58 59 60 61 62 |
# File 'lib/avm/rspec/launcher_controller.rb', line 58 def init_remote(name) r = Avm::Git::Launcher::Base.new(File.join(remotes_dir, name)) r. r end |
#new_context ⇒ Avm::Launcher::Context
73 74 75 76 77 78 |
# File 'lib/avm/rspec/launcher_controller.rb', line 73 def new_context Avm::Launcher::Context.new( settings_file: default_settings_path, cache_root: Dir.mktmpdir ) end |
#projects_root ⇒ Object
81 82 83 |
# File 'lib/avm/rspec/launcher_controller.rb', line 81 def projects_root @projects_root ||= Dir.mktmpdir end |
#projects_root=(path) ⇒ Object
86 87 88 |
# File 'lib/avm/rspec/launcher_controller.rb', line 86 def projects_root=(path) @projects_root = path.to_pathname.to_path end |
#temp_context(settings_path) ⇒ Object
54 55 56 |
# File 'lib/avm/rspec/launcher_controller.rb', line 54 def temp_context(settings_path) context_set(settings_path, Dir.mktmpdir) end |
#templates_directory ⇒ Pathname
91 92 93 |
# File 'lib/avm/rspec/launcher_controller.rb', line 91 def templates_directory '../../../template/avm/rspec/launcher_controller'.to_pathname.(__dir__) end |
#touch_commit(repos, subpath) ⇒ Object
97 98 99 |
# File 'lib/avm/rspec/launcher_controller.rb', line 97 def touch_commit(repos, subpath) commit_file(repos, subpath, '') end |