Class: Jackhammer::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/jackhammer/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jackhammer/rake_task.rb', line 24

def initialize
  super
  @name = :jackhammer
  @env = 'production'
  @path = './config/jackhammer.yml'
  @description = 'Validate Jackhammer configuration'
  @deps = []
  yield self if block_given?
  if @name.is_a?(Hash)
    @deps = @name.values.first
    @name = @name.keys.first
  end
  define
end

Instance Attribute Details

#depsObject

Task prerequisites.



19
20
21
# File 'lib/jackhammer/rake_task.rb', line 19

def deps
  @deps
end

#descriptionObject

Description of the test task. (default is ‘Validate Jackhammer configuration’)



16
17
18
# File 'lib/jackhammer/rake_task.rb', line 16

def description
  @description
end

#envObject

Specifies the environment to inspect. (default is ‘production’)



22
23
24
# File 'lib/jackhammer/rake_task.rb', line 22

def env
  @env
end

#nameObject

Name of test task. (default is :jackhammer)



9
10
11
# File 'lib/jackhammer/rake_task.rb', line 9

def name
  @name
end

#pathObject

File path of the configuration file. (default is ./config/jackhammer.yml)



12
13
14
# File 'lib/jackhammer/rake_task.rb', line 12

def path
  @path
end

Instance Method Details

#defineObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/jackhammer/rake_task.rb', line 39

def define
  desc @description
  task @name => Array(deps) do
    validator = ConfigurationValidator.new
    validator.config_yaml = YAML.safe_load(File.read(@path), [], [], true)
    validator.environment = env
    validator.validate
    print_results validator.errors
  end
end