Sutto-perennial 0.2.2.1 → 0.2.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,11 +55,11 @@ module Perennial
55
55
  options = args.extract_options!
56
56
  path = File.expand_path(args[0] || ".")
57
57
  Settings.root = path
58
- if options[:kill]
58
+ if options.delete(:kill)
59
59
  puts "Attempting to kill processess..."
60
60
  Daemon.kill_all(controller)
61
61
  else
62
- Loader.run!(controller)
62
+ Loader.run!(controller, options)
63
63
  end
64
64
  end
65
65
  end
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Perennial
2
4
  # = Perennial::Daemon provides a relatively simple
3
5
  # interface to creating unix daemons from a given process.
@@ -112,6 +114,7 @@ module Perennial
112
114
  f = pid_file_for(type)
113
115
  pids = pids_from(f)
114
116
  pids << Process.pid unless pids.include?(Process.pid)
117
+ FileUtils.mkdir_p(File.dirname(f))
115
118
  File.open(f, "w+") { |f| f.puts pids.join("\n") }
116
119
  end
117
120
 
@@ -21,16 +21,16 @@ module Perennial
21
21
  RUBY
22
22
  end
23
23
 
24
- def self.run!(type = self.default_type)
24
+ def self.run!(type = self.default_type, options = {})
25
25
  @@current_type = type.to_sym
26
- self.instance.run!
26
+ self.instance.run!(options)
27
27
  end
28
28
 
29
29
  def self.stop!(force = false)
30
30
  self.instance.stop!(force)
31
31
  end
32
32
 
33
- def run!
33
+ def run!(options = {})
34
34
  self.register_signals
35
35
  self.class.invoke_hooks! :before_setup
36
36
  Daemon.daemonize! if Settings.daemon?
@@ -39,7 +39,7 @@ module Perennial
39
39
  Settings.setup
40
40
  self.load_custom_code
41
41
  self.class.invoke_hooks! :before_run
42
- self.attempt_controller_action! :run
42
+ self.attempt_controller_action! :run, options
43
43
  end
44
44
 
45
45
  def stop!(force = false)
@@ -85,10 +85,17 @@ module Perennial
85
85
  end
86
86
  end
87
87
 
88
- def attempt_controller_action!(action)
88
+ def attempt_controller_action!(action, *args)
89
89
  action = action.to_sym
90
90
  unless current_controller.blank? || !current_controller.respond_to?(action)
91
- current_controller.send(action)
91
+ method = current_controller.method(action)
92
+ if method.arity == 0
93
+ method.call
94
+ elsif method.arity < 0 || method.arity == args.size
95
+ method.call(*args)
96
+ else
97
+ raise ArgumentError, "controller action #{action} requires #{method.arity} arguments, provided #{args.size}"
98
+ end
92
99
  end
93
100
  end
94
101
 
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Perennial
2
4
  class Logger
3
5
 
@@ -57,9 +59,10 @@ module Perennial
57
59
 
58
60
  attr_accessor :level, :file, :verbose
59
61
 
60
- def initialize(path, level = :info, verbose = false)
62
+ def initialize(path, level = :info, verbose = Settings.verbose?)
61
63
  @level = level.to_sym
62
64
  @verbose = verbose
65
+ FileUtils.mkdir_p(File.dirname(path))
63
66
  @file = File.open(path, "a+")
64
67
  end
65
68
 
@@ -86,7 +89,7 @@ module Perennial
86
89
  end
87
90
 
88
91
  def verbose?
89
- !!@vebose
92
+ !!@verbose
90
93
  end
91
94
 
92
95
  private
data/lib/perennial.rb CHANGED
@@ -8,11 +8,11 @@ require 'perennial/exceptions'
8
8
 
9
9
  module Perennial
10
10
 
11
- VERSION = "0.2.2.1"
11
+ VERSION = "0.2.2.2"
12
12
 
13
13
  has_libary :dispatchable, :hookable, :loader, :logger,
14
14
  :loggable, :manifest, :settings, :argument_parser,
15
- :option_parser, :application, :generator
15
+ :option_parser, :application, :generator, :daemon
16
16
 
17
17
  def self.included(parent)
18
18
  parent.extend(Manifest::Mixin)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Sutto-perennial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.1
4
+ version: 0.2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-08 00:00:00 -07:00
12
+ date: 2009-08-09 00:00:00 -07:00
13
13
  default_executable: perennial
14
14
  dependencies: []
15
15