Sutto-perennial 1.0.0.0 → 1.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,12 +74,13 @@ module Perennial
74
74
  controller_name = controller.to_s.underscore
75
75
  controller = controller.to_sym
76
76
  command_name = controller_name.gsub("_", "-")
77
+ parent = self
77
78
  add("#{command_name} #{"[PATH]" if !opts[:skip_path]}".strip, description) do |*args|
78
79
  options = args.extract_options!
79
80
  path = File.expand_path(args[0] || ".")
80
81
  Settings.root = path
81
82
  if options.delete(:kill)
82
- attempt_showing_banner
83
+ parent.attempt_showing_banner
83
84
  puts "Attempting to kill processess for #{command_name}"
84
85
  Daemon.kill_all(controller)
85
86
  else
@@ -148,7 +149,7 @@ module Perennial
148
149
  end
149
150
  application.execute args
150
151
  end
151
-
152
+
152
153
  def attempt_showing_banner
153
154
  if banner.present?
154
155
  puts banner
data/lib/perennial.rb CHANGED
@@ -9,7 +9,7 @@ require 'perennial/exceptions'
9
9
 
10
10
  module Perennial
11
11
 
12
- VERSION = "1.0.0.0"
12
+ VERSION = "1.0.0.1"
13
13
 
14
14
  has_library :dispatchable, :hookable, :loader, :logger, :nash,
15
15
  :loggable, :manifest, :settings, :argument_parser,
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: 1.0.0.0
4
+ version: 1.0.0.1
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-09-17 00:00:00 -07:00
12
+ date: 2009-09-19 00:00:00 -07:00
13
13
  default_executable: perennial
14
14
  dependencies: []
15
15
 
@@ -23,15 +23,6 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - bin/perennial
26
- - vendor/fakefs
27
- - vendor/fakefs/lib
28
- - vendor/fakefs/lib/fakefs.rb
29
- - vendor/fakefs/LICENSE
30
- - vendor/fakefs/Rakefile
31
- - vendor/fakefs/README.markdown
32
- - vendor/fakefs/test
33
- - vendor/fakefs/test/fakefs_test.rb
34
- - vendor/fakefs/test/verify.rb
35
26
  - lib/perennial
36
27
  - lib/perennial/application.rb
37
28
  - lib/perennial/argument_parser.rb
@@ -58,15 +49,6 @@ files:
58
49
  - lib/perennial/reloading.rb
59
50
  - lib/perennial/settings.rb
60
51
  - lib/perennial.rb
61
- - test/delegateable_test.rb
62
- - test/dispatchable_test.rb
63
- - test/hookable_test.rb
64
- - test/loader_test.rb
65
- - test/loggable_test.rb
66
- - test/logger_test.rb
67
- - test/proxy_test.rb
68
- - test/settings_test.rb
69
- - test/test_helper.rb
70
52
  - templates/application.erb
71
53
  - templates/boot.erb
72
54
  - templates/rakefile.erb
@@ -1,38 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class DelegateableTest < Test::Unit::TestCase
4
-
5
- context 'basic delegates' do
6
-
7
- setup do
8
- @klass = test_class_for(Perennial::Delegateable)
9
- @delegateable = @klass.new
10
- end
11
-
12
- should 'define a delegate= method' do
13
- assert @delegateable.respond_to?(:delegate=)
14
- end
15
-
16
- should 'define a delegate_to method' do
17
- assert @delegateable.respond_to?(:delegate_to)
18
- end
19
-
20
- should 'let you get the delegate proxy' do
21
- @delegateable.delegate_to :awesome
22
- assert proxy = @delegateable.delegate
23
- assert_nothing_raised { proxy.awesomesauce }
24
- assert_nothing_raised { proxy.ninja_party }
25
- assert_equal "awesome", proxy.to_s
26
- end
27
-
28
- should 'let you get the real target of the delegate' do
29
- @delegateable.delegate_to :awesome
30
- assert real = @delegateable.real_delegate
31
- assert_raises(NoMethodError) { proxy.awesomesauce }
32
- assert_raises(NoMethodError) { proxy.ninja_party }
33
- assert_equal "awesome", real.to_s
34
- end
35
-
36
- end
37
-
38
- end
@@ -1,212 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class DispatchableTest < Test::Unit::TestCase
4
-
5
- class ExampleDispatcher
6
- include Perennial::Dispatchable
7
- end
8
-
9
- class ExampleHandlerA
10
-
11
- attr_accessor :messages
12
-
13
- def initialize
14
- @messages = []
15
- end
16
-
17
- def handle(name, opts)
18
- @messages << [name, opts]
19
- end
20
-
21
- end
22
-
23
- class ExampleHandlerB < ExampleHandlerA; end
24
-
25
- class ExampleHandlerC
26
- attr_reader :max_count, :messages, :call_stack
27
- def initialize(d)
28
- @messages = []
29
- @max_count = 0
30
- @current_count = 0
31
- @dispatcher = d
32
- @call_stack = []
33
- end
34
-
35
- def handle(name, opts)
36
- @call_stack << "start-#{name}"
37
- @current_count += 1
38
- @messages << name
39
- @dispatcher.dispatch(:b) if name == :a
40
- @max_count = @current_count if @current_count > @max_count
41
- @current_count -= 1
42
- @call_stack << "end-#{name}"
43
- end
44
-
45
- end
46
-
47
- class RegisterableHandler
48
-
49
- def registered=(value)
50
- @registered = value
51
- end
52
-
53
- def registered?
54
- @registered ||= false
55
- end
56
-
57
- def handle(name, opts = {})
58
- end
59
-
60
- end
61
-
62
- context 'marking a class as dispatchable' do
63
-
64
- setup do
65
- @dispatcher = ExampleDispatcher.new
66
- end
67
-
68
- should 'define a dispatch method' do
69
- assert @dispatcher.respond_to?(:dispatch)
70
- end
71
-
72
- should 'require atleast a name for dispatch' do
73
- assert_equal -2, @dispatcher.method(:dispatch).arity
74
- end
75
-
76
- end
77
-
78
- context 'when registering handlers' do
79
-
80
- setup do
81
- @dispatcher = test_class_for(Perennial::Dispatchable)
82
- end
83
-
84
- should 'append a handler using register_handler' do
85
- assert_equal [], @dispatcher.handlers
86
- @dispatcher.register_handler(handler = ExampleHandlerA.new)
87
- assert_equal [handler], @dispatcher.handlers
88
- end
89
-
90
- should 'batch assign handlers on handlers= using register_handler' do
91
- handlers = [ExampleHandlerA.new, ExampleHandlerB.new]
92
- assert_equal [], @dispatcher.handlers
93
- @dispatcher.handlers = handlers
94
- assert_equal handlers, @dispatcher.handlers
95
- end
96
-
97
- should 'return all handlers via the handlers class method' do
98
- handlers = [ExampleHandlerA.new, ExampleHandlerB.new]
99
- @dispatcher.handlers = handlers
100
- assert_equal handlers, @dispatcher.handlers
101
- end
102
-
103
- should 'make handlers available to myself and all subclasses' do
104
- # Set A
105
- dispatcher_a = class_via(@dispatcher)
106
- dispatcher_a.register_handler(handler_a = ExampleHandlerA.new)
107
- # Set B
108
- dispatcher_b = class_via(dispatcher_a)
109
- dispatcher_b.register_handler(handler_b = ExampleHandlerA.new)
110
- # Set C
111
- dispatcher_c = class_via(dispatcher_b)
112
- dispatcher_c.register_handler(handler_c = ExampleHandlerA.new)
113
- # Set D
114
- dispatcher_d = class_via(dispatcher_a)
115
- dispatcher_d.register_handler(handler_d = ExampleHandlerB.new)
116
- # Actual Assertions
117
- assert_equal [], @dispatcher.handlers
118
- assert_equal [handler_a], dispatcher_a.handlers
119
- assert_equal [handler_a, handler_b], dispatcher_b.handlers
120
- assert_equal [handler_a, handler_b, handler_c], dispatcher_c.handlers
121
- assert_equal [handler_a, handler_d], dispatcher_d.handlers
122
- end
123
-
124
- end
125
-
126
- context 'dispatching events' do
127
-
128
- setup do
129
- @dispatcher = class_via(ExampleDispatcher).new
130
- @handler = ExampleHandlerA.new
131
- @dispatcher.class.register_handler @handler
132
- end
133
-
134
- should 'attempt to call handle_[event_name] on itself' do
135
- mock(@dispatcher).respond_to?(:handle_sample_event) { true }
136
- mock(@dispatcher).handle_sample_event(:awesome => true, :sauce => 2)
137
- @dispatcher.dispatch :sample_event, :awesome => true, :sauce => 2
138
- end
139
-
140
- should 'attempt to call handle_[event_name] on each handler' do
141
- mock(@handler).respond_to?(:handle_sample_event) { true }
142
- mock(@handler).handle_sample_event(:awesome => true, :sauce => 2)
143
- @dispatcher.dispatch :sample_event, :awesome => true, :sauce => 2
144
- end
145
-
146
- should 'call handle on each handler if handle_[event_name] isn\'t defined' do
147
- mock(@handler).respond_to?(:handle_sample_event) { false }
148
- mock(@handler).handle(:sample_event, :awesome => true, :sauce => 2)
149
- @dispatcher.dispatch :sample_event, :awesome => true, :sauce => 2
150
- end
151
-
152
- should 'let you halt handler processing if you raise HaltHandlerProcessing' do
153
- handler_two = ExampleHandlerB.new
154
- @dispatcher.class.register_handler handler_two
155
- mock(@handler).handle(:sample_event, :awesome => true, :sauce => 2) do
156
- raise Perennial::HaltHandlerProcessing
157
- end
158
- dont_allow(handler_two).handle(:sample_event, :awesome => true, :sauce => 2)
159
- @dispatcher.dispatch :sample_event, :awesome => true, :sauce => 2
160
- end
161
-
162
- should 'log exceptions when encountered and not crash'
163
-
164
- end
165
-
166
- context 'dispatching nested events' do
167
-
168
- setup do
169
- @dispatcher = class_via(ExampleDispatcher).new
170
- @handler = ExampleHandlerC.new(@dispatcher)
171
- @dispatcher.class.register_handler @handler
172
- @dispatcher.dispatch :a
173
- end
174
-
175
- should 'call them in the correct order' do
176
- assert_equal [:a, :b], @handler.messages
177
- end
178
-
179
- should 'only call 1 dispatch at a time' do
180
- assert_equal 1, @handler.max_count
181
- end
182
-
183
- should 'finish a before dispatching b' do
184
- assert_equal ["start-a", "end-a", "start-b", "end-b"], @handler.call_stack
185
- end
186
-
187
- end
188
-
189
- context 'registering handlers' do
190
-
191
- setup do
192
- @dispatcher = class_via(ExampleDispatcher).new
193
- @handler = class_via(RegisterableHandler).new
194
- end
195
-
196
- should 'default to not being registered' do
197
- assert !@handler.registered?
198
- end
199
-
200
- should 'set registered on register_handler' do
201
- @dispatcher.class.register_handler @handler
202
- assert @handler.registered?
203
- end
204
-
205
- should 'call registered= on the handler' do
206
- mock(@handler).registered = true
207
- @dispatcher.class.register_handler @handler
208
- end
209
-
210
- end
211
-
212
- end
@@ -1,61 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class HookableTest < Test::Unit::TestCase
4
-
5
- context 'Hookable Classes' do
6
-
7
- setup do
8
- @hookable_class = test_class_for(Perennial::Hookable)
9
- end
10
-
11
- should 'let you append hooks via append_hook' do
12
- assert_equal [], @hookable_class.hooks_for(:awesome)
13
- @hookable_class.append_hook(:awesome) { puts "Hello!" }
14
- assert_equal 1, @hookable_class.hooks_for(:awesome).size
15
- end
16
-
17
- should 'only append hooks if they aren\'t blank' do
18
- @hookable_class.append_hook(:awesome)
19
- assert_equal [], @hookable_class.hooks_for(:awesome)
20
- end
21
-
22
- should 'let you get an array of hooks' do
23
- @hookable_class.append_hook(:awesome) { puts "A" }
24
- @hookable_class.append_hook(:awesome) { puts "B" }
25
- assert_equal 2, @hookable_class.hooks_for(:awesome).size
26
- end
27
-
28
- should 'let you invoke hooks' do
29
- items = []
30
- @hookable_class.append_hook(:awesome) { items << :a }
31
- @hookable_class.append_hook(:awesome) { items << :b }
32
- @hookable_class.append_hook(:awesome) { items << :c }
33
- @hookable_class.invoke_hooks!(:awesome)
34
- assert_equal [:a, :b, :c], items
35
- end
36
-
37
- should 'call them in the order they are appended' do
38
- items = []
39
- @hookable_class.append_hook(:awesome) { items << :a }
40
- @hookable_class.append_hook(:awesome) { items << :b }
41
- @hookable_class.append_hook(:awesome) { items << :c }
42
- @hookable_class.invoke_hooks!(:awesome)
43
- [:a, :b, :c].each_with_index do |value, index|
44
- assert_equal value, items[index]
45
- end
46
- end
47
-
48
- should 'let you define hook accessors' do
49
- assert_equal [], @hookable_class.hooks_for(:awesome)
50
- assert !@hookable_class.respond_to?(:awesome)
51
- assert !@hookable_class.respond_to?(:sauce)
52
- @hookable_class.define_hook :awesome, :sauce
53
- assert @hookable_class.respond_to?(:awesome)
54
- assert @hookable_class.respond_to?(:sauce)
55
- @hookable_class.awesome { puts "A" }
56
- assert_equal 1, @hookable_class.hooks_for(:awesome).size
57
- end
58
-
59
- end
60
-
61
- end
data/test/loader_test.rb DELETED
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
@@ -1,38 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class LoggableTest < Test::Unit::TestCase
4
-
5
- class ExampleLoggable
6
- include Perennial::Loggable
7
- end
8
-
9
- context "Defining a class as loggable" do
10
-
11
- setup do
12
- @example = ExampleLoggable.new
13
- end
14
-
15
- should 'define a logger instance method' do
16
- assert @example.respond_to?(:logger)
17
- end
18
-
19
- should 'define a logger class method' do
20
- assert ExampleLoggable.respond_to?(:logger)
21
- end
22
-
23
- should 'not define a logger= instance method' do
24
- assert !@example.respond_to?(:logger=)
25
- end
26
-
27
- should 'not define a logger= class method' do
28
- assert !ExampleLoggable.respond_to?(:logger=)
29
- end
30
-
31
- should 'define logger to be an instance of Perennial::Logger' do
32
- assert_equal Perennial::Logger, ExampleLoggable.logger
33
- assert_equal Perennial::Logger, @example.logger
34
- end
35
-
36
- end
37
-
38
- end
data/test/logger_test.rb DELETED
@@ -1,59 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "test_helper")
2
-
3
- class LoggerTest < Test::Unit::TestCase
4
- context 'logger tests' do
5
-
6
- setup do
7
- @root_path = Perennial::Settings.root / "log"
8
- Perennial::Logger.log_name = "example.log"
9
- FileUtils.mkdir_p @root_path
10
- end
11
-
12
- context 'setting up a logger' do
13
-
14
- setup { Perennial::Logger.setup! }
15
-
16
- should 'create the log file file after writing' do
17
- Perennial::Logger.fatal "Blergh."
18
- assert File.exist?(@root_path / "example.log")
19
- end
20
-
21
- Perennial::Logger::LEVELS.each_key do |level_name|
22
- should "define a method for the #{level_name} log level" do
23
- assert Perennial::Logger.respond_to?(level_name)
24
- assert Perennial::Logger.logger.respond_to?(level_name)
25
- assert_equal 1, Perennial::Logger.logger.method(level_name).arity
26
- end
27
- end
28
-
29
- should 'have a log exception method' do
30
- assert Perennial::Logger.respond_to?(:log_exception)
31
- assert Perennial::Logger.logger.respond_to?(:log_exception)
32
- end
33
-
34
- should 'let you configure a dir that logs are loaded from'
35
-
36
- end
37
-
38
- context 'writing to the log' do
39
-
40
- Perennial::Logger::LEVELS.each_key do |level_name|
41
- should "let you write to the #{level_name} log level" do
42
- Perennial::Logger.verbose = false
43
- Perennial::Logger.level = level_name
44
- assert_nothing_raised do
45
- Perennial::Logger.logger.send(level_name, "An Example Message No. 1")
46
- end
47
- end
48
- end
49
-
50
- end
51
-
52
- teardown do
53
- log_path = @root_path / "example.log"
54
- FileUtils.rm_rf(log_path) if File.exist?(log_path)
55
- end
56
-
57
- end
58
-
59
- end