Class: Toys::Templates::GemBuild

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

Overview

A template for tools that build, install, and release gems

Constant Summary collapse

DEFAULT_TOOL_NAME =

Default tool name.

Returns:

  • (String)
"build"
DEFAULT_OUTPUT_FLAGS =

Default output flags. If output_flags is set to true, this is the value used.

Returns:

  • (Array<String>)
["-o", "--output"].freeze
DEFAULT_PUSH_REMOTE =

Default remote for pushing tags.

Returns:

  • (String)
"origin"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Toys::Template

create

Constructor Details

#initialize(name: nil, gem_name: nil, output: nil, output_flags: nil, push_gem: false, install_gem: false, tag: false, push_tag: false, context_directory: nil) ⇒ GemBuild

Create the template settings for the GemBuild template.

Parameters:

  • name (String) (defaults to: nil)

    Name of the tool to create. Defaults to DEFAULT_TOOL_NAME.

  • gem_name (String) (defaults to: nil)

    Name of the gem to build. If not provided, searches the context and current directories and uses the first gemspec file it finds.

  • output (String) (defaults to: nil)

    Path to the gem package to generate. Optional. If not provided, defaults to a file name based on the gem name and version, under "pkg" in the current directory.

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

    Provide flags on the tool that set the output path. Optional. If not provided, no flags are created. You may set this to an array of flags (e.g. ["-o"]) or set to true to choose DEFAULT_OUTPUT_FLAGS.

  • push_gem (Boolean) (defaults to: false)

    If true, pushes the built gem to rubygems.

  • install_gem (Boolean) (defaults to: false)

    If true, installs the built gem locally.

  • tag (Boolean) (defaults to: false)

    If true, tags the git repo with the gem version.

  • push_tag (Boolean, String) (defaults to: false)

    If truthy, pushes the new tag to a git remote. You may specify which remote by setting the value to a string. Otherwise, if the value is simply true, the "origin" remote is used by default.

  • context_directory (String) (defaults to: nil)

    A custom context directory to use when executing this tool.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/toys/templates/gem_build.rb', line 55

def initialize(name: nil,
               gem_name: nil,
               output: nil,
               output_flags: nil,
               push_gem: false,
               install_gem: false,
               tag: false,
               push_tag: false,
               context_directory: nil)
  @name = name
  @gem_name = gem_name
  @output = output
  @output_flags = output_flags
  @push_gem = push_gem
  @install_gem = install_gem
  @tag = tag
  @push_tag = push_tag
  @context_directory = context_directory
end

Instance Attribute Details

#context_directory=(value) ⇒ String

Custom context directory for this tool.

Parameters:

  • value (String)

Returns:

  • (String)


150
151
152
# File 'lib/toys/templates/gem_build.rb', line 150

def context_directory=(value)
  @context_directory = value
end

#gem_name=(value) ⇒ String?

Name of the gem to build. If nil, searches the context and current directories and uses the first gemspec file it finds.

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


90
91
92
# File 'lib/toys/templates/gem_build.rb', line 90

def gem_name=(value)
  @gem_name = value
end

#install_gem=(value) ⇒ Boolean

Whether the tool should install the built gen locally.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


124
125
126
# File 'lib/toys/templates/gem_build.rb', line 124

def install_gem=(value)
  @install_gem = value
end

#name=(value) ⇒ String

Name of the tool to create.

Parameters:

  • value (String)

Returns:

  • (String)


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

def name=(value)
  @name = value
end

#output=(value) ⇒ String?

Path to the gem package to generate. If nil, defaults to a file name based on the gem name and version, under "pkg" in the current directory.

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


99
100
101
# File 'lib/toys/templates/gem_build.rb', line 99

def output=(value)
  @output = value
end

#output_flags=(value) ⇒ Array<String>, ...

Flags that set the output path on the generated tool. If nil, no flags are generated. If set to true, DEFAULT_OUTPUT_FLAGS is used.

Parameters:

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

Returns:

  • (Array<String>, true, nil)


108
109
110
# File 'lib/toys/templates/gem_build.rb', line 108

def output_flags=(value)
  @output_flags = value
end

#push_gem=(value) ⇒ Boolean

Whether the tool should push the gem to Rubygems.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


116
117
118
# File 'lib/toys/templates/gem_build.rb', line 116

def push_gem=(value)
  @push_gem = value
end

#push_tag=(value) ⇒ Boolean, String

Whether to push the new tag to a git remote. This may be set to the name of the remote as a string, to true to use DEFAULT_PUSH_REMOTE by default, or to false to disable pushing.

Parameters:

  • value (Boolean, String)

Returns:

  • (Boolean, String)


142
143
144
# File 'lib/toys/templates/gem_build.rb', line 142

def push_tag=(value)
  @push_tag = value
end

#tag=(value) ⇒ Boolean

Whether to tag the git repo with the gem version.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


132
133
134
# File 'lib/toys/templates/gem_build.rb', line 132

def tag=(value)
  @tag = value
end