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



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

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



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

def base
  @base
end

#gem_nameString (readonly)

Name of the gem to use in these Rake tasks.

Returns:

  • (String)

Since:

  • 1.0.0



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

def gem_name
  @gem_name
end

#optionsHash<Symbol, Object> (readonly)

Helper options.

Returns:

  • (Hash<Symbol, Object>)

Since:

  • 1.0.0



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

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



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

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



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

def install
  raise NotImplementedError
end