Class: Toys::Templates::Rake

Inherits:
Object
  • Object
show all
Includes:
Template
Defined in:
lib/toys/templates/rake.rb

Overview

A template that generates tools matching a rakefile.

Constant Summary collapse

DEFAULT_RAKEFILE_PATH =

Default path to the Rakefile.

Returns:

  • (String)
"Rakefile"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_version: nil, rakefile_path: nil, only_described: false, use_flags: false, bundler: false) ⇒ Rake

Create the template settings for the rake template.

Parameters:

  • gem_version (String, Array<String>, nil) (defaults to: nil)

    Version requirements for the rake gem. Defaults to nil, indicating no version requirement.

  • rakefile_path (String) (defaults to: nil)

    Path to the Rakefile. Defaults to DEFAULT_RAKEFILE_PATH.

  • only_described (Boolean) (defaults to: false)

    If true, tools are generated only for rake tasks with descriptions. Default is false.

  • use_flags (Boolean) (defaults to: false)

    Generated tools use flags instead of positional arguments to pass arguments to rake tasks. Default is false.

  • bundler (Boolean, Hash) (defaults to: false)

    If false (the default), bundler is not enabled for Rake tools. If true or a Hash of options, bundler is enabled. See the documentation for the bundler mixin for information on available options.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/toys/templates/rake.rb', line 35

def initialize(gem_version: nil,
               rakefile_path: nil,
               only_described: false,
               use_flags: false,
               bundler: false)
  @gem_version = gem_version
  @rakefile_path = rakefile_path
  @only_described = only_described
  @use_flags = use_flags
  @bundler = bundler
end

Instance Attribute Details

#bundler=(value) ⇒ Boolean, Hash (writeonly)

Set the bundler state and options for all Rake tools.

Pass false to disable bundler. Pass true or a hash of options to enable bundler. See the documentation for the bundler mixin for information on the options that can be passed.

Parameters:

  • value (Boolean, Hash)

Returns:

  • (Boolean, Hash)


94
95
96
# File 'lib/toys/templates/rake.rb', line 94

def bundler=(value)
  @bundler = value
end

#gem_version=(value) ⇒ String, ...

Version requirements for the minitest gem. If set to nil, has no version requirement (unless one is specified in the bundle.)

Parameters:

  • value (String, Array<String>, nil)

Returns:

  • (String, Array<String>, nil)


55
56
57
# File 'lib/toys/templates/rake.rb', line 55

def gem_version=(value)
  @gem_version = value
end

#only_described=(value) ⇒ Boolean

Whether to generate tools only for rake tasks with descriptions.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


72
73
74
# File 'lib/toys/templates/rake.rb', line 72

def only_described=(value)
  @only_described = value
end

#rakefile_path=(value) ⇒ String?

Path to the Rakefile. If set to nil, defaults to DEFAULT_RAKEFILE_PATH.

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


64
65
66
# File 'lib/toys/templates/rake.rb', line 64

def rakefile_path=(value)
  @rakefile_path = value
end

#use_flags=(value) ⇒ Boolean

Whether generated tools should use flags instead of positional arguments to pass arguments to rake tasks.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


81
82
83
# File 'lib/toys/templates/rake.rb', line 81

def use_flags=(value)
  @use_flags = value
end

Instance Method Details

#use_bundler(**opts) ⇒ self

Use bundler for all Rake tools.

See the documentation for the bundler mixin for information on the options that can be passed.

Parameters:

  • opts (keywords)

    Options for bundler

Returns:

  • (self)


106
107
108
109
# File 'lib/toys/templates/rake.rb', line 106

def use_bundler(**opts)
  @bundler = opts
  self
end