Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrs/gensym
A library for generating unbound variable names in Ruby.
https://github.com/hrs/gensym
bad-idea metaprogramming ruby
Last synced: 22 days ago
JSON representation
A library for generating unbound variable names in Ruby.
- Host: GitHub
- URL: https://github.com/hrs/gensym
- Owner: hrs
- Created: 2017-05-30T05:23:08.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2020-06-11T16:46:16.000Z (over 4 years ago)
- Last Synced: 2024-10-07T07:50:36.497Z (about 1 month ago)
- Topics: bad-idea, metaprogramming, ruby
- Language: Ruby
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Gensym [![Build Status](https://secure.travis-ci.org/hrs/gensym.png?branch=master&.png)](http://travis-ci.org/hrs/gensym) [![Code Climate](https://codeclimate.com/github/hrs/gensym/badges/gpa.svg)](https://codeclimate.com/github/hrs/gensym)
Generate new, unbound variable names in your Ruby program. An homage to Lisp's
`gensym` macro.Handy for the kind of metaprogramming you really shouldn't be doing.
## Usage
Instantiate a `Gensym` object by passing in a [`Binding`][]. You'll probably
want the binding of the current scope returned by `Kernel#binding`. Generate a
new symbol by calling `generate`:```ruby
Gensym.new(binding).generate # => :gensym_OMUYsTEIbvjGwqhQgifkJNaByAHzxc
```[`Binding`]: http://ruby-doc.org/core-2.4.1/Binding.html
## Installation
Add this line to your application's Gemfile:
```ruby
gem "gensym"
```And then execute:
$ bundle
Or install it yourself as:
$ gem install gensym
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run
`rake spec` to run the tests. You can also run `bin/console` for an interactive
prompt that will allow you to experiment.To install this gem onto your local machine, run `bundle exec rake install`. To
release a new version, update the version number in `version.rb`, and then run
`bundle exec rake release`, which will create a git tag for the version, push
git commits and tags, and push the `.gem` file to [rubygems.org][].[rubygems.org]: https://rubygems.org