cakewalk 3.0.0 → 3.0.1

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: 7d80b397852e16785d686f599bbe07e8abd304a48d120c54c2faf6a685439084
4
- data.tar.gz: 1f66b25d408532dd5510c6b0f876f19aabc1da9c4ea30ffda3879c2d1fd0a552
3
+ metadata.gz: 929c625da975e28dea593eb8de1085387ff44b307f6473a667914312c073668b
4
+ data.tar.gz: b15475feb47c1fde4fd9b7d36c8298b63d02a02396766d1e1bb683be911aa279
5
5
  SHA512:
6
- metadata.gz: 2dbb18d3cba0ea8b5361f23565c21fc4420cd3f837f9945330e57c846f07908b0fa1dedac9beb012e0c300991c465772c51cb6904423fe2dd86cf86faae10726
7
- data.tar.gz: 8dfdbdf6c6a0045435248e2cbff36e3e8b8f859e9888c8da22ea7c97df3cf270553da208fcf45053b6c88f778d3a3da921d6f28880e5f56b87887a5b567aebf1
6
+ metadata.gz: 1a3f8def3f8fb0fce1b441c8a93ba9b25b54cd1ebb98edfe82643d66a072872b916823aa0157a69cbd42c312625a50c15c02b4e64b2b3f1098fb8dba066ce9f1
7
+ data.tar.gz: 141ffff916b9cc9ec9df712991ad4daca53013043044d318c9941be651e0b0acb2893691dc606ea29514ae06de9e3e8b719dae3b832657769b14a188b3454457
data/README.md CHANGED
@@ -2,8 +2,7 @@ Cakewalk - The IRC Bot Building Framework
2
2
  =====================================
3
3
 
4
4
  Cakewalk is an attempt at reviving a retired IRC bot building framework called **cinch**.
5
- While the codebase seems to be working just fine with Ruby versions up to 2.7.x, our main
6
- focus is Ruby 3.x.
5
+ Cakewalk supports Ruby 3.x and 4.x (tested on Ruby 4.0).
7
6
 
8
7
  Description
9
8
  -----------
@@ -15,7 +15,7 @@ bot = Cakewalk::Bot.new do
15
15
  # or "No results found" otherwise
16
16
  def google(query)
17
17
  url = "http://www.google.com/search?q=#{CGI.escape(query)}"
18
- res = Nokogiri.parse(open(url).read).at("h3.r")
18
+ res = Nokogiri.parse(URI.open(url).read).at("h3.r")
19
19
 
20
20
  title = res.text
21
21
  link = res.at('a')[:href]
@@ -19,7 +19,7 @@ bot = Cakewalk::Bot.new do
19
19
  # can be done.. it works!
20
20
  def urban_dict(query)
21
21
  url = "http://www.urbandictionary.com/define.php?term=#{CGI.escape(query)}"
22
- CGI.unescape_html Nokogiri::HTML(open(url)).css("div.meaning").first.text.gsub(/\s+/, ' ').strip rescue nil
22
+ CGI.unescape_html Nokogiri::HTML(URI.open(url)).css("div.meaning").first.text.gsub(/\s+/, ' ').strip rescue nil
23
23
  end
24
24
  end
25
25
 
@@ -1,4 +1,6 @@
1
1
  require 'open-uri'
2
+ require 'cgi'
3
+ require 'uri'
2
4
  require 'cakewalk'
3
5
 
4
6
  # Automatically shorten URL's found in messages
@@ -12,7 +14,7 @@ bot = Cakewalk::Bot.new do
12
14
 
13
15
  helpers do
14
16
  def shorten(url)
15
- url = open("http://tinyurl.com/api-create.php?url=#{URI.escape(url)}").read
17
+ url = URI.open("http://tinyurl.com/api-create.php?url=#{CGI.escape(url)}").read
16
18
  url == "Error" ? nil : url
17
19
  rescue OpenURI::HTTPError
18
20
  nil
@@ -9,7 +9,7 @@ class Google
9
9
 
10
10
  def search(query)
11
11
  url = "http://www.google.com/search?q=#{CGI.escape(query)}"
