mysql-pr 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: 5ce47189eb8bd23be5060e50a453931288bb181ac3828a1f817ef6cd7aad614c
4
- data.tar.gz: e691aedc4982b11659d226a608a33a68b0003861322c8a180e6685eb43ea0c5c
3
+ metadata.gz: 740a7c4a533c1dfee294b1fd1d5d71a094c758309157bc1b0366eeaa30417e7f
4
+ data.tar.gz: a50dc6eae35b3c41b166e7532b798b32b414c9753fadc06f9e43aaf413502aee
5
5
  SHA512:
6
- metadata.gz: e0dcf0581aac4cea02ba61ed3ff6fb45775a3a57b6c298418c09fbf1b02244e1759a9946bf1910394ca870d77c73bae6cc85b96962b5962e9df033bd6beabf73
7
- data.tar.gz: 3bcb3bceaef9cc048563d799d1612dccfba01f954b79ec1fc6558a08f2c0ac15b000a3eeb54cd6a5e860b5fae0be8e1502dbfc09d582b911d75fc0bf68e95d86
6
+ metadata.gz: e5b48f7d27454ee4f21d0bb5d3f785d2edd98d32c3ed5629be97fb2809f7705f0650ae6d460695c95f3e42a36e23f94c15266cb533b99e66b50aae1c0867d0d3
7
+ data.tar.gz: 44ced5a010465b9cee5abb5522401f1429575bc3787f63637d7818776aa4f01ed61a496a8fa4b30820a60734b5a5a33068e29a030bba46d2be52fa3d5443790c
data/.rubocop.yml CHANGED
@@ -1,34 +1,39 @@
1
- require:
2
- - rubocop-rspec
3
-
4
1
  AllCops:
5
2
  TargetRubyVersion: 3.0
6
- NewCops: enable
3
+ NewCops: disable
7
4
  SuggestExtensions: false
8
5
  Exclude:
9
6
  - "vendor/**/*"
10
7
  - "bin/**/*"
8
+ - "spec/**/*"
11
9
 
12
- # Metrics
10
+ Gemspec/DevelopmentDependencies:
11
+ Enabled: false
12
+
13
+ Gemspec/RequireMFA:
14
+ Enabled: false
15
+
16
+ # Metrics - Relaxed for protocol parsing code
13
17
  Metrics/AbcSize:
14
- Max: 50
18
+ Max: 60
19
+ Exclude:
20
+ - "lib/mysql-pr/protocol.rb"
15
21
 
16
22
  Metrics/BlockLength:
17
23
  Exclude:
18
- - "spec/**/*"
19
24
  - "*.gemspec"
20
25
 
21
26
  Metrics/ClassLength:
22
- Max: 500
27
+ Max: 750
23
28
 
24
29
  Metrics/CyclomaticComplexity:
25
- Max: 20
30
+ Max: 25
26
31
 
27
32
  Metrics/MethodLength:
28
- Max: 50
33
+ Max: 60
29
34
 
30
35
  Metrics/PerceivedComplexity:
31
- Max: 20
36
+ Max: 25
32
37
 
33
38
  # Layout
34
39
  Layout/LineLength:
@@ -51,7 +56,7 @@ Style/StringLiteralsInInterpolation:
51
56
  EnforcedStyle: double_quotes
52
57
 
53
58
  # Naming
54
- Naming/PredicateName:
59
+ Naming/PredicatePrefix:
55
60
  AllowedMethods:
56
61
  - is_num?
57
62
  - is_not_null?
@@ -60,9 +65,20 @@ Naming/PredicateName:
60
65
  Naming/AccessorMethodName:
61
66
  Enabled: false
62
67
 
63
- # RSpec
64
- RSpec/ExampleLength:
65
- Max: 20
68
+ Naming/FileName:
69
+ Enabled: false
66
70
 
67
- RSpec/MultipleExpectations:
68
- Max: 5
71
+ Naming/MethodParameterName:
72
+ MinNameLength: 1
73
+
74
+ Metrics/ParameterLists:
75
+ Enabled: false
76
+
77
+ Style/OptionalBooleanParameter:
78
+ Enabled: false
79
+
80
+ Style/FormatStringToken:
81
+ Enabled: false
82
+
83
+ Lint/UnreachableCode:
84
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [3.0.0] - Unreleased
8
+ ## [3.0.1] - 2025-11-25
9
+
10
+ ### Fixed
11
+
12
+ - Fixed RuboCop style issues across codebase
13
+ - Fixed CI configuration for GitHub Actions
14
+
15
+ ## [3.0.0] - 2025-11-25
9
16
 
