iseq_rails_tools 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a802839bd0e4261a2dd82d40a707494ba223eef
4
- data.tar.gz: 923dc5b3171c51ed69f92585fe532649c0bbd4df
3
+ metadata.gz: 38cc126c4ad1685ae0d5566b172d1b46866a0700
4
+ data.tar.gz: 78f7769d2ece39c928a636b8c56629c129304032
5
5
  SHA512:
6
- metadata.gz: 50a3674a4d4fde446ff856eba2a06326c380718194946a6a38c22d3ba7ea55ae7054d878a78b29b2ad75b74fca47a85d1458c51dc128fabe3aa18cecabb3d696
7
- data.tar.gz: abe87ccfbfd509e806b90b33ead97e5e002ced034633631a693dd47d0be6334f711ab61c089ea613794a68300831107d7099cc97746492f92c3bf96f7b5c5807
6
+ metadata.gz: c3fc6829a53d4bcf72a82de0aade64f8449414b3d72e7e2890504f012059b0a955723d39fa3afa0cee0ade773cf9d1f771e6938359d325500e50a79ff7299c12
7
+ data.tar.gz: 2b95b97e1b814c400672b85624517583b283071617a5843abb56fd3859e3e4919dbd9ae9f3cfd92e2e61c949aa635716a9bcc657af7bc489769ed3a4bda54517
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/kddeisz/iseq-rails-tools.svg?branch=master)](https://travis-ci.org/kddeisz/iseq-rails-tools)
4
4
  [![Gem](https://img.shields.io/gem/v/iseq_rails_tools.svg)](https://rubygems.org/gems/iseq_rails_tools)
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
+ 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. With this gem in your `Gemfile`, your app can boot up to about 30% faster.
7
7
 
8
8
  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'])`.
9
9
 
data/Rakefile CHANGED
@@ -1,34 +1,18 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
-
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'IseqRailsTools'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
-
18
-
19
-
20
-
21
-
22
1
  require 'bundler/gem_tasks'
23
-
2
+ require 'rake/extensiontask'
24
3
  require 'rake/testtask'
25
4
 
5
+ Rake::ExtensionTask.new('iseq_rails_tools') do |ext|
6
+ ext.lib_dir = File.join('lib', 'iseq_rails_tools')
7
+ end
8
+
26
9
  Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
10
  t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
11
+ t.libs << 'lib'
12
+ t.test_files = FileList['test/**/*_test.rb']
30
13
  t.verbose = false
31
14
  end
32
15
 
16
+ Rake::Task[:test].prerequisites << :compile
33
17
 
34
18
  task default: :test
@@ -0,0 +1,2 @@
1
+ require 'mkmf'
2
+ create_makefile 'iseq_rails_tools/iseq_rails_tools'
@@ -0,0 +1,39 @@
1
+ #include <iseq_rails_tools.h>
2
+
3
+ static int whitelisted(char ch)
4
+ {
5
+ return (ch >= 'a' && ch <= 'z') ||
6
+ (ch >= 'A' && ch <= 'Z') ||
7
+ (ch >= '0' && ch <= '9') ||
8
+ (ch == '.' || ch == '_' || ch == '-');
9
+ }
10
+
11
+ static VALUE iseq_path_for(VALUE self, VALUE ruby_source_path)
12
+ {
13
+ char *source_path = rb_string_value_cstr(&ruby_source_path);
14
+ char iseq_path[strlen(source_path) * 2 + 1];
15
+
16
+ int source_idx = 0;
17
+ int iseq_idx = 0;
18
+
19
+ while(source_path[source_idx] != '\0') {
20
+ if (whitelisted(source_path[source_idx])) {
21
+ memcpy(iseq_path + iseq_idx, source_path + source_idx, 1);
22
+ source_idx++;
23
+ iseq_idx++;
24
+ } else {
25
+ sprintf(iseq_path + iseq_idx, "%02x", source_path[source_idx]);
26
+ source_idx++;
27
+ iseq_idx += 2;
28
+ }
29
+ }
30
+ iseq_path[iseq_idx] = '\0';
31
+
32
+ return rb_str_new(iseq_path, iseq_idx);
33
+ }
34
+
35
+ void Init_iseq_rails_tools()
36
+ {
37
+ VALUE IseqRailsTools = rb_define_module("IseqRailsTools");
38
+ rb_define_singleton_method(IseqRailsTools, "iseq_path_for", iseq_path_for, 1);
39
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef RUBY_ISEQ_RAILS_TOOLS
2
+ #define RUBY_ISEQ_RAILS_TOOLS
3
+
4
+ #include <ruby.h>
5
+
6
+ void Init_iseq_rails_tools();
7
+
8
+ #endif
@@ -1,7 +1,11 @@
1
+ module IseqRailsTools
2
+ end
3
+
1
4
  # Only actually hook into Rails when the environment isn't test so that tools
2
5
  # like simplecov will continue to function as expected. Also people do weird
3
6
  # stuff in test mode, so who knows.
4
7
  if !Rails.env.test? || IseqRailsTools.respond_to?(:internal?)
8
+ require 'iseq_rails_tools/iseq_rails_tools'
5
9
  require 'iseq_rails_tools/railtie'
6
10
  require 'iseq_rails_tools/source_file'
7
11
 
@@ -23,7 +27,10 @@ if !Rails.env.test? || IseqRailsTools.respond_to?(:internal?)
23
27
  break File.dirname(path)
24
28
  end
25
29
  end
26
- root = File.dirname(root) until File.exist?("#{root}/config.ru")
30
+
31
+ if !File.exist?("#{root}/config.ru") && root != File.dirname(root)
32
+ root = File.dirname(root)
33
+ end
27
34
 
28
35
  self.iseq_dir = File.join(root, DIRECTORY_NAME)
29
36
  FileUtils.mkdir_p(iseq_dir) unless File.directory?(iseq_dir)
@@ -33,7 +33,7 @@ module IseqRailsTools
33
33
  end
34
34
 
35
35
  def self.load(source_path)
36
- iseq_path = source_path.gsub(/[^A-Za-z0-9\._-]/) { |c| '%02x' % c.ord }
36
+ iseq_path = IseqRailsTools.iseq_path_for(source_path)
37
37
  iseq_path = File.join(IseqRailsTools.iseq_dir, "#{iseq_path}.yarb")
38
38
  new(source_path, iseq_path).load
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module IseqRailsTools
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iseq_rails_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Deisz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,19 +24,38 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
27
41
  description: |2
28
42
  Allows you to take advantage of ruby's AOT bytecode generation
29
43
  within a Rails project.
30
44
  email:
31
45
  - kevin.deisz@gmail.com
32
46
  executables: []
33
- extensions: []
47
+ extensions:
48
+ - ext/iseq_rails_tools/extconf.rb
34
49
  extra_rdoc_files: []
35
50
  files:
36
51
  - MIT-LICENSE
37
52
  - README.md
38
53
  - Rakefile
54
+ - ext/iseq_rails_tools/extconf.rb
55
+ - ext/iseq_rails_tools/iseq_rails_tools.c
56
+ - ext/iseq_rails_tools/iseq_rails_tools.h
39
57
  - lib/iseq_rails_tools.rb
58
+ - lib/iseq_rails_tools/iseq_rails_tools.bundle
40
59
  - lib/iseq_rails_tools/railtie.rb
41
60
  - lib/iseq_rails_tools/source_file.rb
42
61
  - lib/iseq_rails_tools/version.rb