bootscale 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/bootscale/core_ext.rb +26 -0
- data/lib/bootscale/file_storage.rb +16 -6
- data/lib/bootscale/setup.rb +2 -26
- data/lib/bootscale/version.rb +1 -1
- data/lib/bootscale.rb +1 -1
- metadata +4 -25
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -10
- data/Gemfile +0 -18
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/bootscale.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ddc3940d5c39be4fafd2a7c813ba49fa4ec5a8a
|
4
|
+
data.tar.gz: 3df41db20b0aa76c75ba21b54b91be29851ca090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac9d2cef90836d14e9b05fbd6d965cc1d9c945898c5d7f6d7f96ce2a704be74961448b208768f0803f800150121b66592f7f2c40aca39e4303db68764b81382e
|
7
|
+
data.tar.gz: 62b77423f58c73c43bf72e30de7e4fb3950cfd87c04b6c6e75fdf2f29be428b42ac2c4c84a290b3a43b81b463b516b5cd9f86de5035955b7cfb7f75bb8e7ea79
|
data/README.md
CHANGED
@@ -3,8 +3,7 @@
|
|
3
3
|
Speedup applications boot by caching require calls.
|
4
4
|
|
5
5
|
Speed gain depends on your number of gems. Under 100 gems you likely won't see the difference,
|
6
|
-
but for bigger applications
|
7
|
-
|
6
|
+
but for bigger applications it can save 1 to 2 seconds of boot time per 100 gems in the Gemfile.
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
@@ -17,8 +16,7 @@ Then you need to add right after `require 'bundler/setup'`:
|
|
17
16
|
|
18
17
|
```ruby
|
19
18
|
require 'bundler/setup'
|
20
|
-
require 'bootscale'
|
21
|
-
Bootscale.setup(cache_directory: 'tmp/bootscale')
|
19
|
+
require 'bootscale/setup'
|
22
20
|
```
|
23
21
|
|
24
22
|
If your application is a Rails application, you will find this in `config/boot.rb`.
|
@@ -39,6 +37,10 @@ module MyApp
|
|
39
37
|
end
|
40
38
|
```
|
41
39
|
|
40
|
+
## Faster cache loading
|
41
|
+
|
42
|
+
Add the `msgpack` gem and `require 'msgpack'` to gain ~10-30ms of extra load speed by using msgpack.
|
43
|
+
|
42
44
|
## Contributing
|
43
45
|
|
44
46
|
Bug reports and pull requests are welcome on GitHub at https://github.com/byroot/bootscale.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Kernel
|
2
|
+
def require_with_cache(path)
|
3
|
+
require_without_cache(Bootscale[path] || path)
|
4
|
+
end
|
5
|
+
|
6
|
+
alias_method :require_without_cache, :require
|
7
|
+
alias_method :require, :require_with_cache
|
8
|
+
end
|
9
|
+
|
10
|
+
class << Kernel
|
11
|
+
def require_with_cache(path)
|
12
|
+
require_without_cache(Bootscale[path] || path)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :require_without_cache, :require
|
16
|
+
alias_method :require, :require_with_cache
|
17
|
+
end
|
18
|
+
|
19
|
+
class Module
|
20
|
+
def autoload_with_cache(const, path)
|
21
|
+
autoload_without_cache(const, Bootscale[path] || path)
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :autoload_without_cache, :autoload
|
25
|
+
alias_method :autoload, :autoload_with_cache
|
26
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'digest/md5'
|
2
|
-
require 'msgpack'
|
3
2
|
|
4
3
|
module Bootscale
|
5
4
|
class FileStorage
|
@@ -9,19 +8,30 @@ module Bootscale
|
|
9
8
|
|
10
9
|
def load(load_path)
|
11
10
|
path = cache_path(load_path)
|
12
|
-
|
11
|
+
Serializer.load(File.read(path)) if File.exist?(path)
|
13
12
|
end
|
14
13
|
|
15
14
|
def dump(load_path, cache)
|
16
15
|
path = cache_path(load_path)
|
17
16
|
return if File.exist?(path)
|
18
17
|
FileUtils.mkdir_p(File.dirname(path))
|
19
|
-
File.
|
18
|
+
File.write(path, Serializer.dump(cache))
|
20
19
|
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
if defined?(MessagePack)
|
22
|
+
Serializer = MessagePack
|
23
|
+
|
24
|
+
def cache_path(load_path)
|
25
|
+
hash = Digest::MD5.hexdigest((load_path + [RUBY_VERSION, Bootscale::VERSION, MessagePack::VERSION]).join('|'))
|
26
|
+
File.join(@directory, "bootscale-#{hash}.msgpack")
|
27
|
+
end
|
28
|
+
else
|
29
|
+
Serializer = Marshal
|
30
|
+
|
31
|
+
def cache_path(load_path)
|
32
|
+
hash = Digest::MD5.hexdigest((load_path + [RUBY_VERSION, Bootscale::VERSION]).join('|'))
|
33
|
+
File.join(@directory, "bootscale-#{hash}.marshal")
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
end
|
data/lib/bootscale/setup.rb
CHANGED
@@ -1,26 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_without_cache(Bootscale[path] || path)
|
4
|
-
end
|
5
|
-
|
6
|
-
alias_method :require_without_cache, :require
|
7
|
-
alias_method :require, :require_with_cache
|
8
|
-
end
|
9
|
-
|
10
|
-
class << Kernel
|
11
|
-
def require_with_cache(path)
|
12
|
-
require_without_cache(Bootscale[path] || path)
|
13
|
-
end
|
14
|
-
|
15
|
-
alias_method :require_without_cache, :require
|
16
|
-
alias_method :require, :require_with_cache
|
17
|
-
end
|
18
|
-
|
19
|
-
class Module
|
20
|
-
def autoload_with_cache(const, path)
|
21
|
-
autoload_without_cache(const, Bootscale[path] || path)
|
22
|
-
end
|
23
|
-
|
24
|
-
alias_method :autoload_without_cache, :autoload
|
25
|
-
alias_method :autoload, :autoload_with_cache
|
26
|
-
end
|
1
|
+
require 'bootscale'
|
2
|
+
Bootscale.setup(cache_directory: 'tmp/bootscale')
|
data/lib/bootscale/version.rb
CHANGED
data/lib/bootscale.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootscale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-08-24 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: msgpack
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.2
|
12
|
+
dependencies: []
|
27
13
|
description: Inspired by Aaron Patterson's talk on the subject
|
28
14
|
email:
|
29
15
|
- jean.boussier@gmail.com
|
@@ -31,18 +17,11 @@ executables: []
|
|
31
17
|
extensions: []
|
32
18
|
extra_rdoc_files: []
|
33
19
|
files:
|
34
|
-
- ".gitignore"
|
35
|
-
- ".rspec"
|
36
|
-
- ".travis.yml"
|
37
|
-
- Gemfile
|
38
20
|
- LICENSE.txt
|
39
21
|
- README.md
|
40
|
-
- Rakefile
|
41
|
-
- bin/console
|
42
|
-
- bin/setup
|
43
|
-
- bootscale.gemspec
|
44
22
|
- lib/bootscale.rb
|
45
23
|
- lib/bootscale/cache_builder.rb
|
24
|
+
- lib/bootscale/core_ext.rb
|
46
25
|
- lib/bootscale/entry.rb
|
47
26
|
- lib/bootscale/file_storage.rb
|
48
27
|
- lib/bootscale/setup.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
gem 'bundler'
|
6
|
-
gem 'rake'
|
7
|
-
gem 'rspec'
|
8
|
-
|
9
|
-
group :dummy do
|
10
|
-
gem 'rails', '4.2.3'
|
11
|
-
gem 'sqlite3'
|
12
|
-
gem 'sass-rails', '~> 5.0'
|
13
|
-
gem 'uglifier', '>= 1.3.0'
|
14
|
-
gem 'coffee-rails', '~> 4.1.0'
|
15
|
-
gem 'jquery-rails'
|
16
|
-
gem 'turbolinks'
|
17
|
-
gem 'jbuilder', '~> 2.0'
|
18
|
-
end
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "bootscale"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/bootscale.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'bootscale/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'bootscale'
|
8
|
-
spec.version = Bootscale::VERSION
|
9
|
-
spec.authors = ['Jean Boussier']
|
10
|
-
spec.email = ['jean.boussier@gmail.com']
|
11
|
-
|
12
|
-
spec.summary = %q{Speedup applications boot by caching require calls}
|
13
|
-
spec.description = %q{Inspired by Aaron Patterson's talk on the subject}
|
14
|
-
spec.homepage = "https://github.com/byroot/bootscale"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = 'exe'
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.required_ruby_version = '>= 1.9.3'
|
22
|
-
spec.add_runtime_dependency 'msgpack', '~> 0.6.2'
|
23
|
-
end
|