class Guard::Bosh::ChangeAssessor
Determines the impact of a code change to enable a subset of files to be re-evaluated.
Public Class Methods
new(deployment_manifest)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 8 def initialize(deployment_manifest) @deployment_manifest = deployment_manifest end
Public Instance Methods
determine_scope(raw_paths)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 12 def determine_scope(raw_paths) paths = raw_paths.map { |p| Pathname.new(p) } return :all if paths.include?(@deployment_manifest) spec_scope = scope(jobs_for_paths(paths), :all_templates_for_job) return spec_scope if spec_scope jobs = paths.select { |p| template_path?(p) }.map do |t| template_job(t) end template_scope = scope(jobs, :single_template) return template_scope if template_scope :none end
Private Instance Methods
jobs_for_paths(paths)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 30 def jobs_for_paths(paths) paths.select { |p| spec_path?(p) }.map do |p| p.dirname.basename.to_s end end
scope(jobs, value)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 50 def scope(jobs, value) if jobs.size > 1 :all elsif jobs.any? [value, jobs.first] end end
spec_path?(path)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 36 def spec_path?(path) path.basename.to_s == 'spec' end
template_job(template_path)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 44 def template_job(template_path) template_path.ascend do |p| break p.dirname.basename.to_s if p.basename.to_s == 'templates' end end
template_path?(path)
click to toggle source
# File lib/guard/bosh/change_assessor.rb, line 40 def template_path?(path) path.descend { |p| break true if p.basename.to_s == 'templates' } end