geewiz 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 014b8d7b3b4e8e467174f86e1784dbba0b1d83affbe0b19fa3c9cc6368c6573b
4
- data.tar.gz: 0d503a8c1e3c3a0d3810728c9fb1d9d18e03530f6c39563e3b9e4548dd19aedc
3
+ metadata.gz: 470c2e0206995689b82812d1d2a357e9baf0f818ec89cc27153c597c6e6231cf
4
+ data.tar.gz: 392f167bcfa145c10c67a2c70789041b8dec625283b25f6606a6e3b305326479
5
5
  SHA512:
6
- metadata.gz: c98200cb66fc440a00d1af44c539719b54f72ca3d8a4c96283bb566d93f617588cef237b9ad80001b8e4280cc0a1abbc2cc64e63bd5b39c0b72bfd5122f6962c
7
- data.tar.gz: 905180bc3a49a60aa8b104e267432ec71bb0eebd8fe847463a9af30219b69783c450364f211b51e74934e8cd7c0f14e2b6eb4fcde885faafdad7bfc03e0e7cda
6
+ metadata.gz: d52dc1c3183b15bfb9bd1564f3ac7f8b1abeada4d5b5de47fb54a8226a21f48bd171a73803a5a0adad5e8ce681fb61822f331b2035826c21af95081434cc7e0e
7
+ data.tar.gz: 210d522fdb5488dbabfb77cd8896fa09a98851518cdcc193e786550c7cc7a0432d4aea5cfb2c8465a878b3b48d590083a0bb48bc16b3bd012f6d25260eaa5a74
data/README.md CHANGED
@@ -1,32 +1,136 @@
1
1
  # Geewiz
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/geewiz`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ SDK for interacting with Geewiz. Works with Ruby 2.6 (the version that currently come preinstalled on MacOS) and above.
6
4
 
7
5
  ## Installation
8
6
 
9
- Install the gem and add to the application's Gemfile by executing:
7
+ ### For use with MacOS's system Ruby 2.6.0 using `bundler`
8
+
9
+ To start a new project using MacOS's preinstalled Ruby:
10
+
11
+ Make a new directory for your project
12
+
13
+ ```bash
14
+ mkdir my-new-project
15
+ cd my-new-project
16
+ ```
17
+
18
+ Configure Bundler to use the `vendor/bundle` directory for your gems instead of installing them system wide, which requires root access:
19
+
20
+ ```bash
21
+ bundle config --local path vendor/bundle
22
+
23
+ # Ignore the bundled gems in git
24
+ echo /vendor/ >> .gitignore
25
+ ```
26
+
27
+ Create a new Gemfile
10
28
 
11
- $ bundle add geewiz
29
+ ```bash
30
+ # Make a new Gemfile
31
+ bundle init
12
32
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
33
+ # Add the gem to the Gemfile
34
+ bundle add geewiz
35
+ ```
36
+
37
+ To use the gem in your project:
38
+
39
+ ```ruby
40
+ require 'bundler/setup'
41
+ require 'geewiz'
42
+
43
+ Geewiz.card "hello-world-card"
44
+ ```
45
+
46
+ ### For most other cases:
47
+
48
+ ```bash
49
+ bundle add geewiz
50
+ ```
51
+
52
+ or
53
+
54
+ ```bash
55
+ gem install geewiz
56
+ ```
14
57
 
15
- $ gem install geewiz
16
58
 
17
59
  ## Usage
18
60
 
19
- TODO: Write usage instructions here
61
+ ### Requiring the gem
62
+
63
+ ```ruby
64
+ require 'bundler/setup' # you may need to require this if you're using bundler
65
+
66
+ require 'geewiz'
67
+ ```
68
+
69
+ ### Showing a card
70
+
71
+ ```ruby
72
+ # show a card with the id "my_card_id"
73
+ result = Geewiz.card :my_card_id
74
+ result = Geewiz.card "another-card-id" # all data going to Geewiz is json encoded, so either symbols or strings are fine
75
+
76
+ # show a card with the id "my_card_id" override `type` and `selectOne` parameters
77
+ result = Geewiz.card :my_card_id, type: "selectOne", items: ["one", "two", "three"]
78
+
79
+ # show a card with no id
80
+ result = Geewiz.card type: "selectOne", items: ["one", "two", "three"]
81
+
82
+ # `vars:` can be used to send variables to Geewiz before showing a card
83
+ # (it's a bit cleaner than using `Geewiz.vars[]=` directly)
84
+ result = Geewiz.card :my_card, vars: { my_var: "my value", another_var: "another value" }
85
+
86
+ # if card doesn't have an input, or you don't need the input:
87
+ Geewiz.card :my_card_without_input
88
+ ```
89
+
90
+ ### Setting a variable
91
+
92
+ ```ruby
93
+ Geewiz.vars[:my_var] = "my value"
94
+ Geewiz.vars['my-var-with-dashes'] = "my value" # strings are fine as variable names
95
+
96
+ # you can use the variables in Ruby
97
+ Geewiz.vars[:username] = load_username_from_db
98
+
99
+ if Geewiz.vars[:username] == 'nicholaides'
100
+ # ...
101
+ end
102
+
103
+ # this also works for setting one variable
104
+ Geewiz.var :my_var, "my value"
105
+ ```
106
+
107
+ ### Setting the title of the app
108
+
109
+ ```ruby
110
+ Geewiz.set title: "my app"
111
+ ```
112
+
113
+ ### Getting user config
114
+
115
+ ```ruby
116
+ config_value = Geewiz.get_user_config :my_key
117
+ ```
20
118
 
21
- ## Development
119
+ ### Using the global client (simplest way to use the gem)
22
120
 
23
- 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.
121
+ ```ruby
122
+ Geewiz.card :my_card_id
123
+ ```
24
124
 
25
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
125
+ ### Using a non-global client (better for testing/mocking)
26
126
 
27
- ## Contributing
127
+ ```ruby
128
+ geewiz = Geewiz::Client.new
28
129
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/geewiz.
130
+ geewiz.set title: "my app"
131
+ geewiz.vars[:my_var] = "my value"
132
+ result = geewiz.card :my_card_id
133
+ ```
30
134
 
31
135
  ## License
32
136
 
data/lib/geewiz/client.rb CHANGED
@@ -27,6 +27,10 @@ module Geewiz
27
27
  end
28
28
 
29
29
  def card(id = nil, vars: {}, **params)
30
+ if params[:responseFormat] && params[:responseFormat].to_s != "json"
31
+ raise Error, "responseFormat cannot be set to anything other than json"
32
+ end
33
+
30
34
  vars.each { |name, value| var(name, value) }
31
35
  command "card", **params, **(id ? { id: id } : {}), responseFormat: "json"
32
36
  read_response
@@ -1,3 +1,3 @@
1
1
  module Geewiz
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geewiz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nicholaides
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-11 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Geewiz SDK for Ruby
14
14
  email:
@@ -17,9 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - LICENSE.txt
21
20
  - README.md
22
- - geewiz.gemspec
23
21
  - lib/geewiz.rb
24
22
  - lib/geewiz/client.rb
25
23
  - lib/geewiz/var_cache.rb
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 Mike Nicholaides
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/geewiz.gemspec DELETED
@@ -1,38 +0,0 @@
1
- require_relative "lib/geewiz/version"
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = "geewiz"
5
- spec.version = Geewiz::VERSION
6
- spec.authors = ["Mike Nicholaides"]
7
- spec.email = ["mike@nicholaides.com"]
8
-
9
- spec.summary = "Geewiz SDK for Ruby"
10
- spec.description = "Geewiz SDK for Ruby"
11
- # spec.homepage = "TODO: Put your gem's website or public repo URL here."
12
- spec.license = "MIT"
13
- spec.required_ruby_version = ">= 2.6.0"
14
-
15
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
- spec.metadata["rubygems_mfa_required"] = "true"
17
-
18
- # spec.metadata["homepage_uri"] = spec.homepage
19
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
20
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
-
22
- # Specify which files should be added to the gem when it is released.
23
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(__dir__) do
25
- `git ls-files -z`.split("\x0").reject do |f|
26
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
- end
28
- end - %w[.rspec .rubocop.yml .rubocop_todo.yml Gemfile Gemfile.lock Rakefile .tool-versions]
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- # Uncomment to register a new dependency of your gem
34
- # spec.add_dependency "example-gem", "~> 1.0"
35
-
36
- # For more information and examples about making a new gem, check out our
37
- # guide at: https://bundler.io/guides/creating_gem.html
38
- end