Module: Assemblr

Defined in:
lib/assemblr.rb,
lib/assemblr.rb,
lib/assemblr/shell.rb,
lib/assemblr/remote.rb,
lib/assemblr/network.rb,
lib/assemblr/version.rb

Overview

Define the core Assemblr methods.

Defined Under Namespace

Modules: Log, Network, Remote, Shell

Constant Summary collapse

VERSION =
'0.2.0'
@@options =
[]
@@error_hook =
-> {}

Instance Method Summary collapse

Instance Method Details

#define_option(name, value) ⇒ Object



23
24
25
26
# File 'lib/assemblr.rb', line 23

def define_option(name, value)
  Assemblr.class_variable_set("@@#{name}", value)
  @@options << name.to_sym
end

#error_hookObject



32
33
34
# File 'lib/assemblr.rb', line 32

def error_hook
  @@on_error
end

#expose_method(name) ⇒ Object

Generates method definitions in all supported styles.



42
43
44
45
46
# File 'lib/assemblr.rb', line 42

def expose_method(name)
  prefix = to_s.downcase.gsub('::', '_').delete_prefix('assemblr_')
  eval "#{self}.define_method(:#{prefix}_#{name}, &#{self}.method(:#{name}))"
  eval "#{self}.define_singleton_method(:#{name}, &#{self}.method(:#{name}))"
end

#get_option(key) ⇒ Object



19
20
21
# File 'lib/assemblr.rb', line 19

def get_option(key)
  Assemblr.class_variable_get("@@#{key}")
end

#on_error(&block) ⇒ Object



36
37
38
# File 'lib/assemblr.rb', line 36

def on_error(&block)
  @@on_error = block
end

#optionsObject



28
29
30
# File 'lib/assemblr.rb', line 28

def options
  Assemblr.class_variable_get('@@options')
end

#set_option(key, value) ⇒ Object



13
14
15
16
17
# File 'lib/assemblr.rb', line 13

def set_option(key, value)
  return unless @@options.include?(key.to_sym)

  Assemblr.class_variable_set("@@#{key}", value)
end