Zendesk

Build Status Gem Version

Install

gem install zendesk-james-moriarty

Usage

$ zendesk 
usage: zendesk [options]
    -f, --files     "path/to/file.json"
    -c, --command   "<FIELD>=<VALUE>"
    -s, --strategy  "ruby", "sqlite3" supported
    -p, --printer   "table", "json" supported
    -h, --help      
    --version       print the version

examples:

  # search field "_id" for value equal to "101" in "organizations.json".
  zendesk --command _id=101 --files data/organizations.json

  # search field "domain_names" for value equal to "zentix.com" using default fixtures.
  zendesk --command domain_names=zentix.com

  # search with multiple command expressions.
  zendesk --command "_id=101 _id=102" --files data/organizations.json

  # search with multiple file paths.
  zendesk --command "_id=101" --files data/organizations.json --files data/users.json

A command with specific files:

zendesk -f data/organizations.json -f data/tickets.json -c "_id=101"  
+----------------+----------------------------------------------------------+
|                               Organizations                               |
+----------------+----------------------------------------------------------+
| _id            | 101                                                      |
| url            | http://initech.zendesk.com/api/v2/organizations/101.json |
| external_id    | 9270ed79-35eb-4a38-a46f-35725197ea8d                 
...

A command with the default fixtures:

zendesk -c "_id=101"  
+----------------+----------------------------------------------------------+
|                               Organizations                               |
+----------------+----------------------------------------------------------+
| _id            | 101                                                      |
| url            | http://initech.zendesk.com/api/v2/organizations/101.json |
| external_id    | 9270ed79-35eb-4a38-a46f-35725197ea8d
...

Development

Tests

rake

Usage

$ ./exe/zendesk
usage: ./exe/zendesk [options]
...

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.

Design

Below is a diagram illustrating the transforms as vertices and the data as edges.

alt text

  • LoadFiles -> Execute have a common Strategy abstraction to allow for a different underlying implementation. This will hopefully help scale with more data.
  • ParseCommand abstracts user input and give a common command AST input across different strategies.
  • Print can be more abstracted and provide different outputs like JSON, CSV, ...
  • In an attempt to separate Behaviour and Data:
    • I've tried to write "pure functions" when possible.
    • I've been attempting to reduce side effects by making some objects immutable.
  • I've tried to incorporate things like SOLID without making the code feel anemic.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/zendesk.

License

The gem is available as open source under the terms of the MIT License.