Class: Guard::Falcon::Plugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/falcon/plugin.rb

Defined Under Namespace

Modules: Environment

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Plugin

Returns a new instance of Plugin.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/guard/falcon/plugin.rb', line 38

def initialize(**options)
	super
	
	options[:root] ||= Dir.pwd
	options[:name] ||= "falcon"
	
	if paths = options[:paths]
		@configuration = Async::Service::Configuration.load(paths)
	else
		@configuration = Async::Service::Configuration.new
		
		# Compatibility
		if rackup_path = options.delete(:config)
			warn "The :config option is deprecated, please use :rackup_path instead.", uplevel: 1
			options[:rackup_path] = rackup_path
		end
		
		@configuration.add(self.class.default_environment(**options))
	end
	
	@controller = ::Async::Service::Controller.new(@configuration.services.to_a)
end

Class Method Details

.default_environment(**options) ⇒ Object



34
35
36
# File 'lib/guard/falcon/plugin.rb', line 34

def self.default_environment(**options)
	Async::Service::Environment.new(Environment).with(**options)
end

Instance Method Details

#reloadObject



70
71
72
73
# File 'lib/guard/falcon/plugin.rb', line 70

def reload
	Console.info(self, "Reloading...")
	@controller.restart
end

#run_on_change(paths) ⇒ Object



80
81
82
# File 'lib/guard/falcon/plugin.rb', line 80

def run_on_change(paths)
	reload
end

#running?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/guard/falcon/plugin.rb', line 66

def running?
	@controller.running?
end

#startObject



61
62
63
64
# File 'lib/guard/falcon/plugin.rb', line 61

def start
	Console.info(self, "Starting...")
	@controller.start
end

#stopObject



75
76
77
78
# File 'lib/guard/falcon/plugin.rb', line 75

def stop
	Console.info(self, "Stopping...")
	@controller.stop
end