10
17
  ### Changed
11
18
 
@@ -27,98 +27,98 @@ class MysqlPR
27
27
 
28
28
  # [[charset_number, charset_name, collation_name, default], ...]
29
29
  CHARSETS = [
30
- [ 1, "big5", "big5_chinese_ci", true ],
31
- [ 2, "latin2", "latin2_czech_cs", false],
32
- [ 3, "dec8", "dec8_swedish_ci", true ],
33
- [ 4, "cp850", "cp850_general_ci", true ],
34
- [ 5, "latin1", "latin1_german1_ci", false],
35
- [ 6, "hp8", "hp8_english_ci", true ],
36
- [ 7, "koi8r", "koi8r_general_ci", true ],
37
- [ 8, "latin1", "latin1_swedish_ci", true ],
38
- [ 9, "latin2", "latin2_general_ci", true ],
39
- [ 10, "swe7", "swe7_swedish_ci", true ],
40
- [ 11, "ascii", "ascii_general_ci", true ],
41
- [ 12, "ujis", "ujis_japanese_ci", true ],
42
- [ 13, "sjis", "sjis_japanese_ci", true ],
43
- [ 14, "cp1251", "cp1251_bulgarian_ci", false],
44
- [ 15, "latin1", "latin1_danish_ci", false],
45
- [ 16, "hebrew", "hebrew_general_ci", true ],
46
- [ 17, "filename", "filename", true ],
47
- [ 18, "tis620", "tis620_thai_ci", true ],
48
- [ 19, "euckr", "euckr_korean_ci", true ],
49
- [ 20, "latin7", "latin7_estonian_cs", false],
50
- [ 21, "latin2", "latin2_hungarian_ci", false],
51
- [ 22, "koi8u", "koi8u_general_ci", true ],
52
- [ 23, "cp1251", "cp1251_ukrainian_ci", false],
53
- [ 24, "gb2312", "gb2312_chinese_ci", true ],
54
- [ 25, "greek", "greek_general_ci", true ],
55
- [ 26, "cp1250", "cp1250_general_ci", true ],
56
- [ 27, "latin2", "latin2_croatian_ci", false],
57
- [ 28, "gbk", "gbk_chinese_ci", true ],
58
- [ 29, "cp1257", "cp1257_lithuanian_ci", false],
59
- [ 30, "latin5", "latin5_turkish_ci", true ],
60
- [ 31, "latin1", "latin1_german2_ci", false],
61
- [ 32, "armscii8", "armscii8_general_ci", true ],
62
- [ 33, "utf8", "utf8_general_ci", true ],
63
- [ 34, "cp1250", "cp1250_czech_cs", false],
64
- [ 35, "ucs2", "ucs2_general_ci", true ],
65
- [ 36, "cp866", "cp866_general_ci", true ],
66
- [ 37, "keybcs2", "keybcs2_general_ci", true ],
67
- [ 38, "macce", "macce_general_ci", true ],
68
- [ 39, "macroman", "macroman_general_ci", true ],
69
- [ 40, "cp852", "cp852_general_ci", true ],
70
- [ 41, "latin7", "latin7_general_ci", true ],
71
- [ 42, "latin7", "latin7_general_cs", false],
72
- [ 43, "macce", "macce_bin", false],
73
- [ 44, "cp1250", "cp1250_croatian_ci", false],
74
- [ 45, "utf8mb4", "utf8mb4_general_ci", true ],
75
- [ 46, "utf8mb4", "utf8mb4_bin", false],
76
- [ 47, "latin1", "latin1_bin", false],
77
- [ 48, "latin1", "latin1_general_ci", false],
78
- [ 49, "latin1", "latin1_general_cs", false],
79
- [ 50, "cp1251", "cp1251_bin", false],
80
- [ 51, "cp1251", "cp1251_general_ci", true ],
81
- [ 52, "cp1251", "cp1251_general_cs", false],
82
- [ 53, "macroman", "macroman_bin", false],
83
- [ 57, "cp1256", "cp1256_general_ci", true ],
84
- [ 58, "cp1257", "cp1257_bin", false],
85
- [ 59, "cp1257", "cp1257_general_ci", true ],
86
- [ 63, "binary", "binary", true ],
87
- [ 64, "armscii8", "armscii8_bin", false],
88
- [ 65, "ascii", "ascii_bin", false],
89
- [ 66, "cp1250", "cp1250_bin", false],
90
- [ 67, "cp1256", "cp1256_bin", false],
91
- [ 68, "cp866", "cp866_bin", false],
92
- [ 69, "dec8", "dec8_bin", false],
93
- [ 70, "greek", "greek_bin", false],
94
- [ 71, "hebrew", "hebrew_bin", false],
95
- [ 72, "hp8", "hp8_bin", false],
96
- [ 73, "keybcs2", "keybcs2_bin", false],
97
- [ 74, "koi8r", "koi8r_bin", false],
98
- [ 75, "koi8u", "koi8u_bin", false],
99
- [ 77, "latin2", "latin2_bin", false],
100
- [ 78, "latin5", "latin5_bin", false],
101
- [ 79, "latin7", "latin7_bin", false],
102
- [ 80, "cp850", "cp850_bin", false],
103
- [ 81, "cp852", "cp852_bin", false],
104
- [ 82, "swe7", "swe7_bin", false],
105
- [ 83, "utf8", "utf8_bin", false],
106
- [ 84, "big5", "big5_bin", false],
107
- [ 85, "euckr", "euckr_bin", false],
108
- [ 86, "gb2312", "gb2312_bin", false],
109
- [ 87, "gbk", "gbk_bin", false],
110
- [ 88, "sjis", "sjis_bin", false],
111
- [ 89, "tis620", "tis620_bin", false],
112
- [ 90, "ucs2", "ucs2_bin", false],
113
- [ 91, "ujis", "ujis_bin", false],
114
- [ 92, "geostd8", "geostd8_general_ci", true ],
115
- [ 93, "geostd8", "geostd8_bin", false],
116
- [ 94, "latin1", "latin1_spanish_ci", false],
117
- [ 95, "cp932", "cp932_japanese_ci", true ],
118
- [ 96, "cp932", "cp932_bin", false],
119
- [ 97, "eucjpms", "eucjpms_japanese_ci", true ],
120
- [ 98, "eucjpms", "eucjpms_bin", false],
121
- [ 99, "cp1250", "cp1250_polish_ci", false],
30
+ [1, "big5", "big5_chinese_ci", true],
31
+ [2, "latin2", "latin2_czech_cs", false],
32
+ [3, "dec8", "dec8_swedish_ci", true],
33
+ [4, "cp850", "cp850_general_ci", true],
34
+ [5, "latin1", "latin1_german1_ci", false],
35
+ [6, "hp8", "hp8_english_ci", true],
36
+ [7, "koi8r", "koi8r_general_ci", true],
37
+ [8, "latin1", "latin1_swedish_ci", true],
38
+ [9, "latin2", "latin2_general_ci", true],
39
+ [10, "swe7", "swe7_swedish_ci", true],
40
+ [11, "ascii", "ascii_general_ci", true],
41
+ [12, "ujis", "ujis_japanese_ci", true],
42
+ [13, "sjis", "sjis_japanese_ci", true],
43
+ [14, "cp1251", "cp1251_bulgarian_ci", false],
44
+ [15, "latin1", "latin1_danish_ci", false],
45
+ [16, "hebrew", "hebrew_general_ci", true],
46
+ [17, "filename", "filename", true],
47
+ [18, "tis620", "tis620_thai_ci", true],
48
+ [19, "euckr", "euckr_korean_ci", true],
49
+ [20, "latin7", "latin7_estonian_cs", false],
50
+ [21, "latin2", "latin2_hungarian_ci", false],
51
+ [22, "koi8u", "koi8u_general_ci", true],
52
+ [23, "cp1251", "cp1251_ukrainian_ci", false],
53
+ [24, "gb2312", "gb2312_chinese_ci", true],
54
+ [25, "greek", "greek_general_ci", true],
55
+ [26, "cp1250", "cp1250_general_ci", true],
56
+ [27, "latin2", "latin2_croatian_ci", false],
57
+ [28, "gbk", "gbk_chinese_ci", true],
58
+ [29, "cp1257", "cp1257_lithuanian_ci", false],
59
+ [30, "latin5", "latin5_turkish_ci", true],
60
+ [31, "latin1", "latin1_german2_ci", false],
61
+ [32, "armscii8", "armscii8_general_ci", true],
62
+ [33, "utf8", "utf8_general_ci", true],
63
+ [34, "cp1250", "cp1250_czech_cs", false],
64
+ [35, "ucs2", "ucs2_general_ci", true],
65
+ [36, "cp866", "cp866_general_ci", true],
66
+ [37, "keybcs2", "keybcs2_general_ci", true],
67
+ [38, "macce", "macce_general_ci", true],
68
+ [39, "macroman", "macroman_general_ci", true],
69
+ [40, "cp852", "cp852_general_ci", true],
70
+ [41, "latin7", "latin7_general_ci", true],
71
+ [42, "latin7", "latin7_general_cs", false],
72
+ [43, "macce", "macce_bin", false],
73
+ [44, "cp1250", "cp1250_croatian_ci", false],
74
+ [45, "utf8mb4", "utf8mb4_general_ci", true],
75
+ [46, "utf8mb4", "utf8mb4_bin", false],
76
+ [47, "latin1", "latin1_bin", false],
77
+ [48, "latin1", "latin1_general_ci", false],
78
+ [49, "latin1", "latin1_general_cs", false],
79
+ [50, "cp1251", "cp1251_bin", false],
80
+ [51, "cp1251", "cp1251_general_ci", true],
81
+ [52, "cp1251", "cp1251_general_cs", false],
82
+ [53, "macroman", "macroman_bin", false],
83
+ [57, "cp1256", "cp1256_general_ci", true],
84
+ [58, "cp1257", "cp1257_bin", false],
85
+ [59, "cp1257", "cp1257_general_ci", true],
86
+ [63, "binary", "binary", true],
87
+ [64, "armscii8", "armscii8_bin", false],
88
+ [65, "ascii", "ascii_bin", false],
89
+ [66, "cp1250", "cp1250_bin", false],
90
+ [67, "cp1256", "cp1256_bin", false],
91
+ [68, "cp866", "cp866_bin", false],
92
+ [69, "dec8", "dec8_bin", false],
93
+ [70, "greek", "greek_bin", false],
94
+ [71, "hebrew", "hebrew_bin", false],
95
+ [72, "hp8", "hp8_bin", false],
96
+ [73, "keybcs2", "keybcs2_bin", false],
97
+ [74, "koi8r", "koi8r_bin", false],
98
+ [75, "koi8u", "koi8u_bin", false],
99
+ [77, "latin2", "latin2_bin", false],
100
+ [78, "latin5", "latin5_bin", false],
101
+ [79, "latin7", "latin7_bin", false],
102
+ [80, "cp850", "cp850_bin", false],
103
+ [81, "cp852", "cp852_bin", false],
104
+ [82, "swe7", "swe7_bin", false],
105
+ [83, "utf8", "utf8_bin", false],
106
+ [84, "big5", "big5_bin", false],
107
+ [85, "euckr", "euckr_bin", false],
108
+ [86, "gb2312", "gb2312_bin", false],
109
+ [87, "gbk", "gbk_bin", false],
110
+ [88, "sjis", "sjis_bin", false],
111
+ [89, "tis620", "tis620_bin", false],
112
+ [90, "ucs2", "ucs2_bin", false],
113
+ [91, "ujis", "ujis_bin", false],
114
+ [92, "geostd8", "geostd8_general_ci", true],
115
+ [93, "geostd8", "geostd8_bin", false],
116
+ [94, "latin1", "latin1_spanish_ci", false],
117
+ [95, "cp932", "cp932_japanese_ci", true],
118
+ [96, "cp932", "cp932_bin", false],
119
+ [97, "eucjpms", "eucjpms_japanese_ci", true],
120
+ [98, "eucjpms", "eucjpms_bin", false],
121
+ [99, "cp1250", "cp1250_polish_ci", false],
122
122
  [128, "ucs2", "ucs2_unicode_ci", false],
123
123
  [129, "ucs2", "ucs2_icelandic_ci", false],
124
124
  [130, "ucs2", "ucs2_latvian_ci", false],
@@ -179,14 +179,14 @@ class MysqlPR
179
179
  [242, "utf8mb4", "utf8mb4_hungarian_ci", false],
180
180
  [243, "utf8mb4", "utf8mb4_sinhala_ci", false],
181
181
  [254, "utf8", "utf8_general_cs", false],
182
- [255, "utf8mb4", "utf8mb4_0900_ai_ci", false],
182
+ [255, "utf8mb4", "utf8mb4_0900_ai_ci", false]
183
183
  ].freeze
