diff --git a/README.md b/README.md index bf4c5c4..0adc33b 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,9 @@ GET http://localhost:4567/api/1/preview/:label.pdf POST http://localhost:4567/api/1/print/:label where :label is a `spejstore` label.id or item.short_id + +to test without spejstore running locally, pass: + +```sh +DEBUG_JSON='{"short_id":"abcdef","name":"Some long test item","owner":"testowner"}' bundle exec ruby main.rb +``` diff --git a/main.rb b/main.rb index d2dd13a..2d913db 100644 --- a/main.rb +++ b/main.rb @@ -41,7 +41,11 @@ BACKEND_URL = 'https://inventory.hackerspace.pl/api/1/' CODE_PREFIX = "https://inventory.hackerspace.pl/" def api(uri) - Excon.get(BACKEND_URL + uri + "/").json! + if ENV["DEBUG_JSON"] + JSON.parse(ENV["DEBUG_JSON"]) + else + Excon.get(BACKEND_URL + uri + "/").json! + end end def render_identicode(data, id, extent)