opal-irb 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opal-irb (0.8.0)
4
+ opal-irb (0.8.1)
5
5
  opal (~> 0.8.0)
6
6
  opal-jquery (~> 0.4.0)
7
7
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  opal-irb
2
2
  =========
3
+ [![Gem Version](https://badge.fury.io/rb/opal-irb.svg)](http://badge.fury.io/rb/opal-irb)
3
4
 
4
5
  irb (interactive ruby) for Opal (Ruby running on javascript). This is
5
6
  interactive console (REPL) on a webpage. Good for testing Opal/ruby
@@ -52,7 +53,10 @@ Embedding into lissio app, as made by lissio new
52
53
 
53
54
  * add to Gemfile opal-irb
54
55
  ```ruby
55
- gem 'opal-irb', github: 'fkchang/opal-irb'
56
+ # gem 'opal-irb', '0.7.0' for Opal 0.7.*
57
+ # gem 'opal-irb', '0.8.*' for Opal 0.8.*
58
+ # For latest do below
59
+ gem 'opal-irb', github: 'fkchang/opal-irb'
56
60
  ```
57
61
  * invoke app to require opal-jquery and opal-irb
58
62
  ```bash
@@ -41846,6 +41846,374 @@ Opal.modules["browser"] = function(Opal) {
41846
41846
  return self.$require("browser/css");
41847
41847
  };
41848
41848
 
41849
+ /* Generated by Opal 0.8.0 */
41850
+ Opal.modules["date"] = function(Opal) {
41851
+ Opal.dynamic_require_severity = "error";
41852
+ function $rb_plus(lhs, rhs) {
41853
+ return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
41854
+ }
41855
+ function $rb_minus(lhs, rhs) {
41856
+ return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
41857
+ }
41858
+ var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
41859
+
41860
+ Opal.add_stubs(['$allocate', '$wrap', '$clone', '$raise', '$>>', '$==', '$wday', '$to_s', '$alias_method']);
41861
+ return (function($base, $super) {
41862
+ function $Date(){};
41863
+ var self = $Date = $klass($base, $super, 'Date', $Date);
41864
+
41865
+ var def = self.$$proto, $scope = self.$$scope;
41866
+
41867
+ def.date = nil;
41868
+ (function(self) {
41869
+ var $scope = self.$$scope, def = self.$$proto;
41870
+
41871
+ self.$$proto.$civil = self.$$proto.$new;
41872
+ self.$$proto.$wrap = function(native$) {
41873
+ var self = this, instance = nil;
41874
+
41875
+ instance = self.$allocate();
41876
+ instance.date = native$;
41877
+ return instance;
41878
+ };
41879
+ self.$$proto.$parse = function(string) {
41880
+ var self = this, match = nil;
41881
+
41882
+ match = /^(\d*)-(\d*)-(\d*)/.exec(string);
41883
+ return self.$wrap(new Date(parseInt(match[1]), parseInt(match[2]) - 1, parseInt(match[3])));
41884
+ };
41885
+ return (self.$$proto.$today = function() {
41886
+ var self = this;
41887
+
41888
+ return self.$wrap(new Date());
41889
+ }, nil) && 'today';
41890
+ })(self.$singleton_class());
41891
+
41892
+ def.$initialize = function(year, month, day) {
41893
+ var self = this;
41894
+
41895
+ return self.date = new Date(year, month - 1, day);
41896
+ };
41897
+
41898
+ def['$-'] = function(date) {
41899
+ var self = this;
41900
+
41901
+
41902
+ if (date.$$is_number) {
41903
+ var result = self.$clone();
41904
+ result.date.setDate(self.date.getDate() - date);
41905
+ return result;
41906
+ }
41907
+ else if (date.date) {
41908
+ return Math.round((self.date - date.date) / (1000 * 60 * 60 * 24));
41909
+ }
41910
+ else {
41911
+ self.$raise($scope.get('TypeError'));
41912
+ }
41913
+ ;
41914
+ };
41915
+
41916
+ def['$+'] = function(date) {
41917
+ var self = this;
41918
+
41919
+
41920
+ if (date.$$is_number) {
41921
+ var result = self.$clone();
41922
+ result.date.setDate(self.date.getDate() + date);
41923
+ return result;
41924
+ }
41925
+ else {
41926
+ self.$raise($scope.get('TypeError'));
41927
+ }
41928
+ ;
41929
+ };
41930
+
41931
+ def['$<'] = function(other) {
41932
+ var self = this;
41933
+
41934
+
41935
+ var a = self.date, b = other.date;
41936
+ a.setHours(0, 0, 0, 0);
41937
+ b.setHours(0, 0, 0, 0);
41938
+ return a < b;
41939
+ ;
41940
+ };
41941
+
41942
+ def['$<='] = function(other) {
41943
+ var self = this;
41944
+
41945
+
41946
+ var a = self.date, b = other.date;
41947
+ a.setHours(0, 0, 0, 0);
41948
+ b.setHours(0, 0, 0, 0);
41949
+ return a <= b;
41950
+ ;
41951
+ };
41952
+
41953
+ def['$>'] = function(other) {
41954
+ var self = this;
41955
+
41956
+
41957
+ var a = self.date, b = other.date;
41958
+ a.setHours(0, 0, 0, 0);
41959
+ b.setHours(0, 0, 0, 0);
41960
+ return a > b;
41961
+ ;
41962
+ };
41963
+
41964
+ def['$>='] = function(other) {
41965
+ var self = this;
41966
+
41967
+
41968
+ var a = self.date, b = other.date;
41969
+ a.setHours(0, 0, 0, 0);
41970
+ b.setHours(0, 0, 0, 0);
41971
+ return a >= b;
41972
+ ;
41973
+ };
41974
+
41975
+ def['$<=>'] = function(other) {
41976
+ var self = this;
41977
+
41978
+
41979
+ var a = self.date, b = other.date;
41980
+ a.setHours(0, 0, 0, 0);
41981
+ b.setHours(0, 0, 0, 0);
41982
+
41983
+ if (a < b) {
41984
+ return -1;
41985
+ }
41986
+ else if (a > b) {
41987
+ return 1;
41988
+ }
41989
+ else {
41990
+ return 0;
41991
+ }
41992
+ ;
41993
+ };
41994
+
41995
+ def['$=='] = function(other) {
41996
+ var self = this;
41997
+
41998
+
41999
+ var a = self.date, b = other.date;
42000
+ return (a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate());
42001
+ ;
42002
+ };
42003
+
42004
+ def['$>>'] = function(n) {
42005
+ var self = this;
42006
+
42007
+
42008
+ if (!n.$$is_number) {
42009
+ self.$raise($scope.get('TypeError'));
42010
+ }
42011
+
42012
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42013
+ date.setDate(1);
42014
+ date.setMonth(date.getMonth() + n);
42015
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42016
+ return result;
42017
+ ;
42018
+ };
42019
+
42020
+ def['$<<'] = function(n) {
42021
+ var self = this;
42022
+
42023
+
42024
+ if (!n.$$is_number) {
42025
+ self.$raise($scope.get('TypeError'));
42026
+ }
42027
+
42028
+ return self['$>>'](-n);
42029
+ ;
42030
+ };
42031
+
42032
+ Opal.defn(self, '$eql?', def['$==']);
42033
+
42034
+ def.$clone = function() {
42035
+ var self = this;
42036
+
42037
+ return $scope.get('Date').$wrap(new Date(self.date.getTime()));
42038
+ };
42039
+
42040
+ def.$day = function() {
42041
+ var self = this;
42042
+
42043
+ return self.date.getDate();
42044
+ };
42045
+
42046
+ def['$friday?'] = function() {
42047
+ var self = this;
42048
+
42049
+ return self.$wday()['$=='](5);
42050
+ };
42051
+
42052
+ def['$monday?'] = function() {
42053
+ var self = this;
42054
+
42055
+ return self.$wday()['$=='](1);
42056
+ };
42057
+
42058
+ def.$month = function() {
42059
+ var self = this;
42060
+
42061
+ return self.date.getMonth() + 1;
42062
+ };
42063
+
42064
+ def.$next = function() {
42065
+ var self = this;
42066
+
42067
+ return $rb_plus(self, 1);
42068
+ };
42069
+
42070
+ def.$next_day = function(n) {
42071
+ var self = this;
42072
+
42073
+ if (n == null) {
42074
+ n = 1
42075
+ }
42076
+ return $rb_plus(self, n);
42077
+ };
42078
+
42079
+ def.$next_month = function() {
42080
+ var self = this;
42081
+
42082
+
42083
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42084
+ date.setDate(1);
42085
+ date.setMonth(date.getMonth() + 1);
42086
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42087
+ return result;
42088
+ ;
42089
+ };
42090
+
42091
+ def.$prev_day = function(n) {
42092
+ var self = this;
42093
+
42094
+ if (n == null) {
42095
+ n = 1
42096
+ }
42097
+ return $rb_minus(self, n);
42098
+ };
42099
+
42100
+ def.$prev_month = function() {
42101
+ var self = this;
42102
+
42103
+
42104
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42105
+ date.setDate(1);
42106
+ date.setMonth(date.getMonth() - 1);
42107
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42108
+ return result;
42109
+ ;
42110
+ };
42111
+
42112
+ def['$saturday?'] = function() {
42113
+ var self = this;
42114
+
42115
+ return self.$wday()['$=='](6);
42116
+ };
42117
+
42118
+ def.$strftime = function(format) {
42119
+ var self = this;
42120
+
42121
+ if (format == null) {
42122
+ format = ""
42123
+ }
42124
+
42125
+ if (format == '') {
42126
+ return self.$to_s();
42127
+ }
42128
+
42129
+ return self.date.$strftime(format);
42130
+ ;
42131
+ };
42132
+
42133
+ self.$alias_method("succ", "next");
42134
+
42135
+ def['$sunday?'] = function() {
42136
+ var self = this;
42137
+
42138
+ return self.$wday()['$=='](0);
42139
+ };
42140
+
42141
+ def['$thursday?'] = function() {
42142
+ var self = this;
42143
+
42144
+ return self.$wday()['$=='](4);
42145
+ };
42146
+
42147
+ def.$to_s = function() {
42148
+ var self = this;
42149
+
42150
+
42151
+ var d = self.date, year = d.getFullYear(), month = d.getMonth() + 1, day = d.getDate();
42152
+ if (month < 10) { month = '0' + month; }
42153
+ if (day < 10) { day = '0' + day; }
42154
+ return year + '-' + month + '-' + day;
42155
+ ;
42156
+ };
42157
+
42158
+ def['$tuesday?'] = function() {
42159
+ var self = this;
42160
+
42161
+ return self.$wday()['$=='](2);
42162
+ };
42163
+
42164
+ def.$wday = function() {
42165
+ var self = this;
42166
+
42167
+ return self.date.getDay();
42168
+ };
42169
+
42170
+ def['$wednesday?'] = function() {
42171
+ var self = this;
42172
+
42173
+ return self.$wday()['$=='](3);
42174
+ };
42175
+
42176
+ def.$year = function() {
42177
+ var self = this;
42178
+
42179
+ return self.date.getFullYear();
42180
+ };
42181
+
42182
+
42183
+ function days_in_month(year, month) {
42184
+ var leap = ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
42185
+ return [31, (leap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
42186
+ }
42187
+
42188
+ })(self, null)
42189
+ };
42190
+
42191
+ /* Generated by Opal 0.8.0 */
42192
+ Opal.modules["time"] = function(Opal) {
42193
+ Opal.dynamic_require_severity = "error";
42194
+ var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
42195
+
42196
+ Opal.add_stubs(['$strftime']);
42197
+ return (function($base, $super) {
42198
+ function $Time(){};
42199
+ var self = $Time = $klass($base, $super, 'Time', $Time);
42200
+
42201
+ var def = self.$$proto, $scope = self.$$scope;
42202
+
42203
+ Opal.defs(self, '$parse', function(str) {
42204
+ var self = this;
42205
+
42206
+ return new Date(Date.parse(str));
42207
+ });
42208
+
42209
+ return (def.$iso8601 = function() {
42210
+ var self = this;
42211
+
42212
+ return self.$strftime("%FT%T%z");
42213
+ }, nil) && 'iso8601';
42214
+ })(self, null)
42215
+ };
42216
+
41849
42217
  /* Generated by Opal 0.8.0 */
41850
42218
  (function(Opal) {
41851
42219
  Opal.dynamic_require_severity = "error";
@@ -41855,6 +42223,8 @@ Opal.modules["browser"] = function(Opal) {
41855
42223
  self.$require("opal_irb_jqconsole");
41856
42224
  self.$require("browser");
41857
42225
  self.$require("browser/dom");
42226
+ self.$require("date");
42227
+ self.$require("time");
41858
42228
  return ($a = ($b = $scope.get('Document'))['$ready?'], $a.$$p = (TMP_1 = function(){var self = TMP_1.$$s || this;
41859
42229
 
41860
42230
  $scope.get('OpalIrbJqconsole').$create_bottom_panel();
@@ -39052,22 +39052,56 @@ if (var_name == null) var_name = nil;
39052
39052
  /* Generated by Opal 0.8.0 */
39053
39053
  Opal.modules["opal_irb"] = function(Opal) {
39054
39054
  Opal.dynamic_require_severity = "error";
39055
- var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars, $hash2 = Opal.hash2;
39055
+ var TMP_1, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $hash2 = Opal.hash2, $klass = Opal.klass, $gvars = Opal.gvars;
39056
39056
 
39057
- Opal.add_stubs(['$require', '$map', '$irb_vars', '$irb_gvars', '$Native', '$each', '$[]', '$is_a?', '$<<', '$sort_by', '$name', '$uniq', '$attr_reader', '$compile', '$new']);
39057
+ Opal.add_stubs(['$require', '$is_a?', '$last', '$pop', '$lambda', '$each', '$resolved?', '$resolve', '$[]', '$new', '$<<', '$tap', '$then', '$call', '$when', '$map', '$irb_vars', '$irb_gvars', '$Native', '$sort_by', '$name', '$uniq', '$attr_reader', '$compile']);
39058
39058
  self.$require("opal");
39059
39059
  self.$require("opal/compiler");
39060
39060
  self.$require("object_extensions");
39061
39061
  self.$require("opal-parser");
39062
- Opal.Object.$$proto.$require_js = function(url) {
39063
- var self = this;
39062
+ Opal.Object.$$proto.$require_js = TMP_1 = function(urls) {
39063
+ var $a, $b, TMP_2, $c, TMP_4, $d, TMP_6, self = this, $iter = TMP_1.$$p, block = $iter || nil, promises = nil, opts = nil, clear_promises = nil;
39064
+
39065
+ urls = $slice.call(arguments, 0);
39066
+ TMP_1.$$p = null;
39067
+ promises = [];
39068
+ opts = (function() {if ((($a = urls.$last()['$is_a?']($scope.get('Hash'))) !== nil && (!$a.$$is_boolean || $a == true))) {
39069
+ return urls.$pop()
39070
+ } else {
39071
+ return $hash2([], {})
39072
+ }; return nil; })();
39073
+ clear_promises = ($a = ($b = self).$lambda, $a.$$p = (TMP_2 = function(){var self = TMP_2.$$s || this, $a, $b, TMP_3;
39064
39074
 
39065
-
39066
- var script = document.createElement( 'script' );
39067
- script.type = 'text/javascript';
39068
- script.src = url;
39069
- document.body.appendChild(script);
39070
-
39075
+ return ($a = ($b = promises).$each, $a.$$p = (TMP_3 = function(promise){var self = TMP_3.$$s || this, $a;
39076
+ if (promise == null) promise = nil;
39077
+ if ((($a = promise['$resolved?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
39078
+ return nil
39079
+ } else {
39080
+ return promise.$resolve(false)
39081
+ }}, TMP_3.$$s = self, TMP_3), $a).call($b)}, TMP_2.$$s = self, TMP_2), $a).call($b);
39082
+ if ((($a = opts['$[]']("timeout")) !== nil && (!$a.$$is_boolean || $a == true))) {
39083
+ setTimeout(clear_promises, opts['$[]']("timeout") * 1000);};
39084
+ ($a = ($c = urls).$each, $a.$$p = (TMP_4 = function(url){var self = TMP_4.$$s || this, $a, $b, TMP_5, promise = nil, loaded = nil;
39085
+ if (url == null) url = nil;
39086
+ promise = $scope.get('Promise').$new();
39087
+ promises['$<<'](promise);
39088
+ loaded = ($a = ($b = self).$lambda, $a.$$p = (TMP_5 = function(){var self = TMP_5.$$s || this;
39089
+
39090
+ return promise.$resolve(true)}, TMP_5.$$s = self, TMP_5), $a).call($b);
39091
+
39092
+ var script = document.createElement( 'script' );
39093
+ script.type = 'text/javascript';
39094
+ script.src = url;
39095
+ script.onload = loaded;
39096
+ document.body.appendChild(script);
39097
+ }, TMP_4.$$s = self, TMP_4), $a).call($c);
39098
+ return ($a = ($d = $scope.get('Promise').$new()).$tap, $a.$$p = (TMP_6 = function(promise){var self = TMP_6.$$s || this, $a, $b, TMP_7, $c;
39099
+ if (promise == null) promise = nil;
39100
+ return ($a = ($b = ($c = $scope.get('Promise')).$when.apply($c, [].concat(promises))).$then, $a.$$p = (TMP_7 = function(results){var self = TMP_7.$$s || this, $a, $b;
39101
+ if (results == null) results = nil;
39102
+ if (block !== false && block !== nil) {
39103
+ ($a = block).$call.apply($a, [].concat(results))};
39104
+ return ($b = promise).$resolve.apply($b, [].concat(results));}, TMP_7.$$s = self, TMP_7), $a).call($b)}, TMP_6.$$s = self, TMP_6), $a).call($d);
39071
39105
  };
39072
39106
  Opal.Object.$$proto.$require_js_sync = function(url) {
39073
39107
  var self = this;
@@ -39099,11 +39133,11 @@ Opal.modules["opal_irb"] = function(Opal) {
39099
39133
  };
39100
39134
 
39101
39135
  def.$irb_varnames = function() {
39102
- var $a, $b, TMP_1, self = this;
39136
+ var $a, $b, TMP_8, self = this;
39103
39137
 
39104
- return ($a = ($b = self.$irb_vars()).$map, $a.$$p = (TMP_1 = function(varname, value){var self = TMP_1.$$s || this;
39138
+ return ($a = ($b = self.$irb_vars()).$map, $a.$$p = (TMP_8 = function(varname, value){var self = TMP_8.$$s || this;
39105
39139
  if (varname == null) varname = nil;if (value == null) value = nil;
39106
- return varname}, TMP_1.$$s = self, TMP_1), $a).call($b);
39140
+ return varname}, TMP_8.$$s = self, TMP_8), $a).call($b);
39107
39141
  };
39108
39142
 
39109
39143
  def.$irb_gvars = function() {
@@ -39119,20 +39153,20 @@ if (varname == null) varname = nil;if (value == null) value = nil;
39119
39153
  };
39120
39154
 
39121
39155
  def.$irb_gvarnames = function() {
39122
- var $a, $b, TMP_2, self = this;
39156
+ var $a, $b, TMP_9, self = this;
39123
39157
 
39124
- return ($a = ($b = self.$irb_gvars()).$map, $a.$$p = (TMP_2 = function(varname, value){var self = TMP_2.$$s || this;
39158
+ return ($a = ($b = self.$irb_gvars()).$map, $a.$$p = (TMP_9 = function(varname, value){var self = TMP_9.$$s || this;
39125
39159
  if (varname == null) varname = nil;if (value == null) value = nil;
39126
- return varname}, TMP_2.$$s = self, TMP_2), $a).call($b);
39160
+ return varname}, TMP_9.$$s = self, TMP_9), $a).call($b);
39127
39161
  };
39128
39162
 
39129
39163
  def.$opal_classes = function() {
39130
- var $a, $b, TMP_3, $c, TMP_4, self = this, classes = nil;
39164
+ var $a, $b, TMP_10, $c, TMP_11, self = this, classes = nil;
39131
39165
  if ($gvars.opal_js_object == null) $gvars.opal_js_object = nil;
39132
39166
 
39133
39167
  classes = [];
39134
39168
  $gvars.opal_js_object = self.$Native(Opal);
39135
- ($a = ($b = $gvars.opal_js_object).$each, $a.$$p = (TMP_3 = function(k){var self = TMP_3.$$s || this, $a, attr = nil;
39169
+ ($a = ($b = $gvars.opal_js_object).$each, $a.$$p = (TMP_10 = function(k){var self = TMP_10.$$s || this, $a, attr = nil;
39136
39170
  if ($gvars.opal_js_object == null) $gvars.opal_js_object = nil;
39137
39171
  if (k == null) k = nil;
39138
39172
  attr = $gvars.opal_js_object['$[]'](k);
@@ -39140,23 +39174,23 @@ if (k == null) k = nil;
39140
39174
  return classes['$<<'](attr)
39141
39175
  } else {
39142
39176
  return nil
39143
- };}, TMP_3.$$s = self, TMP_3), $a).call($b);
39144
- return ($a = ($c = classes.$uniq()).$sort_by, $a.$$p = (TMP_4 = function(cls){var self = TMP_4.$$s || this;
39177
+ };}, TMP_10.$$s = self, TMP_10), $a).call($b);
39178
+ return ($a = ($c = classes.$uniq()).$sort_by, $a.$$p = (TMP_11 = function(cls){var self = TMP_11.$$s || this;
39145
39179
  if (cls == null) cls = nil;
39146
- return cls.$name()}, TMP_4.$$s = self, TMP_4), $a).call($c);
39180
+ return cls.$name()}, TMP_11.$$s = self, TMP_11), $a).call($c);
39147
39181
  };
39148
39182
 
39149
39183
  def.$opal_constants = function() {
39150
- var $a, $b, TMP_5, self = this, constants = nil;
39184
+ var $a, $b, TMP_12, self = this, constants = nil;
39151
39185
  if ($gvars.opal_js_object == null) $gvars.opal_js_object = nil;
39152
39186
 
39153
39187
  constants = [];
39154
39188
  $gvars.opal_js_object = self.$Native(Opal);
39155
- ($a = ($b = $gvars.opal_js_object).$each, $a.$$p = (TMP_5 = function(k){var self = TMP_5.$$s || this, attr = nil;
39189
+ ($a = ($b = $gvars.opal_js_object).$each, $a.$$p = (TMP_12 = function(k){var self = TMP_12.$$s || this, attr = nil;
39156
39190
  if ($gvars.opal_js_object == null) $gvars.opal_js_object = nil;
39157
39191
  if (k == null) k = nil;
39158
39192
  attr = $gvars.opal_js_object['$[]'](k);
39159
- return constants['$<<'](attr);}, TMP_5.$$s = self, TMP_5), $a).call($b);
39193
+ return constants['$<<'](attr);}, TMP_12.$$s = self, TMP_12), $a).call($b);
39160
39194
  return constants.$uniq();
39161
39195
  };
39162
39196
 
@@ -41846,6 +41880,374 @@ if (c == null) c = nil;
41846
41880
  })(self, null);
41847
41881
  };
41848
41882
 
41883
+ /* Generated by Opal 0.8.0 */
41884
+ Opal.modules["date"] = function(Opal) {
41885
+ Opal.dynamic_require_severity = "error";
41886
+ function $rb_plus(lhs, rhs) {
41887
+ return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs);
41888
+ }
41889
+ function $rb_minus(lhs, rhs) {
41890
+ return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs);
41891
+ }
41892
+ var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
41893
+
41894
+ Opal.add_stubs(['$allocate', '$wrap', '$clone', '$raise', '$>>', '$==', '$wday', '$to_s', '$alias_method']);
41895
+ return (function($base, $super) {
41896
+ function $Date(){};
41897
+ var self = $Date = $klass($base, $super, 'Date', $Date);
41898
+
41899
+ var def = self.$$proto, $scope = self.$$scope;
41900
+
41901
+ def.date = nil;
41902
+ (function(self) {
41903
+ var $scope = self.$$scope, def = self.$$proto;
41904
+
41905
+ self.$$proto.$civil = self.$$proto.$new;
41906
+ self.$$proto.$wrap = function(native$) {
41907
+ var self = this, instance = nil;
41908
+
41909
+ instance = self.$allocate();
41910
+ instance.date = native$;
41911
+ return instance;
41912
+ };
41913
+ self.$$proto.$parse = function(string) {
41914
+ var self = this, match = nil;
41915
+
41916
+ match = /^(\d*)-(\d*)-(\d*)/.exec(string);
41917
+ return self.$wrap(new Date(parseInt(match[1]), parseInt(match[2]) - 1, parseInt(match[3])));
41918
+ };
41919
+ return (self.$$proto.$today = function() {
41920
+ var self = this;
41921
+
41922
+ return self.$wrap(new Date());
41923
+ }, nil) && 'today';
41924
+ })(self.$singleton_class());
41925
+
41926
+ def.$initialize = function(year, month, day) {
41927
+ var self = this;
41928
+
41929
+ return self.date = new Date(year, month - 1, day);
41930
+ };
41931
+
41932
+ def['$-'] = function(date) {
41933
+ var self = this;
41934
+
41935
+
41936
+ if (date.$$is_number) {
41937
+ var result = self.$clone();
41938
+ result.date.setDate(self.date.getDate() - date);
41939
+ return result;
41940
+ }
41941
+ else if (date.date) {
41942
+ return Math.round((self.date - date.date) / (1000 * 60 * 60 * 24));
41943
+ }
41944
+ else {
41945
+ self.$raise($scope.get('TypeError'));
41946
+ }
41947
+ ;
41948
+ };
41949
+
41950
+ def['$+'] = function(date) {
41951
+ var self = this;
41952
+
41953
+
41954
+ if (date.$$is_number) {
41955
+ var result = self.$clone();
41956
+ result.date.setDate(self.date.getDate() + date);
41957
+ return result;
41958
+ }
41959
+ else {
41960
+ self.$raise($scope.get('TypeError'));
41961
+ }
41962
+ ;
41963
+ };
41964
+
41965
+ def['$<'] = function(other) {
41966
+ var self = this;
41967
+
41968
+
41969
+ var a = self.date, b = other.date;
41970
+ a.setHours(0, 0, 0, 0);
41971
+ b.setHours(0, 0, 0, 0);
41972
+ return a < b;
41973
+ ;
41974
+ };
41975
+
41976
+ def['$<='] = function(other) {
41977
+ var self = this;
41978
+
41979
+
41980
+ var a = self.date, b = other.date;
41981
+ a.setHours(0, 0, 0, 0);
41982
+ b.setHours(0, 0, 0, 0);
41983
+ return a <= b;
41984
+ ;
41985
+ };
41986
+
41987
+ def['$>'] = function(other) {
41988
+ var self = this;
41989
+
41990
+
41991
+ var a = self.date, b = other.date;
41992
+ a.setHours(0, 0, 0, 0);
41993
+ b.setHours(0, 0, 0, 0);
41994
+ return a > b;
41995
+ ;
41996
+ };
41997
+
41998
+ def['$>='] = function(other) {
41999
+ var self = this;
42000
+
42001
+
42002
+ var a = self.date, b = other.date;
42003
+ a.setHours(0, 0, 0, 0);
42004
+ b.setHours(0, 0, 0, 0);
42005
+ return a >= b;
42006
+ ;
42007
+ };
42008
+
42009
+ def['$<=>'] = function(other) {
42010
+ var self = this;
42011
+
42012
+
42013
+ var a = self.date, b = other.date;
42014
+ a.setHours(0, 0, 0, 0);
42015
+ b.setHours(0, 0, 0, 0);
42016
+
42017
+ if (a < b) {
42018
+ return -1;
42019
+ }
42020
+ else if (a > b) {
42021
+ return 1;
42022
+ }
42023
+ else {
42024
+ return 0;
42025
+ }
42026
+ ;
42027
+ };
42028
+
42029
+ def['$=='] = function(other) {
42030
+ var self = this;
42031
+
42032
+
42033
+ var a = self.date, b = other.date;
42034
+ return (a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate());
42035
+ ;
42036
+ };
42037
+
42038
+ def['$>>'] = function(n) {
42039
+ var self = this;
42040
+
42041
+
42042
+ if (!n.$$is_number) {
42043
+ self.$raise($scope.get('TypeError'));
42044
+ }
42045
+
42046
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42047
+ date.setDate(1);
42048
+ date.setMonth(date.getMonth() + n);
42049
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42050
+ return result;
42051
+ ;
42052
+ };
42053
+
42054
+ def['$<<'] = function(n) {
42055
+ var self = this;
42056
+
42057
+
42058
+ if (!n.$$is_number) {
42059
+ self.$raise($scope.get('TypeError'));
42060
+ }
42061
+
42062
+ return self['$>>'](-n);
42063
+ ;
42064
+ };
42065
+
42066
+ Opal.defn(self, '$eql?', def['$==']);
42067
+
42068
+ def.$clone = function() {
42069
+ var self = this;
42070
+
42071
+ return $scope.get('Date').$wrap(new Date(self.date.getTime()));
42072
+ };
42073
+
42074
+ def.$day = function() {
42075
+ var self = this;
42076
+
42077
+ return self.date.getDate();
42078
+ };
42079
+
42080
+ def['$friday?'] = function() {
42081
+ var self = this;
42082
+
42083
+ return self.$wday()['$=='](5);
42084
+ };
42085
+
42086
+ def['$monday?'] = function() {
42087
+ var self = this;
42088
+
42089
+ return self.$wday()['$=='](1);
42090
+ };
42091
+
42092
+ def.$month = function() {
42093
+ var self = this;
42094
+
42095
+ return self.date.getMonth() + 1;
42096
+ };
42097
+
42098
+ def.$next = function() {
42099
+ var self = this;
42100
+
42101
+ return $rb_plus(self, 1);
42102
+ };
42103
+
42104
+ def.$next_day = function(n) {
42105
+ var self = this;
42106
+
42107
+ if (n == null) {
42108
+ n = 1
42109
+ }
42110
+ return $rb_plus(self, n);
42111
+ };
42112
+
42113
+ def.$next_month = function() {
42114
+ var self = this;
42115
+
42116
+
42117
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42118
+ date.setDate(1);
42119
+ date.setMonth(date.getMonth() + 1);
42120
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42121
+ return result;
42122
+ ;
42123
+ };
42124
+
42125
+ def.$prev_day = function(n) {
42126
+ var self = this;
42127
+
42128
+ if (n == null) {
42129
+ n = 1
42130
+ }
42131
+ return $rb_minus(self, n);
42132
+ };
42133
+
42134
+ def.$prev_month = function() {
42135
+ var self = this;
42136
+
42137
+
42138
+ var result = self.$clone(), date = result.date, cur = date.getDate();
42139
+ date.setDate(1);
42140
+ date.setMonth(date.getMonth() - 1);
42141
+ date.setDate(Math.min(cur, days_in_month(date.getFullYear(), date.getMonth())));
42142
+ return result;
42143
+ ;
42144
+ };
42145
+
42146
+ def['$saturday?'] = function() {
42147
+ var self = this;
42148
+
42149
+ return self.$wday()['$=='](6);
42150
+ };
42151
+
42152
+ def.$strftime = function(format) {
42153
+ var self = this;
42154
+
42155
+ if (format == null) {
42156
+ format = ""
42157
+ }
42158
+
42159
+ if (format == '') {
42160
+ return self.$to_s();
42161
+ }
42162
+
42163
+ return self.date.$strftime(format);
42164
+ ;
42165
+ };
42166
+
42167
+ self.$alias_method("succ", "next");
42168
+
42169
+ def['$sunday?'] = function() {
42170
+ var self = this;
42171
+
42172
+ return self.$wday()['$=='](0);
42173
+ };
42174
+
42175
+ def['$thursday?'] = function() {
42176
+ var self = this;
42177
+
42178
+ return self.$wday()['$=='](4);
42179
+ };
42180
+
42181
+ def.$to_s = function() {
42182
+ var self = this;
42183
+
42184
+
42185
+ var d = self.date, year = d.getFullYear(), month = d.getMonth() + 1, day = d.getDate();
42186
+ if (month < 10) { month = '0' + month; }
42187
+ if (day < 10) { day = '0' + day; }
42188
+ return year + '-' + month + '-' + day;
42189
+ ;
42190
+ };
42191
+
42192
+ def['$tuesday?'] = function() {
42193
+ var self = this;
42194
+
42195
+ return self.$wday()['$=='](2);
42196
+ };
42197
+
42198
+ def.$wday = function() {
42199
+ var self = this;
42200
+
42201
+ return self.date.getDay();
42202
+ };
42203
+
42204
+ def['$wednesday?'] = function() {
42205
+ var self = this;
42206
+
42207
+ return self.$wday()['$=='](3);
42208
+ };
42209
+
42210
+ def.$year = function() {
42211
+ var self = this;
42212
+
42213
+ return self.date.getFullYear();
42214
+ };
42215
+
42216
+
42217
+ function days_in_month(year, month) {
42218
+ var leap = ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
42219
+ return [31, (leap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
42220
+ }
42221
+
42222
+ })(self, null)
42223
+ };
42224
+
42225
+ /* Generated by Opal 0.8.0 */
42226
+ Opal.modules["time"] = function(Opal) {
42227
+ Opal.dynamic_require_severity = "error";
42228
+ var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
42229
+
42230
+ Opal.add_stubs(['$strftime']);
42231
+ return (function($base, $super) {
42232
+ function $Time(){};
42233
+ var self = $Time = $klass($base, $super, 'Time', $Time);
42234
+
42235
+ var def = self.$$proto, $scope = self.$$scope;
42236
+
42237
+ Opal.defs(self, '$parse', function(str) {
42238
+ var self = this;
42239
+
42240
+ return new Date(Date.parse(str));
42241
+ });
42242
+
42243
+ return (def.$iso8601 = function() {
42244
+ var self = this;
42245
+
42246
+ return self.$strftime("%FT%T%z");
42247
+ }, nil) && 'iso8601';
42248
+ })(self, null)
42249
+ };
42250
+
41849
42251
  /* Generated by Opal 0.8.0 */
41850
42252
  (function(Opal) {
41851
42253
  Opal.dynamic_require_severity = "error";
@@ -41858,6 +42260,8 @@ if (c == null) c = nil;
41858
42260
  self.$require("browser");
41859
42261
  self.$require("browser/dom");
41860
42262
  self.$require("opal_irb_jqconsole");
42263
+ self.$require("date");
42264
+ self.$require("time");
41861
42265
  return ($a = ($b = $scope.get('Document'))['$ready?'], $a.$$p = (TMP_1 = function(){var self = TMP_1.$$s || this;
41862
42266
 
41863
42267
  return $scope.get('OpalIrbJqconsole').$create("#console")}, TMP_1.$$s = self, TMP_1), $a).call($b);
@@ -1,6 +1,8 @@
1
1
  require 'opal_irb_jqconsole'
2
2
  require 'browser' # include opal browser so we have access to it
3
3
  require 'browser/dom'
4
+ require 'date'
5
+ require 'time'
4
6
 
5
7
  Document.ready? do
6
8
  OpalIrbJqconsole.create_bottom_panel
@@ -4,6 +4,8 @@ require 'opal-parser'
4
4
  require 'browser' # include opal browser so we have access to it
5
5
  require 'browser/dom'
6
6
  require 'opal_irb_jqconsole'
7
+ require 'date'
8
+ require 'time'
7
9
 
8
10
  Document.ready? do
9
11
  OpalIrbJqconsole.create("#console")
@@ -1,3 +1,3 @@
1
1
  class OpalIrb
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
data/lib/opal-irb.rb CHANGED
@@ -34,11 +34,14 @@ module OpalIrbUtils
34
34
  }.join("\n")
35
35
  end
36
36
 
37
- def self.include_code_mirror
38
- '<link rel="stylesheet" href="//codemirror.net/lib/codemirror.css"/>' +
39
- require_scripts( [ "//codemirror.net/lib/codemirror.js",
40
- "//codemirror.net/keymap/emacs.js",
41
- "//codemirror.net/mode/ruby/ruby.js"])
37
+ def self.include_code_mirror(https=nil)
38
+
39
+ prefix = https ? 'https:' : ''
40
+ cdn = 'cdnjs.cloudflare.com/ajax/libs/codemirror/5.7.0'
41
+ %|<link rel="stylesheet" href="#{prefix}//#{cdn}/codemirror.css"/>| +
42
+ require_scripts( [ "#{prefix}//#{cdn}/codemirror.js",
43
+ "#{prefix}//#{cdn}/keymap/emacs.js",
44
+ "#{prefix}//#{cdn}/mode/ruby/ruby.js"])
42
45
  end
43
46
 
44
47
  end
@@ -10,11 +10,3 @@ class Object
10
10
  end
11
11
 
12
12
  end
13
-
14
- # test class
15
- class Foo
16
- def initialize
17
- @a = "a"
18
- @b = "b"
19
- end
20
- end
data/opal/opal_irb.rb CHANGED
@@ -6,15 +6,43 @@ require 'opal-parser' # so I can have require_remote
6
6
  # 'require' a javascript filename over the internet, asynchronously,
7
7
  # so you'll have to delay before using. Should be fine if typed by hand
8
8
  # but if scripted add delay
9
- def require_js(url)
9
+ def require_js(*urls, &block)
10
10
  # used to use this, but don't want to depend on opal-jquery
11
11
  # Element.find("head").append("<script src='#{js_filename}' type='text/javascript'></script>")
12
- %x|
13
- var script = document.createElement( 'script' );
14
- script.type = 'text/javascript';
15
- script.src = url;
16
- document.body.appendChild(script);
17
- |
12
+ promises = []
13
+
14
+ opts = urls.last.is_a?(Hash) ? urls.pop : {}
15
+
16
+ clear_promises = lambda do
17
+ promises.each do |promise|
18
+ promise.resolve(false) unless promise.resolved?
19
+ end
20
+ end
21
+
22
+ `setTimeout(#{clear_promises}, #{opts[:timeout]} * 1000)` if opts[:timeout]
23
+
24
+ urls.each do |url|
25
+ promise = Promise.new
26
+ promises << promise
27
+ loaded = lambda do
28
+ promise.resolve(true)
29
+ end
30
+ %x|
31
+ var script = document.createElement( 'script' );
32
+ script.type = 'text/javascript';
33
+ script.src = url;
34
+ script.onload = #{loaded};
35
+ document.body.appendChild(script);
36
+ |
37
+ end
38
+
39
+ Promise.new.tap do |promise|
40
+ Promise.when(*promises).then do |results|
41
+ block.call results if block
42
+ promise.resolve results
43
+ end
44
+ end
45
+
18
46
  end
19
47
 
20
48
  # 'require' a javascrit filename over the internet, synchronously.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-02 00:00:00.000000000 Z
12
+ date: 2015-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: opal
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  segments:
136
136
  - 0
137
- hash: 3661347610369629272
137
+ hash: 848123283666491420
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: 3661347610369629272
146
+ hash: 848123283666491420
147
147
  requirements: []
148
148
  rubyforge_project:
149
149
  rubygems_version: 1.8.23.2