karma 0.1.2 → 0.1.4

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: ece4fcc71dff9720e07830b8b6edbdf951338b8f15b95b5c72fe6945495ad748
4
- data.tar.gz: 1022d07ed67ba6f46d95e1b2807d086000b0950d65b2e986289120a8c75f81e2
3
+ metadata.gz: 2e31b4cc150b92d64ae5abd3b4f971d97851eb96e808d31e0c9e57878272d20e
4
+ data.tar.gz: f168ddc0e1ebedbdb1bbb1d390d6610af5cb042a113747299d005d442c30dd5f
5
5
  SHA512:
6
- metadata.gz: ed2f81c6cb1ef0d4d8dd25d473338cb68d66f63e48c2e32c93bcb185cced7935f8721cfb720cc0f108b31d0e8b55cdb1236aee067715b76d25a2b3665fb846c4
7
- data.tar.gz: 46d7ae0f5f2b47c7039687343b78d799c5e773cb6881314e7026637fa248c467dfd73898bdfaeb522516a6cec5eb2301689907b49cf1253e0bbe5b6b00271ea8
6
+ metadata.gz: 4e8e0013f78f62f58078d8a94e2c77eb42a6b52f403456c4ee901ce00d5d89780cec27552beb6b98e3124313fc18d8e38fe40c98d21d7773baf9ea9cdf05ec13
7
+ data.tar.gz: a5e5198aa070ba86d48c97933a9029e1f7eeb36156c04dfd44bda70736ff9352e849a29510718c2873421e2daa798a2b6cc76b0702cd1ae329156d6a8e666a75
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karma (0.1.2)
4
+ karma (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/karma/config.rb CHANGED
@@ -1,18 +1,22 @@
1
1
  module Karma
2
- Config = Struct.new(:host, :port) do
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ class Configuration
7
+ attr_accessor :port, :host
8
+
3
9
  def initialize
4
- self.port = 8080
5
- self.host = 'localhost'
10
+ @host = 'localhost'
11
+ @port = 8080
6
12
  end
7
13
  end
8
14
 
9
15
  def self.configure
10
- @config = Config.new
11
- yield(@config) if block_given?
12
- @config
16
+ yield(configuration)
13
17
  end
14
18
 
15
- def self.config
16
- @config || configure
19
+ def self.configuration
20
+ @@configuration ||= Configuration.new
17
21
  end
18
22
  end
@@ -1,8 +1,6 @@
1
1
  module Karma
2
2
  class Connection
3
3
  def initialize
4
- @port = Karma.config.port
5
- @host = Karma.config.host
6
4
  @maxlen = 4096
7
5
  end
8
6
 
@@ -10,7 +8,7 @@ module Karma
10
8
  unless defined?(@socket)
11
9
  establish_connection!
12
10
  end
13
- send(request)
11
+ push(request)
14
12
  read
15
13
  end
16
14
 
@@ -25,7 +23,7 @@ module Karma
25
23
  end
26
24
  end
27
25
 
28
- def send(message)
26
+ def push(message)
29
27
  message = message.to_json
30
28
  connect do |conn|
31
29
  conn.send("#{message}\r\n", 0)
@@ -49,8 +47,8 @@ module Karma
49
47
 
50
48
  def establish_connection!
51
49
  @socket = TCPSocket.new(
52
- @host, @port,
53
- connect_timeout: 0.5
50
+ Karma.configuration.host,
51
+ Karma.configuration.port
54
52
  )
55
53
  end
56
54
 
data/lib/karma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Karma
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/karma.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'json'
2
2
  require 'socket'
3
- require 'ostruct'
4
3
 
5
4
  require 'karma/version'
6
5
  require 'karma/config'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Fedorov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-07-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby client for the Karma key-counter database
14
14
  email: