Geewiz
SDK for interacting with Geewiz. Works with Ruby 2.6 (the version that currently come preinstalled on MacOS) and above.
Installation
For use with MacOS's system Ruby 2.6.0 using bundler
To start a new project using MacOS's preinstalled Ruby:
Make a new directory for your project
mkdir my-new-project
cd my-new-project
Configure Bundler to use the vendor/bundle directory for your gems instead of installing them system wide, which requires root access:
bundle config --local path vendor/bundle
# Ignore the bundled gems in git
echo /vendor/ >> .gitignore
Create a new Gemfile
# Make a new Gemfile
bundle init
# Add the gem to the Gemfile
bundle add geewiz
To use the gem in your project:
require 'bundler/setup'
require 'geewiz'
Geewiz.card "hello-world-card"
For most other cases:
bundle add geewiz
or
gem install geewiz
Usage
Requiring the gem
require 'bundler/setup' # you may need to require this if you're using bundler
require 'geewiz'
Showing a card
# show a card with the id "my_card_id"
result = Geewiz.card :my_card_id
result = Geewiz.card "another-card-id" # all data going to Geewiz is json encoded, so either symbols or strings are fine
# show a card with the id "my_card_id" override `type` and `selectOne` parameters
result = Geewiz.card :my_card_id, type: "selectOne", items: ["one", "two", "three"]
# show a card with no id
result = Geewiz.card type: "selectOne", items: ["one", "two", "three"]
# `vars:` can be used to send variables to Geewiz before showing a card
# (it's a bit cleaner than using `Geewiz.vars[]=` directly)
result = Geewiz.card :my_card, vars: { my_var: "my value", another_var: "another value" }
# if card doesn't have an input, or you don't need the input:
Geewiz.card :my_card_without_input
Setting a variable
Geewiz.vars[:my_var] = "my value"
Geewiz.vars['my-var-with-dashes'] = "my value" # strings are fine as variable names
# you can use the variables in Ruby
Geewiz.vars[:username] = load_username_from_db
if Geewiz.vars[:username] == 'nicholaides'
# ...
end
# this also works for setting one variable
Geewiz.var :my_var, "my value"
Setting the title of the app
Geewiz.set title: "my app"
Getting user config
config_value = Geewiz.get_user_config :my_key
Using the global client (simplest way to use the gem)
Geewiz.card :my_card_id
Using a non-global client (better for testing/mocking)
geewiz = Geewiz::Client.new
geewiz.set title: "my app"
geewiz.vars[:my_var] = "my value"
result = geewiz.card :my_card_id
License
The gem is available as open source under the terms of the MIT License.