184
184
 
185
185
  UNSAFE_CHARSET = %w[big5 sjis filename gbk ucs2 cp932].freeze
186
186
 
187
- NUMBER_TO_CHARSET = {}
188
- COLLATION_TO_CHARSET = {}
189
- CHARSET_DEFAULT = {}
187
+ NUMBER_TO_CHARSET = {} # rubocop:disable Style/MutableConstant
188
+ COLLATION_TO_CHARSET = {} # rubocop:disable Style/MutableConstant
189
+ CHARSET_DEFAULT = {} # rubocop:disable Style/MutableConstant
190
190
 
191
191
  CHARSETS.each do |number, csname, clname, default|
192
192
  cs = Charset.new(number, csname, clname)
@@ -205,42 +205,42 @@ class MysqlPR
205
205
  # MySQL Charset -> Ruby Encoding mapping
206
206
  CHARSET_ENCODING = {
207
207
  "armscii8" => nil,
208
- "ascii" => Encoding::US_ASCII,
209
- "big5" => Encoding::Big5,
210
- "binary" => Encoding::ASCII_8BIT,
211
- "cp1250" => Encoding::Windows_1250,
212
- "cp1251" => Encoding::Windows_1251,
213
- "cp1256" => Encoding::Windows_1256,
214
- "cp1257" => Encoding::Windows_1257,
215
- "cp850" => Encoding::CP850,
216
- "cp852" => Encoding::CP852,
217
- "cp866" => Encoding::IBM866,
218
- "cp932" => Encoding::Windows_31J,
219
- "dec8" => nil,
220
- "eucjpms" => Encoding::EucJP_ms,
221
- "euckr" => Encoding::EUC_KR,
222
- "gb2312" => Encoding::EUC_CN,
223
- "gbk" => Encoding::GBK,
224
- "geostd8" => nil,
225
- "greek" => Encoding::ISO_8859_7,
226
- "hebrew" => Encoding::ISO_8859_8,
227
- "hp8" => nil,
228
- "keybcs2" => nil,
229
- "koi8r" => Encoding::KOI8_R,
230
- "koi8u" => Encoding::KOI8_U,
231
- "latin1" => Encoding::ISO_8859_1,
232
- "latin2" => Encoding::ISO_8859_2,
233
- "latin5" => Encoding::ISO_8859_9,
234
- "latin7" => Encoding::ISO_8859_13,
235
- "macce" => Encoding::MacCentEuro,
208
+ "ascii" => Encoding::US_ASCII,
209
+ "big5" => Encoding::Big5,
210
+ "binary" => Encoding::ASCII_8BIT,
211
+ "cp1250" => Encoding::Windows_1250,
212
+ "cp1251" => Encoding::Windows_1251,
213
+ "cp1256" => Encoding::Windows_1256,
214
+ "cp1257" => Encoding::Windows_1257,
215
+ "cp850" => Encoding::CP850,
216
+ "cp852" => Encoding::CP852,
217
+ "cp866" => Encoding::IBM866,
218
+ "cp932" => Encoding::Windows_31J,
219
+ "dec8" => nil,
220
+ "eucjpms" => Encoding::EucJP_ms,
221
+ "euckr" => Encoding::EUC_KR,
222
+ "gb2312" => Encoding::EUC_CN,
223
+ "gbk" => Encoding::GBK,
224
+ "geostd8" => nil,
225
+ "greek" => Encoding::ISO_8859_7,
226
+ "hebrew" => Encoding::ISO_8859_8,
227
+ "hp8" => nil,
228
+ "keybcs2" => nil,
229
+ "koi8r" => Encoding::KOI8_R,
230
+ "koi8u" => Encoding::KOI8_U,
231
+ "latin1" => Encoding::ISO_8859_1,
232
+ "latin2" => Encoding::ISO_8859_2,
233
+ "latin5" => Encoding::ISO_8859_9,
234
+ "latin7" => Encoding::ISO_8859_13,
235
+ "macce" => Encoding::MacCentEuro,
236
236
  "macroman" => Encoding::MacRoman,
237
- "sjis" => Encoding::SHIFT_JIS,
238
- "swe7" => nil,
239
- "tis620" => Encoding::TIS_620,
240
- "ucs2" => Encoding::UTF_16BE,
241
- "ujis" => Encoding::EucJP_ms,
242
- "utf8" => Encoding::UTF_8,
243
- "utf8mb4" => Encoding::UTF_8,
237
+ "sjis" => Encoding::SHIFT_JIS,
238
+ "swe7" => nil,
239
+ "tis620" => Encoding::TIS_620,
240
+ "ucs2" => Encoding::UTF_16BE,
241
+ "ujis" => Encoding::EucJP_ms,
242
+ "utf8" => Encoding::UTF_8,
243
+ "utf8mb4" => Encoding::UTF_8
244
244
  }.freeze
