Skip to content

Conversation

@dlukyanov
Copy link
Contributor

What is this PR for?

Groovy Interpreter

What type of PR is it?

Feature

Todos

  • [Code] - Task
  • [Samples] - Task
  • [Documentation] - Task
  • [Test cases] - Task

What is the Jira issue?

TODO

How should this be tested?

Outline the steps to test the PR here.

Samples

%groovy
//get a parameter defined as z.angularBind('ngSearchParam', value, 'paragraph_id')
//g is a context object for groovy to avoid mix with z object?
def param = g.angular('ngSearchParam')
//send request https://www.googleapis.com/customsearch/v1?q=ngSearchParam_value
def r = HTTP.get(
  //assume you defined groovy interpreter property `search_baseurl`='https://www.googleapis.com/customsearch/v1'
  //in groovy object o.getProperty('A') == o.'A' == o.A == o['A']
  url : g.search_baseurl,
  query: [ q: param ],
  headers: [
    'Accept':'application/json',
    //'Authorization:' : g.getProperty('search_auth'),
  ] 
)
//check response code
if( r.response.code==200 ) {
  g.html().with{ 
    //g.html() renders %angular to output and returns groovy.xml.MarkupBuilder
    h2("the response ${r.response.code}")
    span( r.response.body )
    h2("headers")
    pre( r.response.headers.join('\n') )
  }
} else {
  //just to show that it's possible to use println with multiline groovy string to render output
  println("""%angular
    <script> alert ("code=${r.response.code} \n msg=${r.response.message}") </script>
  """)
}
%groovy

//renders a table with headers a, b, c  and two rows
g.table(
  [
    ['a','b','c'],
    ['a1','b1','c1'],
    ['a2','b2','c2'],
  ]
)

Questions:

  • Does the licenses files need update?
    no
  • Is there breaking changes for older versions?
    no
  • Does this needs documentation?
    yes

@jongyoul
Copy link
Member

Thanks for contributing new Groovy interpreter but we didn't manage the branch-0.6 anymore. Can you rebase your contribution onto current master?

@dlukyanov
Copy link
Contributor Author

dlukyanov commented Jan 30, 2017 via email

@jongyoul
Copy link
Member

jongyoul commented Feb 1, 2017

If you contribute code based on master, we will review and merge it into master and branch-0.7 if necessary.

@felixcheung
Copy link
Member

Right - please develop against master and open a new PR.

@felixcheung
Copy link
Member

felixcheung commented Feb 4, 2017

and please add interpreter documentation .md file and update license information as suggested in the PR template Does the licenses files need update? should be yes.
and open a JIRA for tracking this change. Thanks!

@dlukyanov
Copy link
Contributor Author

created a new pull request #2068

@dlukyanov dlukyanov closed this Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants