iseq_rails_tools 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/iseq_rails_tools.rb +15 -10
- data/lib/iseq_rails_tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41adbda1e1b89000183500297f553297069a38bf
|
4
|
+
data.tar.gz: 2037d45bda86a9e59d2a01375342bd2f13c32643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cecb536938e03c599314815ccce2a02237d2ee7c236ddd65eaea3be223a398e0f56378179664bdaea81c604c1c412b1c65d8c1933de8e781a7d413023926481d
|
7
|
+
data.tar.gz: 4e89dc8c64eca43d8306d15b40b1acec176e7c132c726b925baa05fd9c1f183ebbac928af2f720a7dd43724003fddedd4cef20a629a40d451f75a7f97ccdb7f8
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# IseqRailsTools
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/kddeisz/iseq-rails-tools.svg?branch=master)](https://travis-ci.org/kddeisz/iseq-rails-tools)
|
4
|
+
[![Gem](https://img.shields.io/gem/v/iseq_rails_tools.svg)](https://rubygems.org/gems/iseq_rails_tools)
|
4
5
|
|
5
6
|
Since Ruby 2.3, we've had the ability to dump out compiled Ruby bytecode to files to alleviate that process when ruby files are required. This can significantly boost boot times, especially when running with larger Ruby projects.
|
6
7
|
|
7
8
|
This gem hooks into ActiveSupport's autoloading in development mode to bring AOT compiling to Rails. This can improve both the console and server boot times.
|
8
9
|
|
9
|
-
When deploying to production, you can take advantage of the quicker boot times by adding the `iseq:all` rake task to your deploy script.
|
10
|
+
When deploying to production, you can take advantage of the quicker boot times by adding the `iseq:all` rake task to your deploy script. A simple way to do this is to make `iseq:all` a prerequisite of `assets:precompile`, like so: `Rake::Task['assets:precompile'].enhance(['iseq:all'])`.
|
10
11
|
|
11
12
|
## Usage
|
12
13
|
|
data/lib/iseq_rails_tools.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
require 'fileutils'
|
3
|
-
|
4
3
|
require 'iseq_rails_tools/compiler'
|
5
|
-
require 'iseq_rails_tools/railtie'
|
6
4
|
|
7
5
|
module IseqRailsTools
|
8
6
|
class NullCompiler
|
@@ -29,12 +27,19 @@ module IseqRailsTools
|
|
29
27
|
self.compiler = NullCompiler.new
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
# Only actually hook into Rails when the environment isn't test so that tools
|
31
|
+
# like simplecov will continue to function as expected. Also people do weird
|
32
|
+
# stuff in test mode, so who knows.
|
33
|
+
unless Rails.env.test?
|
34
|
+
require 'iseq_rails_tools/railtie'
|
35
|
+
|
36
|
+
RubyVM::InstructionSequence.singleton_class.prepend(Module.new do
|
37
|
+
def load_iseq(filepath)
|
38
|
+
if ::IseqRailsTools.compiler.watching?(filepath)
|
39
|
+
::IseqRailsTools.compiler.load_iseq(filepath)
|
40
|
+
elsif method(:load_iseq).super_method
|
41
|
+
super
|
42
|
+
end
|
38
43
|
end
|
39
|
-
end
|
40
|
-
end
|
44
|
+
end)
|
45
|
+
end
|