Class: Halite::HelperBase

Inherits:
Object
  • Object
show all
Defined in:
lib/halite/helper_base.rb

Overview

Base class for helpers like Rake tasks.

Since:

  • 1.0.0

Direct Known Subclasses

RakeHelper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_name: nil, base: nil, **options) ⇒ HelperBase

Returns a new instance of HelperBase.

Parameters:

  • gem_name (String) (defaults to: nil)

    Name of the gem to use in these Rake tasks.

  • base (String) (defaults to: nil)

    Base folder of the gem.

Since:

  • 1.0.0



57
58
59
60
61
62
63
64
65
# File 'lib/halite/helper_base.rb', line 57

def initialize(gem_name: nil, base: nil, **options)
  @base = base || if defined?(::Rake) && ::Rake.original_dir
    ::Rake.original_dir
  else
    Dir.pwd
  end # rubocop:disable Lint/EndAlignment
  @gem_name = gem_name || find_gem_name(@base)
  @options = options
end

Instance Attribute Details

#baseString (readonly)

Base folder of the gem.

Returns:

  • (String)

Since:

  • 1.0.0



48
49
50
# File 'lib/halite/helper_base.rb', line 48

def base
  @base
end

#gem_nameString (readonly)

Name of the gem to use in these Rake tasks.

Returns:

  • (String)

Since:

  • 1.0.0



44
45
46
# File 'lib/halite/helper_base.rb', line 44

def gem_name
  @gem_name
end

#optionsHash<Symbol, Object> (readonly)

Helper options.

Returns:

  • (Hash<Symbol, Object>)

Since:

  • 1.0.0



52
53
54
# File 'lib/halite/helper_base.rb', line 52

def options
  @options
end

Class Method Details

.install(*args)

This method returns an undefined value.

Class method helper to install the tasks.

Examples:

MyApp::RakeHelper.install(gem_name: 'otherapp')

Parameters:

Since:

  • 1.0.0



38
39
40
# File 'lib/halite/helper_base.rb', line 38

def self.install(*args)
  new(*args).install
end

Instance Method Details

#install

This method returns an undefined value.

Subclass hoook to provide the actual tasks or other helpers to install.

Examples:

def install
  extend Rake::DSL
  desc 'My awesome task'
  task 'mytask' do
    # ...
  end
end

Raises:

  • (NotImplementedError)

Since:

  • 1.0.0



78
79
80
# File 'lib/halite/helper_base.rb', line 78

def install
  raise NotImplementedError
end