mirror of
				https://github.com/rails/execjs
				synced 2023-03-27 23:21:20 -04:00 
			
		
		
		
	
							parent
							
								
									b829dcd8b8
								
							
						
					
					
						commit
						c87c363379
					
				
					 3 changed files with 6 additions and 4 deletions
				
			
		
							
								
								
									
										1
									
								
								Rakefile
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								Rakefile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -56,4 +56,5 @@ task :test do
 | 
			
		|||
  banner messages.join("\n")
 | 
			
		||||
 | 
			
		||||
  raise "test failures" if failed.any?
 | 
			
		||||
  raise "all tests skipped" if !passed.any?
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,14 +2,14 @@ module ExecJS
 | 
			
		|||
  class MustangRuntime
 | 
			
		||||
    class Context
 | 
			
		||||
      def initialize(source = "")
 | 
			
		||||
        source = source.encode('UTF-8') if source.respond_to?(:encode)
 | 
			
		||||
        source = ExecJS::encode(source) if source.respond_to?(:encode)
 | 
			
		||||
 | 
			
		||||
        @v8_context = ::Mustang::Context.new
 | 
			
		||||
        @v8_context.eval(source)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def exec(source, options = {})
 | 
			
		||||
        source = source.encode('UTF-8') if source.respond_to?(:encode)
 | 
			
		||||
        source = ExecJS::encode(source) if source.respond_to?(:encode)
 | 
			
		||||
 | 
			
		||||
        if /\S/ =~ source
 | 
			
		||||
          eval "(function(){#{source}})()", options
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ module ExecJS
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def eval(source, options = {})
 | 
			
		||||
        source = source.encode('UTF-8') if source.respond_to?(:encode)
 | 
			
		||||
        source = ExecJS::encode(source) if source.respond_to?(:encode)
 | 
			
		||||
 | 
			
		||||
        if /\S/ =~ source
 | 
			
		||||
          unbox @v8_context.eval("(#{source})")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,12 +92,13 @@ module ExecJS
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  if defined? Encoding
 | 
			
		||||
    if (!defined?(RUBY_ENGINE) || RUBY_ENGINE != "jruby")
 | 
			
		||||
    if (!defined?(RUBY_ENGINE) || (RUBY_ENGINE != "jruby" && RUBY_ENGINE != "rbx"))
 | 
			
		||||
      def self.encode(string)
 | 
			
		||||
        string.encode('UTF-8')
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      # workaround for jruby bug http://jira.codehaus.org/browse/JRUBY-6588
 | 
			
		||||
      # workaround for rbx bug https://github.com/rubinius/rubinius/issues/1729
 | 
			
		||||
      def self.encode(string)
 | 
			
		||||
        if string.encoding.name == 'ASCII-8BIT'
 | 
			
		||||
          data = string.dup
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue