Class: Stendhal::RakeTask

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

Overview

Mostly taken from rspec-core Rake task

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/stendhal/rake_task.rb', line 59

def initialize(*args)
  @name = args.shift || :spec
  @ruby_opts = nil
  @skip_bundler = false
  @verbose, @fail_on_error = true, true
  @gemfile = 'Gemfile'

  yield self if block_given?

  @stendhal_path ||= 'stendhal'

  desc("Run Stendhal code examples") unless ::Rake.application.last_comment

  task name do
    RakeFileUtils.send(:verbose, verbose) do
      begin
        ruby(stendhal_command)
      rescue
        puts failure_message if failure_message
        raise("ruby #{stendhal_command} failed") if fail_on_error
      end
    end
  end
end

Instance Attribute Details

#fail_on_errorObject

Whether or not to fail Rake when an error occurs (typically when examples fail).

default:

true


35
36
37
# File 'lib/stendhal/rake_task.rb', line 35

def fail_on_error
  @fail_on_error
end

#failure_messageObject

A message to print to stderr when there are failures.



38
39
40
# File 'lib/stendhal/rake_task.rb', line 38

def failure_message
  @failure_message
end

#gemfileObject

Name of Gemfile to use

default:

Gemfile


29
30
31
# File 'lib/stendhal/rake_task.rb', line 29

def gemfile
  @gemfile
end

#nameObject

Name of task.

default:

:spec


15
16
17
# File 'lib/stendhal/rake_task.rb', line 15

def name
  @name
end

#ruby_optsObject

Command line options to pass to ruby.

default:

nil


51
52
53
# File 'lib/stendhal/rake_task.rb', line 51

def ruby_opts
  @ruby_opts
end

#skip_bundlerObject

By default, if there is a Gemfile, the generated command will include ‘bundle exec’. Set this to true to ignore the presence of a Gemfile, and not add ‘bundle exec’ to the command.

default:

false


23
24
25
# File 'lib/stendhal/rake_task.rb', line 23

def skip_bundler
  @skip_bundler
end

#stendhal_pathObject

Path to stendhal

default:

'stendhal'


57
58
59
# File 'lib/stendhal/rake_task.rb', line 57

def stendhal_path
  @stendhal_path
end

#verboseObject

Use verbose output. If this is set to true, the task will print the executed spec command to stdout.

default:

true


45
46
47
# File 'lib/stendhal/rake_task.rb', line 45

def verbose
  @verbose
end