245
245
 
246
246
  # @param [Integer] n charset number
@@ -286,9 +286,7 @@ class MysqlPR
286
286
  # @param [String] value
287
287
  # @return [String]
288
288
  def convert(value)
289
- if value.is_a?(String) && value.encoding != Encoding::ASCII_8BIT
290
- value = value.encode(encoding)
291
- end
289
+ value = value.encode(encoding) if value.is_a?(String) && value.encoding != Encoding::ASCII_8BIT
292
290
  value
293
291
  end
294
292
  end
@@ -153,11 +153,11 @@ class MysqlPR
153
153
  AUTO_INCREMENT_FLAG = 512
154
154
  TIMESTAMP_FLAG = 1024
155
155
  SET_FLAG = 2048
156
- NUM_FLAG = 32768
157
- PART_KEY_FLAG = 16384
158
- GROUP_FLAG = 32768
159
- UNIQUE_FLAG = 65536
160
- BINCMP_FLAG = 131072
156
+ NUM_FLAG = 32_768
157
+ PART_KEY_FLAG = 16_384
158
+ GROUP_FLAG = 32_768
159
+ UNIQUE_FLAG = 65_536
160
+ BINCMP_FLAG = 131_072
161
161
  end
162
162
 
163
163
  class Stmt
@@ -8,14 +8,15 @@ class MysqlPR
8
8
  ERRNO = 0
9
9
 
10
10
  def self.define_error_class(prefix_re)
11
- self.constants.each do |errname|
11
+ constants.each do |errname|
12
12
  errname = errname.to_s
13
13
  next unless errname =~ prefix_re
14
- errno = self.const_get errname
15
- excname = errname.sub(prefix_re,'').gsub(/(\A.|_.)([A-Z]+)/){$1+$2.downcase}.gsub(/_/,'')
14
+
15
+ errno = const_get errname
16
+ excname = errname.sub(prefix_re, "").gsub(/(\A.|_.)([A-Z]+)/) { ::Regexp.last_match(1) + ::Regexp.last_match(2).downcase }.gsub(/_/, "")
16
17
  klass = Class.new self
17
- klass.const_set 'ERRNO', errno
18
- self.const_set excname, klass
18
+ klass.const_set "ERRNO", errno
19
+ const_set excname, klass
19
20
  self::ERROR_MAP[errno] = klass
20
21
  MysqlPR::Error.const_set errname, errno
21
22
  end
@@ -23,7 +24,7 @@ class MysqlPR
23
24
 
24
25
  attr_reader :sqlstate, :error
25
26
 
26
- def initialize(message, sqlstate='HY000')
27
+ def initialize(message, sqlstate = "HY000")
27
28
  @sqlstate = sqlstate
28
29
  @error = message
29
30
  super message
@@ -36,7 +37,7 @@ class MysqlPR
36
37
 
37
38
  # server side error
38
39
  class ServerError < Error
39
- ERROR_MAP = {}
40
+ ERROR_MAP = {} # rubocop:disable Style/MutableConstant
40
41
 
41
42
  ER_HASHCHK = 1000
42
43
  ER_NISAMCHK = 1001
@@ -747,11 +748,11 @@ class MysqlPR
747
748
  end
748
749
 
749
750
  ServerError.define_error_class(/\AER_/)
750
- ServerError::ERROR_MAP.values.each{|v| MysqlPR.const_set v.name.split(/::/).last, v} # for compatibility
751
+ ServerError::ERROR_MAP.each_value { |v| MysqlPR.const_set v.name.split(/::/).last, v } # for compatibility
751
752
 
752
753
  # client side error
753
754
  class ClientError < Error
754
- ERROR_MAP = {}
755
+ ERROR_MAP = {} # rubocop:disable Style/MutableConstant
755
756
 
756
757
  CR_UNKNOWN_ERROR = 2000
757
758
  CR_SOCKET_CREATE_ERROR = 2001
@@ -820,5 +821,4 @@ class MysqlPR
820
821
  # protocol error
821
822
  class ProtocolError < ClientError
822
823
  end
823
-
824
824
  end
@@ -7,15 +7,16 @@ class MysqlPR
7
7
  def self.lcb(num)
8
8
  return "\xfb".b if num.nil?
9
9
  return [num].pack("C") if num < 251
10
- return [252, num].pack("Cv") if num < 65536
10
+ return [252, num].pack("Cv") if num < 65_536
11
11
  return [253, num & 0xffff, num >> 16].pack("CvC") if num < 16_777_216
12
- return [254, num & 0xffffffff, num >> 32].pack("CVV")
12
+
13
+ [254, num & 0xffffffff, num >> 32].pack("CVV")
13
14
  end
14
15
 
15
16
  # convert String to LengthCodedString
16
17
  def self.lcs(str)
17
18
  str = Charset.to_binary str
18
- lcb(str.length)+str
19
+ lcb(str.length) + str
19
20
  end
20
21
 
21
22
  def initialize(data)
@@ -24,25 +25,29 @@ class MysqlPR
24
25
 
25
26
  def lcb
26
27
  return nil if @data.empty?
28
+
27
29
  case v = utiny
28
30
  when 0xfb
29
- return nil
31
+ nil
30
32
  when 0xfc
31
- return ushort
33
+ ushort
32
34
  when 0xfd
33
- c, v = utiny, ushort
34
- return (v << 8)+c
35
+ c = utiny
36
+ v = ushort
37
+ (v << 8) + c
35
38
  when 0xfe
36
- v1, v2 = ulong, ulong
37
- return (v2 << 32)+v1
39
+ v1 = ulong
40
+ v2 = ulong
41
+ (v2 << 32) + v1
38
42
  else
39
- return v
43
+ v
40
44
  end
41
45
  end
42
46
 
43
47
  def lcs
44
- len = self.lcb
48
+ len = lcb
45
49
  return nil unless len
50
+
46
51
  @data.slice!(0, len)
47
52
  end
48
53
 
@@ -51,21 +56,21 @@ class MysqlPR
51
56
  end
52
57
 
53
58
  def string
54
- str = @data.unpack('Z*').first
55
- @data.slice!(0, str.length+1)
59
+ str = @data.unpack1("Z*")
60
+ @data.slice!(0, str.length + 1)
56
61
  str
57
62
  end
58
63
 
59
64
  def utiny
60
- @data.slice!(0, 1).unpack('C').first
65
+ @data.slice!(0, 1).unpack1("C")
61
66
  end
62
67
 
63
68
  def ushort
64
- @data.slice!(0, 2).unpack('v').first
69
+ @data.slice!(0, 2).unpack1("v")
65
70
  end
66
71
 
67
72
  def ulong
68
- @data.slice!(0, 4).unpack('V').first
73
+ @data.slice!(0, 4).unpack1("V")
69
74
  end
70
75
 
71
76
  def eof?
@@ -75,6 +80,5 @@ class MysqlPR
75
80
  def to_s
76
81
  @data
77
82
  end
78
-
79
83
  end
80
84
  end