geewiz 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '039474659cf46318c5a4c771c9e34c8fc49d6931e8fc70acee6e9c02e974f0ee'
4
+ data.tar.gz: 662bd008faff4ad118255f399a30fb83b409489549230c3e73db30f2673a1d7b
5
+ SHA512:
6
+ metadata.gz: 3627fa5b0a9c2103d4b42e191510b24f58a45542f0129fc70b00df578457df159e8a89581f72a7c3a455429ac83b1ba33d04ba352606387768412ebb69b136e2
7
+ data.tar.gz: a0c0f4a959ef85564b7d0113a498a56578e0f26898584d775ffa520b00d097cb5d12c23e037cbc42edc1be68c54f01969dd8ea17750d6b52f33fe808a4ec06e3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Geewiz
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
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add geewiz
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install geewiz
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
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.
24
+
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).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/geewiz.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/geewiz.gemspec ADDED
@@ -0,0 +1,38 @@
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 = ">= 3.1.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]
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
@@ -0,0 +1,37 @@
1
+ module Geewiz
2
+ # Client class for interacting with Geewiz.
3
+ class Client
4
+ def initialize(input: $stdin, output: $stdout)
5
+ @input = input
6
+ @output = output
7
+ @output.sync = true
8
+ end
9
+
10
+ def command(type, **params) = @output.print "@#{[type, params].to_json}\n"
11
+
12
+ def read = @input.readline.chomp
13
+
14
+ def read_response = JSON.parse(read)
15
+
16
+ def set(**options) = command("set", **options)
17
+
18
+ def card(id = nil, **params)
19
+ command "card", **(id ? { id: } : params), responseFormat: "json"
20
+ read_response
21
+ end
22
+
23
+ def get_user_config(key)
24
+ command "get-user-config", key:, responseFormat: "json"
25
+ read_response
26
+ end
27
+
28
+ def var(name, value)
29
+ command("var", name:, value:)
30
+ vars.store name, value
31
+ end
32
+
33
+ def vars
34
+ @vars ||= VarCache.new(self)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ module Geewiz
2
+ # VarCache is responsible for caching variables and interacting with Geewiz to store variables.
3
+ class VarCache
4
+ def initialize(client)
5
+ @client = client
6
+ @vars = {}
7
+ end
8
+
9
+ def [](name) = @vars[name.to_s]
10
+
11
+ def []=(*args)
12
+ @client.var(*args)
13
+ end
14
+
15
+ def store(name, value)
16
+ @vars[name.to_s] = value
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Geewiz
2
+ VERSION = "0.1.0".freeze
3
+ end
data/lib/geewiz.rb ADDED
@@ -0,0 +1,27 @@
1
+ require_relative "geewiz/version"
2
+ require_relative "geewiz/var_cache"
3
+ require_relative "geewiz/client"
4
+
5
+ require "json"
6
+
7
+ # Provides functionality interacting with clients.
8
+ # To use the global client, call `Geewiz.card(...)`, `Geewiz.vars[...] = ...`, etc.
9
+ module Geewiz
10
+ class Error < StandardError; end
11
+
12
+ module_function
13
+
14
+ def initialize_client(...)
15
+ @client = Client.new(...)
16
+ end
17
+
18
+ def client(...)
19
+ @client ||= initialize_client(...)
20
+ end
21
+
22
+ def set(...) = client.set(...)
23
+ def card(...) = client.card(...)
24
+ def get_user_config(...) = client.get_user_config(...)
25
+ def var(...) = client.var(...)
26
+ def vars(...) = client.vars(...)
27
+ end
data/sig/geewiz.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Geewiz
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geewiz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Nicholaides
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-08-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Geewiz SDK for Ruby
14
+ email:
15
+ - mike@nicholaides.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.txt
21
+ - README.md
22
+ - geewiz.gemspec
23
+ - lib/geewiz.rb
24
+ - lib/geewiz/client.rb
25
+ - lib/geewiz/var_cache.rb
26
+ - lib/geewiz/version.rb
27
+ - sig/geewiz.rbs
28
+ homepage:
29
+ licenses:
30
+ - MIT
31
+ metadata:
32
+ allowed_push_host: https://rubygems.org
33
+ rubygems_mfa_required: 'true'
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.1.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.3.27
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Geewiz SDK for Ruby
53
+ test_files: []