spork 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/mkrf_conf.rb +12 -6
- data/lib/spork/app_framework/rails.rb +29 -29
- metadata +12 -5
data/ext/mkrf_conf.rb
CHANGED
@@ -2,18 +2,24 @@ require 'rubygems'
|
|
2
2
|
require 'rubygems/command.rb'
|
3
3
|
require 'rubygems/dependency_installer.rb'
|
4
4
|
STDERR.puts "Actually, there aren't any native extensions. I'm just dynamically installing dependencies based off of your operating system"
|
5
|
-
begin
|
6
|
-
Gem::Command.build_args = ARGV
|
7
|
-
rescue NoMethodError
|
8
|
-
end
|
9
5
|
inst = Gem::DependencyInstaller.new
|
6
|
+
|
7
|
+
# this will fail if rake isn't installed.
|
10
8
|
begin
|
11
9
|
inst.install "rake"
|
12
|
-
inst.install "win32-process", "~> 0.6.1" if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
|
13
10
|
rescue
|
14
|
-
|
11
|
+
# oh well. Let it fail later.
|
15
12
|
end
|
16
13
|
|
14
|
+
if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
|
15
|
+
STDERR.puts "installing windows dependencies"
|
16
|
+
begin
|
17
|
+
inst.install "win32-process", "~> 0.6.1"
|
18
|
+
rescue
|
19
|
+
exit(1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
|
18
24
|
f.write("task :default\n")
|
19
25
|
f.close
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Spork::AppFramework::Rails < Spork::AppFramework
|
2
|
-
|
2
|
+
|
3
3
|
# TODO - subclass this out to handle different versions of rails
|
4
4
|
# Also... this is the nastiest duck punch ever. Clean this up.
|
5
5
|
module NinjaPatcher
|
@@ -9,7 +9,7 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
9
9
|
alias :load_environment_without_spork :load_environment
|
10
10
|
alias :load_environment :load_environment_with_spork
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def self.run_with_spork(*args, &block) # it's all fun and games until someone gets an eye poked out
|
14
14
|
if ENV['RAILS_ENV']
|
15
15
|
Object.send(:remove_const, :RAILS_ENV)
|
@@ -17,7 +17,7 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
17
17
|
end
|
18
18
|
run_without_spork(*args, &block)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
class << self
|
22
22
|
unless method_defined?(:run_without_spork)
|
23
23
|
alias :run_without_spork :run
|
@@ -26,13 +26,13 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def load_environment_with_spork
|
31
31
|
result = load_environment_without_spork
|
32
32
|
install_hooks
|
33
33
|
result
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def install_hooks
|
37
37
|
auto_reestablish_db_connection
|
38
38
|
delay_observer_loading
|
@@ -41,15 +41,15 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
41
41
|
delay_route_loading
|
42
42
|
delay_eager_view_loading
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def reset_rails_env
|
46
46
|
return unless ENV['RAILS_ENV']
|
47
47
|
Object.send(:remove_const, :RAILS_ENV)
|
48
48
|
Object.const_set(:RAILS_ENV, ENV['RAILS_ENV'].dup)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def delay_observer_loading
|
52
|
-
if ::Rails::Initializer.instance_methods.include?(
|
52
|
+
if ::Rails::Initializer.instance_methods.map(&:to_sym).include?(:load_observers)
|
53
53
|
Spork.trap_method(::Rails::Initializer, :load_observers)
|
54
54
|
end
|
55
55
|
if Object.const_defined?(:ActionController)
|
@@ -57,13 +57,13 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
57
57
|
Spork.trap_class_method(::ActionController::Dispatcher, :define_dispatcher_callbacks) if ActionController::Dispatcher.respond_to?(:define_dispatcher_callbacks)
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
def delay_app_preload
|
62
|
-
if ::Rails::Initializer.instance_methods.include?(
|
62
|
+
if ::Rails::Initializer.instance_methods.map(&:to_sym).include?(:load_application_classes)
|
63
63
|
Spork.trap_method(::Rails::Initializer, :load_application_classes)
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def delay_application_controller_loading
|
68
68
|
if application_controller_source = ["#{Dir.pwd}/app/controllers/application.rb", "#{Dir.pwd}/app/controllers/application_controller.rb"].find { |f| File.exist?(f) }
|
69
69
|
application_helper_source = "#{Dir.pwd}/app/helpers/application_helper.rb"
|
@@ -77,7 +77,7 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def auto_reestablish_db_connection
|
82
82
|
if Object.const_defined?(:ActiveRecord)
|
83
83
|
Spork.each_run do
|
@@ -87,20 +87,20 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def delay_route_loading
|
92
|
-
if ::Rails::Initializer.instance_methods.include?(
|
92
|
+
if ::Rails::Initializer.instance_methods.map(&:to_sym).include?(:initialize_routing)
|
93
93
|
Spork.trap_method(::Rails::Initializer, :initialize_routing)
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
def delay_eager_view_loading
|
98
|
-
# So, in testing mode it seems it would be optimal to not eager load
|
98
|
+
# So, in testing mode it seems it would be optimal to not eager load
|
99
99
|
# views (as your may only run a test that uses one or two views).
|
100
|
-
# However, I decided to delay eager loading rather than force it to
|
101
|
-
# disable because you may wish to eager load your views (I.E. you're
|
100
|
+
# However, I decided to delay eager loading rather than force it to
|
101
|
+
# disable because you may wish to eager load your views (I.E. you're
|
102
102
|
# testing concurrency)
|
103
|
-
|
103
|
+
|
104
104
|
# Rails 2.3.x +
|
105
105
|
if defined?(::ActionView::Template::EagerPath)
|
106
106
|
Spork.trap_method(::ActionView::Template::EagerPath, :load!)
|
@@ -112,7 +112,7 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
112
112
|
# Rails 2.0.5 - 2.1.x don't appear to eager cache views.
|
113
113
|
end
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def preload(&block)
|
117
117
|
STDERR.puts "Preloading Rails environment"
|
118
118
|
STDERR.flush
|
@@ -120,25 +120,25 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
120
120
|
preload_rails
|
121
121
|
yield
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def entry_point
|
125
125
|
@entry_point ||= File.expand_path("config/environment.rb", Dir.pwd)
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
alias :environment_file :entry_point
|
129
|
-
|
129
|
+
|
130
130
|
def boot_file
|
131
131
|
@boot_file ||= File.join(File.dirname(environment_file), 'boot')
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
def environment_contents
|
135
135
|
@environment_contents ||= File.read(environment_file)
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
def vendor
|
139
139
|
@vendor ||= File.expand_path("vendor/rails", Dir.pwd)
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
def version
|
143
143
|
@version ||= (
|
144
144
|
if /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/.match(environment_contents)
|
@@ -148,11 +148,11 @@ class Spork::AppFramework::Rails < Spork::AppFramework
|
|
148
148
|
end
|
149
149
|
)
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def preload_rails
|
153
153
|
Object.const_set(:RAILS_GEM_VERSION, version) if version
|
154
154
|
require boot_file
|
155
155
|
::Rails::Initializer.send(:include, Spork::AppFramework::Rails::NinjaPatcher)
|
156
156
|
end
|
157
|
-
|
158
|
-
end
|
157
|
+
|
158
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 8
|
8
|
+
- 3
|
9
|
+
version: 0.8.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tim Harper
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2010-
|
18
|
+
date: 2010-04-19 00:00:00 -06:00
|
14
19
|
default_executable: spork
|
15
20
|
dependencies: []
|
16
21
|
|
@@ -66,18 +71,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
71
|
requirements:
|
67
72
|
- - ">="
|
68
73
|
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
69
76
|
version: "0"
|
70
|
-
version:
|
71
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - ">="
|
74
80
|
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
75
83
|
version: "0"
|
76
|
-
version:
|
77
84
|
requirements: []
|
78
85
|
|
79
86
|
rubyforge_project: spork
|
80
|
-
rubygems_version: 1.3.
|
87
|
+
rubygems_version: 1.3.6
|
81
88
|
signing_key:
|
82
89
|
specification_version: 3
|
83
90
|
summary: spork
|