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 |
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
@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
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
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
@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
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
//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
//Grooscript version of https://github.com/Reactive-Extensions/RxJS/tree/master/examples/autocomplete | |
import org.grooscript.asts.GsNative | |
import static org.grooscript.GrooScript.toJavascript | |
import static rxjs.ReactiveResolver.reactive | |
reactive { | |
def searchWikipedia = { term -> | |
$.ajax(url: 'http://en.wikipedia.org/w/api.php', | |
dataType: 'jsonp', | |
data: toJavascript([ |
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 version of https://github.com/Reactive-Extensions/RxJS/tree/master/examples/autocomplete | |
import groovy.transform.BaseScript | |
import org.grooscript.asts.GsNative | |
import static org.grooscript.GrooScript.toJavascript | |
@BaseScript | |
ReactiveScript baseScript | |
def keyUp = observeEvent(textInput, 'keyup') |
OlderNewer