gobstones-blockly 0.19.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ea3b4b8c8c5a9a5626424759cfb545fe3aeb06bbdba73fe7f5b41f813899ad2
4
- data.tar.gz: 7ea186db0def9c8f28ec00d66df72090cd61989403f8f75fa83ce863b19c2522
3
+ metadata.gz: 920c5934d5686a81610961b1ebeb8fd20d69d5f99a25d70ee13f68eca2f7ad99
4
+ data.tar.gz: a794e4321b9aa6b894bc4f1e063cae3489a61093617b4fd18ca315d0fe0f8e61
5
5
  SHA512:
6
- metadata.gz: f580833b194e9adb2346b643e2b839bb58ddc6269a56b6c36a88b81e40419c12a7e70e77ebdd19d8397941bf88697c16a1ad42599fe1fae26af38669d52f3d11
7
- data.tar.gz: eb8fa9c88a4a94779ba7dc13105b45ef45166269dcb605cc0d73d2711b6be8fd78933b36427ecfd6d97cfc1b2f2560c8c764536987d8a1d454239869e8ac395e
6
+ metadata.gz: 43b7372f467fd059bec1d83b2b6a24d54f63eb2d652882bd0570bfc51428e1cdccfce2eaa42e81b393797536b32715d657dfc6da6d7d8175fe14d33333033b23
7
+ data.tar.gz: 2688976a1d3c2f031e1c1639eaad57682173b25b9a70df32e08f99e06036305e66979eb1b04ec0bdcd63c400faa75ef4865b3eae04ec4af50978cd36772ad255
@@ -41,7 +41,7 @@ Example:
41
41
  <block type="VaciarTablero"></block>
42
42
  <block type="BOOM"></block>
43
43
  </category>
44
- <category name="Procedimientos primitivos">
44
+ <category name="Procedimientos primitivos" gbs_custom="PRIMITIVE_PROCEDURES">
45
45
  </category>
46
46
  <category name="Mis procedimientos" custom="PROCEDURE_CALLS">
47
47
  </category>
@@ -69,7 +69,7 @@ Example:
69
69
  <block type="puedeMover"></block>
70
70
  <block type="nroBolitas"></block>
71
71
  </category>
72
- <category name="Funciones primitivas">
72
+ <category name="Funciones primitivas" gbs_custom="PRIMITIVE_FUNCTIONS">
73
73
  </category>
74
74
  <category name="Mis funciones" custom="FUNCTION_CALLS">
75
75
  </category>
@@ -5871,13 +5871,20 @@ Blockly.ErrorInforming.CssContent = [
5871
5871
  ];</script>
5872
5872
 
5873
5873
  <script>
