Module: Gerd::Inspections::Repositories
- Defined in:
- lib/gerd/inspections/diffs/repositories.rb
Class Method Summary collapse
- .inspect_no_extra_repos_exist(expected, actual) ⇒ Object
- .inspect_repo_privacy(expected, actual) ⇒ Object
- .inspect_repositories(expected, actual) ⇒ Object
- .inspect_required_repos_exist(expected, actual) ⇒ Object
Class Method Details
.inspect_no_extra_repos_exist(expected, actual) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gerd/inspections/diffs/repositories.rb', line 46 def self.inspect_no_extra_repos_exist(expected, actual) diffs = [] expected_repos = expected.repositories actual_repos= actual.repositories actual_repos.keys.each do | repo | if !expected_repos.keys.include? repo action = Gerd::Inspections::Actions::DeleteRepo.new(repo, expected.organisation) diffs << Gerd::Inspections::Diff.new(false, "I did not expect to see repository #{repo} but saw it anyway", [action]) end end diffs end |
.inspect_repo_privacy(expected, actual) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/gerd/inspections/diffs/repositories.rb', line 66 def self.inspect_repo_privacy(expected, actual) diffs = [] expected_repos = expected.repositories actual_repos= actual.repositories expected_repos.each do | repo_name, expected_repo | actual_repo = actual_repos[repo_name] next if !actual_repo if expected_repo['private'] == true && actual_repo['private'] == false action = Gerd::Inspections::Actions::ChangeRepoPrivacy.new(actual_repo, true) diffs << Gerd::Inspections::Diff.new(false, "I expected repo #{repo_name} to be private, but it is not", [action]) end if expected_repo['private'] == false && actual_repo['private'] == true action = Gerd::Inspections::Actions::ChangeRepoPrivacy.new(actual_repo, false) diffs << Gerd::Inspections::Diff.new(false, "I did not expect repo #{repo_name} to be private, but it is", [action]) end end diffs end |
.inspect_repositories(expected, actual) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gerd/inspections/diffs/repositories.rb', line 11 def self.inspect_repositories(expected, actual) diffs = [] diffs << inspect_required_repos_exist(expected, actual) diffs << inspect_no_extra_repos_exist(expected, actual) diffs << inspect_repo_privacy(expected, actual) diffs.flatten end |
.inspect_required_repos_exist(expected, actual) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gerd/inspections/diffs/repositories.rb', line 25 def self.inspect_required_repos_exist(expected, actual) diffs = [] expected_repos = expected.repositories actual_repos= actual.repositories expected_repos.keys.each do | expected_repo | if !actual_repos.keys.include? expected_repo repo_to_create = expected_repos[expected_repo] privacy = repo_to_create['privacy'] action = Gerd::Inspections::Actions::CreateRepo.new(expected_repo, expected.organisation, privacy) diffs << Gerd::Inspections::Diff.new(false, "I expected to see repository #{expected_repo} but did not", [action]) end end diffs end |