Class: Seedog::Evaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/seedog/evaluator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, dry_run: false) ⇒ Evaluator

Returns a new instance of Evaluator.



8
9
10
11
12
# File 'lib/seedog/evaluator.rb', line 8

def initialize(config, dry_run: false)
  @config = config
  @dry_run = dry_run
  @changed = false
end

Instance Attribute Details

#changedObject

Returns the value of attribute changed.



6
7
8
# File 'lib/seedog/evaluator.rb', line 6

def changed
  @changed
end

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/seedog/evaluator.rb', line 5

def config
  @config
end

#dry_runObject (readonly)

Returns the value of attribute dry_run.



5
6
7
# File 'lib/seedog/evaluator.rb', line 5

def dry_run
  @dry_run
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/seedog/evaluator.rb', line 14

def run
  if dry_run
    puts "Apply `#{config.file.relative_path_from(Rails.root)}` (dry-run)"
  else
    puts "Apply `#{config.file.relative_path_from(Rails.root)}`"
  end

  dsl = DSL.new(self)
  dsl.instance_eval(config.file.read)

  unless changed
    puts 'No change'
  end
end