12
- res = Nokogiri.parse(open(url).read).at("h3.r")
12
+ res = Nokogiri.parse(URI.open(url).read).at("h3.r")
13
13
 
14
14
  title = res.text
15
15
  link = res.at('a')[:href]
@@ -1,4 +1,6 @@
1
1
  require 'open-uri'
2
+ require 'cgi'
3
+ require 'uri'
2
4
  require 'cakewalk'
3
5
 
4
6
  class TinyURL
@@ -7,7 +9,7 @@ class TinyURL
7
9
  listen_to :channel
8
10
 
9
11
  def shorten(url)
10
- url = open("http://tinyurl.com/api-create.php?url=#{URI.escape(url)}").read
12
+ url = URI.open("http://tinyurl.com/api-create.php?url=#{CGI.escape(url)}").read
11
13
  url == "Error" ? nil : url
12
14
  rescue OpenURI::HTTPError
13
15
  nil
@@ -1,3 +1,5 @@
1
+ require "ostruct"
2
+
1
3
  module Cakewalk
2
4
  # @since 2.0.0
3
5
  class Configuration < OpenStruct
@@ -16,20 +18,26 @@ module Cakewalk
16
18
  end
17
19
 
18
20
  # @return [Hash]
19
- def to_h
20
- @table.clone
21
+ def to_h(&block)
22
+ if block
23
+ @table.to_h(&block)
24
+ else
25
+ @table.dup
26
+ end
21
27
  end
22
28
 
23
29
  def [](key)
24
30
  # FIXME also adjust method_missing
31
+ key = key.to_sym
25
32
  raise ArgumentError, "Unknown option #{key}" unless self.class::KnownOptions.include?(key)
26
33
  @table[key]
27
34
  end
28
35
 
29
36
  def []=(key, value)
30
37
  # FIXME also adjust method_missing
38
+ key = key.to_sym
31
39
  raise ArgumentError, "Unknown option #{key}" unless self.class::KnownOptions.include?(key)
32
- modifiable[new_ostruct_member(key)] = value
40
+ super(key, value)
33
41
  end
34
42
 
35
43
  # Loads a configuration from a hash by merging the hash with
@@ -43,7 +51,19 @@ module Cakewalk
43
51
  # @return [void]
44
52
  def load(new_config, from_default = false)
45
53
  if from_default
46
- @table = self.class.default_config
54
+ if respond_to?(:update_to_values!, true)
55
+ send(:update_to_values!, self.class.default_config)
56
+ else
57
+ @table = self.class.default_config.dup
58
+ # Ensure singleton methods exist for old OpenStruct (Ruby < 3.5)
59
+ self.class.default_config.each_key do |k|
60
+ if respond_to?(:new_ostruct_member!, true)
61
+ send(:new_ostruct_member!, k)
62
+ elsif respond_to?(:new_ostruct_member, true)
63
+ send(:new_ostruct_member, k)
64
+ end
65
+ end
66
+ end
47
67
  end
48
68
 
49
69
  new_config.each do |option, value|
@@ -1,4 +1,4 @@
1
1
  module Cakewalk
2
2
  # Version of the library
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cakewalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petru Madar
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-11-27 00:00:00.000000000 Z
12
- dependencies: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: ostruct
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
13
26
  description: A simple, friendly DSL for creating IRC bots
14
27
  email:
15
28
  - petru@mdr.sh
@@ -114,11 +127,10 @@ files:
114
127
  - lib/cakewalk/utilities/encoding.rb
115
128
  - lib/cakewalk/utilities/kernel.rb
116
129
  - lib/cakewalk/version.rb
117
- homepage: http://cakewalk.mdr.sh
130
+ homepage: https://cakewalk.mdr.sh
118
131
  licenses:
119
132
  - MIT
120
133
  metadata: {}
121
- post_install_message:
122
134
  rdoc_options: []
123
135
  require_paths:
124
136
  - lib
@@ -133,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
145
  - !ruby/object:Gem::Version
134
146
  version: '0'
135
147
  requirements: []
136
- rubygems_version: 3.2.32
137
- signing_key:
148
+ rubygems_version: 4.0.16
138
149
  specification_version: 4
139
150
  summary: An IRC Bot Building Framework
140
151
  test_files: []