geewiz 0.1.2 → 0.2.0

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: 38b1fa4a300fe01b6173425d70a6999ba149641ee0d759fa161a9a09ef4890f6
4
+ data.tar.gz: 0d3b6bc44c7594c055896a3dae249cb862176bf8dc1cae9dbad2e034ed382d8e
5
5
  SHA512:
6
- metadata.gz: c98200cb66fc440a00d1af44c539719b54f72ca3d8a4c96283bb566d93f617588cef237b9ad80001b8e4280cc0a1abbc2cc64e63bd5b39c0b72bfd5122f6962c
7
- data.tar.gz: 905180bc3a49a60aa8b104e267432ec71bb0eebd8fe847463a9af30219b69783c450364f211b51e74934e8cd7c0f14e2b6eb4fcde885faafdad7bfc03e0e7cda
6
+ metadata.gz: 88f6456e7880d4b401a659607dd10a1135391864ae8cf2699a90edf157f00561665c156f0a6aa728a52930fbbe61965715fbbdd8503d5462193488ae24f8f02a
7
+ data.tar.gz: 730ec8e53cb2ef0e6663d94c607f3c1961c3fddd79818bc538c04b0d07e9eb809415dd4d2e7215624c29c1a46c6d95e2c8c1037db7fa9e3efaeb60220f3ec035
data/README.md CHANGED
@@ -1,32 +1,138 @@
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 the `type` and `items` 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
+ # or
118
+ config_value = Geewiz.get_user_config 'my_key'
119
+ ```
20
120
 
21
- ## Development
121
+ ### Using the global client (simplest way to use the gem)
22
122
 
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.
123
+ ```ruby
124
+ Geewiz.card :my_card_id
125
+ ```
24
126
 
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).
127
+ ### Using a non-global client (better for testing/mocking)
26
128
 
27
- ## Contributing
129
+ ```ruby
130
+ geewiz = Geewiz::Client.new
28
131
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/geewiz.
132
+ geewiz.set title: "my app"
133
+ geewiz.vars[:my_var] = "my value"
134
+ result = geewiz.card :my_card_id
135
+ ```
30
136
 
31
137
  ## License
32
138
 
data/lib/geewiz/client.rb CHANGED
@@ -11,7 +11,7 @@ module Geewiz
11
11
  end
12
12
 
13
13
  def command(type, **params)
14
- @output.print "@#{[type, params].to_json}\n"
14
+ @output.print "\n@#{[type, params].to_json}\n"
15
15
  end
16
16
 
17
17
  def read
@@ -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.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nicholaides
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-08-11 00:00:00.000000000 Z
10
+ date: 2025-04-25 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Geewiz SDK for Ruby
14
13
  email:
@@ -17,21 +16,17 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - LICENSE.txt
21
19
  - README.md
22
- - geewiz.gemspec
23
20
  - lib/geewiz.rb
24
21
  - lib/geewiz/client.rb
25
22
  - lib/geewiz/var_cache.rb
26
23
  - lib/geewiz/version.rb
27
24
  - sig/geewiz.rbs
28
- homepage:
29
25
  licenses:
30
26
  - MIT
31
27
  metadata:
32
28
  allowed_push_host: https://rubygems.org
33
29
  rubygems_mfa_required: 'true'
34
- post_install_message:
35
30
  rdoc_options: []
36
31
  require_paths:
37
32
  - lib
@@ -46,8 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  requirements: []
49
- rubygems_version: 3.5.11
50
- signing_key:
44
+ rubygems_version: 3.6.2
51
45
  specification_version: 4
52
46
  summary: Geewiz SDK for Ruby
53
47
  test_files: []
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