5874
- const BLOCKLY_PRIMITIVE_PROCEDURES = "Procedimientos primitivos";
5875
- const BLOCKLY_PRIMITIVE_FUNCTIONS = "Funciones primitivas";
5876
-
5877
5874
  Polymer({
5878
5875
  is: 'gs-element-blockly',
5879
5876
 
5880
5877
  properties: {
5878
+ primitiveProceduresCategoryName: {
5879
+ type: String,
5880
+ value: "Procedimientos primitivos"
5881
+ },
5882
+
5883
+ primitiveFunctionsCategoryName: {
5884
+ type: String,
5885
+ value: "Funciones primitivas"
5886
+ },
5887
+
5881
5888
  /*
5882
5889
  * `primitiveProcedures` lista de definiciones de procedimientos primitivos.
5883
5890
  * Ej: ["Poner_FloresAl_"] Se transormara en un bloque con dos inputs inline, cuyo
@@ -6043,6 +6050,8 @@ Blockly.ErrorInforming.CssContent = [
6043
6050
  let tree = []
6044
6051
  let xml = toolboxXML || this.$$('#toolbox').innerHTML;
6045
6052
 
6053
+ xml = this._processCustomCategories(xml);
6054
+
6046
6055
  // TODO: Este parseo por strings es tremendo, y esa property `xml` de los nodos se usa en _toolboxBlockXML, _toolboxBlockXML, etc. Hay que hacer de vuelta todo lo de acciones primitivas.
6047
6056
 
6048
6057
  xml = xml.replace(/> *<\/category>/g, ">\n</category>");
@@ -6064,9 +6073,9 @@ Blockly.ErrorInforming.CssContent = [
6064
6073
  else if(line.indexOf('<category') >= 0) {
6065
6074
  let m = line.match('name="([^"]*)"')
6066
6075
  if(m.length == 2 && (
6067
- (m[1] == BLOCKLY_PRIMITIVE_PROCEDURES && primitiveProcedures && primitiveProcedures.length > 0) ||
6068
- (m[1] == BLOCKLY_PRIMITIVE_FUNCTIONS && primitiveFunctions && primitiveFunctions.length > 0) ||
6069
- (m[1] != BLOCKLY_PRIMITIVE_PROCEDURES && m[1] != BLOCKLY_PRIMITIVE_FUNCTIONS))) {
6076
+ (m[1] == this.primitiveProceduresCategoryName && primitiveProcedures && primitiveProcedures.length > 0) ||
6077
+ (m[1] == this.primitiveFunctionsCategoryName && primitiveFunctions && primitiveFunctions.length > 0) ||
6078
+ (m[1] != this.primitiveProceduresCategoryName && m[1] != this.primitiveFunctionsCategoryName))) {
6070
6079
  parent.push({
6071
6080
  type: 'category',
6072
6081
  name: m[1],
@@ -6075,7 +6084,7 @@ Blockly.ErrorInforming.CssContent = [
6075
6084
  });
6076
6085
  stack.push(parent);
6077
6086
  parent = parent[parent.length - 1].child;
6078
- if(m[1] == BLOCKLY_PRIMITIVE_PROCEDURES)
6087
+ if(m[1] == this.primitiveProceduresCategoryName)
6079
6088
  {
6080
6089
  for(var i in primitiveProcedures) {
6081
6090
  parent.push({
@@ -6084,7 +6093,7 @@ Blockly.ErrorInforming.CssContent = [
6084
6093
  });
6085
6094
  }
6086
6095
  }
6087
- if(m[1] == BLOCKLY_PRIMITIVE_FUNCTIONS)
6096
+ if(m[1] == this.primitiveFunctionsCategoryName)
6088
6097
  {
6089
6098
  for(var i in primitiveFunctions) {
6090
6099
  parent.push({
@@ -6200,8 +6209,8 @@ Blockly.ErrorInforming.CssContent = [
6200
6209
  }
6201
6210
  };
6202
6211
 
6203
- addCustomActions("primitiveProcedures", BLOCKLY_PRIMITIVE_PROCEDURES);
6204
- addCustomActions("primitiveFunctions", BLOCKLY_PRIMITIVE_FUNCTIONS);
6212
+ addCustomActions("primitiveProcedures", this.primitiveProceduresCategoryName);
6213
+ addCustomActions("primitiveFunctions", this.primitiveFunctionsCategoryName);
6205
6214
  } else {
6206
6215
  toolbox = tree;
6207
6216
  }
@@ -6609,6 +6618,32 @@ Blockly.ErrorInforming.CssContent = [
6609
6618
  });
6610
6619
  },
6611
6620
 
6621
+ _processCustomCategories(xml) {
6622
+ const parsedXml = Blockly.Xml.textToDom(`<xml>${xml}</xml>`);
6623
+
6624
+ const forEachNode = (node, action) => {
6625
+ action(node);
6626
+ node.childNodes.forEach((node) => forEachNode(node, action));
6627
+ }
6628
+
6629
+ forEachNode(parsedXml, (node) => {
6630
+ if (!node.getAttribute) return;
6631
+
6632
+ const name = node.getAttribute("name");
6633
+ const custom = node.getAttribute("gbs_custom");
6634
+
6635
+ if (custom === "PRIMITIVE_PROCEDURES") {
6636
+ this.primitiveProceduresCategoryName = name;
6637
+ }
6638
+
6639
+ if (custom === "PRIMITIVE_FUNCTIONS") {
6640
+ this.primitiveFunctionsCategoryName = name;
6641
+ }
6642
+ });
6643
+
6644
+ return Blockly.Xml.domToText(parsedXml);
6645
+ },
6646
+
6612
6647
  _mapToolboxTree: function(toolboxTree, f){
6613
6648
  var resultingList = [];
6614
6649
  for (var i in toolboxTree){
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module Blockly
3
- VERSION = "0.19.2"
3
+ VERSION = "0.20.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobstones-blockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.2
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-22 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler