tilt-preload 0.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca9c71fbd54593314c7686fcbe2d58ac247c7ba5
4
+ data.tar.gz: d54086bc1a6005328e182fd88162bb69ca73fb6e
5
+ SHA512:
6
+ metadata.gz: 87bd0bf279190106a7bb2db9118d5b3da52024a3c5209ba6e27d22b14640c36a2a13d21d9bb4301f95f3d5b2b05d1d2159b7f1a0ad5c855eb6fdcfb8b644f353
7
+ data.tar.gz: d52d64ab1e6329cf1026ee89ff9bba08c862a9fa9137ee0318a58c2e55725c33cb824312c5b8d0f8a7276cc4c927e56f673ed2645c44a70dcbc80768a3a49ba6
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.0 ##
2
+
3
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "tilt-preload", :path => File.expand_path("..", __FILE__)
5
+ gem "rake"
6
+ gem "rdoc"
7
+ end
8
+
9
+ group :test do
10
+ gem "minitest"
11
+ end
12
+
13
+ group :debug do
14
+ gem "byebug"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tilt-preload (0.0.0)
5
+ tilt (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (4.0.3)
11
+ columnize (= 0.9.0)
12
+ columnize (0.9.0)
13
+ minitest (5.5.1)
14
+ rake (10.4.2)
15
+ rdoc (4.1.0)
16
+ tilt (2.0.1)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ byebug
23
+ minitest
24
+ rake
25
+ rdoc
26
+ tilt-preload!
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 F Thomas May
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ tilt-preload
2
+ ============
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/tilt-preload.svg)](http://badge.fury.io/rb/tilt-preload)
5
+ [![Build Status](https://travis-ci.org/tommay/tilt-preload.svg)](https://travis-ci.org/tommay/tilt-preload)
6
+
7
+ A simple gem to avoid the "non thread-safe autoload" warnings generated
8
+ by tilt 2.x when it autoloads its tilt/* helper files.
9
+
10
+ Tilt is correct that autoloading these files isn't thread safe. This
11
+ gem works by loading the necessary files at require time. Put
12
+ "tilt-preload" in your Gemfile and require "tilt-preload" in your
13
+ code instead of require "tilt". Require any template engines before
14
+ require "tilt-preload":
15
+
16
+ ```
17
+ require "haml"
18
+ require "redcarpet"
19
+ require "tilt-preload"
20
+ ```
21
+
22
+ tilt-preload is most sugary when you're not using "tilt" directly, but using
23
+ some other gem like [angelo](https://github.com/kenichi/angelo) where
24
+ angelo can use tilt under the hood and you don't care, just be sure to
25
+ require your templating engines first:
26
+
27
+ ```
28
+ require "haml"
29
+ require "redcarpet"
30
+ require "angelo"
31
+ ```
32
+
33
+ There's a [pull request](https://github.com/rtomayko/tilt/pull/253)
34
+ open for tilt to include this functionality but I can't wait forever
35
+ for it to be accepted or rejected so I made this silly gem in the
36
+ interim.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require "rake/clean"
2
+
3
+ task :default => :test
4
+
5
+ require "rake/testtask"
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = "spec/**/*_spec.rb"
8
+ end
9
+
10
+ require "rdoc/task"
11
+ Rake::RDocTask.new do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.rdoc_files.include("lib/**/*.rb")
14
+ end
15
+ CLEAN.include "rdoc"
16
+
17
+ task :gem do
18
+ sh "gem build tilt-preload.gemspec"
19
+ end
20
+ CLEAN.include "*.gem"
21
+
22
+ task :install => :gem do
23
+ sh "gem install tilt-preload"
24
+ end
25
+
26
+ task :push => [:clean, :gem] do
27
+ sh "gem push tilt-preload-*.gem"
28
+ end
@@ -0,0 +1,44 @@
1
+ require "tilt"
2
+
3
+ module TiltPreload
4
+ PRELOADS = {
5
+ :ERB => 'tilt/erb',
6
+ :Erubis => 'tilt/erubis',
7
+ :BlueCloth => 'tilt/bluecloth',
8
+ :Maruku => 'tilt/maruku',
9
+ :Kramdown => 'tilt/kramdown',
10
+ :RDiscount => 'tilt/rdiscount',
11
+ :Redcarpet => 'tilt/redcarpet',
12
+ :Asciidoctor => 'tilt/asciidoc',
13
+ :Builder => 'tilt/builder',
14
+ :CSV => 'tilt/csv',
15
+ :FasterCSV => 'tilt/csv',
16
+ :CoffeeScript => 'tilt/coffee',
17
+ :Creole => 'tilt/creole',
18
+ :Haml => 'tilt/haml',
19
+ :Less => 'tilt/less',
20
+ :Liquid => 'tilt/liquid',
21
+ :Markaby => 'tilt/markaby',
22
+ :Nokogiri => 'tilt/nokogiri',
23
+ :RDoc => 'tilt/rdoc',
24
+ :Radius => 'tilt/radius',
25
+ :RedCloth => 'tilt/redcloth',
26
+ :Sass => 'tilt/sass',
27
+ :Sass => 'tilt/sass',
28
+ :WikiCloth => 'tilt/wikicloth',
29
+ :Yajl => 'tilt/yajl',
30
+ }
31
+
32
+ # Looks to see what template engine classes are defined and require the
33
+ # corresponding tilt helper file.
34
+
35
+ def self.preload
36
+ PRELOADS.each do |k, v|
37
+ if Object.const_defined?(k)
38
+ require v
39
+ end
40
+ end
41
+ end
42
+
43
+ preload
44
+ end
@@ -0,0 +1,50 @@
1
+ require "bundler/setup"
2
+ require "minitest/autorun"
3
+ require "tilt-preload"
4
+
5
+ describe "tilt-preload" do
6
+ # context "Haml" do
7
+ before do
8
+ @haml = Object.const_get(:Haml) rescue nil
9
+ Object.send(:remove_const, :Haml) if defined?(Haml)
10
+ end
11
+
12
+ after do
13
+ if @haml
14
+ Object.const_set(:Haml, @haml)
15
+ else
16
+ Object.send(:remove_const, :Haml) if defined?(Haml)
17
+ end
18
+ end
19
+
20
+ it "requires tilt/haml if Haml is defined" do
21
+ tilt_haml_requred = false
22
+
23
+ req = lambda do |file|
24
+ tilt_haml_requred = true if file == "tilt/haml"
25
+ end
26
+
27
+ Object.const_set(:Haml, :anything)
28
+
29
+ TiltPreload.stub :require, req do
30
+ TiltPreload.preload
31
+ end
32
+
33
+ assert tilt_haml_requred
34
+ end
35
+
36
+ it "dpesn't require tilt/haml if Haml is not defined" do
37
+ tilt_haml_requred = false
38
+
39
+ req = lambda do |file|
40
+ tilt_haml_requred = true if file == "tilt/haml"
41
+ end
42
+
43
+ TiltPreload.stub :require, req do
44
+ TiltPreload.preload
45
+ end
46
+
47
+ assert tilt_haml_requred == false
48
+ end
49
+ # end
50
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.description = "Load tilt/* files according to what classes have been defined."
3
+ gem.summary = gem.description
4
+ gem.authors = ["Tom May"]
5
+ gem.email = ["tom@tommay.net"]
6
+ gem.homepage = "https://github.com/tommay/tilt-preload"
7
+ gem.files = `git ls-files`.split("\n") - [".gitignore", ".travis.yml"]
8
+ gem.test_files = `git ls-files -- spec/*`.split("\n")
9
+ gem.name = "tilt-preload"
10
+ gem.require_paths = ["lib"]
11
+ gem.version = "0.0.0"
12
+ gem.license = "MIT"
13
+ gem.add_runtime_dependency 'tilt', "~> 2.0"
14
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tilt-preload
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom May
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tilt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description: Load tilt/* files according to what classes have been defined.
28
+ email:
29
+ - tom@tommay.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE.md
38
+ - README.md
39
+ - Rakefile
40
+ - lib/tilt-preload.rb
41
+ - spec/tilt-preload_spec.rb
42
+ - tilt-preload.gemspec
43
+ homepage: https://github.com/tommay/tilt-preload
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.5
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Load tilt/* files according to what classes have been defined.
67
+ test_files:
68
+ - spec/tilt-preload_spec.rb