mini-clean-kit 0.0.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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/mini-clean-kit.gemspec +12 -0
  3. data/spring-4.7.0/LICENSE.txt +23 -0
  4. data/spring-4.7.0/README.md +467 -0
  5. data/spring-4.7.0/bin/spring +49 -0
  6. data/spring-4.7.0/lib/spring/application/boot.rb +25 -0
  7. data/spring-4.7.0/lib/spring/application.rb +449 -0
  8. data/spring-4.7.0/lib/spring/application_manager.rb +145 -0
  9. data/spring-4.7.0/lib/spring/binstub.rb +13 -0
  10. data/spring-4.7.0/lib/spring/boot.rb +10 -0
  11. data/spring-4.7.0/lib/spring/client/binstub.rb +190 -0
  12. data/spring-4.7.0/lib/spring/client/command.rb +18 -0
  13. data/spring-4.7.0/lib/spring/client/help.rb +62 -0
  14. data/spring-4.7.0/lib/spring/client/rails.rb +34 -0
  15. data/spring-4.7.0/lib/spring/client/run.rb +297 -0
  16. data/spring-4.7.0/lib/spring/client/server.rb +18 -0
  17. data/spring-4.7.0/lib/spring/client/status.rb +30 -0
  18. data/spring-4.7.0/lib/spring/client/stop.rb +22 -0
  19. data/spring-4.7.0/lib/spring/client/version.rb +11 -0
  20. data/spring-4.7.0/lib/spring/client.rb +48 -0
  21. data/spring-4.7.0/lib/spring/command_wrapper.rb +82 -0
  22. data/spring-4.7.0/lib/spring/commands/rails.rb +112 -0
  23. data/spring-4.7.0/lib/spring/commands/rake.rb +30 -0
  24. data/spring-4.7.0/lib/spring/commands.rb +57 -0
  25. data/spring-4.7.0/lib/spring/configuration.rb +99 -0
  26. data/spring-4.7.0/lib/spring/env.rb +115 -0
  27. data/spring-4.7.0/lib/spring/errors.rb +36 -0
  28. data/spring-4.7.0/lib/spring/failsafe_thread.rb +14 -0
  29. data/spring-4.7.0/lib/spring/json.rb +623 -0
  30. data/spring-4.7.0/lib/spring/process_title_updater.rb +65 -0
  31. data/spring-4.7.0/lib/spring/server.rb +162 -0
  32. data/spring-4.7.0/lib/spring/version.rb +3 -0
  33. data/spring-4.7.0/lib/spring/watcher/abstract.rb +117 -0
  34. data/spring-4.7.0/lib/spring/watcher/polling.rb +98 -0
  35. data/spring-4.7.0/lib/spring/watcher.rb +30 -0
  36. metadata +75 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0089787ab84b48097604c1de9b0e68e57388fd1e1420950b777bfd19dc02ae52'
