Class: Omnitest::Project
- Inherits:
-
Core::Dash
- Object
- Hashie::Dash
- Core::Dash
- Omnitest::Project
- Includes:
- Core::FileSystem, Core::Logging
- Defined in:
- lib/omnitest/project.rb
Defined Under Namespace
Classes: GitOptions
Instance Attribute Summary collapse
-
#basedir ⇒ Pathname
Attribute basedir.
-
#git ⇒ GitOptions
Attribute git.
-
#language ⇒ String
Attribute language.
-
#name ⇒ String
Attribute name.
-
#psychic ⇒ Object
Returns the value of attribute psychic.
-
#skeptic ⇒ Object
Returns the value of attribute skeptic.
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #clone ⇒ Object
- #cloned? ⇒ Boolean
-
#cwd ⇒ Pathname
Attribute basedir.
- #execute(*args) ⇒ Object
- #logger ⇒ Object
- #task(task_name, opts = { fail_if_missing: true }) ⇒ Object
- #workflow(workflow_name) ⇒ Object
Methods inherited from Core::Dash
Instance Attribute Details
#basedir ⇒ Pathname
Attribute basedir.
18 |
# File 'lib/omnitest/project.rb', line 18 field :basedir, Pathname |
#git ⇒ GitOptions
Attribute git.
20 |
# File 'lib/omnitest/project.rb', line 20 field :git, GitOptions |
#language ⇒ String
Attribute language.
19 |
# File 'lib/omnitest/project.rb', line 19 field :language, String |
#name ⇒ String
Attribute name.
17 |
# File 'lib/omnitest/project.rb', line 17 field :name, String |
#psychic ⇒ Object
Returns the value of attribute psychic.
24 25 26 |
# File 'lib/omnitest/project.rb', line 24 def psychic @psychic end |
#skeptic ⇒ Object
Returns the value of attribute skeptic.
24 25 26 |
# File 'lib/omnitest/project.rb', line 24 def skeptic @skeptic end |
Instance Method Details
#bootstrap ⇒ Object
92 93 94 |
# File 'lib/omnitest/project.rb', line 92 def bootstrap task('bootstrap', custom_banner: "Bootstrapping #{name}", fail_if_missing: false) end |
#clone ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/omnitest/project.rb', line 46 def clone if git.nil? || git.repo.nil? logger.info 'Skipping clone because there are no git options' return end branch = git.branch ||= 'master' target_dir = git.to ||= basedir target_dir = Omnitest::Core::FileSystem.relativize(target_dir, Omnitest.basedir) if File.exist? target_dir logger.info "Skipping clone because #{target_dir} already exists" else clone_cmd = "git clone #{git.repo} -b #{branch} #{target_dir}" logger.info "Cloning: #{clone_cmd}" Omnitest.psychic.execute(clone_cmd) end end |
#cloned? ⇒ Boolean
96 97 98 |
# File 'lib/omnitest/project.rb', line 96 def cloned? File.directory? basedir end |
#cwd ⇒ Pathname
Attribute basedir.
22 |
# File 'lib/omnitest/project.rb', line 22 field :basedir, Pathname |
#execute(*args) ⇒ Object
34 35 36 |
# File 'lib/omnitest/project.rb', line 34 def execute(*args) psychic.execute(*args) end |
#logger ⇒ Object
42 43 44 |
# File 'lib/omnitest/project.rb', line 42 def logger @logger ||= Omnitest.new_logger(self) end |
#task(task_name, opts = { fail_if_missing: true }) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/omnitest/project.rb', line 63 def task(task_name, opts = { fail_if_missing: true }) = opts[:custom_banner] || "Running task #{task_name} for #{name}" fail "Project #{name} has not been cloned" unless cloned? psychic.task(task_name).execute rescue Omnitest::Psychic::TaskNotImplementedError => e if opts[:fail_if_missing] logger.error("Could not run task #{task_name} for #{name}: #{e.}") raise ActionFailed.new("Failed to run task #{task_name} for #{name}: #{e.}", e) else logger.warn "Skipping #{task_name} for #{name}, no #{task_name} task exists" end end |
#workflow(workflow_name) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/omnitest/project.rb', line 77 def workflow(workflow_name) workflow_definition = Omnitest.configuration.project_set.workflows[workflow_name] fail UserError, "Workflow '#{workflow_name}' is not defined" if workflow_definition.nil? workflow = psychic.workflow(workflow_name) do workflow_definition.tasks.each do | task_name | task task_name end end workflow.execute rescue Psychic::TaskNotImplementedError => e raise UserError, "Cannot run workflow '#{workflow_name}' for project '#{name}': #{e.}" end |