ruby-typescript 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby-typescript.rb +15 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58bb694d7fa83deff84ddb9a258db7afda4262c4
4
- data.tar.gz: bbe6fb62b64f3ee6fc97e8f9693222a0d4530a38
3
+ metadata.gz: 471c2fa2583f08ac4296e15e66320b95afc97f36
4
+ data.tar.gz: 46ab7426f5fc680f31092c7c5c64c21d6be43f05
5
5
  SHA512:
6
- metadata.gz: 42b06e7265d5aeb4a25903c5a32503e9743e81131685ebcebfd7f070b2290aa8da3bb21a6572c011d455f96323f9676867858ceaba0323611a32cfdf56a9dbdd
7
- data.tar.gz: 7801027150bc3435db6bf7d0058a38cc09dbac98dada06c47924a535a4d1c24b7ab70a79c22ee294a99446c787a30f1df38f073a249f67b7d8415f4ebf42c833
6
+ metadata.gz: b7f55ead44a636e8d379b54d119d80c1809ab0794fb33a41f1a60aafa278ce3b9cbac0b2d82b4e9567697b8110c07b96a0add84063256ebd83b32867bcf90d06
7
+ data.tar.gz: 205501dd9091d3ac624833a90c18bb58763c4657fa9af400087cddd12fa4f3e546b4b3181b088a9187560c8656aa2ce646b4f206c7c010bdfa442d296dd907bd
@@ -1,7 +1,8 @@
1
1
  require "open3"
2
+ require "tempfile"
2
3
 
3
4
  module TypeScript
4
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
5
6
 
6
7
  class Error < StandardError
7
8
  end
@@ -29,6 +30,10 @@ module TypeScript
29
30
  args << '--out' << options[:output]
30
31
  end
31
32
 
33
+ if options[:output_dir]
34
+ args << '--outDir' << options[:output_dir]
35
+ end
36
+
32
37
  if options[:source_map]
33
38
  args << '--sourceMap'
34
39
  end
@@ -50,15 +55,21 @@ module TypeScript
50
55
  # @param [String] filepath the path to the TypeScript file
51
56
  # @param [Hash] options the options for the execution
52
57
  # @option options [String] :output the output path
58
+ # @option options [Boolean] :output_dir the directory to output files to
53
59
  # @option options [Boolean] :source_map create the source map or not
54
60
  # @option options [String] :module module type to compile for (commonjs or amd)
55
61
  # @option options [String] :target the target to compile toward: ES3 (default) or ES5
56
62
  def compile_file(filepath, options={})
57
63
  options = options.clone
58
- if not options[:output]
59
- options[:output] = filepath.gsub(/\.ts$/, '.js')
64
+ if options[:output]
65
+ output_filename = options[:output]
66
+ elsif options[:output_dir]
67
+ filename = File.basename(filepath).gsub(/[.]ts$/, '.js')
68
+ output_filename = File.join(options[:output_dir], filename)
69
+ else
70
+ output_filename = filepath.gsub(/[.]ts$/, '.js')
60
71
  end
61
- output_filename = options[:output]
72
+
62
73
  args = [filepath] + flatten_options(options)
63
74
  stdout, stderr, wait_thr = node_compile(*args)
64
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-typescript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Payton Yao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler