geewiz 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '039474659cf46318c5a4c771c9e34c8fc49d6931e8fc70acee6e9c02e974f0ee'
4
- data.tar.gz: 662bd008faff4ad118255f399a30fb83b409489549230c3e73db30f2673a1d7b
3
+ metadata.gz: 014b8d7b3b4e8e467174f86e1784dbba0b1d83affbe0b19fa3c9cc6368c6573b
4
+ data.tar.gz: 0d503a8c1e3c3a0d3810728c9fb1d9d18e03530f6c39563e3b9e4548dd19aedc
5
5
  SHA512:
6
- metadata.gz: 3627fa5b0a9c2103d4b42e191510b24f58a45542f0129fc70b00df578457df159e8a89581f72a7c3a455429ac83b1ba33d04ba352606387768412ebb69b136e2
7
- data.tar.gz: a0c0f4a959ef85564b7d0113a498a56578e0f26898584d775ffa520b00d097cb5d12c23e037cbc42edc1be68c54f01969dd8ea17750d6b52f33fe808a4ec06e3
6
+ metadata.gz: c98200cb66fc440a00d1af44c539719b54f72ca3d8a4c96283bb566d93f617588cef237b9ad80001b8e4280cc0a1abbc2cc64e63bd5b39c0b72bfd5122f6962c
7
+ data.tar.gz: 905180bc3a49a60aa8b104e267432ec71bb0eebd8fe847463a9af30219b69783c450364f211b51e74934e8cd7c0f14e2b6eb4fcde885faafdad7bfc03e0e7cda
data/geewiz.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = "Geewiz SDK for Ruby"
11
11
  # spec.homepage = "TODO: Put your gem's website or public repo URL here."
12
12
  spec.license = "MIT"
13
- spec.required_ruby_version = ">= 3.1.0"
13
+ spec.required_ruby_version = ">= 2.6.0"
14
14
 
15
15
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
16
  spec.metadata["rubygems_mfa_required"] = "true"
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  `git ls-files -z`.split("\x0").reject do |f|
26
26
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
27
  end
28
- end - %w[.rspec .rubocop.yml .rubocop_todo.yml Gemfile Gemfile.lock Rakefile]
28
+ end - %w[.rspec .rubocop.yml .rubocop_todo.yml Gemfile Gemfile.lock Rakefile .tool-versions]
29
29
  spec.bindir = "exe"
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
data/lib/geewiz/client.rb CHANGED
@@ -1,37 +1,45 @@
1
1
  module Geewiz
2
2
  # Client class for interacting with Geewiz.
3
3
  class Client
4
+ attr_reader :vars
5
+
4
6
  def initialize(input: $stdin, output: $stdout)
5
7
  @input = input
6
8
  @output = output
7
9
  @output.sync = true
10
+ @vars = VarCache.new(self)
8
11
  end
9
12
 
10
- def command(type, **params) = @output.print "@#{[type, params].to_json}\n"
13
+ def command(type, **params)
14
+ @output.print "@#{[type, params].to_json}\n"
15
+ end
11
16
 
12
- def read = @input.readline.chomp
17
+ def read
18
+ @input.readline
19
+ end
13
20
 
14
- def read_response = JSON.parse(read)
21
+ def read_response
22
+ JSON.parse(read)
23
+ end
15
24
 
16
- def set(**options) = command("set", **options)
25
+ def set(**options)
26
+ command("set", **options)
27
+ end
17
28
 
18
- def card(id = nil, **params)
19
- command "card", **(id ? { id: } : params), responseFormat: "json"
29
+ def card(id = nil, vars: {}, **params)
30
+ vars.each { |name, value| var(name, value) }
31
+ command "card", **params, **(id ? { id: id } : {}), responseFormat: "json"
20
32
  read_response
21
33
  end
22
34
 
23
35
  def get_user_config(key)
24
- command "get-user-config", key:, responseFormat: "json"
36
+ command "get-user-config", key: key, responseFormat: "json"
25
37
  read_response
26
38
  end
27
39
 
28
40
  def var(name, value)
29
- command("var", name:, value:)
41
+ command("var", name: name, value: value)
30
42
  vars.store name, value
31
43
  end
32
-
33
- def vars
34
- @vars ||= VarCache.new(self)
35
- end
36
44
  end
37
45
  end
@@ -6,7 +6,9 @@ module Geewiz
6
6
  @vars = {}
7
7
  end
8
8
 
9
- def [](name) = @vars[name.to_s]
9
+ def [](name)
10
+ @vars[name.to_s]
11
+ end
10
12
 
11
13
  def []=(*args)
12
14
  @client.var(*args)
@@ -1,3 +1,3 @@
1
1
  module Geewiz
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.2".freeze
3
3
  end
data/lib/geewiz.rb CHANGED
@@ -11,17 +11,31 @@ module Geewiz
11
11
 
12
12
  module_function
13
13
 
14
- def initialize_client(...)
15
- @client = Client.new(...)
14
+ def initialize_client(*args, **options)
15
+ @client = Client.new(*args, **options)
16
16
  end
17
17
 
18
- def client(...)
19
- @client ||= initialize_client(...)
18
+ def client(*args, **options)
19
+ @client ||= initialize_client(*args, **options)
20
20
  end
21
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(...)
22
+ def set(*args, **options)
23
+ client.set(*args, **options)
24
+ end
25
+
26
+ def card(*args, **options)
27
+ client.card(*args, **options)
28
+ end
29
+
30
+ def get_user_config(*args, **options)
31
+ client.get_user_config(*args, **options)
32
+ end
33
+
34
+ def var(*args, **options)
35
+ client.var(*args, **options)
36
+ end
37
+
38
+ def vars
39
+ client.vars
40
+ end
27
41
  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.0
4
+ version: 0.1.2
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-09 00:00:00.000000000 Z
11
+ date: 2024-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Geewiz SDK for Ruby
14
14
  email:
@@ -39,14 +39,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 3.1.0
42
+ version: 2.6.0
43
43
  required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 3.3.27
49
+ rubygems_version: 3.5.11
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: Geewiz SDK for Ruby