zeus 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -50,8 +50,10 @@ module Zeus
50
50
 
51
51
  pid = socket.readline.chomp.to_i
52
52
  rescue Errno::ENOENT, Errno::ECONNREFUSED, Errno::ECONNRESET
53
- Zeus.ui.error "Zeus doesn't seem to be running, try 'zeus start`"
54
- abort
53
+ # we need a \r at the end because the terminal is in raw mode.
54
+ # we need to reset the cursor to position 0
55
+ Zeus.ui.error "Zeus doesn't seem to be running, try 'zeus start`\r"
56
+ exit 1
55
57
  end
56
58
 
57
59
  def make_winch_channel
@@ -58,15 +58,13 @@ module Zeus
58
58
  File.unlink(Zeus::SOCKET_NAME)
59
59
  end
60
60
 
61
- # this is used in conjunction with Zeus::LoadTracking to track files loaded
62
- # using `load` rather than `require`.
63
61
  def add_extra_feature(full_expanded_path)
64
- @extra_loaded_features ||= []
65
- @extra_loaded_features << full_expanded_path
62
+ $extra_loaded_features ||= []
63
+ $extra_loaded_features << full_expanded_path
66
64
  end
67
65
 
68
66
  def extra_features
69
- @extra_loaded_features || []
67
+ $extra_loaded_features || []
70
68
  end
71
69
 
72
70
  # Child process API
@@ -47,11 +47,6 @@ module Zeus
47
47
 
48
48
  defined?(ActiveRecord::Base) and ActiveRecord::Base.clear_all_connections!
49
49
 
50
- new_features = newly_loaded_features()
51
- $previously_loaded_features = new_features
52
- Thread.new {
53
- new_features.each { |f| notify_feature(f) }
54
- }
55
50
  end
56
51
 
57
52
  def newly_loaded_features
@@ -74,6 +69,19 @@ module Zeus
74
69
  def after_setup
75
70
  end
76
71
 
72
+ def notify_new_features
73
+ new_features = newly_loaded_features()
74
+ $previously_loaded_features ||= []
75
+ $previously_loaded_features |= new_features
76
+ Thread.new {
77
+ new_features.each { |f| notify_feature(f) }
78
+ }
79
+ end
80
+
81
+ def after_notify
82
+ end
83
+
84
+ # TODO: This just got really ugly and needs a refactor more than ever.
77
85
  def run(close_parent_sockets = false)
78
86
  @pid = fork {
79
87
  before_setup
@@ -82,6 +90,9 @@ module Zeus
82
90
  Zeus.run_after_fork!
83
91
 
84
92
  after_setup
93
+ notify_new_features
94
+
95
+ after_notify
85
96
  runloop!
86
97
  }
87
98
  kill_pid_on_exit(@pid)
@@ -3,18 +3,13 @@ module Zeus
3
3
  class LoadTracking
4
4
 
5
5
  def self.inject!(server)
6
- mod = module_for_server(server)
7
- Object.class_eval { include mod }
8
- end
9
-
10
- def self.module_for_server(server)
11
- Module.new.tap do |load_tracking|
12
- load_tracking.send(:define_method, :load) { |file, *a|
13
- if ret = super(file, *a)
14
- LoadTracking.add_feature(server, file)
15
- end
16
- ret
17
- }
6
+ $server = server
7
+ class << Kernel
8
+ alias_method :__original_load, :load
9
+ def load(file, *a)
10
+ LoadTracking.add_feature($server, file)
11
+ __original_load(file, *a)
12
+ end
18
13
  end
19
14
  end
20
15
 
@@ -16,7 +16,9 @@ module Zeus
16
16
  rescue => e
17
17
  handle_load_error(e)
18
18
  end
19
+ end
19
20
 
21
+ def after_notify
20
22
  @pids = {}
21
23
  @stages.each do |stage|
22
24
  @pids[stage.run] = stage
@@ -1,3 +1,3 @@
1
1
  module Zeus
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["burke@libbey.me"]
7
7
  gem.description = %q{Boot any rails app in under a second}
8
8
  gem.summary = %q{Zeus is an intelligent preloader for ruby applications. It allows normal development tasks to be run in a fraction of a second.}
9
- gem.homepage = "http://github.com/burke/zeus"
9
+ gem.homepage = "https://github.com/burke/zeus"
10
10
 
11
11
  gem.files = `git ls-files`.split("\n").reject{ |f| f =~ /xcodeproj/ }
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -14,4 +14,5 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "zeus"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Zeus::VERSION
17
+ gem.license = "MIT"
17
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Boot any rails app in under a second
15
15
  email:
@@ -23,7 +23,7 @@ files:
23
23
  - .travis.yml
24
24
  - .zeus.rb
25
25
  - Gemfile
26
- - LICENSE
26
+ - MIT-LICENSE
27
27
  - README.md
28
28
  - Rakefile
29
29
  - bin/zeus
@@ -52,8 +52,9 @@ files:
52
52
  - spec/server/process_tree_monitor_spec.rb
53
53
  - spec/ui_spec.rb
54
54
  - zeus.gemspec
55
- homepage: http://github.com/burke/zeus
56
- licenses: []
55
+ homepage: https://github.com/burke/zeus
56
+ licenses:
57
+ - MIT
57
58
  post_install_message:
58
59
  rdoc_options: []
59
60
  require_paths: