Skip to content

Commit 9059fe3

Browse files
committed
Updated with two fixes for Rails 4 and Ruby 2.0.
Added a check to the sprocket initialization to load if Rails >= 4 Updated the references Regex to play nice with Ruby 2.0 regex and fixed a minor bug causing errors when more than one reference line is provided
1 parent f81c0ba commit 9059fe3

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea/*
12
*.gem
23
*.rbc
34
.bundle

lib/typescript/rails/railtie.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Railtie < ::Rails::Railtie
44
config.before_initialize do |app|
55
require 'typescript-rails'
66

7-
if app.config.assets.enabled
7+
if ::Rails::VERSION::MAJOR >= 4 || app.config.assets.enabled
88
require 'sprockets'
99
require 'sprockets/engines'
1010
Sprockets.register_engine '.ts', Typescript::Rails::TypeScriptTemplate

lib/typescript/rails/template_handler.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def self.call(template)
7777
def self.replace_relative_references(ts_path, source)
7878
ts_dir = File.dirname(File.expand_path(ts_path))
7979
escaped_dir = ts_dir.gsub(/["\\]/, '\\\\\&') # "\"" => "\\\"", '\\' => '\\\\'
80-
source.gsub(%r!(^///\s*<reference\s+path=")([^/"][^"]+)("\s*/>)!, '\1' + File.join(escaped_dir, '\2') + '\3')
80+
source.gsub(%r!(^///\s*<reference\s+path=")([^"]+)("\s*/>\s*)!) {|m| $1 + File.join(escaped_dir, $2) + $3 }
8181
end
8282
end
8383
end

lib/typescript/rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Typescript
22
module Rails
3-
VERSION = "0.1.2"
3+
VERSION = "0.1.3"
44
end
55
end

0 commit comments

Comments
 (0)