The Multi-Value Dictionary app is a command line application that stores a multivalue dictionary in memory. All keys and values are strings.
- ruby > 2.5
- Clone this repo
cd mvdict
gem build mvdict.gemspec
gem install mvdict.0.3.5.gem
~/CAREER/Spreetail/technical/ mvdict
┏(-_-)┛┗(-_- )┓ mvdict loaded ... ┗(-_-)┛┏(-_-)┓
>
Returns all the keys in the dictionary. Order is not guaranteed.
> add 'foo', 'bar'
) Added
> add 'baz', 'bang'
) Added
> keys
1) foo
2) baz
Returns the collection of strings for the given key. Return order is not guaranteed. Returns an error if the key does not exists.
> add 'foo', 'bar'
> add 'foo', 'baz'
> members 'foo'
1) bar
2) baz
> members 'bad'
) ERROR, key does not exist.
Add a member to a collection for a given key. Displays an error if the value already existed in the collection.
> add 'foo', 'bar'
) Added
> add 'foo', 'baz'
) Added
> add 'foo', 'bar'
) ERROR, value already exists
Removes a value from a key. If the last value is removed from the key, they key is removed from the dictionary. If the key or value does not exist, displays an error.
> add 'foo', 'bar'
) Added
> add 'foo', 'baz'
) Added
> remove 'foo', 'bar'
) Removed
> remove 'foo', 'bar'
) ERROR, value does not exist
> keys
1) foo
> remove 'foo', 'baz'
) Removed
> keys
) empty set
> remove 'boom'
) ERROR, key does not exist
Removes all value for a key and removes the key from the dictionary. Returns an error if the key does not exist.
> add 'foo', 'bar'
) Added
> add 'foo', 'baz'
) Added
> keys
1) foo
> removeall 'foo'
) Removed
> keys
(empty set)
removeall 'foo'
) ERROR, key does not exist
Removes all keys and all values from the dictionary.
> add 'foo', 'bar'
) Added
> add 'bang', 'zip'
) Added
> keys
1) foo
2) bang
> clear
) Cleared
> keys
(empty set)
> clear
) Cleared
> keys
(empty set)
Returns whether a key exists or not.
> keyexists 'foo'
) false
> add 'foo', 'bar'
) Added
> keyexists 'foo'
) true
Returns whether a value exists within a key. Returns false if the key does not exist.
> valueexists 'foo', 'bar'
) false
> add 'foo', 'bar'
) Added
> valueexists 'foo', 'bar'
) true
> valueexists 'foo', 'baz'
) false
Returns all the values in the dictionary. Returns nothing if there are none. Order is not guaranteed.
> allmembers
(empty set)
> add 'foo', 'bar'
) Added
> add 'foo', 'baz'
) Added
> allmembers
1) bar
2) baz
> add 'bang', 'bar'
) Added
> add 'bang', 'baz'
> allmembers
1) bar
2) baz
3) bar
4) baz
Returns all keys in the dictionary and all of their values. Returns nothing if there are none. Order is not guaranteed.
> items
(empty set)
> add 'foo', 'bar'
) Added
> add 'foo', 'baz'
) Added
> items
1) foo: bar
2) foo: baz
> add 'bang', 'bar'
) Added
> add 'bang', 'baz'
> items
1) foo: bar
2) foo: baz
3) bang: bar
4) bang: baz
bundle exec rspec
bundle exec pronto run
The current state requires the following to be considered ready for QA. If you would like a peak at the development up to the current point, some notes below that also contain some roadmap notes.
- [X] add simplecov
- [X] basic linting is in place
- [X] add pronto
- [X] configured as a ruby gem with support for exe binaries
- [X] manual testing
- [X] update README with new install/usage information
- [ ] rspec test coverage above 90%
Current coverage (Mon Feb 15 22:47:41 CST 2021) 88.19%
~/CAREER/Spreetail/technical/ bundle exec rspec ............................ Finished in 0.01321 seconds (files took 0.38032 seconds to load) 28 examples, 0 failures Coverage report generated for RSpec to /Users/sonander/projects/career/Spreetail/technical/coverage. 209 / 237 LOC (88.19%) covered.
- [ ] add github workflow actions
- [ ] rspec
- [ ] pronto
- [ ] coverage threshold
- [ ] pr template
- [ ] improve documentation
- [ ] add yardoc
- [ ] tighten up dependency versioning
$ gem build mvdict.gemspec WARNING: open-ended dependency on tty-prompt (>= 0) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on pry (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on pry-byebug (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on simplecov (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on pronto (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on pronto-rubocop (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: open-ended dependency on pronto-reek (>= 0, development) is not recommended use a bounded requirement, such as '~> x.y' WARNING: See https://guides.rubygems.org/specification-reference/ for help
The Multi-Value Dictionary
app is a command line application that stores a multivalue
dictionary in memory. All keys and values are strings.
mvdict
mvdict loaded...
>
It should support the following commands.
Returns all the keys in the dictionary. Order is not guaranteed.
> ADD foo bar
) Added
> ADD baz bang
) Added
> KEYS
1) foo
2) baz
Returns the collection of strings for the given key. Return order is not guaranteed. Returns an error if the key does not exists.
> ADD foo bar
> ADD foo baz
> MEMBERS foo
1) bar
2) baz
> MEMBERS bad
) ERROR, key does not exist.
Add a member to a collection for a given key. Displays an error if the value already existed in the collection.
> ADD foo bar
) Added
> ADD foo baz
) Added
> ADD foo bar
) ERROR, value already exists
Removes a value from a key. If the last value is removed from the key, they key is removed from the dictionary. If the key or value does not exist, displays an error.
> ADD foo bar
) Added
> ADD foo baz
) Added
> REMOVE foo bar
) Removed
> REMOVE foo bar
) ERROR, value does not exist
> KEYS
1) foo
> REMOVE foo baz
) Removed
> KEYS
) empty set
> REMOVE boom
) ERROR, key does not exist
Removes all value for a key and removes the key from the dictionary. Returns an error if the key does not exist.
> ADD foo bar
) Added
> ADD foo baz
) Added
> KEYS
1) foo
> REMOVEALL foo
) Removed
> KEYS
(empty set)
REMOVEALL foo
) ERROR, key does not exist
Removes all keys and all values from the dictionary.
> ADD foo bar
) Added
> ADD bang zip
) Added
> KEYS
1) foo
2) bang
> CLEAR
) Cleared
> KEYS
(empty set)
> CLEAR
) Cleared
> KEYS
(empty set)
Returns whether a key exists or not.
> KEYEXISTS foo
) false
> ADD foo bar
) Added
> KEYEXISTS foo
) true
Returns whether a value exists within a key. Returns false if the key does not exist.
> VALUEEXISTS foo bar
) false
> ADD foo bar
) Added
> VALUEEXISTS foo bar
) true
> VALUEEXISTS foo baz
) false
Returns all the values in the dictionary. Returns nothing if there are none. Order is not guaranteed.
> ALLMEMBERS
(empty set)
> ADD foo bar
) Added
> ADD foo baz
) Added
> ALLMEMBERS
1) bar
2) baz
> ADD bang bar
) Added
> ADD bang baz
> ALLMEMBERS
1) bar
2) baz
3) bar
4) baz
Returns all keys in the dictionary and all of their values. Returns nothing if there are none. Order is not guaranteed.
> ITEMS
(empty set)
> ADD foo bar
) Added
> ADD foo baz
) Added
> ITEMS
1) foo: bar
2) foo: baz
> ADD bang bar
) Added
> ADD bang baz
> ITEMS
1) foo: bar
2) foo: baz
3) bang: bar
4) bang: baz
- type
- ruby library
- ./Gemfile
- [ ] need to point to gemspect
- mvdict.gemspec
- bin
- exe
- lib
- mvdict.rb
- version.rb
- mvdict
- utils.rb
- utils
- cli.rb
- [ ] require ‘tty-prompt’
- cli
- cli.rb
https://github.com/piotrmurach/tty-prompt
- [ ] how much effort to I want to put in to match the print style in the specification?
- ie
ADD
vsadd
ADD foo bar
vs ~add ‘foo’, ‘bar’~) result
vsresult
- etc
- ie
The Multi-Value Dictionary app is a command line application that stores a multivalue dictionary in memory. All keys and values are strings.
It should support the following commands.
### KEYS
Returns all the keys in the dictionary. Order is not guaranteed.
Example
```
> ADD foo bar
) Added
> ADD baz bang
) Added
> KEYS
1) foo
2) baz
```
### MEMBERS
Returns the collection of strings for the given key. Return order is not guaranteed. Returns an error if the key does not exists.
Example:
```
> ADD foo bar
> ADD foo baz
> MEMBERS foo
1) bar
2) baz
> MEMBERS bad
) ERROR, key does not exist.
```
### ADD
Add a member to a collection for a given key. Displays an error if the value already existed in the collection.
```
> ADD foo bar
) Added
> ADD foo baz
) Added
> ADD foo bar
) ERROR, value already exists
```
### REMOVE
Removes a value from a key. If the last value is removed from the key, they key is removed from the dictionary. If the key or value does not exist, displays an error.
Example:
```
> ADD foo bar
) Added
> ADD foo baz
) Added
> REMOVE foo bar
) Removed
> REMOVE foo bar
) ERROR, value does not exist
> KEYS
1) foo
> REMOVE foo baz
) Removed
> KEYS
) empty set
> REMOVE boom
) ERROR, key does not exist
```
### REMOVEALL
Removes all value for a key and removes the key from the dictionary. Returns an error if the key does not exist.
Example:
```
> ADD foo bar
) Added
> ADD foo baz
) Added
> KEYS
1) foo
> REMOVEALL foo
) Removed
> KEYS
(empty set)
REMOVEALL foo
) ERROR, key does not exist
```
### CLEAR
Removes all keys and all values from the dictionary.
Example:
```
> ADD foo bar
) Added
> ADD bang zip
) Added
> KEYS
1) foo
2) bang
> CLEAR
) Cleared
> KEYS
(empty set)
> CLEAR
) Cleared
> KEYS
(empty set)
```
### KEYEXISTS
Returns whether a key exists or not.
Example:
```
> KEYEXISTS foo
) false
> ADD foo bar
) Added
> KEYEXISTS foo
) true
```
### VALUEEXISTS
Returns whether a value exists within a key. Returns false if the key does not exist.
Example:
```
> VALUEEXISTS foo bar
) false
> ADD foo bar
) Added
> VALUEEXISTS foo bar
) true
> VALUEEXISTS foo baz
) false
```
### ALLMEMBERS
Returns all the values in the dictionary. Returns nothing if there are none. Order is not guaranteed.
Example:
```
> ALLMEMBERS
(empty set)
> ADD foo bar
) Added
> ADD foo baz
) Added
> ALLMEMBERS
1) bar
2) baz
> ADD bang bar
) Added
> ADD bang baz
> ALLMEMBERS
1) bar
2) baz
3) bar
4) baz
```
### ITEMS
Returns all keys in the dictionary and all of their values. Returns nothing if there are none. Order is not guaranteed.
Example:
```
> ITEMS
(empty set)
> ADD foo bar
) Added
> ADD foo baz
) Added
> ITEMS
1) foo: bar
2) foo: baz
> ADD bang bar
) Added
> ADD bang baz
> ITEMS
1) foo: bar
2) foo: baz
3) bang: bar
4) bang: baz
```