twitch-bot 3.2.1 → 4.0.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: 593044bf44aec13e9f1c91329ea6a32500315809cf03c10c847c3eb571d84b04
4
- data.tar.gz: 19eac94cc9374a36af56528dbdce6a6969c57157034c6474a65e6e1550a8cbab
3
+ metadata.gz: 97bde27ec4cc411f28c30523554adb7ad7a0d6dc3cf717704f1db493a507b3d8
4
+ data.tar.gz: e485c169f546a94351cfad4243cff63e56dd098326cec70ef1a1628e5e4052b8
5
5
  SHA512:
6
- metadata.gz: 40e85ac406718f664c217c1c3dcf681cb5c58d03a95856c7f6063b27d478e7b014b8fe53b364f536e756ae7f52be631c0fe543c140e1b9200b5a01675b261d91
7
- data.tar.gz: 63cb2c49bbbf0be7b71a5f81f56fcdc96fcff8af6e5a15d12084181edde63898e77633260c83450a15a46bb5f3587b71c727b95b570ba8a306d453cdedb84554
6
+ metadata.gz: 92caf967720585dc8d0c09ea9a2505bdb1d28b1b856287dc6bdb4d16ab0daac1b243a63c11b93817ece43920d7b70be657383787c0ec3c107fffb9ad4b772643
7
+ data.tar.gz: a27bd67581b402f6cfe84dbb4f467ff19b090c4c5969d0c6e9c6fc2864fa965702b8dcb06b4602ea28636bc4065e19bda4e8aa9215f20086daeaf82f1e955f0c
@@ -1,5 +1,9 @@
1
1
  # Changelog Twitch::Bot
2
2
 
3
+ ## v4.0.0
4
+
5
+ * [BREAKING] Using `REDIS_HOST` and `REDIS_PORT` for the connection details in `Twitch::Bot::Memory::Redis` was a bad choice. Providers like Heroku use a combined `REDIS_URL` instead. So do we now. (Alternatively, there's still the way via the `Config` object.)
6
+
3
7
  ## v3.2.1
4
8
 
5
9
  * [FIXED] The Terminal adapter now returns all messages from the channel owner, allowing to test privileged functionality in dev mode.
@@ -25,12 +25,15 @@ module Twitch
25
25
  attr_reader :client, :redis
26
26
 
27
27
  def connect_db
28
+ url = ENV["REDIS_URL"] || redis_config_url
29
+ ::Redis.new(url: url)
30
+ end
31
+
32
+ def redis_config_url
28
33
  config = client.config
29
- host = config.setting("redis_host") ||
30
- ENV["REDIS_HOST"] || "localhost"
31
- port = config.setting("redis_port") ||
32
- ENV["REDIS_PORT"] || 6379
33
- ::Redis.new(host: host, port: port)
34
+ host = config.setting("redis_host") || "localhost"
35
+ port = config.setting("redis_port") || 6379
36
+ "redis://#{host}:#{port}"
34
37
  end
35
38
  end
36
39
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Twitch
4
4
  module Bot
5
- VERSION = "3.2.1"
5
+ VERSION = "4.0.0"
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec.describe Twitch::Bot::Memory::Redis do
4
4
  describe "#store" do
5
- it "persists a value for a key" do
5
+ it "works with default connection details" do
6
6
  config = Twitch::Bot::Config.new(
7
7
  settings: {
8
8
  bot_user: "testuser",
@@ -19,4 +19,43 @@ RSpec.describe Twitch::Bot::Memory::Redis do
19
19
  expect(mem.retrieve("foo")).to eq "bar"
20
20
  end
21
21
  end
22
+
23
+ it "works with ENV connection details" do
24
+ ENV["REDIS_URL"] = "redis://localhost:6379"
25
+ config = Twitch::Bot::Config.new(
26
+ settings: {
27
+ bot_user: "testuser",
28
+ },
29
+ )
30
+ client = Twitch::Bot::Client.new(
31
+ config: config,
32
+ channel: "testchannel",
33
+ )
34
+ mem = described_class.new(client: client)
35
+
36
+ mem.store("foo", "bar")
37
+
38
+ expect(mem.retrieve("foo")).to eq "bar"
39
+ end
40
+
41
+ it "works with config connection details" do
42
+ config = Twitch::Bot::Config.new(
43
+ settings: {
44
+ bot_user: "testuser",
45
+ redis: {
46
+ host: "localhost",
47
+ port: 6379,
48
+ },
49
+ },
50
+ )
51
+ client = Twitch::Bot::Client.new(
52
+ config: config,
53
+ channel: "testchannel",
54
+ )
55
+ mem = described_class.new(client: client)
56
+
57
+ mem.store("foo", "bar")
58
+
59
+ expect(mem.retrieve("foo")).to eq "bar"
60
+ end
22
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitch-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jochen Lillich