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

get_code to return concatenated code string #250

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

kartikeyakirar
Copy link
Contributor

@kartikeyakirar kartikeyakirar merged commit b7e74c1 into refactor Nov 29, 2023
@kartikeyakirar kartikeyakirar deleted the 173_fix_get_code@refactor branch November 29, 2023 07:33
kartikeyakirar added a commit to insightsengineering/teal.code that referenced this pull request Nov 29, 2023
…ression` (#176)

this fixes #173


In this pull request, I've made updates to both the `get_code` and
`replace_code` methods. Now, when the `deparse `arg is set to TRUE,
these methods will return a concatenated string. Specifically, the
`get_code` method will return character(0) when used with `new_qenv(),`
provided no code has been set. As for `replace_code,` it will first
split the input string using "\n", then replace the last string in this
sequence. Finally, it concatenates these strings again before replacing
the code.

Removed `format_expression` function.

Example
```

q <- new_qenv()
get_code(q) # return character(0)
replace_code(q, "i <- iris")  # @code return character(0)

qq <- within(q, i <- iris)
qq <- within(qq, m <- mtcars)
get_code(qq) # return "i <- iris\nm <- mtcars"

replacement <- "i <- mtcars"
qr <- replace_code(qq, replacement)
get_code(qr) #return "i <- iris\ni <- mtcars"
```

Also review following modules for PR for changes.

- [ ] teal insightsengineering/teal#976
- [ ] teal.data
insightsengineering/teal.data#206
- [ ] teal.modules.general
insightsengineering/teal.modules.general#615
- [ ] teal.modules.clinical
insightsengineering/teal.modules.clinical#898
- [ ] teal.goshawk
insightsengineering/teal.goshawk#250
- [ ] teal.osprey
insightsengineering/teal.osprey#244

---------

Signed-off-by: kartikeya kirar <kirar.kartikeya1@gmail.com>
Co-authored-by: Vedha Viyash <49812166+vedhav@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants