This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Grooscript Angular.js TODO example from https://angularjs.org/ | |
//You need next release of grooscript to run it (1.0.1) | |
class TodoController implements AngularController { | |
def todos = [ | |
[text:'learn angular', done: true], | |
[text:'build an angular app', done: false] | |
] | |
def addTodo() { | |
scope.todos << [text: scope.todoText, done: false] | |
scope.todoText = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Todo app controller written in groovy, from https://angularjs.org/ | |
def todoAngular = { $scope -> | |
$scope.todos = [ | |
[text:'learn angular', done: true], | |
[text:'build an angular app', done: false] | |
] | |
$scope.addTodo = { | |
$scope.todos << [text:$scope.todoText, done:false] | |
$scope.todoText = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Three.scene { | |
tetrahedron 200 moveTo -360, 300, 300 | |
icosahedron 200 moveTo 360, 200, 300 | |
sphere 100, 50, 50 moveTo -300, -200, 100 | |
torus 200, 50, 50, 50 moveTo -300, -200, 100 | |
ring 20, 200, 50 moveTo 450, -200, 100 | |
setMaterial(grooscriptMaterial) | |
box 200, 200, 200 | |
}.animate { items -> | |
items.findAll { it.name != 'Box' }.each { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Colorable { | |
static COLOR_CLASSES = [ | |
'navy','blue','aqua','teal','olive','green','lime','yellow', 'orange', | |
'red','fuchsia','purple','gray','maroon' | |
] | |
} | |
import org.grooscript.builder.HtmlBuilder | |
import org.grooscript.jquery.GQuery | |
import org.grooscript.jquery.GQueryImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabConfig(systemClassLoader=true) | |
@Grab('org.grooscript:grooscript:1.0.0-rc-1') | |
import org.grooscript.asts.PhantomJsTest | |
//Where you have phantom js, in my case 'which phantomjs' is '/usr/local/bin/phantomjs' | |
System.setProperty('PHANTOMJS_HOME', '/usr/local') | |
@PhantomJsTest(url = 'http://plugins.gradle.org') | |
void getLatestPlugins() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.grooscript.asts.GsNative | |
class A { | |
def b = 6 | |
static c = 7 | |
@GsNative | |
def a() {/* | |
//This js code is inserted in the javascript conversion | |
//You can use gSobject better than this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def firebase = new GrooscriptFirebase() | |
firebase.message = [list: [1, 2, 3], number: 5, name: 'grooscript'] | |
//Show on console: | |
// Message received: [list: [1, 2, 3] ,name: grooscript ,number: 5 ,] | |
class GrooscriptFirebase extends BaseFirebase { | |
GrooscriptFirebase() { | |
super('https://XXXX.firebaseio.com/') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabConfig(systemClassLoader=true) | |
@Grab('org.grooscript:grooscript:0.5.1') | |
import org.grooscript.GrooScript | |
GrooScript.setConversionProperty(GrooScript.INITIAL_TEXT_OPTION, "var gs = require('grooscript');") | |
GrooScript.convert('run.groovy', '.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.grooscript.asts.GsNative | |
//ExpressServer class | |
class ExpressServer { | |
//Initial functions, so this groovy script will run | |
def expressApp = [get: { path, closure -> "Get in '${path}'."}, | |
listen: { port -> println 'Listening in port ' + port}] | |
ExpressServer() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello | |
import conversion.GrooscriptConverter | |
import org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration | |
import org.springframework.boot.SpringApplication | |
import org.springframework.context.ApplicationContextInitializer | |
import org.springframework.context.ConfigurableApplicationContext | |
import org.springframework.context.annotation.ComponentScan | |
import org.springframework.context.annotation.Configuration |
NewerOlder