New DSLs in the groovy platform itself for more script like use cases

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

New DSLs in the groovy platform itself for more script like use cases

adithyank
I have always felt that groovy platform itself can have rich set of DSLs (list given below) so that groovy will be in hands of many non-developers. Even developers will find it much useful for quicker outputs. We can design the DSLs in such a way that non-developers can define the work in declarative style. Some of my ideas and an example structure for each idea is given below. These are my proposals. We can identify lot of such use cases. Can I start working on these if the team approves ! Is it the right channel to gain the votes, I am not sure. Pls advice

1. Database

a. Database querying, data transformation, print
def db = db(url, user, pwd)
db.execute {
    query "select........."

    transform {
         forfield(dbfieldname) { some transformation logic }
   }

   printAsTable
}
b. Similar Use cases can be listed very easily

2. Text / String processing

a. use cases for more command line text processing like `awk`
def s = ....
......
......
matches (regex) {
   work for those lines
}

matches {
   condition {expression for line selection}
   process {
        work for those lines
   }
}

END {
   end closure after processing all matching lines of the input files
}
b. command line usage
groovy -e --complex 'def s = 0; EACHLINE {s+=line.numval}; END {println s}'

3. Lot of String Extension methods

a. static String left(String self, int chars)
b.  static String right(String self, int chars)
c. static String after(String self, String after)
d. static String before(String self, String searchString)
e. static String getBeforeeq(String self) //before '=' char

f.
/**

Splits the given String with the given separator String and returns the value at the given column Index. By
default, successive occurrence of the separator String is taken are one unit and the split is performed
@param self
@param separator
@param colIndex
@return
*/
static String column(String self, String separator, int colIndex)

g.
/**
Splits the given String with Space characters and returns the value at the given column Index.
@param self
@param colIndex
@return
*/
static String column(String self, int colIndex)

h. static String bwDoubleQuotes(String line)
i. static String bwSingleQuotes(String line)
j. static String bw(String line, String enclosure)
k. static String bw(String line, String from, String to)
l. static String bwDoubleQuotes(String line, int item)
m. static String bwSingleQuotes(String line, int item)
n. static String bw(String line, String enclosure, int item)
o. static void split(String self, String regex, Closure closure)
p. static long getHexToLong(String hexString)

4. Simple Unit conversions

a. 938.meter.toMiles b. 9823749.bytes.toGB c. lots like this

5. Http Client DSL

a. Download / xml processing / print raw text
httpGET {
	
	url "http://some.url.com/redmine"
	path "issues/6184.xml"
	
	requestProperty 'X-Redmine-API-Key', '92fe8740d557'
	requestProperty 'Content-Type', 'application/xml'

	param 'include', 'journals'

	downloadTo '/tmp/abc.xml'
	
	xmlresponse { root ->

		//println "Response came"
		println 'user = ' + root.journals.journal[3].user.@name
		println 'notes = ' + root.journals.journal[3].notes

	}
	
	rawtextresponse { println it }
}

6. Xml to different types of 2d conversion

7. Json to different types of 2d conversion



Sent from the Groovy Dev mailing list archive at Nabble.com.
Thanks,

Adithyan K
India
Reply | Threaded
Open this post in threaded view
|

Re: New DSLs in the groovy platform itself for more script like use cases

adithyank
Hi All,

Sorry for the disturbance !

I had proposed some of the friendly DSLs in groovy platform itself. The
original post here

http://groovy.329449.n5.nabble.com/New-DSLs-in-the-groovy-platform-itself-for-more-script-like-use-cases-td5750522.html

As I am new the this dev group, I have couple of doubts in the protocol

1. Is this `dev` mailing list the best way to propose new language features
2. There has been `no reply` to this original thread. How should I
understand now. Couple of options below
     * Project maintainers are not interested to this proposal. So, not
replied
     * or People are busy in other things (new releases, etc), so no reply.
I have to wait for more days and give reminder
     * or what is the best way to take the proposals forward

Pls advice



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Thanks,

Adithyan K
India
Reply | Threaded
Open this post in threaded view
|

Re: New DSLs in the groovy platform itself for more script like use cases

paulk_asert
Hi, reminders are always welcome - we are all busy and sometimes leave things hoping someone else will respond.
When I first saw your email I thought some of these looked good but perhaps not all and I haven't had time to go through and select and suspect I won't have time for another couple of weeks. The hardest choices with languages is to work out what to leave out rather than what might be good to have in.

Cheers, Paul.


On Thu, May 31, 2018 at 3:09 PM, adithyank <[hidden email]> wrote:
Hi All,

Sorry for the disturbance !

I had proposed some of the friendly DSLs in groovy platform itself. The
original post here

http://groovy.329449.n5.nabble.com/New-DSLs-in-the-groovy-platform-itself-for-more-script-like-use-cases-td5750522.html

As I am new the this dev group, I have couple of doubts in the protocol

1. Is this `dev` mailing list the best way to propose new language features
2. There has been `no reply` to this original thread. How should I
understand now. Couple of options below
     * Project maintainers are not interested to this proposal. So, not
replied
     * or People are busy in other things (new releases, etc), so no reply.
I have to wait for more days and give reminder
     * or what is the best way to take the proposals forward

Pls advice



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Reply | Threaded
Open this post in threaded view
|

Re: New DSLs in the groovy platform itself for more script like use cases

Jochen Theodorou
In reply to this post by adithyank


Am 31.05.2018 um 07:09 schrieb adithyank:

> Hi All,
>
> Sorry for the disturbance !
>
> I had proposed some of the friendly DSLs in groovy platform itself. The
> original post here
>
> http://groovy.329449.n5.nabble.com/New-DSLs-in-the-groovy-platform-itself-for-more-script-like-use-cases-td5750522.html
>
> As I am new the this dev group, I have couple of doubts in the protocol
>
> 1. Is this `dev` mailing list the best way to propose new language features

dev is for the implementation, I personally think user and dev should be
used. Depending on if I want a wider audience right away or not I
usually go with either first

> 2. There has been `no reply` to this original thread. How should I
> understand now. Couple of options below
>       * Project maintainers are not interested to this proposal. So, not
> replied
>       * or People are busy in other things (new releases, etc), so no reply.
> I have to wait for more days and give reminder
>       * or what is the best way to take the proposals forward

reading it again your proposal was very specific without actually saying
much ;) I think you need to chop them up one DSL at a time, maybe the
suggestions for the extension methods in one mail on their own and then
we can start discussing about if we want that like that or at all or
different.

You will also have to explain why you want what you want specifically...
for example those bw prefixed methods... I am not sure what they are
actually for.

bye Jochen
Reply | Threaded
Open this post in threaded view
|

Re: New DSLs in the groovy platform itself for more script like use cases

adithyank
Thanks Jochen Theodorou,

Thanks for the feedback. I will create new topic of each DSL and elaborate
there to enable easy discussions...!

Reg,

Adithyan K




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Thanks,

Adithyan K
India