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

Feature request: add ability to configure readers and serializers #11

Closed
gonzedge opened this issue Jan 9, 2017 · 2 comments
Closed

Comments

@gonzedge
Copy link
Owner

gonzedge commented Jan 9, 2017

Now that the gem can serialize in-memory tries into disk and back, let's add the ability for people to configure them. Someone using the gem should be able to configure the available serializers, the default serializer, etc. I'm thinking an API like this:

require 'rambling-trie'

Rambling::Trie.config do |c|
  c.serializers.add :json, MyJsonSerializer.new
  c.serializers.default = c.serializers[:yml]
end

# Load a trie from disk and do things with it...

Also, the way Readers are configured and treated in general should be very similar to what would be done with Serializers. That way, you could also provide your own readers for getting a list of words from disk (or any IO, really):

require 'rambling-trie'

Rambling::Trie.config do |c|
  c.readers.add :html, MyHtmlReader.new
  c.readers.default = c.readers[:html]
end

# Create a trie and do things with it...
@gonzedge
Copy link
Owner Author

gonzedge commented Jan 9, 2017

While we're at it, might as well add a way to configure other default values, like #default_root and #default_compressor for Rambling::Trie::Container:

require 'rambling-trie'

Rambling::Trie.config do |c|
  c.compressor = MyCustomCompressor.new
  c.root_builder = lambda { MyCustomNode.new }
end

# Create a trie and do things with it...

😄

@gonzedge gonzedge changed the title Feature request: Add ability to configure readers and serializers Feature request: add ability to configure readers and serializers Jan 9, 2017
gonzedge added a commit that referenced this issue Jan 9, 2017
gonzedge added a commit that referenced this issue Jan 9, 2017
- Add docs for Properties
- Add docs for ProviderCollection

[Related to #11]
gonzedge added a commit that referenced this issue Jan 9, 2017
gonzedge added a commit that referenced this issue Jan 9, 2017
@gonzedge gonzedge modified the milestone: 1.0.0 Jan 9, 2017
@dare05
Copy link

dare05 commented Jan 15, 2017

Great job!

gonzedge added a commit that referenced this issue Feb 26, 2018
gonzedge added a commit that referenced this issue Feb 26, 2018
- Add docs for Properties
- Add docs for ProviderCollection

[Related to #11]
gonzedge added a commit that referenced this issue Feb 26, 2018
gonzedge added a commit that referenced this issue Feb 26, 2018
gonzedge added a commit that referenced this issue Feb 26, 2018
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