tilt-livescript 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +22 -0
- data/Rakefile +10 -0
- data/lib/tilt/livescript.rb +39 -0
- data/lib/tilt/livescript/version.rb +5 -0
- data/test/test_helper.rb +62 -0
- data/test/tilt_livescripttemplate_test.rb +94 -0
- data/tilt-livescript.gemspec +27 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68bce77c7ff81271efc48a15ef4c5dae8d0938b4
|
4
|
+
data.tar.gz: 887fcc9a17b946b1616ea307f58731fc2bf9045a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0fef29f0a4e4f3580e93eda3f9156d2a21151db57a92cc960add18742a745dc5a738d9526b42d7b643e962f890147a8d140b5dc77d37fa1c38986ba6465ab62
|
7
|
+
data.tar.gz: 0ef165084d61e841cb80efd6e27759d9926c9cd1b1242ddc4f2138e803e8cb8e193d09a00f63978f582a2aa8ce1923dc973c81d46d915537cbb870e8c6393e37
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Vaseeharan Thirukumaran <http://vasyharan.com>
|
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.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Tilt::Livescript
|
2
|
+
|
3
|
+
LiveScript support for Tilt. For more information on Tilt see: http://github.com/rtomayko/tilt
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'tilt-livescript'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install tilt-livescript
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
1. Install and integrate Tilt.
|
22
|
+
2. Compile your LiveScript (.ls) files.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'livescript'
|
3
|
+
require 'tilt/livescript/version'
|
4
|
+
|
5
|
+
module Tilt
|
6
|
+
register_lazy :LiveScriptTemplate, 'tilt/livescript', 'ls'
|
7
|
+
|
8
|
+
# LiveScript template implementation. See:
|
9
|
+
# http://livescript.net/
|
10
|
+
#
|
11
|
+
# LiveScript templates do not support object scopes, locals, or yield.
|
12
|
+
class LiveScriptTemplate < Template
|
13
|
+
self.default_mime_type = 'application/javascript'
|
14
|
+
|
15
|
+
@@default_bare = false
|
16
|
+
|
17
|
+
def self.default_bare
|
18
|
+
@@default_bare
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.default_bare=(value)
|
22
|
+
@@default_bare = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def prepare
|
26
|
+
if !options.key?(:bare)
|
27
|
+
options[:bare] = self.class.default_bare
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def evaluate(scope, locals, &block)
|
32
|
+
@output ||= LiveScript.compile(data, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def allows_script?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'minitest/mock'
|
6
|
+
|
7
|
+
# Contest adds +teardown+, +test+ and +context+ as class methods, and the
|
8
|
+
# instance methods +setup+ and +teardown+ now iterate on the corresponding
|
9
|
+
# blocks. Note that all setup and teardown blocks must be defined with the
|
10
|
+
# block syntax. Adding setup or teardown instance methods defeats the purpose
|
11
|
+
# of this library.
|
12
|
+
class Minitest::Test
|
13
|
+
def self.setup(&block)
|
14
|
+
define_method :setup do
|
15
|
+
super(&block)
|
16
|
+
instance_eval(&block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.teardown(&block)
|
21
|
+
define_method :teardown do
|
22
|
+
instance_eval(&block)
|
23
|
+
super(&block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.context(name, &block)
|
28
|
+
subclass = Class.new(self)
|
29
|
+
remove_tests(subclass)
|
30
|
+
subclass.class_eval(&block) if block_given?
|
31
|
+
const_set(context_name(name), subclass)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.test(name, &block)
|
35
|
+
define_method(test_name(name), &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
alias_method :should, :test
|
40
|
+
alias_method :describe, :context
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.context_name(name)
|
46
|
+
"Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.test_name(name)
|
50
|
+
"test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.sanitize_name(name)
|
54
|
+
name.gsub(/\W+/, ' ').strip
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.remove_tests(subclass)
|
58
|
+
subclass.public_instance_methods.grep(/^test_/).each do |meth|
|
59
|
+
subclass.send(:undef_method, meth.to_sym)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tilt'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'tilt/livescript'
|
6
|
+
|
7
|
+
class LiveScriptTemplateTest < Minitest::Test
|
8
|
+
|
9
|
+
test "is registered for '.ls' files" do
|
10
|
+
assert_equal Tilt::LiveScriptTemplate, Tilt['test.ls']
|
11
|
+
end
|
12
|
+
|
13
|
+
test "bare is disabled by default" do
|
14
|
+
assert_equal false, Tilt::LiveScriptTemplate.default_bare
|
15
|
+
end
|
16
|
+
|
17
|
+
test "compiles and evaluates the template on #render" do
|
18
|
+
template = Tilt::LiveScriptTemplate.new { |t| "puts 'Hello, World!'\n" }
|
19
|
+
assert_match "puts('Hello, World!');", template.render
|
20
|
+
end
|
21
|
+
|
22
|
+
test "can be rendered more than once" do
|
23
|
+
template = Tilt::LiveScriptTemplate.new { |t| "puts 'Hello, World!'\n" }
|
24
|
+
3.times { assert_match "puts('Hello, World!');", template.render }
|
25
|
+
end
|
26
|
+
|
27
|
+
test "disabling coffee-script wrapper" do
|
28
|
+
str = 'name = "Josh"; puts "Hello #{name}"'
|
29
|
+
|
30
|
+
template = Tilt::LiveScriptTemplate.new { str }
|
31
|
+
assert_match "(function(){", template.render
|
32
|
+
assert_match "puts(\"Hello \" + name);", template.render
|
33
|
+
|
34
|
+
template = Tilt::LiveScriptTemplate.new(:bare => true) { str }
|
35
|
+
refute_match "(function(){", template.render
|
36
|
+
assert_equal "var name;\nname = \"Josh\";\nputs(\"Hello \" + name);", template.render
|
37
|
+
end
|
38
|
+
|
39
|
+
context "wrapper globally enabled" do
|
40
|
+
setup do
|
41
|
+
@bare = Tilt::LiveScriptTemplate.default_bare
|
42
|
+
Tilt::LiveScriptTemplate.default_bare = false
|
43
|
+
end
|
44
|
+
|
45
|
+
teardown do
|
46
|
+
Tilt::LiveScriptTemplate.default_bare = @bare
|
47
|
+
end
|
48
|
+
|
49
|
+
test "no options" do
|
50
|
+
template = Tilt::LiveScriptTemplate.new { |t| 'name = "Josh"; puts "Hello, #{name}"' }
|
51
|
+
assert_match "puts(\"Hello, \" + name);", template.render
|
52
|
+
assert_match "(function(){", template.render
|
53
|
+
end
|
54
|
+
|
55
|
+
test "overridden by :bare" do
|
56
|
+
template = Tilt::LiveScriptTemplate.new(:bare => true) { |t| 'name = "Josh"; puts "Hello, #{name}"' }
|
57
|
+
assert_match "puts(\"Hello, \" + name);", template.render
|
58
|
+
refute_match "(function(){", template.render
|
59
|
+
end
|
60
|
+
|
61
|
+
test "overridden by :no_wrap" do
|
62
|
+
template = Tilt::LiveScriptTemplate.new(:no_wrap => true) { |t| 'name = "Josh"; puts "Hello, #{name}"' }
|
63
|
+
assert_match "puts(\"Hello, \" + name);", template.render
|
64
|
+
refute_match "(function() {", template.render
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "wrapper globally disabled" do
|
69
|
+
setup do
|
70
|
+
@bare = Tilt::LiveScriptTemplate.default_bare
|
71
|
+
Tilt::LiveScriptTemplate.default_bare = true
|
72
|
+
end
|
73
|
+
|
74
|
+
teardown do
|
75
|
+
Tilt::LiveScriptTemplate.default_bare = @bare
|
76
|
+
end
|
77
|
+
|
78
|
+
test "no options" do
|
79
|
+
template = Tilt::LiveScriptTemplate.new { |t| 'name = "Josh"; puts "Hello, #{name}"' }
|
80
|
+
assert_match "puts(\"Hello, \" + name);", template.render
|
81
|
+
refute_match "(function() {", template.render
|
82
|
+
end
|
83
|
+
|
84
|
+
test "overridden by :bare" do
|
85
|
+
template = Tilt::LiveScriptTemplate.new(:bare => false) { |t| 'name = "Josh"; puts "Hello, #{name}"' }
|
86
|
+
assert_match "puts(\"Hello, \" + name);", template.render
|
87
|
+
assert_match "(function(){", template.render
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
rescue LoadError => boom
|
93
|
+
warn "Tilt::LiveScriptTemplate (disabled)"
|
94
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tilt/livescript/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tilt-livescript"
|
8
|
+
spec.version = Tilt::Livescript::VERSION
|
9
|
+
spec.authors = ["Vaseeharan Thirukumaran"]
|
10
|
+
spec.email = ["vasyharan@gmail.com"]
|
11
|
+
spec.summary = %q{Adds support Livescript to tilt.}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/vasyharan/tilt-livescript"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
|
25
|
+
spec.add_dependency "tilt"
|
26
|
+
spec.add_dependency "livescript"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tilt-livescript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vaseeharan Thirukumaran
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tilt
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: livescript
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Adds support Livescript to tilt.
|
84
|
+
email:
|
85
|
+
- vasyharan@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/tilt/livescript.rb
|
96
|
+
- lib/tilt/livescript/version.rb
|
97
|
+
- test/test_helper.rb
|
98
|
+
- test/tilt_livescripttemplate_test.rb
|
99
|
+
- tilt-livescript.gemspec
|
100
|
+
homepage: https://github.com/vasyharan/tilt-livescript
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Adds support Livescript to tilt.
|
124
|
+
test_files:
|
125
|
+
- test/test_helper.rb
|
126
|
+
- test/tilt_livescripttemplate_test.rb
|