Skip to content

Commit

Permalink
Add missing YARD docs
Browse files Browse the repository at this point in the history
Add missing YARD docs
  • Loading branch information
Ladas committed Jul 27, 2018
1 parent 23d06da commit 0a01bef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/ansible/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def run_via_cli(env_vars, extra_vars, playbook_path: nil, role_name: nil, roles_
end
end

# @param base_dir [String] ansible-runner private_data_dir parameter
# @param ansible_runner_method [String] Method we will use to run the ansible-runner. It can be either "run",
# which is sync call, or "start" which is async call
# @param result [AwesomeSpawn::CommandResult] Result object of AwesomeSpawn.run
# @return [Ansible::Runner::ResponseAsync, Ansible::Runner::Response] response or ResponseAsync based on the
# ansible_runner_method
def response(base_dir, ansible_runner_method, result)
if async?(ansible_runner_method)
Ansible::Runner::ResponseAsync.new(:base_dir => base_dir)
Expand All @@ -163,6 +169,7 @@ def response(base_dir, ansible_runner_method, result)
end
end

# @return [Bollean] True if ansible-runner will run on background
def async?(ansible_runner_method)
ansible_runner_method == "start"
end
Expand Down Expand Up @@ -254,7 +261,12 @@ def assert_path!(path)
end
end

# @return [String] ansible_runner executable command
# Returns ansible-runner executable command
#
# @param base_dir [String] ansible-runner private_data_dir parameter
# @param ansible_runner_method [String] Method we will use to run the ansible-runner. It can be either "run",
# which is sync call, or "start" which is async call
# @return [String] ansible-runner executable command
def ansible_command(base_dir, ansible_runner_method)
"ansible-runner #{ansible_runner_method} #{base_dir} --json -i result --hosts localhost"
end
Expand Down
5 changes: 5 additions & 0 deletions lib/ansible/runner/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ def initialize(base_dir:, return_code: nil, stdout: nil, stderr: nil, ident: "re
@stderr = stderr
end

# @return [Integer] Return code of the ansible-runner run, 0 == ok, others mean failure
def return_code
@return_code ||= load_return_code
end

# @return [String] Stdout that is text, where each line should be JSON encoded object
def stdout
@stdout ||= load_stdout
end

# @return [Array<Hash>] Array of hashes as individual Ansible plays
def parsed_stdout
@parsed_stdout ||= parse_stdout(stdout)
end

# Loads needed data from the filesystem and deletes the ansible-runner base dir
def cleanup_filesystem!
# Load all needed files, before we cleanup the dir
return_code
Expand Down Expand Up @@ -75,6 +79,7 @@ def load_return_code
1
end

# @return [String] Stdout that is text, where each line should be JSON encoded object
def load_stdout
File.read(File.join(base_dir, "artifacts", ident, "stdout"))
rescue
Expand Down

0 comments on commit 0a01bef

Please sign in to comment.