Login  Register

Re: Upgrading Asciidoctor.js to the latest version of Asciidoctor

Posted by ggrossetie on Oct 06, 2013; 3:43pm
URL: https://discuss.asciidoctor.org/Upgrading-Asciidoctor-js-to-the-latest-version-of-Asciidoctor-tp636p731.html

I have a strange behavior with a quite simple Ruby code:
RUBY_ENGINE = 'unknown' unless defined? RUBY_ENGINE
RUBY_ENGINE_OPAL = (RUBY_ENGINE == 'opal')
RUBY_ENGINE_JRUBY = (RUBY_ENGINE == 'jruby')
This code compiles in Javascript as :
  if (($a = ($scope.RUBY_ENGINE != null)) === false || $a === nil) {
    $scope.RUBY_ENGINE = "unknown"
  };
  $scope.RUBY_ENGINE_OPAL = $scope.RUBY_ENGINE['$==']("opal");
  $scope.RUBY_ENGINE_JRUBY = $scope.RUBY_ENGINE['$==']("jruby");
I added console.log because $scope.RUBY_ENGINE_OPAL was false :
  console.log("$scope.RUBY_ENGINE: '" + $scope.RUBY_ENGINE + "'");
  console.log("$scope.RUBY_ENGINE['$==']: " + $scope.RUBY_ENGINE['$==']);
  console.log("$scope.RUBY_ENGINE['$=='](\"opal\"): " + ($scope.RUBY_ENGINE['$==']("opal")));
Output :
$scope.RUBY_ENGINE: 'opal'
$scope.RUBY_ENGINE['$==']: function (other) {
      var self = this;
      return self === other;
    } 
$scope.RUBY_ENGINE['$==']("opal"): false 
Just to be sure, I modified the Javascript code to :
$scope.RUBY_ENGINE_OPAL = $scope.RUBY_ENGINE === "opal";
And its works, $scope.RUBY_ENGINE_OPAL is now true...
strange no ?