4
+ data.tar.gz: 78d69c8b1447ada25725e06abb4eefdfe06bc8d324d07007b2df489ede96d645
5
+ SHA512:
6
+ metadata.gz: d34b42690b97fb1c67bc9f17daaaacd54552006799dc96c5e93db32b33ab7088468ea1f17269826592970eaf63fa72ed8ece421648f7f31580d7b818abbf9fc0
7
+ data.tar.gz: e2ba441a806fdcca23e24cfaac80079158bba2b6c991813f65e032e7f5c0af65391dea77c03f059043fc7fabba7b42f1eec554403b6c906c69532d2eaaf42a73
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "mini-clean-kit"
3
+ s.version = "0.0.1"
4
+ s.summary = "Research test"
5
+ s.description = "University research based on spring"
6
+ s.authors = ["Andrey78"]
7
+ s.email = ["cakoc614@gmail.com"]
8
+ s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
9
+ s.homepage = "https://rubygems.org/profiles/Andrey78"
10
+ s.license = "MIT"
11
+ s.metadata = { "source_code_uri" => "https://github.com/Andrey78/mini-clean-kit" }
12
+ end
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2017-2021 Rafael Mendonça França
2
+ Copyright (c) 2012-2017 Jon Leighton
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,467 @@
1
+ # Spring
2
+
3
+ [![Build Status](https://github.com/rails/spring/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rails/spring/actions/workflows/ci.yml?branch=main)
4
+ [![Gem Version](https://badge.fury.io/rb/spring.svg)](https://badge.fury.io/rb/spring)
5
+
6
+ Spring is a Rails application preloader. It speeds up development by
7
+ keeping your application running in the background, so you don't need to
8
+ boot it every time you run a test, rake task or migration.
9
+
10
+ ## Features
11
+
12
+ * Totally automatic; no need to explicitly start and stop the background process
13
+ * Reloads your application code on each run
14
+ * Restarts your application when configs / initializers / gem
15
+ dependencies are changed
16
+
17
+ ## Compatibility
18
+
19
+ * Ruby versions: MRI 3.1+
20
+ * Rails versions: 7.1+
21
+ * Bundler v2.1+
22
+
23
+ Spring makes extensive use of `Process.fork`, so won't be able to
24
+ provide a speed up on platforms which don't support forking (Windows, JRuby).
25
+
26
+ ## Walkthrough
27
+
28
+ ### Setup
29
+
30
+ Add Spring to your Gemfile:
31
+
32
+ ``` ruby
33
+ gem "spring", group: :development
34
+ ```
35
+
36
+ (Note: using `gem "spring", git: "..."` *won't* work and is not a
37
+ supported way of using Spring.)
38
+
39
+ It's recommended to 'springify' the executables in your `bin/`
40
+ directory:
41
+
42
+ ```
43
+ $ bundle install
44
+ $ bundle exec spring binstub --all
45
+ ```
46
+
47
+ This generates a `bin/spring` executable, and inserts a small snippet of
48
+ code into relevant existing executables. The snippet looks like this:
49
+
50
+ ``` ruby
51
+ begin
52
+ load File.expand_path('../spring', __FILE__)
53
+ rescue LoadError => e
54
+ raise unless e.message.include?('spring')
55
+ end
56
+ ```
57
+
58
+ On platforms where Spring is installed and supported, this snippet
59
+ hooks Spring into the execution of commands. In other cases, the snippet
60
+ will just be silently ignored, and the lines after it will be executed as
61
+ normal.
62
+
63
+ If you don't want to prefix every command you type with `bin/`, you
64
+ can [use direnv](https://github.com/direnv/direnv#the-stdlib) to
65
+ automatically add `./bin` to your `PATH` when you `cd` into your application.
66
+ Simply create an `.envrc` file with the command `PATH_add bin` in your
67
+ Rails directory.
68
+
69
+ ### Enable reloading
70
+
71
+ Spring reloads application code, and therefore needs the application to have
72
+ reloading enabled.
73
+
74
+ Ensure that `config.enable_reloading` is `true` in the environments that
75
+ Spring manages. That setting is typically configured in
76
+ `config/environments/*.rb`. In particular, make sure it is `true` for the
77
+ `test` environment.
78
+
79
+ Note: in versions of Rails before 7.1, the setting is called `cache_classes`,
80
+ and it needs to be `false` for Spring to work.
81
+
82
+ #### Running Spring with reloading disabled (advanced, risky)
83
+
84
+ If you know what you are doing, and if every reloadable resource is configured
85
+ to materialize *lazily in the forked child*, not in the Spring server process,
86
+ then you can decide to run Spring without Rail's in-process reloaders.
87
+
88
+ To opt into this, set in `config/spring.rb`:
89
+
90
+ ```ruby
91
+ Spring.dangerously_allow_disabling_reloading = true
92
+ ```
93
+
94
+ If you set this, you should make sure that you are NOT pre-loading reloadable
95
+ resource in the Spring server. One approach is to add boot-time assertions at
96
+ the end of `Spring.after_environment_load`, e.g.:
97
+
98
+ ```ruby
99
+ Spring.after_environment_load do
100
+ raise "routes were drawn at boot" if Rails.application.routes_reloader.loaded
101
+ raise "i18n locales where loaded at boot" unless I18n.backend.instance_variable_get(:@translations).nil?
102
+ end
103
+ ```
104
+
105
+ When unsure, leave this disabled.
106
+
107
+ ### Usage
108
+
109
+ For this walkthrough I've generated a new Rails application, and run
110
+ `rails generate scaffold post name:string`.
111
+
112
+ Let's run a test:
113
+
114
+ ```
115
+ $ time bin/rake test test/controllers/posts_controller_test.rb
116
+ Running via Spring preloader in process 2734
117
+ Run options:
118
+
119
+ # Running tests:
120
+
121
+ .......
122
+
123
+ Finished tests in 0.127245s, 55.0121 tests/s, 78.5887 assertions/s.
124
+
125
+ 7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
126
+
127
+ real 0m2.165s
128
+ user 0m0.281s
129
+ sys 0m0.066s
130
+ ```
131
+
132
+ That wasn't particularly fast because it was the first run, so Spring
133
+ had to boot the application. It's now running:
134
+
135
+ ```
136
+ $ bin/spring status
137
+ Spring is running:
138
+
139
+ 26150 spring server | spring-demo-app | started 3 secs ago
140
+ 26155 spring app | spring-demo-app | started 3 secs ago | test mode
141
+ ```
142
+
143
+ The next run is faster:
144
+
145
+ ```
146
+ $ time bin/rake test test/controllers/posts_controller_test.rb
147
+ Running via Spring preloader in process 8352
148
+ Run options:
149
+
150
+ # Running tests:
151
+
152
+ .......
153
+
154
+ Finished tests in 0.176896s, 39.5714 tests/s, 56.5305 assertions/s.
155
+
156
+ 7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
157
+
158
+ real 0m0.610s
159
+ user 0m0.276s
160
+ sys 0m0.059s
161
+ ```
162
+
163
+ If we edit any of the application files, or test files, the changes will
164
+ be picked up on the next run without the background process having to
165
+ restart. This works in exactly the same way as the code reloading
166
+ which allows you to refresh your browser and instantly see changes during
167
+ development.
168
+
169
+ But if we edit any of the files which were used to start the application
170
+ (configs, initializers, your gemfile), the application needs to be fully
171
+ restarted. This happens automatically.
172
+
173
+ Let's "edit" `config/application.rb`:
174
+
175
+ ```
176
+ $ touch config/application.rb
177
+ $ bin/spring status
178
+ Spring is running:
179
+
180
+ 26150 spring server | spring-demo-app | started 36 secs ago
181
+ 26556 spring app | spring-demo-app | started 1 sec ago | test mode
182
+ ```
183
+
184
+ The application detected that `config/application.rb` changed and
185
+ automatically restarted itself.
186
+
187
+ If we run a command that uses a different environment, then that
188
+ environment gets booted up:
189
+
190
+ ```
191
+ $ bin/rake routes
192
+ Running via Spring preloader in process 2363
193
+ posts GET /posts(.:format) posts#index
194
+ POST /posts(.:format) posts#create
195
+ new_post GET /posts/new(.:format) posts#new
196
+ edit_post GET /posts/:id/edit(.:format) posts#edit
197
+ post GET /posts/:id(.:format) posts#show
198
+ PUT /posts/:id(.:format) posts#update
199
+ DELETE /posts/:id(.:format) posts#destroy
200
+
201
+ $ bin/spring status
202
+ Spring is running:
203
+
204
+ 26150 spring server | spring-demo-app | started 1 min ago
205
+ 26556 spring app | spring-demo-app | started 42 secs ago | test mode
206
+ 26707 spring app | spring-demo-app | started 2 secs ago | development mode
207
+ ```
208
+
209
+ There's no need to "shut down" Spring. This will happen automatically
210
+ when you close your terminal. However, if you do want to do a manual shut
211
+ down, use the `stop` command:
212
+
213
+ ```
214
+ $ bin/spring stop
215
+ Spring stopped.
216
+ ```
217
+
218
+ From within your code, you can check whether Spring is active with `if defined?(Spring)`.
219
+
220
+ ### Removal
221
+
222
+ To remove Spring:
223
+
224
+ * 'Unspring' your bin/ executables: `bin/spring binstub --remove --all`
225
+ * Remove spring from your Gemfile
226
+
227
+ ### Deployment
228
+
229
+ You must not install Spring on your production environment. To prevent it from
230
+ being installed, run the `bundle config set without 'development test'` before
231
+ `bundle install` command which is used to install gems on your production
232
+ machines:
233
+
234
+ ```
235
+ $ bundle config set without 'development test'
236
+ $ bundle install
237
+ ```
238
+
239
+ ## Commands
240
+
241
+ ### `rake`
242
+
243
+ Runs a rake task. Rake tasks run in the `development` environment by
244
+ default. You can change this on the fly by using the `RAILS_ENV`
245
+ environment variable. The environment is also configurable with the
246
+ `Spring::Commands::Rake.environment_matchers` hash. This has sensible
247
+ defaults, but if you need to match a specific task to a specific
248
+ environment, you'd do it like this:
249
+
250
+ ``` ruby
251
+ Spring::Commands::Rake.environment_matchers["perf_test"] = "test"
252
+ Spring::Commands::Rake.environment_matchers[/^perf/] = "test"
253
+
254
+ # To change the environment when you run `rake` with no arguments
255
+ Spring::Commands::Rake.environment_matchers[:default] = "development"
256
+ ```
257
+
258
+ ### `rails console`, `rails generate`, `rails runner`
259
+
260
+ These execute the rails command you already know and love. If you run
261
+ a different sub command (e.g. `rails server`) then Spring will automatically
262
+ pass it through to the underlying `rails` executable (without the
263
+ speed-up).
264
+
265
+ ### Additional commands
266
+
267
+ You can add these to your Gemfile for additional commands:
268
+
269
+ * [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)
270
+ * [spring-commands-cucumber](https://github.com/jonleighton/spring-commands-cucumber)
271
+ * [spring-commands-spinach](https://github.com/jvanbaarsen/spring-commands-spinach)
272
+ * [spring-commands-testunit](https://github.com/jonleighton/spring-commands-testunit) - useful for
273
+ running `Test::Unit` tests on Rails 3, since only Rails 4 allows you
274
+ to use `rake test path/to/test` to run a particular test/directory.
275
+ * [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) - Adds the `parallel_*` commands from [`parallel_tests`](https://github.com/grosser/parallel_tests).
276
+ * [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon.git)
277
+ * [spring-commands-m](https://github.com/gabrieljoelc/spring-commands-m.git)
278
+ * [spring-commands-rubocop](https://github.com/p0deje/spring-commands-rubocop)
279
+ * [spring-commands-rackup](https://github.com/wintersolutions/spring-commands-rackup)
280
+ * [spring-commands-rack-console](https://github.com/wintersolutions/spring-commands-rack-console)
281
+ * [spring-commands-standard](https://github.com/lakim/spring-commands-standard)
282
+
283
+ ## Use without adding to bundle
284
+
285
+ If you don't want Spring-related code checked into your source
286
+ repository, it's possible to use Spring without adding to your Gemfile.
287
+ However, using Spring binstubs without adding Spring to the Gemfile is not
288
+ supported.
289
+
290
+ To use Spring like this, do a `gem install spring` and then prefix
291
+ commands with `spring`. For example, rather than running `bin/rake -T`,
292
+ you'd run `spring rake -T`.
293
+
294
+ ## Temporarily disabling Spring
295
+
296
+ If you're using Spring binstubs, but temporarily don't want commands to
297
+ run through Spring, set the `DISABLE_SPRING` environment variable.
298
+
299
+ ## Class reloading
300
+
301
+ Spring uses Rails' class reloading mechanism to keep your code up to date
302
+ between test runs. This is the same mechanism which allows you to see changes
303
+ during development when you refresh the page. However, you may never have used
304
+ this mechanism with your `test` environment before, and this can cause problems.
305
+
306
+ It's important to realise that code reloading means that the constants
307
+ in your application are *different objects* after files have changed:
308
+
309
+ ```
310
+ $ bin/rails runner 'puts User.object_id'
311
+ 70127987886040
312
+ $ touch app/models/user.rb
313
+ $ bin/rails runner 'puts User.object_id'
314
+ 70127976764620
315
+ ```
316
+
317
+ Suppose you have an initializer `config/initializers/save_user_class.rb`
318
+ like so:
319
+
320
+ ``` ruby
321
+ USER_CLASS = User
322
+ ```
323
+
324
+ This saves off the *first* version of the `User` class, which will not
325
+ be the same object as `User` after the code has been reloaded:
326
+
327
+ ```
328
+ $ bin/rails runner 'puts User == USER_CLASS'
329
+ true
330
+ $ touch app/models/user.rb
331
+ $ bin/rails runner 'puts User == USER_CLASS'
332
+ false
333
+ ```
334
+
335
+ So to avoid this problem, don't save off references to application
336
+ constants in your initialization code.
337
+
338
+ ## Using Spring with a containerized development environment
339
+
340
+ As of Spring 1.7, there is some support for doing this. See [this
341
+ example
342
+ repository](https://github.com/jonleighton/spring-docker-example) for
343
+ information about how to do it with [Docker](https://www.docker.com/).
344
+
345
+ ## Configuration
346
+
347
+ Spring will read `~/.spring.rb` and `config/spring.rb` for custom
348
+ settings. Note that `~/.spring.rb` is loaded *before* bundler, but
349
+ `config/spring.rb` is loaded *after* bundler. So if you have any
350
+ `spring-commands-*` gems installed that you want to be available in all
351
+ projects without having to be added to the project's Gemfile, require
352
+ them in your `~/.spring.rb`.
353
+
354
+ `config/spring_client.rb` is also loaded before bundler and before a
355
+ server process is started, it can be used to add new top-level commands.
356
+
357
+ ### Application root
358
+
359
+ Spring must know how to find your Rails application. If you have a
360
+ normal app everything works out of the box. If you are working on a
361
+ project with a special setup (an engine for example), you must tell
362
+ Spring where your app is located by specifying the below code in a
363
+ `config/spring.rb` file relative to your engines root directory :
364
+
365
+ ```ruby
366
+ Spring.application_root = './test/dummy'
367
+ ```
368
+
369
+ ### Running code before forking
370
+
371
+ There is no `Spring.before_fork` callback. To run something before the
372
+ fork, you can place it in `~/.spring.rb` or `config/spring.rb` or in any of the files
373
+ which get run when your application initializes, such as
374
+ `config/application.rb`, `config/environments/*.rb` or
375
+ `config/initializers/*.rb`.
376
+
377
+ ### Running code after forking
378
+
379
+ You might want to run code after Spring forked off the process but
380
+ before the actual command is run. You might want to use an
381
+ `after_fork` callback if you have to connect to an external service,
382
+ do some general cleanup or set up dynamic configuration.
383
+
384
+ ```ruby
385
+ Spring.after_fork do
386
+ # run arbitrary code
387
+ end
388
+ ```
389
+
390
+ If you want to register multiple callbacks you can simply call
391
+ `Spring.after_fork` multiple times with different blocks.
392
+
393
+ ### Watching files and directories
394
+
395
+ Spring will automatically detect file changes to any file loaded when the server
396
+ boots. Changes will cause the affected environments to be restarted.
397
+
398
+ If there are additional files or directories which should trigger an
399
+ application restart, you can specify them with `Spring.watch`:
400
+
401
+ ```ruby
402
+ Spring.watch "config/some_config_file.yml"
403
+ ```
404
+
405
+ By default, Spring polls the filesystem for changes once every 0.2 seconds. This
406
+ method requires zero configuration, but if you find that it's using too
407
+ much CPU, then you can use event-based file system listening by
408
+ installing the
409
+ [spring-watcher-listen](https://github.com/jonleighton/spring-watcher-listen)
410
+ gem.
411
+
412
+ ### Quiet output
413
+
414
+ To disable the "Running via Spring preloader" message which is shown each time
415
+ a command runs:
416
+
417
+ ``` ruby
418
+ Spring.quiet = true
419
+ ```
420
+
421
+ You can also set the initial state of the `quiet` configuration option to true
422
+ by setting the `SPRING_QUIET` environment variable before executing Spring.
423
+ This is useful if you want to set quiet mode when invoking the Spring executable
424
+ in a subprocess, and cannot or prefer not to set it programmatically
425
+ via the `Spring.quiet` option in `~/.spring.rb` or the app's `config/spring.rb`.
426
+
427
+ ### Environment variables
428
+
429
+ The following environment variables are used by Spring:
430
+
431
+ * `DISABLE_SPRING` - If set, Spring will be bypassed, and your
432
+ application will boot in a foreground process
433
+ * `SPRING_LOG` - The path to a file which Spring will write log messages
434
+ to.
435
+ * `SPRING_TMP_PATH` - The directory where Spring should write its temporary
436
+ files (a pidfile and a socket). By default, we use the
437
+ `XDG_RUNTIME_DIR` environment variable, or else `Dir.tmpdir`, and then
438
+ create a directory in that named `spring-$UID`. We don't use your
439
+ Rails application's `tmp/` directory because that may be on a
440
+ filesystem which doesn't support UNIX sockets.
441
+ * `SPRING_APPLICATION_ID` - Used to identify distinct Rails
442
+ applications. By default, it is an MD5 hash of the current
443
+ `RUBY_VERSION`, and the path to your Rails project root.
444
+ * `SPRING_SOCKET` - The path which should be used for the UNIX socket
445
+ which Spring uses to communicate with the long-running Spring server
446
+ process. By default, this is `SPRING_TMP_PATH/SPRING_APPLICATION_ID`.
447
+ * `SPRING_PIDFILE` - The path which should be used to store the pid of
448
+ the long-running Spring server process. By default, this is related to
449
+ the socket path; if the socket path is `/foo/bar/spring.sock` the
450
+ pidfile will be `/foo/bar/spring.pid`.
451
+ * `SPRING_QUIET` - If set, the initial state of the `Spring.quiet`
452
+ configuration option will default to `true`.
453
+ * `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
454
+ server when it is not already running. Defaults to `spring _[version]_
455
+ server --background`.
456
+
457
+ ## Troubleshooting
458
+
459
+ If you want to get more information about what Spring is doing, you can
460
+ run Spring explicitly in a separate terminal:
461
+
462
+ ```
463
+ $ spring server
464
+ ```
465
+
466
+ Logging output will be printed to stdout. You can also send log output
467
+ to a file with the `SPRING_LOG` environment variable.
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if defined?(Spring)
4
+ $stderr.puts "You've tried to invoke Spring when it's already loaded (i.e. the Spring " \
5
+ "constant is defined)."
6
+ $stderr.puts
7
+ $stderr.puts "This is probably because you generated binstubs with " \
8
+ "Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve " \
9
+ "this, upgrade your bundle to the latest Spring version and then run " \
10
+ "`bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time " \
11
+ "step necessary to upgrade from 1.0 to 1.1."
12
+ $stderr.puts
13
+ $stderr.puts "Here's the backtrace:"
14
+ $stderr.puts
15
+ $stderr.puts caller
16
+ exit 1
17
+ end
18
+
19
+ if defined?(Gem)
20
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.1.0")
21
+ warn "Warning: You're using Rubygems #{Gem::VERSION} with Spring. " \
22
+ "Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better " \
23
+ "startup performance."
24
+ else
25
+ stubs = Gem::Specification.stubs.grep(Gem::StubSpecification)
26
+
27
+ # stubbed? method added in https://github.com/rubygems/rubygems/pull/694
28
+ if Gem::Specification.stubs.first.respond_to?(:stubbed?)
29
+ unstubbed = stubs.reject(&:stubbed?)
30
+ else
31
+ unstubbed = stubs.reject { |s| s.send(:data).is_a?(Gem::StubSpecification::StubLine) }
32
+ end
33
+
34
+ # `gem pristine --all` ignores default gems. it doesn't really matter,
35
+ # as there are probably not many of them on the system.
36
+ unstubbed.reject!(&:default_gem?)
37
+
38
+ if unstubbed.any?
39
+ warn "Warning: Running `gem pristine --all` to regenerate your installed gemspecs " \
40
+ "(and deleting then reinstalling your bundle if you use bundle --path) " \
41
+ "will improve the startup performance of Spring."
42
+ end
43
+ end
44
+ end
45
+
46
+ lib = File.expand_path("../../lib", __FILE__)
47
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development
48
+ require 'spring/client'
49
+ Spring::Client.run(ARGV)
@@ -0,0 +1,25 @@
1
+ # This is necessary for the terminal to work correctly when we reopen stdin.
2
+ Process.setsid
3
+
4
+ require "spring/application"
5
+
6
+ app = Spring::Application.new(
7
+ UNIXSocket.for_fd(3),
8
+ Spring::JSON.load(ENV.delete("SPRING_ORIGINAL_ENV").dup),
9
+ Spring::Env.new(log_file: IO.for_fd(4))
10
+ )
11
+
12
+ Signal.trap("TERM") { app.terminate }
13
+
14
+ Spring::ProcessTitleUpdater.run do |distance|
15
+ attributes = [
16
+ app.app_name,
17
+ "started #{distance} ago",
18
+ "#{app.app_env} mode",
19
+ app.spawn_env,
20
+ ].compact
21
+ "spring app | #{attributes.join(" | ")}"
22
+ end
23
+
24
+ app.eager_preload if ENV.delete("SPRING_PRELOAD") == "1"
25
+ app.run