UNPKG

opal-compiler

Version:
1,288 lines (950 loc) 2.11 MB
Opal.modules["opal/regexp_anchors"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $const_set = Opal.const_set, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('new'); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); $const_set(self, 'REGEXP_START', "^"); $const_set(self, 'REGEXP_END', "$"); $const_set(self, 'FORBIDDEN_STARTING_IDENTIFIER_CHARS', "\\u0001-\\u002F\\u003A-\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); $const_set(self, 'FORBIDDEN_ENDING_IDENTIFIER_CHARS', "\\u0001-\\u0020\\u0022-\\u002F\\u003A-\\u003E\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); $const_set(self, 'INLINE_IDENTIFIER_REGEXP', $$('Regexp').$new("[^" + ($$$(self, 'FORBIDDEN_STARTING_IDENTIFIER_CHARS')) + "]*[^" + ($$$(self, 'FORBIDDEN_ENDING_IDENTIFIER_CHARS')) + "]")); $const_set(self, 'FORBIDDEN_CONST_NAME_CHARS', "\\u0001-\\u0020\\u0021-\\u002F\\u003B-\\u003F\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); return $const_set(self, 'CONST_NAME_REGEXP', $$('Regexp').$new("" + ($$$(self, 'REGEXP_START')) + "(::)?[A-Z][^" + ($$$(self, 'FORBIDDEN_CONST_NAME_CHARS')) + "]*" + ($$$(self, 'REGEXP_END')))); })($nesting[0], $nesting) }; Opal.modules["corelib/comparable"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $truthy = Opal.truthy, $module = Opal.module, $rb_gt = Opal.rb_gt, $rb_lt = Opal.rb_lt, $eqeqeq = Opal.eqeqeq, $Kernel = Opal.Kernel, $def = Opal.def, nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('>,<,===,raise,class,<=>,equal?'); return (function($base) { var self = $module($base, 'Comparable'); var $ret_or_1 = nil; function normalize(what) { if (Opal.is_a(what, Opal.Integer)) { return what; } if ($rb_gt(what, 0)) { return 1; } if ($rb_lt(what, 0)) { return -1; } return 0; } function fail_comparison(lhs, rhs) { var class_name; (($eqeqeq(nil, ($ret_or_1 = rhs)) || (($eqeqeq(true, $ret_or_1) || (($eqeqeq(false, $ret_or_1) || (($eqeqeq($$$('Integer'), $ret_or_1) || ($eqeqeq($$$('Float'), $ret_or_1))))))))) ? (class_name = rhs.$inspect()) : (class_name = rhs.$$class)) $Kernel.$raise($$$('ArgumentError'), "comparison of " + ((lhs).$class()) + " with " + (class_name) + " failed") } function cmp_or_fail(lhs, rhs) { var cmp = (lhs)['$<=>'](rhs); if (!$truthy(cmp)) fail_comparison(lhs, rhs); return normalize(cmp); } ; $def(self, '$==', function $Comparable_$eq_eq$1(other) { var self = this, cmp = nil; if ($truthy(self['$equal?'](other))) { return true }; if (self["$<=>"] == Opal.Kernel["$<=>"]) { return false; } // check for infinite recursion if (self.$$comparable) { self.$$comparable = false; return false; } ; if (!$truthy((cmp = self['$<=>'](other)))) { return false }; return normalize(cmp) == 0;; }); $def(self, '$>', function $Comparable_$gt$2(other) { var self = this; return cmp_or_fail(self, other) > 0; }); $def(self, '$>=', function $Comparable_$gt_eq$3(other) { var self = this; return cmp_or_fail(self, other) >= 0; }); $def(self, '$<', function $Comparable_$lt$4(other) { var self = this; return cmp_or_fail(self, other) < 0; }); $def(self, '$<=', function $Comparable_$lt_eq$5(other) { var self = this; return cmp_or_fail(self, other) <= 0; }); $def(self, '$between?', function $Comparable_between$ques$6(min, max) { var self = this; if ($rb_lt(self, min)) { return false }; if ($rb_gt(self, max)) { return false }; return true; }); return $def(self, '$clamp', function $$clamp(min, max) { var self = this; if (max == null) max = nil; var c, excl; if (max === nil) { // We are dealing with a new Ruby 2.7 behaviour that we are able to // provide a single Range argument instead of 2 Comparables. if (!Opal.is_a(min, Opal.Range)) { $Kernel.$raise($$$('TypeError'), "wrong argument type " + (min.$class()) + " (expected Range)") } excl = min.excl; max = min.end; min = min.begin; if (max !== nil && excl) { $Kernel.$raise($$$('ArgumentError'), "cannot clamp with an exclusive range") } } if (min !== nil && max !== nil && cmp_or_fail(min, max) > 0) { $Kernel.$raise($$$('ArgumentError'), "min argument must be smaller than max argument") } if (min !== nil) { c = cmp_or_fail(self, min); if (c == 0) return self; if (c < 0) return min; } if (max !== nil) { c = cmp_or_fail(self, max); if (c > 0) return max; } return self; ; }, -2); })('::') }; Opal.modules["pathname"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $klass = Opal.klass, $const_set = Opal.const_set, $regexp = Opal.regexp, $eqeqeq = Opal.eqeqeq, $truthy = Opal.truthy, $eqeq = Opal.eqeq, $def = Opal.def, $defs = Opal.defs, $to_ary = Opal.to_ary, $slice = Opal.slice, $send = Opal.send, $to_a = Opal.to_a, $return_ivar = Opal.return_ivar, $neqeq = Opal.neqeq, $rb_plus = Opal.rb_plus, $not = Opal.not, $thrower = Opal.thrower, $alias = Opal.alias, $module = Opal.module, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('require,include,quote,===,to_s,path,respond_to?,to_path,is_a?,nil?,raise,class,==,new,pwd,attr_reader,!,relative?,chop_basename,basename,=~,source,[],rindex,sub,absolute?,expand_path,plus,unshift,length,!=,empty?,first,shift,+,join,dirname,pop,reverse_each,directory?,extname,<=>,nonzero?,proc,casecmp,cleanpath,inspect,include?,fill,map,entries'); self.$require("corelib/comparable"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Pathname'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; $proto.path = nil; self.$include($$('Comparable')); $const_set($nesting[0], 'SEPARATOR_PAT', $regexp([$$('Regexp').$quote($$$($$('File'), 'SEPARATOR'))])); $def(self, '$initialize', function $$initialize(path) { var self = this; if ($eqeqeq($$('Pathname'), path)) { self.path = path.$path().$to_s() } else if ($truthy(path['$respond_to?']("to_path"))) { self.path = path.$to_path() } else if ($truthy(path['$is_a?']($$('String')))) { self.path = path } else if ($truthy(path['$nil?']())) { self.$raise($$('TypeError'), "no implicit conversion of nil into String") } else { self.$raise($$('TypeError'), "no implicit conversion of " + (path.$class()) + " into String") }; if ($eqeq(self.path, "\u0000")) { return self.$raise($$('ArgumentError')) } else { return nil }; }); $defs(self, '$pwd', function $$pwd() { var self = this; return self.$new($$('Dir').$pwd()) }); self.$attr_reader("path"); $def(self, '$==', function $Pathname_$eq_eq$1(other) { var self = this; return other.$path()['$=='](self.path) }); $def(self, '$absolute?', function $Pathname_absolute$ques$2() { var self = this; return self['$relative?']()['$!']() }); $def(self, '$relative?', function $Pathname_relative$ques$3() { var $a, $b, self = this, path = nil, r = nil; path = self.path; while ($truthy((r = self.$chop_basename(path)))) { $b = r, $a = $to_ary($b), (path = ($a[0] == null ? nil : $a[0])), $b }; return path['$=='](""); }); $def(self, '$chop_basename', function $$chop_basename(path) { var base = nil; base = $$('File').$basename(path); if ($truthy($$('Regexp').$new("^" + ($$$($$('Pathname'), 'SEPARATOR_PAT').$source()) + "?$")['$=~'](base))) { return nil } else { return [path['$[]'](0, path.$rindex(base)), base] }; }); $def(self, '$root?', function $Pathname_root$ques$4() { var self = this; return self.path['$==']("/") }); $def(self, '$parent', function $$parent() { var self = this, new_path = nil; new_path = self.path.$sub(/\/([^\/]+\/?$)/, ""); if ($eqeq(new_path, "")) { new_path = ($truthy(self['$absolute?']()) ? ("/") : (".")) }; return $$('Pathname').$new(new_path); }); $def(self, '$sub', function $$sub($a) { var $post_args, args, self = this; $post_args = $slice(arguments); args = $post_args; return $$('Pathname').$new($send(self.path, 'sub', $to_a(args))); }, -1); $def(self, '$cleanpath', function $$cleanpath() { var self = this; return Opal.normalize(self.path) }); $def(self, '$to_path', $return_ivar("path")); $def(self, '$hash', $return_ivar("path")); $def(self, '$expand_path', function $$expand_path() { var self = this; return $$('Pathname').$new($$('File').$expand_path(self.path)) }); $def(self, '$+', function $Pathname_$plus$5(other) { var self = this; if (!$eqeqeq($$('Pathname'), other)) { other = $$('Pathname').$new(other) }; return $$('Pathname').$new(self.$plus(self.path, other.$to_s())); }); $def(self, '$plus', function $$plus(path1, path2) { var $a, $b, self = this, prefix2 = nil, index_list2 = nil, basename_list2 = nil, r2 = nil, basename2 = nil, prefix1 = nil, $ret_or_1 = nil, r1 = nil, basename1 = nil, suffix2 = nil; prefix2 = path2; index_list2 = []; basename_list2 = []; while ($truthy((r2 = self.$chop_basename(prefix2)))) { $b = r2, $a = $to_ary($b), (prefix2 = ($a[0] == null ? nil : $a[0])), (basename2 = ($a[1] == null ? nil : $a[1])), $b; index_list2.$unshift(prefix2.$length()); basename_list2.$unshift(basename2); }; if ($neqeq(prefix2, "")) { return path2 }; prefix1 = path1; while ($truthy(true)) { while ($truthy(($truthy(($ret_or_1 = basename_list2['$empty?']()['$!']())) ? (basename_list2.$first()['$=='](".")) : ($ret_or_1)))) { index_list2.$shift(); basename_list2.$shift(); }; if (!$truthy((r1 = self.$chop_basename(prefix1)))) { break }; $b = r1, $a = $to_ary($b), (prefix1 = ($a[0] == null ? nil : $a[0])), (basename1 = ($a[1] == null ? nil : $a[1])), $b; if ($eqeq(basename1, ".")) { continue }; if ((($eqeq(basename1, "..") || ($truthy(basename_list2['$empty?']()))) || ($neqeq(basename_list2.$first(), "..")))) { prefix1 = $rb_plus(prefix1, basename1); break; }; index_list2.$shift(); basename_list2.$shift(); }; r1 = self.$chop_basename(prefix1); if (($not(r1) && ($truthy($regexp([$$('SEPARATOR_PAT')])['$=~']($$('File').$basename(prefix1)))))) { while ($truthy(($truthy(($ret_or_1 = basename_list2['$empty?']()['$!']())) ? (basename_list2.$first()['$==']("..")) : ($ret_or_1)))) { index_list2.$shift(); basename_list2.$shift(); } }; if ($not(basename_list2['$empty?']())) { suffix2 = path2['$[]'](Opal.Range.$new(index_list2.$first(), -1, false)); if ($truthy(r1)) { return $$('File').$join(prefix1, suffix2) } else { return $rb_plus(prefix1, suffix2) }; } else if ($truthy(r1)) { return prefix1 } else { return $$('File').$dirname(prefix1) }; }); $def(self, '$join', function $$join($a) {try { var $t_return = $thrower('return'); var $post_args, args, self = this, result = nil; $post_args = $slice(arguments); args = $post_args; if ($truthy(args['$empty?']())) { return self }; result = args.$pop(); if (!$eqeqeq($$('Pathname'), result)) { result = $$('Pathname').$new(result) }; if ($truthy(result['$absolute?']())) { return result }; $send(args, 'reverse_each', [], function $$6(arg){ if (arg == null) arg = nil; if (!$eqeqeq($$('Pathname'), arg)) { arg = $$('Pathname').$new(arg) }; result = $rb_plus(arg, result); if ($truthy(result['$absolute?']())) { $t_return.$throw(result) } else { return nil };}, {$$ret: $t_return}); return $rb_plus(self, result);} catch($e) { if ($e === $t_return) return $e.$v; throw $e; } }, -1); $def(self, '$split', function $$split() { var self = this; return [self.$dirname(), self.$basename()] }); $def(self, '$dirname', function $$dirname() { var self = this; return $$('Pathname').$new($$('File').$dirname(self.path)) }); $def(self, '$basename', function $$basename() { var self = this; return $$('Pathname').$new($$('File').$basename(self.path)) }); $def(self, '$directory?', function $Pathname_directory$ques$7() { var self = this; return $$('File')['$directory?'](self.path) }); $def(self, '$extname', function $$extname() { var self = this; return $$('File').$extname(self.path) }); $def(self, '$<=>', function $Pathname_$lt_eq_gt$8(other) { var self = this; return self.$path()['$<=>'](other.$path()) }); $const_set($nesting[0], 'SAME_PATHS', ($truthy($$$($$('File'), 'FNM_SYSCASE')['$nonzero?']()) ? ($send(self, 'proc', [], function $Pathname$9(a, b){ if (a == null) a = nil; if (b == null) b = nil; return a.$casecmp(b)['$=='](0);})) : ($send(self, 'proc', [], function $Pathname$10(a, b){ if (a == null) a = nil; if (b == null) b = nil; return a['$=='](b);})))); $def(self, '$relative_path_from', function $$relative_path_from(base_directory) { var $a, $b, self = this, dest_directory = nil, dest_prefix = nil, dest_names = nil, r = nil, basename = nil, base_prefix = nil, base_names = nil, $ret_or_1 = nil, $ret_or_2 = nil, relpath_names = nil; dest_directory = self.$cleanpath().$to_s(); base_directory = base_directory.$cleanpath().$to_s(); dest_prefix = dest_directory; dest_names = []; while ($truthy((r = self.$chop_basename(dest_prefix)))) { $b = r, $a = $to_ary($b), (dest_prefix = ($a[0] == null ? nil : $a[0])), (basename = ($a[1] == null ? nil : $a[1])), $b; if ($neqeq(basename, ".")) { dest_names.$unshift(basename) }; }; base_prefix = base_directory; base_names = []; while ($truthy((r = self.$chop_basename(base_prefix)))) { $b = r, $a = $to_ary($b), (base_prefix = ($a[0] == null ? nil : $a[0])), (basename = ($a[1] == null ? nil : $a[1])), $b; if ($neqeq(basename, ".")) { base_names.$unshift(basename) }; }; if (!$truthy($$('SAME_PATHS')['$[]'](dest_prefix, base_prefix))) { self.$raise($$('ArgumentError'), "different prefix: " + (dest_prefix.$inspect()) + " and " + (base_directory.$inspect())) }; while ($truthy(($truthy(($ret_or_1 = ($truthy(($ret_or_2 = dest_names['$empty?']()['$!']())) ? (base_names['$empty?']()['$!']()) : ($ret_or_2)))) ? ($$('SAME_PATHS')['$[]'](dest_names.$first(), base_names.$first())) : ($ret_or_1)))) { dest_names.$shift(); base_names.$shift(); }; if ($truthy(base_names['$include?'](".."))) { self.$raise($$('ArgumentError'), "base_directory has ..: " + (base_directory.$inspect())) }; base_names.$fill(".."); relpath_names = $rb_plus(base_names, dest_names); if ($truthy(relpath_names['$empty?']())) { return $$('Pathname').$new(".") } else { return $$('Pathname').$new($send($$('File'), 'join', $to_a(relpath_names))) }; }); $def(self, '$entries', function $$entries() { var self = this; return $send($$('Dir').$entries(self.path), 'map', [], function $$11(f){var self = $$11.$$s == null ? this : $$11.$$s; if (f == null) f = nil; return self.$class().$new(f);}, {$$s: self}) }); $alias(self, "===", "=="); $alias(self, "eql?", "=="); $alias(self, "to_s", "to_path"); return $alias(self, "to_str", "to_path"); })($nesting[0], null, $nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); return $def(self, '$Pathname', function $$Pathname(path) { return $$('Pathname').$new(path) }) })($nesting[0], $nesting); }; Opal.modules["opal/hike"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2, $def = Opal.def, $return_self = Opal.return_self, $truthy = Opal.truthy, $thrower = Opal.thrower, $to_ary = Opal.to_ary, $regexp = Opal.regexp, $rb_plus = Opal.rb_plus, $slice = Opal.slice, $to_a = Opal.to_a, self = Opal.top, $nesting = [], nil = Opal.nil; Opal.add_stubs('require,attr_reader,freeze,dup,map,new,to_s,sub,=~,find_in_base_path,find_in_paths,[],[]=,directory?,sort,reject,entries,key?,exist?,stat,protected,is_a?,last,pop,split,each,match,join,to_proc,paths_contain?,pattern_for,select,sort_matches,file?,any?,paths,==,length,build_pattern_for,extensions,escape,sort_by,scan,inject,index,+,expand_path,concat,normalize_path,normalize_extension,find,root,private,start_with?,relative?'); self.$require("pathname"); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Hike'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Index'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; $proto.root = $proto.entries = $proto.stats = $proto.pathnames = $proto.patterns = nil; self.$attr_reader("paths"); self.$attr_reader("extensions"); $def(self, '$initialize', function $$initialize(root, paths, extensions) { var self = this; self.root = root; self.paths = paths.$dup().$freeze(); self.extensions = extensions.$dup().$freeze(); self.pathnames = $send(paths, 'map', [], function $$1(path){ if (path == null) path = nil; return $$('Pathname').$new(path);}); self.stats = $hash2([], {}); self.entries = $hash2([], {}); return (self.patterns = $hash2([], {})); }); $def(self, '$root', function $$root() { var self = this; return self.root.$to_s() }); $def(self, '$index', $return_self); $def(self, '$find', function $$find(logical_path) {try { var $t_return = $thrower('return'); var self = this, base_path = nil; base_path = $$('Pathname').$new(self.root); logical_path = $$('Pathname').$new(logical_path.$sub(/^\//, "")); if ($truthy(logical_path.$to_s()['$=~'](/^\.\.?\//))) { $send(self, 'find_in_base_path', [logical_path, base_path], function $$2(path){ if (path == null) path = nil; $t_return.$throw(path);}, {$$ret: $t_return}) } else { $send(self, 'find_in_paths', [logical_path], function $$3(path){ if (path == null) path = nil; $t_return.$throw(path);}, {$$ret: $t_return}) }; return nil;} catch($e) { if ($e === $t_return) return $e.$v; throw $e; } }); $def(self, '$entries', function $$entries(path) { var $a, self = this, $ret_or_1 = nil, pathname = nil; if ($truthy(($ret_or_1 = self.entries['$[]'](path.$to_s())))) { return $ret_or_1 } else { return ($a = [path.$to_s(), ((pathname = $$('Pathname').$new(path)), ($truthy(pathname['$directory?']()) ? ($send(pathname.$entries(), 'reject', [], function $$4(entry){ if (entry == null) entry = nil; return entry.$to_s()['$=~'](/^\.|~$|^\#.*\#$/);}).$sort()) : ([])))], $send(self.entries, '[]=', $a), $a[$a.length - 1]) } }); $def(self, '$stat', function $$stat(path) { var $a, self = this, key = nil; key = path.$to_s(); if ($truthy(self.stats['$key?'](key))) { return self.stats['$[]'](key) } else if ($truthy($$('File')['$exist?'](path))) { return ($a = [key, $$('File').$stat(path)], $send(self.stats, '[]=', $a), $a[$a.length - 1]) } else { return ($a = [key, nil], $send(self.stats, '[]=', $a), $a[$a.length - 1]) }; }); self.$protected(); $def(self, '$extract_options!', function $Index_extract_options$excl$5(arguments$) { if ($truthy(arguments$.$last()['$is_a?']($$('Hash')))) { return arguments$.$pop().$dup() } else { return $hash2([], {}) } }); $def(self, '$find_in_paths', function $$find_in_paths(logical_path) { var block = $$find_in_paths.$$p || nil, $a, $b, self = this, dirname = nil, basename = nil; $$find_in_paths.$$p = null; ; $b = logical_path.$split(), $a = $to_ary($b), (dirname = ($a[0] == null ? nil : $a[0])), (basename = ($a[1] == null ? nil : $a[1])), $b; return $send(self.pathnames, 'each', [], function $$6(base_path){var self = $$6.$$s == null ? this : $$6.$$s; if (base_path == null) base_path = nil; return $send(self, 'match', [base_path.$join(dirname), basename], block.$to_proc());}, {$$s: self}); }); $def(self, '$find_in_base_path', function $$find_in_base_path(logical_path, base_path) { var block = $$find_in_base_path.$$p || nil, $a, $b, self = this, candidate = nil, dirname = nil, basename = nil; $$find_in_base_path.$$p = null; ; candidate = base_path.$join(logical_path); $b = candidate.$split(), $a = $to_ary($b), (dirname = ($a[0] == null ? nil : $a[0])), (basename = ($a[1] == null ? nil : $a[1])), $b; if ($truthy(self['$paths_contain?'](dirname))) { return $send(self, 'match', [dirname, basename], block.$to_proc()) } else { return nil }; }); $def(self, '$match', function $$match(dirname, basename) { var $yield = $$match.$$p || nil, self = this, matches = nil, pattern = nil; $$match.$$p = null; matches = self.$entries(dirname); pattern = self.$pattern_for(basename); matches = $send(matches, 'select', [], function $$7(m){ if (m == null) m = nil; return m.$to_s()['$=~'](pattern);}); return $send(self.$sort_matches(matches, basename), 'each', [], function $$8(path){var self = $$8.$$s == null ? this : $$8.$$s, pathname = nil, stat = nil; if (path == null) path = nil; pathname = dirname.$join(path); stat = self.$stat(pathname); if (($truthy(stat) && ($truthy(stat['$file?']())))) { return Opal.yield1($yield, pathname.$to_s()); } else { return nil };}, {$$s: self}); }); $def(self, '$paths_contain?', function $Index_paths_contain$ques$9(dirname) { var self = this; return $send(self.$paths(), 'any?', [], function $$10(path){ if (path == null) path = nil; return dirname.$to_s()['$[]'](0, path.$length())['$=='](path);}) }); $def(self, '$pattern_for', function $$pattern_for(basename) { var $a, self = this, $ret_or_1 = nil; if ($truthy(($ret_or_1 = self.patterns['$[]'](basename)))) { return $ret_or_1 } else { return ($a = [basename, self.$build_pattern_for(basename)], $send(self.patterns, '[]=', $a), $a[$a.length - 1]) } }); $def(self, '$build_pattern_for', function $$build_pattern_for(basename) { var self = this, extension_pattern = nil; extension_pattern = $send(self.$extensions(), 'map', [], function $$11(e){ if (e == null) e = nil; return $$('Regexp').$escape(e);}).$join("|"); return $regexp(["^", basename, "(?:", extension_pattern, ")*$"]); }); return $def(self, '$sort_matches', function $$sort_matches(matches, basename) { var self = this; return $send(matches, 'sort_by', [], function $$12(match){var self = $$12.$$s == null ? this : $$12.$$s, extnames = nil; if (match == null) match = nil; extnames = match.$sub(basename.$to_s(), "").$to_s().$scan(/\.[^.]+/); return $send(extnames, 'inject', [0], function $$13(sum, ext){var self = $$13.$$s == null ? this : $$13.$$s, index = nil; if (sum == null) sum = nil; if (ext == null) ext = nil; index = self.$extensions().$index(ext); if ($truthy(index)) { return $rb_plus($rb_plus(sum, index), 1) } else { return sum };}, {$$s: self});}, {$$s: self}) }); })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Trail'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; $proto.root = $proto.paths = $proto.extensions = nil; self.$attr_reader("paths"); self.$attr_reader("extensions"); $def(self, '$initialize', function $$initialize(root) { var self = this; if (root == null) root = "."; self.root = $$('Pathname').$new(root).$expand_path(); self.paths = []; return (self.extensions = []); }, -1); $def(self, '$root', function $$root() { var self = this; return self.root.$to_s() }); $def(self, '$append_paths', function $$append_paths($a) { var $post_args, paths, self = this; $post_args = $slice(arguments); paths = $post_args; return self.paths.$concat($send(paths, 'map', [], function $$14(p){var self = $$14.$$s == null ? this : $$14.$$s; if (p == null) p = nil; return self.$normalize_path(p);}, {$$s: self})); }, -1); $def(self, '$append_extensions', function $$append_extensions($a) { var $post_args, extensions, self = this; $post_args = $slice(arguments); extensions = $post_args; return self.extensions.$concat($send(extensions, 'map', [], function $$15(e){var self = $$15.$$s == null ? this : $$15.$$s; if (e == null) e = nil; return self.$normalize_extension(e);}, {$$s: self})); }, -1); $def(self, '$find', function $$find($a) { var block = $$find.$$p || nil, $post_args, args, self = this; $$find.$$p = null; ; $post_args = $slice(arguments); args = $post_args; return $send(self.$index(), 'find', $to_a(args), block.$to_proc()); }, -1); $def(self, '$index', function $$index() { var self = this; return $$('Index').$new(self.$root(), self.$paths(), self.$extensions()) }); $def(self, '$entries', function $$entries(path) { var pathname = nil; pathname = $$('Pathname').$new(path); if ($truthy(pathname['$directory?']())) { return $send(pathname.$entries(), 'reject', [], function $$16(entry){ if (entry == null) entry = nil; return entry.$to_s()['$=~'](/^\.|~$|^\#.*\#$/);}).$sort() } else { return [] }; }); $def(self, '$stat', function $$stat(path) { if ($truthy($$('File')['$exist?'](path))) { return $$('File').$stat(path.$to_s()) } else { return nil } }); self.$private(); $def(self, '$normalize_extension', function $$normalize_extension(ext) { if ($truthy(ext['$start_with?']("."))) { return ext } else { return "." + (ext) } }); return $def(self, '$normalize_path', function $$normalize_path(path) { var self = this; path = $$('Pathname').$new(path); if ($truthy(path['$relative?']())) { path = self.root.$join(path) }; return path.$expand_path().$to_s(); }); })($nesting[0], null, $nesting); })($nesting[0], $nesting) })($nesting[0], $nesting); }; Opal.modules["opal/path_reader"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $klass = Opal.klass, $const_set = Opal.const_set, $regexp = Opal.regexp, $send = Opal.send, $to_a = Opal.to_a, $def = Opal.def, $truthy = Opal.truthy, $slice = Opal.slice, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('require,freeze,quote,paths,new,append_paths,append_extensions,expand,nil?,exist?,open,to_proc,=~,absolute?,find_path,file_finder,extensions,private,Pathname,find,attr_reader'); self.$require("opal/regexp_anchors"); self.$require("opal/hike"); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'PathReader'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting), $proto = self.$$prototype; $proto.file_finder = nil; $const_set($nesting[0], 'RELATIVE_PATH_REGEXP', $regexp([$$$($$('Opal'), 'REGEXP_START'), "\\.?\\.", $$('Regexp').$quote($$$($$('File'), 'SEPARATOR'))]).$freeze()); $const_set($nesting[0], 'DEFAULT_EXTENSIONS', [".js", ".js.rb", ".rb", ".opalerb"].$freeze()); $def(self, '$initialize', function $$initialize(paths, extensions) { var self = this; if (paths == null) paths = $$('Opal').$paths(); if (extensions == null) extensions = $$('DEFAULT_EXTENSIONS'); self.file_finder = $$$($$('Hike'), 'Trail').$new(); $send(self.file_finder, 'append_paths', $to_a(paths)); return $send(self.file_finder, 'append_extensions', $to_a(extensions)); }, -1); $def(self, '$read', function $$read(path) { var self = this, full_path = nil; full_path = self.$expand(path); if ($truthy(full_path['$nil?']())) { return nil }; if ($truthy($$('File')['$exist?'](full_path))) { return $send($$('File'), 'open', [full_path, "rb:UTF-8"], "read".$to_proc()) } else { return nil }; }); $def(self, '$expand', function $$expand(path) { var self = this; if (($truthy($$('Pathname').$new(path)['$absolute?']()) || ($truthy(path['$=~']($$('RELATIVE_PATH_REGEXP')))))) { return path } else { return self.$find_path(path) } }); $def(self, '$paths', function $$paths() { var self = this; return self.$file_finder().$paths() }); $def(self, '$extensions', function $$extensions() { var self = this; return self.$file_finder().$extensions() }); $def(self, '$append_paths', function $$append_paths($a) { var $post_args, paths, self = this; $post_args = $slice(arguments); paths = $post_args; return $send(self.$file_finder(), 'append_paths', $to_a(paths)); }, -1); self.$private(); $def(self, '$find_path', function $$find_path(path) { var self = this, pathname = nil; pathname = self.$Pathname(path); if (($truthy(pathname['$absolute?']()) && ($truthy(pathname['$exist?']())))) { return path }; return self.$file_finder().$find(path); }); return self.$attr_reader("file_finder"); })($nesting[0], null, $nesting) })($nesting[0], $nesting); }; Opal.modules["opal/paths"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $defs = Opal.defs, $slice = Opal.slice, $rb_plus = Opal.rb_plus, $gvars = Opal.gvars, $send = Opal.send, $to_a = Opal.to_a, $def = Opal.def, $truthy = Opal.truthy, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('expand_path,append_paths,concat,gem_dir,[],+,grep,require_paths_for_gem,private,find_by_name,raise,each,runtime_dependencies,name,map,require_paths,<<,join,extend,freeze,core_dir,std_dir,reset_paths!'); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); $defs(self, '$gem_dir', function $$gem_dir() { return $$('File').$expand_path("../..", "opal/paths.rb") }); $defs(self, '$core_dir', function $$core_dir() { return $$('File').$expand_path("../../../opal", "opal/paths.rb") }); $defs(self, '$std_dir', function $$std_dir() { return $$('File').$expand_path("../../../stdlib", "opal/paths.rb") }); $defs(self, '$append_path', function $$append_path(path) { var self = this; return self.$append_paths(path) }); $defs(self, '$append_paths', function $$append_paths($a) { var $post_args, paths, self = this; if (self.paths == null) self.paths = nil; $post_args = $slice(arguments); paths = $post_args; self.paths.$concat(paths); return nil; }, -1); $defs(self, '$dependent_files', function $$dependent_files() { var opal_path = nil, files = nil; if ($gvars.LOADED_FEATURES == null) $gvars.LOADED_FEATURES = nil; opal_path = $$('File').$expand_path("..", $$('Opal').$gem_dir()); files = $$('Dir')['$[]']("" + (opal_path) + "/{Gemfile*,*.gemspec,lib/**/*}"); files = $rb_plus(files, $gvars.LOADED_FEATURES.$grep(/lib\/(parser|ast)/)); return files; }); (function($base, $parent_nesting) { var self = $module($base, 'UseGem'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); $def(self, '$use_gem', function $$use_gem(gem_name, include_dependencies) { var self = this; if (include_dependencies == null) include_dependencies = true; return $send(self, 'append_paths', $to_a(self.$require_paths_for_gem(gem_name, include_dependencies))); }, -2); self.$private(); return $def(self, '$require_paths_for_gem', function $$require_paths_for_gem(gem_name, include_dependencies) { var self = this, paths = nil, spec = nil, gem_dir = nil; paths = []; spec = $$$($$('Gem'), 'Specification').$find_by_name(gem_name); if (!$truthy(spec)) { self.$raise($$('GemNotFound'), gem_name) }; if ($truthy(include_dependencies)) { $send(spec.$runtime_dependencies(), 'each', [], function $$1(dependency){var self = $$1.$$s == null ? this : $$1.$$s; if (dependency == null) dependency = nil; return (paths = $rb_plus(paths, self.$require_paths_for_gem(dependency.$name(), include_dependencies)));}, {$$s: self}) }; gem_dir = spec.$gem_dir(); $send(spec.$require_paths(), 'map', [], function $$2(path){ if (path == null) path = nil; return paths['$<<']($$('File').$join(gem_dir, path));}); return paths; }); })($nesting[0], $nesting); self.$extend($$('UseGem')); $defs(self, '$paths', function $$paths() { var self = this; if (self.paths == null) self.paths = nil; return self.paths.$freeze() }); $defs(self, '$reset_paths!', function $Opal_reset_paths$excl$3() { var self = this; self.paths = [self.$core_dir(), self.$std_dir(), self.$gem_dir()]; nil; return nil; }); return self['$reset_paths!'](); })($nesting[0], $nesting) }; Opal.modules["set"] = Opal.return_val(Opal.nil); /* Generated by Opal 1.7.3 */ Opal.modules["opal/config"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $truthy = Opal.truthy, $hash2 = Opal.hash2, $def = Opal.def, $send = Opal.send, $eqeqeq = Opal.eqeqeq, $assign_ivar_val = Opal.assign_ivar_val, $lambda = Opal.lambda, self = Opal.top, $nesting = [], nil = Opal.nil; Opal.add_stubs('require,extend,private,fetch,[]=,config_options,define_singleton_method,config,any?,===,raise,inspect,public,each,call,default_config,config_option,new'); self.$require("set"); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Config'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); self.$extend(self); self.$private(); $def(self, '$config_options', function $$config_options() { var self = this, $ret_or_1 = nil; if (self.config_options == null) self.config_options = nil; return (self.config_options = ($truthy(($ret_or_1 = self.config_options)) ? ($ret_or_1) : ($hash2([], {})))) }); $def(self, '$config_option', function $$config_option(name, default_value, options) { var self = this, compiler = nil, valid_values = nil; if (options == null) options = $hash2([], {}); compiler = options.$fetch("compiler_option", nil); valid_values = options.$fetch("valid_values", [true, false]); self.$config_options()['$[]='](name, $hash2(["default", "compiler"], {"default": default_value, "compiler": compiler})); $send(self, 'define_singleton_method', [name], function $$1(){var self = $$1.$$s == null ? this : $$1.$$s; return self.$config().$fetch(name, default_value)}, {$$s: self}); return $send(self, 'define_singleton_method', ["" + (name) + "="], function $$2(value){var $a, self = $$2.$$s == null ? this : $$2.$$s; if (value == null) value = nil; if (!$truthy($send(valid_values, 'any?', [], function $$3(valid_value){ if (valid_value == null) valid_value = nil; return valid_value['$==='](value);}))) { self.$raise($$('ArgumentError'), "" + ("Not a valid value for option " + (self) + "." + (name) + ", provided " + (value.$inspect()) + ". ") + ("Must be " + (valid_values.$inspect()) + " === " + (value.$inspect()))) }; return ($a = [name, value], $send(self.$config(), '[]=', $a), $a[$a.length - 1]);}, {$$s: self}); }, -3); self.$public(); $def(self, '$default_config', function $$default_config() { var self = this, default_config = nil; default_config = $hash2([], {}); $send(self.$config_options(), 'each', [], function $$4(name, options){var $a, default_value = nil; if (name == null) name = nil; if (options == null) options = nil; default_value = options.$fetch("default"); default_value = ($eqeqeq($$('Proc'), default_value) ? (default_value.$call()) : (default_value)); return ($a = [name, default_value], $send(default_config, '[]=', $a), $a[$a.length - 1]);}); return default_config; }); $def(self, '$compiler_options', function $$compiler_options() { var self = this, compiler_options = nil; compiler_options = $hash2([], {}); $send(self.$config_options(), 'each', [], function $$5(name, options){var $a, self = $$5.$$s == null ? this : $$5.$$s, compiler_option_name = nil; if (name == null) name = nil; if (options == null) options = nil; compiler_option_name = options.$fetch("compiler"); return ($a = [compiler_option_name, self.$config().$fetch(name)], $send(compiler_options, '[]=', $a), $a[$a.length - 1]);}, {$$s: self}); return compiler_options; }); $def(self, '$config', function $$config() { var self = this, $ret_or_1 = nil; if (self.config == null) self.config = nil; return (self.config = ($truthy(($ret_or_1 = self.config)) ? ($ret_or_1) : (self.$default_config()))) }); $def(self, '$reset!', $assign_ivar_val("config", nil)); self.$config_option("method_missing_enabled", true, $hash2(["compiler_option"], {"compiler_option": "method_missing"})); self.$config_option("const_missing_enabled", true, $hash2(["compiler_option"], {"compiler_option": "const_missing"})); self.$config_option("arity_check_enabled", false, $hash2(["compiler_option"], {"compiler_option": "arity_check"})); self.$config_option("freezing_stubs_enabled", true, $hash2(["compiler_option"], {"compiler_option": "freezing"})); self.$config_option("esm", false, $hash2(["compiler_option"], {"compiler_option": "esm"})); self.$config_option("dynamic_require_severity", "warning", $hash2(["compiler_option", "valid_values"], {"compiler_option": "dynamic_require_severity", "valid_values": ["error", "warning", "ignore"]})); self.$config_option("missing_require_severity", "error", $hash2(["valid_values"], {"valid_values": ["error", "warning", "ignore"]})); self.$config_option("irb_enabled", false, $hash2(["compiler_option"], {"compiler_option": "irb"})); self.$config_option("inline_operators_enabled", true, $hash2(["compiler_option"], {"compiler_option": "inline_operators"})); self.$config_option("source_map_enabled", true); self.$config_option("enable_source_location", false, $hash2(["compiler_option"], {"compiler_option": "enable_source_location"})); self.$config_option("enable_file_source_embed", false, $hash2(["compiler_option"], {"compiler_option": "enable_file_source_embed"})); return self.$config_option("stubbed_files", $lambda(function $Config$6(){ return $$('Set').$new()}), $hash2(["valid_values"], {"valid_values": [$$('Set')]})); })($nesting[0], $nesting) })($nesting[0], $nesting); }; Opal.modules["opal/cache"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $truthy = Opal.truthy, $not = Opal.not, $eqeq = Opal.eqeq, $defs = Opal.defs, $klass = Opal.klass, $slice = Opal.slice, $def = Opal.def, $send = Opal.send, $rb_plus = Opal.rb_plus, $range = Opal.range, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('require,attr_writer,singleton_class,!,find_dir,[],==,new,module_function,respond_to?,fetch,to_proc,+,digest,join,runtime_key,get,dynamic_cache_result,set,dependent_files,map,sort,size,to_f,mtime,to_s,to_i,hexdigest'); self.$require("opal/paths"); nil; nil; return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); self.$singleton_class().$attr_writer("cache"); $defs(self, '$cache', function $$cache() { var self = this, $ret_or_1 = nil; if (self.cache == null) self.cache = nil; return (self.cache = ($truthy(($ret_or_1 = self.cache)) ? ($ret_or_1) : ((($eqeq($$('RUBY_ENGINE'), "opal") || ($truthy($$('ENV')['$[]']("OPAL_CACHE_DISABLE")))) || ($not($$$($$('Cache'), 'FileCache').$find_dir()))) ? ($$$($$('Cache'), 'NullCache').$new()) : ($$$($$('Cache'), 'FileCache').$new())))) }); return (function($base, $parent_nesting) { var self = $module($base, 'Cache'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); (function($base, $super) { var self = $klass($base, $super, 'NullCache'); return $def(self, '$fetch', function $$fetch($a) { var $post_args, $fwd_rest, $yield = $$fetch.$$p || nil; $$fetch.$$p = null; $post_args = $slice(arguments); $fwd_rest = $post_args; return Opal.yieldX($yield, []);; }, -1) })($nesting[0], null); self.$module_function(); $def(self, '$fetch', function $$fetch(cache, key) { var block = $$fetch.$$p || nil, self = this, data = nil, $ret_or_1 = nil, compiler = nil; $$fetch.$$p = null; ; if ($truthy(cache['$respond_to?']("fetch"))) { return $send(cache, 'fetch', [key], block.$to_proc()) }; key = $rb_plus($rb_plus(self.$digest(key.$join("/")), "-"), self.$runtime_key()); data = cache.$get(key); if ($truthy(($ret_or_1 = data))) { return $ret_or_1 } else { compiler = Opal.yieldX(block, []); if (!$truthy(compiler.$dynamic_cache_result())) { cache.$set(key, compiler) }; return compiler; }; }); $def(self, '$runtime_key', function $$runtime_key() { var self = this, $ret_or_1 = nil, files = nil; if (self.runtime_key == null) self.runtime_key = nil; return (self.runtime_key = ($truthy(($ret_or_1 = self.runtime_key)) ? ($ret_or_1) : (((files = $$('Opal').$dependent_files()), self.$digest([$send(files.$sort(), 'map', [], function $$1(f){ if (f == null) f = nil; return "" + (f) + ":" + ($$('File').$size(f)) + ":" + ($$('File').$mtime(f).$to_f());}), $$('RUBY_VERSION'), $$('RUBY_PATCHLEVEL')].$join("/")))))) }); return $def(self, '$digest', function $$digest(string) { return $$$($$$('Digest'), 'SHA256').$hexdigest(string)['$[]']($range(-32, -1, false)).$to_i(16).$to_s(36) }); })($nesting[0], $nesting); })($nesting[0], $nesting); }; Opal.modules["opal/builder_scheduler/sequential"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $def = Opal.def, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('map,process_require,builder,raise,inspect,message,backtrace'); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'BuilderScheduler'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Sequential'); var $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); return $def(self, '$process_requires', function $$process_requires(rel_path, requires, autoloads, options) { var self = this, error = nil; try { return $send(requires, 'map', [], function $$1(r){var self = $$1.$$s == null ? this : $$1.$$s; if (r == null) r = nil; return self.$builder().$process_require(r, autoloads, options);}, {$$s: self}) } catch ($err) { if (Opal.rescue($err, [$$$($$('Builder'), 'MissingRequire')])) {(error = $err) try { return self.$raise(error, "A file required by " + (rel_path.$inspect()) + " wasn't found.\n" + (error.$message()), error.$backtrace()) } finally { Opal.pop_exception(); } } else { throw $err; } } }) })($nesting[0], $$('BuilderScheduler'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; Opal.modules["opal/builder_scheduler"] = function(Opal) {/* Generated by Opal 1.7.3 */ var $module = Opal.module, $klass = Opal.klass, $assign_ivar = Opal.assign_ivar, $def = Opal.def, $send = Opal.send, $nesting = [], nil = Opal.nil, $$$ = Opal.$$$; Opal.add_stubs('attr_accessor,singleton_class,require,builder_scheduler='); nil; return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $a, $nesting = [self].concat($parent_nesting), $$ = Opal.$r($nesting); (function($base, $super) { var self = $klass($base, $super, 'BuilderScheduler'); $def(self, '$initialize', $assign_ivar("builder")); return self.$attr_accessor