Skip to content

Commit

Permalink
Updated with two fixes for Rails 4 and Ruby 2.0.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pdxmholmes committed Jul 23, 2013
1 parent f81c0ba commit 9059fe3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/*
*.gem
*.rbc
.bundle
Expand Down
2 changes: 1 addition & 1 deletion lib/typescript/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Railtie < ::Rails::Railtie
config.before_initialize do |app|
require 'typescript-rails'

if app.config.assets.enabled
if ::Rails::VERSION::MAJOR >= 4 || app.config.assets.enabled
require 'sprockets'
require 'sprockets/engines'
Sprockets.register_engine '.ts', Typescript::Rails::TypeScriptTemplate
Expand Down
2 changes: 1 addition & 1 deletion lib/typescript/rails/template_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def self.call(template)
def self.replace_relative_references(ts_path, source)
ts_dir = File.dirname(File.expand_path(ts_path))
escaped_dir = ts_dir.gsub(/["\\]/, '\\\\\&') # "\"" => "\\\"", '\\' => '\\\\'
source.gsub(%r!(^///\s*<reference\s+path=")([^/"][^"]+)("\s*/>)!, '\1' + File.join(escaped_dir, '\2') + '\3')
source.gsub(%r!(^///\s*<reference\s+path=")([^"]+)("\s*/>\s*)!) {|m| $1 + File.join(escaped_dir, $2) + $3 }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/typescript/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Typescript
module Rails
VERSION = "0.1.2"
VERSION = "0.1.3"
end
end

0 comments on commit 9059fe3

Please sign in to comment.