rake-pipeline-typescript 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.yardopts +2 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.markdown +28 -0
- data/README.yard +20 -0
- data/Rakefile +10 -0
- data/lib/rake-pipeline-typescript.rb +13 -0
- data/lib/rake-pipeline-typescript/filter_with_dependencies.rb +29 -0
- data/lib/rake-pipeline-typescript/helpers.rb +21 -0
- data/lib/rake-pipeline-typescript/type_script_filter.rb +56 -0
- data/lib/rake-pipeline-typescript/version.rb +7 -0
- data/rake-pipeline-typescript.gemspec +27 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/spec_helpers/file_utils.rb +33 -0
- data/spec/support/spec_helpers/filters.rb +37 -0
- data/spec/support/spec_helpers/input_helpers.rb +23 -0
- data/spec/support/spec_helpers/memory_file_wrapper.rb +38 -0
- data/spec/support/spec_helpers/memory_manifest.rb +19 -0
- data/spec/type_script_filter_spec.rb +118 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dcd4ae5c843ad3ce3171d433fe9db603b3e96e11
|
4
|
+
data.tar.gz: 033e0a0412fbc7a28b216b042e4d42df842bcf02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 09405205ef6984c603fcac9e072b13cbeb1f81c2b50385262f954a20ce4e636669855a94cb45aa480efe66098d79c73cea7648fc9a58393f3f625d8f7b7c254d
|
7
|
+
data.tar.gz: b675949a295c43acda4e5cb06059debe35537e8914479d86af8c17c3b2b03a7b64cb3eda02aa4c810c2ed5eceb8ccb1ec25f2333385f8bbf5a1bd568ab50f803
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-cfs -r spec_helper.rb
|
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) <2013> <Taylor Brown and YouNeedABudget.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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Rake::Pipeline::Typescript
|
2
|
+
|
3
|
+
This is a typescript filter to compile Tyescript files in the Rake Pipeline.
|
4
|
+
Probably not ready for production. It appears to be quite slow, and my hunch is
|
5
|
+
that it's due to spawning a separate Node process for each file that needs to be
|
6
|
+
compiled. However, [typescript-rails](https://github.com/klaustopher/typescript-rails) is
|
7
|
+
using the typescript-node-ruby library as well without complaint, so maybe
|
8
|
+
the TS compiler is slow. I'm publishing it anyway. Please feel free to send pull
|
9
|
+
requests.
|
10
|
+
|
11
|
+
(I shamelessly forked [rake-pipeline-web-filters](https://github.com/wycats/rake-pipeline-web-filters)
|
12
|
+
since this is my first Gem)
|
13
|
+
|
14
|
+
Here's how you'd use it in your Assetfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
# Assetfile
|
18
|
+
require 'rake-pipeline-typescript'
|
19
|
+
|
20
|
+
#Other stuff up here (CoffeeScript, etc)
|
21
|
+
|
22
|
+
match "**/*.ts" do
|
23
|
+
type_script
|
24
|
+
end
|
25
|
+
|
26
|
+
#More stuff down here...
|
27
|
+
|
28
|
+
```
|
data/README.yard
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
= Rake::Pipeline::Typescript
|
2
|
+
|
3
|
+
Rake::Pipeline::Typescript is a typescript filter to compile Tyescript
|
4
|
+
files in the Rake Pipeline.
|
5
|
+
|
6
|
+
= Usage
|
7
|
+
|
8
|
+
In your +Assetfile+:
|
9
|
+
|
10
|
+
!!!ruby
|
11
|
+
require "rake-pipeline-typescript"
|
12
|
+
|
13
|
+
input "assets"
|
14
|
+
output "public"
|
15
|
+
|
16
|
+
# Take all TS inputs and compiles them to JS
|
17
|
+
match "*.ts" do
|
18
|
+
type_script
|
19
|
+
end
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rake-pipeline"
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
class Pipeline
|
5
|
+
module Typescript
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require "rake-pipeline-typescript/version"
|
11
|
+
require "rake-pipeline-typescript/filter_with_dependencies"
|
12
|
+
require "rake-pipeline-typescript/type_script_filter"
|
13
|
+
require "rake-pipeline-typescript/helpers"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Rake::Pipeline::Typescript
|
2
|
+
#Taken from Rake::Pipeline::Web::Filters
|
3
|
+
|
4
|
+
# A mixin for filters that have dependencies on external
|
5
|
+
# libraries. Include this module in the filter class and
|
6
|
+
# declare a private `external_dependencies` method that
|
7
|
+
# returns an array of strings. Each one will be passed
|
8
|
+
# to `Kernel#require` when an instance of the filter
|
9
|
+
# is created.
|
10
|
+
module FilterWithDependencies
|
11
|
+
|
12
|
+
def initialize(*args, &block)
|
13
|
+
require_dependencies!
|
14
|
+
super(*args, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def require_dependencies!
|
20
|
+
external_dependencies.each do |d|
|
21
|
+
begin
|
22
|
+
require d
|
23
|
+
rescue LoadError => error
|
24
|
+
raise error, "#{self.class} requires #{d}, but it is not available."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rake::Pipeline::Typescript
|
2
|
+
# Extends the Rake::Pipeline DSL to include shortcuts
|
3
|
+
# for adding filters to the pipeline.
|
4
|
+
#
|
5
|
+
# You can do:
|
6
|
+
# !!!ruby
|
7
|
+
# match("*.ts") do
|
8
|
+
# type_script
|
9
|
+
# end
|
10
|
+
module PipelineHelpers
|
11
|
+
# Add a new {TypeScriptFilter} to the pipeline.
|
12
|
+
# @see TypeScriptFilter#initialize
|
13
|
+
def type_script(*args, &block)
|
14
|
+
filter(Rake::Pipeline::Typescript::TypeScriptFilter, *args, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require "rake-pipeline/dsl"
|
20
|
+
|
21
|
+
Rake::Pipeline::DSL::PipelineDSL.send(:include, Rake::Pipeline::Typescript::PipelineHelpers)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "execjs"
|
2
|
+
|
3
|
+
module Rake::Pipeline::Typescript
|
4
|
+
# A filter that compiles TypeScript to JavaScript.
|
5
|
+
class TypeScriptFilter < Rake::Pipeline::Filter
|
6
|
+
include Rake::Pipeline::Typescript::FilterWithDependencies
|
7
|
+
|
8
|
+
# @return [Hash] a hash of options to pass to CoffeeScript when
|
9
|
+
# rendering.
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
# By default, the CoffeeScriptFilter converts inputs
|
13
|
+
# with the extension +.coffee+ to +.js+.
|
14
|
+
#
|
15
|
+
# @param [Hash] options options to pass to the CoffeeScript
|
16
|
+
# compiler.
|
17
|
+
# @param [Proc] block the output name generator block
|
18
|
+
def initialize(options = {}, &block)
|
19
|
+
block ||= proc { |input| input.sub(/\.ts$/, '.js') }
|
20
|
+
super(&block)
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
# The body of the filter. Compile each input file into
|
25
|
+
# a CoffeeScript compiled output file.
|
26
|
+
#
|
27
|
+
# @param [Array] inputs an Array of FileWrapper objects.
|
28
|
+
# @param [FileWrapper] output a FileWrapper object
|
29
|
+
def generate_output(inputs, output)
|
30
|
+
inputs.each do |input|
|
31
|
+
begin
|
32
|
+
if (input.respond_to?(:read))
|
33
|
+
script = input.read
|
34
|
+
else
|
35
|
+
script = input
|
36
|
+
end
|
37
|
+
#script = input.read if input.respond_to?(:read)
|
38
|
+
|
39
|
+
result = TypeScript::Node::compile(script)
|
40
|
+
output.write(result)
|
41
|
+
# if result.success?
|
42
|
+
# output.write(result.js)
|
43
|
+
# else
|
44
|
+
# raise result.stderr
|
45
|
+
#end
|
46
|
+
rescue ExecJS::Error => error
|
47
|
+
raise error, "Error compiling #{input.path}. #{error.message}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def external_dependencies
|
53
|
+
[ "typescript-node" ]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rake-pipeline-typescript/version.rb', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Taylor Brown"]
|
6
|
+
gem.email = ["taylor@youneedabudget.com"]
|
7
|
+
gem.description = %q{A typescript web filter for rake-pipeline}
|
8
|
+
gem.summary = %q{Contains a Typescript to Javascript filter for use in rake-pipeline}
|
9
|
+
gem.homepage = "http://github.com/taytay/rake-pipeline-typescript"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "rake-pipeline-typescript"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rake::Pipeline::Typescript::VERSION
|
17
|
+
gem.license = "MIT License"
|
18
|
+
|
19
|
+
gem.add_dependency "rake-pipeline", "~> 0.6"
|
20
|
+
gem.add_dependency "rack"
|
21
|
+
gem.add_dependency "typescript-node"
|
22
|
+
gem.add_dependency "typescript-src", "~> 0.9.0"
|
23
|
+
gem.add_dependency "execjs"
|
24
|
+
|
25
|
+
gem.add_development_dependency "rspec"
|
26
|
+
gem.add_development_dependency "therubyracer"
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rake-pipeline"
|
2
|
+
require "rake-pipeline-typescript"
|
3
|
+
|
4
|
+
require "support/spec_helpers/file_utils"
|
5
|
+
require "support/spec_helpers/filters"
|
6
|
+
require "support/spec_helpers/input_helpers"
|
7
|
+
require "support/spec_helpers/memory_file_wrapper"
|
8
|
+
require "support/spec_helpers/memory_manifest"
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
original = Dir.pwd
|
12
|
+
|
13
|
+
config.include Rake::Pipeline::SpecHelpers::FileUtils
|
14
|
+
|
15
|
+
def tmp
|
16
|
+
File.expand_path("../tmp", __FILE__)
|
17
|
+
end
|
18
|
+
|
19
|
+
config.before do
|
20
|
+
rm_rf(tmp)
|
21
|
+
mkdir_p(tmp)
|
22
|
+
Dir.chdir(tmp)
|
23
|
+
end
|
24
|
+
|
25
|
+
config.after do
|
26
|
+
Dir.chdir(original)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Rake::Pipeline
|
2
|
+
module SpecHelpers
|
3
|
+
|
4
|
+
# TODO: OS agnostic modules
|
5
|
+
module FileUtils
|
6
|
+
def mkdir_p(dir)
|
7
|
+
system "mkdir", "-p", dir
|
8
|
+
end
|
9
|
+
|
10
|
+
def touch(file)
|
11
|
+
system "touch", file
|
12
|
+
end
|
13
|
+
|
14
|
+
def rm_rf(dir)
|
15
|
+
system "rm", "-rf", dir
|
16
|
+
end
|
17
|
+
|
18
|
+
def touch_p(file)
|
19
|
+
dir = File.dirname(file)
|
20
|
+
mkdir_p dir
|
21
|
+
touch file
|
22
|
+
end
|
23
|
+
|
24
|
+
def age_existing_files
|
25
|
+
old_time = Time.now - 10
|
26
|
+
Dir[File.join(tmp, "**/*.js")].each do |file|
|
27
|
+
File.utime(old_time, old_time, file)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Rake::Pipeline
|
2
|
+
module SpecHelpers
|
3
|
+
|
4
|
+
module Filters
|
5
|
+
ConcatFilter = Rake::Pipeline::ConcatFilter
|
6
|
+
|
7
|
+
class StripAssertsFilter < Rake::Pipeline::Filter
|
8
|
+
def generate_output(inputs, output)
|
9
|
+
inputs.each do |input|
|
10
|
+
output.write input.read.gsub(%r{^\s*assert\(.*\)\s*;?\s*$}m, '')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class DynamicImportFilter < Rake::Pipeline::Filter
|
16
|
+
def additional_dependencies(input)
|
17
|
+
includes(input)
|
18
|
+
end
|
19
|
+
|
20
|
+
def includes(input)
|
21
|
+
input.read.scan(/^@import\(\"(.*)\"\)$/).map(&:first).map do |inc|
|
22
|
+
File.join(input.root, "#{inc}.import")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_output(inputs, output)
|
27
|
+
inputs.each do |input|
|
28
|
+
output.write input.read
|
29
|
+
includes(input).each do |inc|
|
30
|
+
output.write File.read(inc)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Rake::Pipeline
|
2
|
+
module SpecHelpers
|
3
|
+
module InputHelpers
|
4
|
+
def input_file(path, root=File.join(tmp, "app/assets"))
|
5
|
+
Rake::Pipeline::FileWrapper.new root, path
|
6
|
+
end
|
7
|
+
|
8
|
+
def output_file(path, root=File.join(tmp, "public"))
|
9
|
+
input_file(path, root)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_files(files)
|
13
|
+
Array(files).each do |file|
|
14
|
+
mkdir_p File.dirname(file.fullpath)
|
15
|
+
|
16
|
+
File.open(file.fullpath, "w") do |file|
|
17
|
+
file.write "// This is #{file.path}\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Rake::Pipeline
|
2
|
+
module SpecHelpers
|
3
|
+
class MemoryFileWrapper < Struct.new(:root, :path, :encoding, :body)
|
4
|
+
@@files = {}
|
5
|
+
@@data = {}
|
6
|
+
|
7
|
+
def self.files
|
8
|
+
@@files
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.data
|
12
|
+
@@data
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_encoding(new_encoding)
|
16
|
+
self.class.new(root, path, new_encoding, body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fullpath
|
20
|
+
File.join(root, path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
@@files[fullpath] = self
|
25
|
+
self.body = ""
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
|
29
|
+
def read
|
30
|
+
body || @@data[fullpath] || ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def write(contents)
|
34
|
+
self.body << contents
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Rake::Pipeline
|
2
|
+
module SpecHelpers
|
3
|
+
class MemoryManifest
|
4
|
+
def initialize
|
5
|
+
@entries = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
# Look up an entry by filename.
|
9
|
+
def [](key)
|
10
|
+
@entries[key]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set an entry
|
14
|
+
def []=(key, value)
|
15
|
+
@entries[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
describe "TypeScriptFilter" do
|
2
|
+
TypeScriptFilter ||= Rake::Pipeline::Typescript::TypeScriptFilter
|
3
|
+
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
|
4
|
+
MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
|
5
|
+
|
6
|
+
let(:typescript_input) { <<-TYPESCRIPT }
|
7
|
+
class Student {
|
8
|
+
fullname : string;
|
9
|
+
middleInitial : string;
|
10
|
+
constructor(public firstname, public middleinitial, public lastname) {
|
11
|
+
this.middleInitial = middleinitial;
|
12
|
+
this.fullname = firstname + " " + this.middleInitial + " " + lastname;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
interface Person {
|
17
|
+
firstname: string;
|
18
|
+
lastname: string;
|
19
|
+
}
|
20
|
+
|
21
|
+
function greeter(person : Person) {
|
22
|
+
return "Hello, " + person.firstname + " " + person.lastname;
|
23
|
+
}
|
24
|
+
|
25
|
+
var user = new Student("Jane", "M.", "User");
|
26
|
+
|
27
|
+
alert(greeter(user));
|
28
|
+
|
29
|
+
TYPESCRIPT
|
30
|
+
|
31
|
+
let(:expected_typescript_output) { <<-HTML }
|
32
|
+
var Student = (function () {
|
33
|
+
function Student(firstname, middleinitial, lastname) {
|
34
|
+
this.firstname = firstname;
|
35
|
+
this.middleinitial = middleinitial;
|
36
|
+
this.lastname = lastname;
|
37
|
+
this.middleInitial = middleinitial;
|
38
|
+
this.fullname = firstname + " " + this.middleInitial + " " + lastname;
|
39
|
+
}
|
40
|
+
return Student;
|
41
|
+
})();
|
42
|
+
|
43
|
+
function greeter(person) {
|
44
|
+
return "Hello, " + person.firstname + " " + person.lastname;
|
45
|
+
}
|
46
|
+
|
47
|
+
var user = new Student("Jane", "M.", "User");
|
48
|
+
|
49
|
+
alert(greeter(user));
|
50
|
+
|
51
|
+
HTML
|
52
|
+
|
53
|
+
def input_file(name, content)
|
54
|
+
MemoryFileWrapper.new("/path/to/input", name, "UTF-8", content)
|
55
|
+
end
|
56
|
+
|
57
|
+
def output_file(name)
|
58
|
+
MemoryFileWrapper.new("/path/to/output", name, "UTF-8")
|
59
|
+
end
|
60
|
+
|
61
|
+
def should_match(expected, output)
|
62
|
+
"#{expected}\n".gsub(/\n+/, "\n").should == "#{output}\n".gsub(/\n+/, "\n")
|
63
|
+
end
|
64
|
+
|
65
|
+
def setup_filter(filter)
|
66
|
+
filter.file_wrapper_class = MemoryFileWrapper
|
67
|
+
filter.manifest = MemoryManifest.new
|
68
|
+
filter.last_manifest = MemoryManifest.new
|
69
|
+
filter.input_files = [input_file("input.ts", typescript_input)]
|
70
|
+
filter.output_root = "/path/to/output"
|
71
|
+
filter.rake_application = Rake::Application.new
|
72
|
+
filter
|
73
|
+
end
|
74
|
+
|
75
|
+
it "generates output" do
|
76
|
+
filter = setup_filter TypeScriptFilter.new
|
77
|
+
|
78
|
+
filter.output_files.should == [output_file("input.js")]
|
79
|
+
|
80
|
+
tasks = filter.generate_rake_tasks
|
81
|
+
tasks.each(&:invoke)
|
82
|
+
|
83
|
+
file = MemoryFileWrapper.files["/path/to/output/input.js"]
|
84
|
+
normalized_output = file.body.gsub(/\r\n?/, "\n")
|
85
|
+
should_match normalized_output, expected_typescript_output
|
86
|
+
file.encoding.should == "UTF-8"
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "naming output files" do
|
90
|
+
it "translates .ts extensions to .js by default" do
|
91
|
+
filter = setup_filter TypeScriptFilter.new
|
92
|
+
filter.output_files.first.path.should == "input.js"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "accepts a block to customize output file names" do
|
96
|
+
filter = setup_filter(TypeScriptFilter.new { |input| "octopus" })
|
97
|
+
filter.output_files.first.path.should == "octopus"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "invalid input" do
|
102
|
+
let(:typescript_input) { <<-TYPESCRIPT }
|
103
|
+
var y = function(param : badtype){
|
104
|
+
return "This won't compile"
|
105
|
+
}
|
106
|
+
TYPESCRIPT
|
107
|
+
|
108
|
+
it "has a useful error message including the input file name" do
|
109
|
+
filter = setup_filter TypeScriptFilter.new
|
110
|
+
tasks = filter.generate_rake_tasks
|
111
|
+
lambda {
|
112
|
+
tasks.each(&:invoke)
|
113
|
+
}.should raise_error(RuntimeError, /ts\(1,26\): error TS2095: Could not find symbol 'badtype'/i)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-pipeline-typescript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Taylor Brown
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: typescript-node
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: typescript-src
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.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.9.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: execjs
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: therubyracer
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A typescript web filter for rake-pipeline
|
112
|
+
email:
|
113
|
+
- taylor@youneedabudget.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .yardopts
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.markdown
|
124
|
+
- README.yard
|
125
|
+
- Rakefile
|
126
|
+
- lib/rake-pipeline-typescript.rb
|
127
|
+
- lib/rake-pipeline-typescript/filter_with_dependencies.rb
|
128
|
+
- lib/rake-pipeline-typescript/helpers.rb
|
129
|
+
- lib/rake-pipeline-typescript/type_script_filter.rb
|
130
|
+
- lib/rake-pipeline-typescript/version.rb
|
131
|
+
- rake-pipeline-typescript.gemspec
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/support/spec_helpers/file_utils.rb
|
134
|
+
- spec/support/spec_helpers/filters.rb
|
135
|
+
- spec/support/spec_helpers/input_helpers.rb
|
136
|
+
- spec/support/spec_helpers/memory_file_wrapper.rb
|
137
|
+
- spec/support/spec_helpers/memory_manifest.rb
|
138
|
+
- spec/type_script_filter_spec.rb
|
139
|
+
homepage: http://github.com/taytay/rake-pipeline-typescript
|
140
|
+
licenses:
|
141
|
+
- MIT License
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.0.3
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Contains a Typescript to Javascript filter for use in rake-pipeline
|
163
|
+
test_files:
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/spec_helpers/file_utils.rb
|
166
|
+
- spec/support/spec_helpers/filters.rb
|
167
|
+
- spec/support/spec_helpers/input_helpers.rb
|
168
|
+
- spec/support/spec_helpers/memory_file_wrapper.rb
|
169
|
+
- spec/support/spec_helpers/memory_manifest.rb
|
170
|
+
- spec/type_script_filter_spec.rb
|