typescript 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/LICENSE +22 -0
  2. data/lib/typescript.rb +64 -0
  3. metadata +81 -0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010 Timothy Klim
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/lib/typescript.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'execjs'
2
+ require 'typescript/source'
3
+
4
+ module TypeScript
5
+ EngineError = ExecJS::RuntimeError
6
+ CompilationError = ExecJS::ProgramError
7
+
8
+ module Source
9
+ def self.path
10
+ @path ||= ENV['TYPESCRIPT_SOURCE_PATH'] || bundled_path
11
+ end
12
+
13
+ def self.compiler_path
14
+ @compiler_path ||= compiler_bundled_path
15
+ end
16
+
17
+ def self.path=(path)
18
+ @contents = @version = @bare_option = @context = nil
19
+ @path = path
20
+ end
21
+
22
+ def self.contents
23
+ @contents ||= "#{File.read(path)}\n#{File.read(compiler_path)}"
24
+ end
25
+
26
+ def self.version
27
+ @version ||= '0.8.0'
28
+ end
29
+
30
+ def self.bare_option
31
+ @bare_option ||= 'bare'
32
+ end
33
+
34
+ def self.context
35
+ @context ||= ExecJS.compile(contents)
36
+ end
37
+ end
38
+
39
+ class << self
40
+ def engine
41
+ end
42
+
43
+ def engine=(engine)
44
+ end
45
+
46
+ def version
47
+ Source.version
48
+ end
49
+
50
+ # Compile a script (String or IO) to JavaScript.
51
+ def compile(script, options = {})
52
+ script = script.read if script.respond_to?(:read)
53
+
54
+ if options.key?(:bare)
55
+ elsif options.key?(:no_wrap)
56
+ options[:bare] = options[:no_wrap]
57
+ else
58
+ options[:bare] = false
59
+ end
60
+
61
+ Source.context.call("RubyTypeScriptCompiler", '', script, options)
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: typescript
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - TimothyKlim
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: typescript-source
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: execjs
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! ' Ruby TypeScript is a bridge to the JS TypeScript compiler.
47
+
48
+ '
49
+ email: klimtimothy@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/typescript.rb
55
+ - LICENSE
56
+ homepage: https://github.com/TimothyKlim/typescript-ruby
57
+ licenses: []
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.23
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Ruby TypeScript Compiler
80
+ test_files: []
81
+ has_rdoc: