Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gongo/what_dya_return
Predict Ruby code return values.
https://github.com/gongo/what_dya_return
Last synced: about 4 hours ago
JSON representation
Predict Ruby code return values.
- Host: GitHub
- URL: https://github.com/gongo/what_dya_return
- Owner: gongo
- License: mit
- Created: 2023-07-19T16:15:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-02T16:04:55.000Z (over 1 year ago)
- Last Synced: 2024-10-05T22:17:32.034Z (about 1 month ago)
- Language: Ruby
- Size: 57.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# WhatDyaReturn
:angel: "What do you return?"
```rb
def foo
if bar
42
else
'baz'
end
end
```:robot: "42 and 'baz'"
## Installation
$ gem install what_dya_return
## Usage
```rb
WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
if bar
42
else
'baz'
end
end
CODE
# => ['42', "'baz'"]WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
return 42 if bar # `bar` is not evaluated in this gem123
end
CODE
# => ['42', '123']WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
return 42123
end
CODE
# => ['42']puts WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
do_something
rescue
2
else
3
ensure
4
end
CODE
# => ['3', '2']puts WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
for i in 1..10
1
break 2 if baz
3
end
end
CODE
# => ['2', '1..10']puts WhatDyaReturn::Extractor.new.extract(<<-CODE)
def foo
1.times do
break 2 if bar
3
end
end
CODE
# => ['2', '1.times']```
## Caution
`what_dya_return` is an experimental project. There are still many statements that are not supported.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/gongo/what_dya_return .
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).