Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/lib/ruby-generator/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import minilog from 'minilog';

import GeneratedBlocks from './generated.js';
import MathBlocks from './math.js';
Expand Down Expand Up @@ -495,11 +496,18 @@ export default function (Blockly) {

Blockly.Ruby.blockToCode_ = Blockly.Ruby.blockToCode;

minilog.enable();
const log = minilog('ruby-generator');
Blockly.Ruby.blockToCode = function (block) {
if (block && !block.disabled && block.type.match(/^hardware_/)) {
this.definitions_.prepare__init_hardware = 'init_hardware';
}
return this.blockToCode_(block);
try {
return this.blockToCode_(block);
} catch (error) {
log.error(`'${block.type}' block is not unsupported to generate Ruby code. Please implement it.`);
return null;
}
};

Blockly = GeneratedBlocks(Blockly);
Expand Down