Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ruby string formatting for handling variable replacement #27

Open
stevendaniels opened this issue Oct 26, 2016 · 0 comments
Open

Use Ruby string formatting for handling variable replacement #27

stevendaniels opened this issue Oct 26, 2016 · 0 comments

Comments

@stevendaniels
Copy link
Collaborator

Use Ruby string formatting for handling variable replacement

Currently, @ is used for handling variables and variable replacement in
WebMinion. As an alternative, I suggest we use Ruby's built in string formatting for handling variables in WebMinion configurations.

Currently, the JSON for variable replacement looks like this:

{
  "config": {},
  "flow": {
    "name": "Variable Replacement",
    "actions": [
      {
        "name": "Fill Form",
        "key": 1,
        "steps": [
          {
            "name": "Fill in username",
            "method": "fill_in_input",
            "retain_element": true,
            "target": {"id": "inputEmailHandle"},
            "value": "@username"
          }
        ]
      }
    ]
  }
}

With String formatting, it would look like this:

{
  "config": {},
  "flow": {
    "name": "Variable Replacement",
    "actions": [
      {
        "name": "Fill Form",
        "key": 1,
        "steps": [
          {
            "name": "Fill in username",
            "method": "fill_in_input",
            "retain_element": true,
            "target": {"id": "inputEmailHandle"},
            "value": "%{username}"
          }
        ]
      }
    ]
  }
}

Since the variables are passed in as a hash, replacement would be very simple:

json_configuration % vars # => all variables that can be replaced, do get replaced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants