Sha256: d414498c1440bb03eacc48af6a09cc5b994f74e06e282a8a55a0178bca35e9c9

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'gerd/model/model'
require 'gerd/inspections/diffs/organisation'
require 'gerd/inspections/diffs/repositories'

module Gerd
  module Validation

    class Diff

      def initialize(expression, name)
        @expression = expression
        @name = name
      end

      def validate(expected, actual)
        puts expected
        res = @expression.call(expected, actual)
        res ? "#{@name} passed" : "#{@name} failed"
      end

    end

    StandardDiffs =[
          Gerd::Validation::Diff.new( Proc.new { | e, a | e.organisation == a.organisation}, "Organisations"),
      ]


    class Validator

      def initialize(expected_state, actual_state)
        @expected = expected_state
        @actual = actual_state
      end

      def validate
        validation_result = []
        validation_result << Gerd::Inspections::Organisation.inspect_organisations(@expected, @actual)
        validation_result << Gerd::Inspections::Repositories.inspect_repositories(@expected, @actual)
        validation_result << Gerd::Inspections::Organisation.inspect_teams(@expected, @actual)
        report = validation_result.flatten.collect { | res | res.message }
        report
      end

      def collect_actions
        actions = []
        actions << Gerd::Inspections::Organisation.inspect_organisations(@expected, @actual)
        actions << Gerd::Inspections::Repositories.inspect_repositories(@expected, @actual)
        actions << Gerd::Inspections::Organisation.inspect_teams(@expected, @actual)
        actions.flatten.collect { | res | res.actions }
      end
    end

 end   

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gerd-0.0.1 lib/gerd/validators.rb