mr-sparkle 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +2 -2
- data/lib/mr-sparkle.rb +1 -1
- data/lib/mr-sparkle/version.rb +1 -1
- data/mr-sparkle.gemspec +9 -9
- data/spec/fixtures/full_reload/Gemfile +1 -1
- data/spec/fixtures/hello/Gemfile +1 -1
- data/spec/full_reload_spec.rb +8 -0
- data/spec/spec_helper.rb +18 -1
- metadata +39 -38
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Mr. Sparkle - The Magical Reloading
|
1
|
+
# Mr. Sparkle - The Magical Reloading Rack Server
|
2
2
|
|
3
|
-
This gem contains a script to start a [Unicorn](http://unicorn.bogomips.org/)-based server for your [Rack](http://rack.github.com/) application that reloads your automatically when
|
3
|
+
This gem contains a script to start a [Unicorn](http://unicorn.bogomips.org/)-based server for your [Rack](http://rack.github.com/) application that reloads your application code automatically when its files are changed, but doesn't incur the penalty of reloading all the gem dependencies. It's based on Jonathan D. Stott's blog post ["Magical Reloading Sparkles"](http://namelessjon.posterous.com/magical-reloading-sparkles)--hence the name. (The name is also a Simpsons reference. [CAN YOU SEE THAT I AM SERIOUS?](http://www.youtube.com/watch?v=dnaLRbbc-54))
|
4
4
|
|
5
5
|
The main purpose of this gem is to take Jonathan's idea and package it into something can "just work" without having to be customized inside each project's code. Besides the gem packaging, this code differs from the original watcher script in the following ways:
|
6
6
|
|
data/lib/mr-sparkle.rb
CHANGED
@@ -6,7 +6,7 @@ module Mr
|
|
6
6
|
|
7
7
|
DEFAULT_RELOAD_PATTERN = /\.(?:builder|coffee|creole|css|erb|erubis|haml|html|js|less|liquid|mab|markdown|md|mdown|mediawiki|mkd|mw|nokogiri|radius|rb|rdoc|rhtml|ru|sass|scss|str|textile|txt|wiki|yajl|yml)$/
|
8
8
|
|
9
|
-
DEFAULT_FULL_RELOAD_PATTERN = /^Gemfile
|
9
|
+
DEFAULT_FULL_RELOAD_PATTERN = /^Gemfile(?:\.lock)?$/
|
10
10
|
|
11
11
|
class Daemon
|
12
12
|
|
data/lib/mr-sparkle/version.rb
CHANGED
data/mr-sparkle.gemspec
CHANGED
@@ -17,18 +17,18 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.add_dependency("unicorn", '
|
21
|
-
gem.add_dependency("listen", '
|
20
|
+
gem.add_dependency("unicorn", '>= 4.5')
|
21
|
+
gem.add_dependency("listen", '>= 0.6')
|
22
22
|
|
23
23
|
# Only one of these can actually be used on a given platform, but they
|
24
24
|
# can both be installed OK--see the note about this at:
|
25
25
|
# https://github.com/guard/guard#efficient-filesystem-handling
|
26
|
-
gem.add_dependency('rb-inotify', '
|
27
|
-
gem.add_dependency('rb-fsevent', '
|
26
|
+
gem.add_dependency('rb-inotify', '>= 0.8')
|
27
|
+
gem.add_dependency('rb-fsevent', '>= 0.9')
|
28
28
|
|
29
|
-
gem.add_development_dependency('minitest', '
|
30
|
-
gem.add_development_dependency('minitest-reporters', '
|
31
|
-
gem.add_development_dependency('minitest-around', '
|
32
|
-
gem.add_development_dependency('rack', '
|
33
|
-
gem.add_development_dependency('rake', '
|
29
|
+
gem.add_development_dependency('minitest', '>= 4.3')
|
30
|
+
gem.add_development_dependency('minitest-reporters', '>= 0.13')
|
31
|
+
gem.add_development_dependency('minitest-around', '>= 0.0')
|
32
|
+
gem.add_development_dependency('rack', '>= 1.4')
|
33
|
+
gem.add_development_dependency('rake', '>= 10.0')
|
34
34
|
end
|
data/spec/fixtures/hello/Gemfile
CHANGED
data/spec/full_reload_spec.rb
CHANGED
@@ -38,4 +38,12 @@ describe "App Runner: Full Reloading" do
|
|
38
38
|
watch_until_change_detected
|
39
39
|
app_request('/').body.must_equal("This file was changed.\nThis string is from a gem and this time it will show changes.")
|
40
40
|
end
|
41
|
+
|
42
|
+
it "recovers if the app becomes unstartable" do
|
43
|
+
change_file('Gemfile', /^#A sample/, 'THIS LINE IS BAD')
|
44
|
+
start_app
|
45
|
+
change_file('Gemfile', /^THIS LINE IS BAD/, '# Now this line is OK again')
|
46
|
+
watch_until_change_detected
|
47
|
+
app_request('/').body.must_equal(INITIAL_STRING)
|
48
|
+
end
|
41
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -44,10 +44,18 @@ class ServerAppTest < MiniTest::Spec
|
|
44
44
|
@app_stdout, app_stdout_w = IO.pipe
|
45
45
|
@app_stderr, app_stderr_w = IO.pipe
|
46
46
|
Bundler.with_clean_env do
|
47
|
+
# Need to generate the right Gemfile.lock so that we don't generate it
|
48
|
+
# from the app itself, creating spurious reload events
|
49
|
+
unless File.exists?(File.expand_path('Gemfile.lock', running_app_dir))
|
50
|
+
Kernel.system('bundle install --local', chdir: running_app_dir,
|
51
|
+
in: '/dev/null', out: '/dev/null', err: '/dev/null')
|
52
|
+
end
|
47
53
|
@app_pid = Kernel.spawn(
|
48
54
|
app_command, *app_args, '--', '-l', @app_socket_path,
|
49
55
|
{pgroup: true, chdir: running_app_dir,
|
50
|
-
in: '/dev/null', out: app_stdout_w, err: app_stderr_w
|
56
|
+
in: '/dev/null', out: app_stdout_w, err: app_stderr_w})
|
57
|
+
app_stdout_w.close
|
58
|
+
app_stderr_w.close
|
51
59
|
end
|
52
60
|
|
53
61
|
@old_handler = Signal.trap(:EXIT) do
|
@@ -114,6 +122,15 @@ class ServerAppTest < MiniTest::Spec
|
|
114
122
|
yield
|
115
123
|
rescue Exception=>e
|
116
124
|
puts e.inspect
|
125
|
+
stop_app
|
126
|
+
begin
|
127
|
+
Timeout.timeout(1) do
|
128
|
+
puts "App stdout: #{@app_stdout.read}"
|
129
|
+
puts "App stderr: #{@app_stderr.read}"
|
130
|
+
end
|
131
|
+
rescue Exception=>f
|
132
|
+
puts "Exception while printing app stderr/stdout: #{f.inspect}"
|
133
|
+
end
|
117
134
|
raise
|
118
135
|
ensure
|
119
136
|
stop_app
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mr-sparkle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,152 +9,152 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: unicorn
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 4.5
|
21
|
+
version: '4.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.5
|
29
|
+
version: '4.5'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: listen
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.6
|
37
|
+
version: '0.6'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.6
|
45
|
+
version: '0.6'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rb-inotify
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.8
|
53
|
+
version: '0.8'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.8
|
61
|
+
version: '0.8'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rb-fsevent
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.9
|
69
|
+
version: '0.9'
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.9
|
77
|
+
version: '0.9'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: minitest
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ! '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 4.3
|
85
|
+
version: '4.3'
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 4.3
|
93
|
+
version: '4.3'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: minitest-reporters
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.13
|
101
|
+
version: '0.13'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.13
|
109
|
+
version: '0.13'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: minitest-around
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.0
|
117
|
+
version: '0.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.0
|
125
|
+
version: '0.0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rack
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.4
|
133
|
+
version: '1.4'
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 1.4
|
141
|
+
version: '1.4'
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: rake
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
147
|
-
- -
|
147
|
+
- - ! '>='
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 10.0
|
149
|
+
version: '10.0'
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
153
|
none: false
|
154
154
|
requirements:
|
155
|
-
- -
|
155
|
+
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 10.0
|
157
|
+
version: '10.0'
|
158
158
|
description: This gem contains a script to start a Unicorn-based server for your Rack
|
159
159
|
application that reloads your automatically when they are changed, but doesn't incur
|
160
160
|
the penalty of reloading all the gem dependencies. It's based on Jonathan D. Stott's
|
@@ -167,6 +167,7 @@ extensions: []
|
|
167
167
|
extra_rdoc_files: []
|
168
168
|
files:
|
169
169
|
- .gitignore
|
170
|
+
- .travis.yml
|
170
171
|
- CHANGES.md
|
171
172
|
- Gemfile
|
172
173
|
- LICENSE.txt
|