Class: Nanoc::CLI::CompileListeners::Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/nanoc/cli/compile_listeners/abstract.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAbstract

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Abstract.



5
6
7
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 5

def initialize(*)
  super()
end

Class Method Details

.enable_for?(command_runner, site) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Lint/UnusedMethodArgument

Returns:

  • (Boolean)


9
10
11
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 9

def self.enable_for?(command_runner, site) # rubocop:disable Lint/UnusedMethodArgument
  true
end

Instance Method Details

#on(sym) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 53

def on(sym)
  @_notification_names << sym
  Nanoc::Core::NotificationCenter.on(sym, self) { |*args| yield(*args) }
end

#run_whileObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
39
40
41
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 36

def run_while
  wrapped_start
  yield
ensure
  wrapped_stop
end

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 14

def start
  raise NotImplementedError, "Subclasses of #{self.class} must implement #start"
end

#start_safelyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 43

def start_safely
  wrapped_start
  @_started = true
end

#stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.


19
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 19

def stop; end

#stop_safelyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
51
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 48

def stop_safely
  wrapped_stop if @_started
  @_started = false
end

#wrapped_startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 21

def wrapped_start
  @_notification_names = []
  start
end

#wrapped_stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
30
31
32
33
34
# File 'lib/nanoc/cli/compile_listeners/abstract.rb', line 26

def wrapped_stop
  stop

  Nanoc::Core::NotificationCenter.sync

  @_notification_names.each do |name|
    Nanoc::Core::NotificationCenter.remove(name, self)
  end
end