tilt-indirect 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e164fbaf427e942d8de9d7d2213bd9eaa3617fae
4
+ data.tar.gz: 511918b00c9c9060686f5567a3b6006efd22c4fd
5
+ SHA512:
6
+ metadata.gz: 703b8ce9c1d5e0ef279ab54e3a17004bc71c49f16d6b18c80ecf58b06465c82e9fc2f3f1b82bfe467a0fea77c2d4fa7732c99c7e8b7204a36e666e10076d3b91
7
+ data.tar.gz: 5a5a67022368fabb3baf785a70bcf2f03e60d552204509a33a1ae230e5ebcc079ac89efe5d76f39aa4a5a8ef64139d3c7d3c65c1467105cacc086f5f28239c09
@@ -0,0 +1,3 @@
1
+ === 1.0.0 (2015-10-01)
2
+
3
+ * Initial Public Release
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2015 Jeremy Evans
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ = tilt-indirect
2
+
3
+ tilt-indirect adds indirection for tilt templates. For example, you
4
+ can have a foo.indirect template that when render renders a separate
5
+ template (e.g. /path/to/bar.erb).
6
+
7
+ = Installation
8
+
9
+ gem install tilt-indirect
10
+
11
+ = Source Code
12
+
13
+ Source code is available on GitHub at https://github.com/jeremyevans/tilt-indirect
14
+
15
+ = Usage
16
+
17
+ The main use case for this library is when you have an application/framework that
18
+ only deals with relative template paths, and you would like to use an template
19
+ included outside that location. You can add an indirection file, which when
20
+ rendered will render the referenced file. Unlike when using a symlink, the
21
+ indirection template is ruby code instead of a static value.
22
+
23
+ If you are using bootstrap-sass and would like to have a template that renders
24
+ a file contained in the gem, you could have the indirection template contain:
25
+
26
+ # bootstrap_scss.indirect
27
+ Bootstrap.stylesheets_path + '_bootstrap.scss'
28
+
29
+ And then rendering it would render the template from the gem:
30
+
31
+ Tilt.new('boostrap_scss.indirect').render
32
+
33
+ tilt-indirect also supports raw indirections, where the indirection template
34
+ still returns a file name, but the content of that file is returned directly
35
+ instead of being processed via tilt. This is useful if you are trying to load
36
+ a raw asset file, such as a .js file:
37
+
38
+ # bootstrap_js.indirectraw
39
+ Bootstrap.javascripts_path + '/bootstrap.js'
40
+
41
+ Rendering that template is just like the previous template:
42
+
43
+ Tilt.new('boostrap_js.indirectraw').render
44
+
45
+ Because the indirection templates are using ruby code to determine the path,
46
+ you will not need to modify them when you update to newer versions of the
47
+ bootstrap-sass gem.
48
+
49
+ = License
50
+
51
+ MIT
52
+
53
+ = Author
54
+
55
+ Jeremy Evans <code@jeremyevans.net>
@@ -0,0 +1,45 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+
4
+ CLEAN.include ["tilt-indirect-*.gem", "rdoc", "coverage"]
5
+
6
+ desc "Build tilt-indirect gem"
7
+ task :package=>[:clean] do |p|
8
+ sh %{#{FileUtils::RUBY} -S gem build tilt-indirect.gemspec}
9
+ end
10
+
11
+ ### Specs
12
+
13
+ desc "Run tests"
14
+ task :test do
15
+ sh "#{FileUtils::RUBY} -rubygems spec/tilt_indirect_spec.rb"
16
+ end
17
+
18
+ task :default => :test
19
+
20
+ ### RDoc
21
+
22
+ RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'tilt-indirect: Adds indirection for tilt templates']
23
+
24
+ begin
25
+ gem 'hanna-nouveau'
26
+ RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
27
+ rescue Gem::LoadError
28
+ end
29
+
30
+ rdoc_task_class = begin
31
+ require "rdoc/task"
32
+ RDoc::Task
33
+ rescue LoadError
34
+ require "rake/rdoctask"
35
+ Rake::RDocTask
36
+ end
37
+
38
+ RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
39
+
40
+ rdoc_task_class.new do |rdoc|
41
+ rdoc.rdoc_dir = "rdoc"
42
+ rdoc.options += RDOC_OPTS
43
+ rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb"
44
+ end
45
+
@@ -0,0 +1,35 @@
1
+ require 'tilt'
2
+ require 'tilt/template'
3
+
4
+ module Tilt
5
+ # Evaluate the source data, and render the filename returned.
6
+ class IndirectTemplate < Template
7
+ protected
8
+
9
+ def prepare
10
+ end
11
+
12
+ # Render the filename returned as a tilt template
13
+ def evaluate(scope, locals, &block)
14
+ Tilt.new(eval(data)).render(scope, locals, &block)
15
+ end
16
+ end
17
+
18
+
19
+ # Evaluate the source data, and return the content of the
20
+ # filename returned.
21
+ class IndirectRawTemplate < Template
22
+ protected
23
+
24
+ def prepare
25
+ end
26
+
27
+ # Return the content of the filename returned.
28
+ def evaluate(scope, locals, &block)
29
+ File.read(eval(data))
30
+ end
31
+ end
32
+
33
+ register(IndirectTemplate, 'indirect')
34
+ register(IndirectRawTemplate, 'indirectraw')
35
+ end
@@ -0,0 +1 @@
1
+ 1
@@ -0,0 +1 @@
1
+ #{'2'}
@@ -0,0 +1 @@
1
+ File.join(File.expand_path(Dir.pwd), 'spec/2.str')
@@ -0,0 +1 @@
1
+ File.join(File.expand_path(Dir.pwd), 'spec/2.str')
@@ -0,0 +1 @@
1
+ 'spec/1.str'
@@ -0,0 +1 @@
1
+ 'spec/1.str'
@@ -0,0 +1,23 @@
1
+ $: << 'lib'
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require 'tilt'
5
+ require 'tilt/string'
6
+ require 'tilt/indirect'
7
+
8
+ describe "tilt-indirect" do
9
+ it "is registered for .indirect files" do
10
+ assert_equal Tilt::IndirectTemplate, Tilt['spec/relative.indirect']
11
+ assert_equal Tilt::IndirectRawTemplate, Tilt['spec/relative.indirectraw']
12
+ end
13
+
14
+ it "renders the template returned by the indirection" do
15
+ Tilt.new('spec/relative.indirect').render.chomp.must_equal "1"
16
+ Tilt.new('spec/absolute.indirect').render.chomp.must_equal "2"
17
+ end
18
+
19
+ it "renders the template returned by the indirection" do
20
+ Tilt.new('spec/relative.indirectraw').render.chomp.must_equal "1"
21
+ Tilt.new('spec/absolute.indirectraw').render.chomp.must_equal "\#{'2'}"
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tilt-indirect
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-01 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |
42
+ tilt-indirect adds indirection for tilt templates. For example, you
43
+ can have a foo.indirect template that when render renders a separate
44
+ template (e.g. /path/to/bar.erb).
45
+ email: code@jeremyevans.net
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files:
49
+ - README.rdoc
50
+ - CHANGELOG
51
+ - MIT-LICENSE
52
+ files:
53
+ - CHANGELOG
54
+ - MIT-LICENSE
55
+ - README.rdoc
56
+ - Rakefile
57
+ - lib/tilt/indirect.rb
58
+ - spec/1.str
59
+ - spec/2.str
60
+ - spec/absolute.indirect
61
+ - spec/absolute.indirectraw
62
+ - spec/relative.indirect
63
+ - spec/relative.indirectraw
64
+ - spec/tilt_indirect_spec.rb
65
+ homepage: https://github.com/jeremyevans/tilt-indirect
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options:
71
+ - "--quiet"
72
+ - "--line-numbers"
73
+ - "--inline-source"
74
+ - "--title"
75
+ - 'tilt-indirect: Adds indirection for tilt templates'
76
+ - "--main"
77
+ - README.rdoc
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Adds indirection for tilt templates
96
+ test_files: []