Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Transformations are not supported #9

Open
boc-tothefuture opened this issue Dec 21, 2020 · 4 comments
Open

Transformations are not supported #9

boc-tothefuture opened this issue Dec 21, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@boc-tothefuture
Copy link
Owner

No description provided.

@boc-tothefuture boc-tothefuture added the enhancement New feature or request label Jan 3, 2021
@jimtng
Copy link
Collaborator

jimtng commented Feb 18, 2021

Transformations are available via Actions, e.g.

Transformation.transform('JSONPATH', '$.test', '{ "test": "foo" }')

How do we make this more "Ruby-friendly" to the library users?

Option 1: straight forward basic syntax

test = transform :JSONPATH, '$.test', source_string

Option 2: should we create a specific method for each transformation service, e.g.

transform_json '$.test', source_string
transform_map 'map_file.map', source
transform_javascript 'scriptname.js', source
transform_exec ....

#or should it be named
json_transform 
map_transform
javascript_transform
...

The availability of each transformation service depends on what's installed. We'd need to find a way to get the list of available transformation services to create the corresponding methods.

I am beginning to worry about encroaching into user's namespace, since we already have say, play, notify etc (from Actions).

@pacive
Copy link
Collaborator

pacive commented Feb 18, 2021

IMHO it's okay to have some methods available, such as say, notify etc, like in the DSL rules, but I agree we shouldn't pollute the namespace too much. But to have a generic transform method where you can pass the transformation service as an argument (string or symbol) would be a good idea.

Generally I think that to make it as simple as possible for users, things should be as similar to the DSL as possible, but with the added functionality and simplicity that ruby entails.

@jimtng
Copy link
Collaborator

jimtng commented Feb 18, 2021

Generally I think that to make it as simple as possible for users, things should be as similar to the DSL as possible

I agree that transform should be made available as it is on RulesDSL.

We can make the service name case insensitive and also support string and symbol, so it could be :jsonpath, :javascript, :map, etc.

@boc-tothefuture
Copy link
Owner Author

I haven't looked into this to determine what is possible. I agree we should handle the case close to the dsl with a three argument method. It would be good in that case to support symbols and strings for the transform type.

Additionally it may be beneficial to support each transform type as a method on a transform object.

transform.map(file, value)
transform.js(file, value)

I also wonder if transforms should be additionally associated with item states, which I think is a very common use case.

Item.transform(:map, file)
Item.map(file)
Item.js(file)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants