mysql-pr 3.0.0 → 3.0.2

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MysqlPR
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.2"
5
5
  end
data/lib/mysql-pr.rb CHANGED
@@ -54,7 +54,7 @@ class MysqlPR
54
54
  # @param [String] str
55
55
  # @return [String]
56
56
  def escape_string(str)
57
- str.gsub(/[\0\n\r\\\'\"\x1a]/) do |s|
57
+ str.gsub(/[\0\n\r\\'"\x1a]/) do |s|
58
58
  case s
59
59
  when "\0" then "\\0"
60
60
  when "\n" then "\\n"
@@ -74,7 +74,7 @@ class MysqlPR
74
74
 
75
75
  # @return [Integer] client version (dummy for MySQL/Ruby compatibility)
76
76
  def client_version
77
- 50000
77
+ 50_000
78
78
  end
79
79
  alias get_client_version client_version
80
80
  end
@@ -113,7 +113,7 @@ class MysqlPR
113
113
  @protocol = Protocol.new(host, port, socket, @connect_timeout, @read_timeout, @write_timeout, @ssl_options)
114
114
  @protocol.authenticate(user, passwd, db, (@local_infile ? CLIENT_LOCAL_FILES : 0) | flag, @charset)
115
115
  @charset ||= @protocol.charset
116
- @host_info = (host.nil? || host == "localhost") ? "Localhost via UNIX socket" : "#{host} via TCP/IP"
116
+ @host_info = host.nil? || host == "localhost" ? "Localhost via UNIX socket" : "#{host} via TCP/IP"
117
117
  query(@init_command) if @init_command
118
118
  self
119
119
  end
@@ -198,11 +198,8 @@ class MysqlPR
198
198
  # @option options [Boolean] :required raise error if server doesn't support SSL
199
199
  # @option options [String] :hostname hostname for SNI
200
200
  # @option options [Symbol] :min_version minimum TLS version (:TLS1_2, :TLS1_3, etc.)
201
- # @return [MysqlPR] self
202
- def ssl_options=(options)
203
- @ssl_options = options
204
- self
205
- end
201
+ # @return [Hash] the options hash
202
+ attr_writer :ssl_options
206
203
 
207
204
  # Check if SSL is enabled for the current connection.
208
205
  # @return [Boolean] true if SSL is enabled
@@ -238,6 +235,7 @@ class MysqlPR
238
235
 
239
236
  # Set charset of MySQL connection.
240
237
  # @param [String, MysqlPR::Charset] cs
238
+ # @return [MysqlPR::Charset] the charset
241
239
  def charset=(cs)
242
240
  charset = cs.is_a?(Charset) ? cs : Charset.by_name(cs)
243
241
  if @protocol
@@ -245,7 +243,6 @@ class MysqlPR
245
243
  query("SET NAMES #{charset.name}")
246
244
  end
247
245
  @charset = charset
248
- cs
249
246
  end
250
247
 
251
248
  # @return [String] charset name
@@ -274,9 +271,7 @@ class MysqlPR
274
271
  end
275
272
 
276
273
  # @return [String] connection type
277
- def host_info
278
- @host_info
279
- end
274
+ attr_reader :host_info
280
275
  alias get_host_info host_info
281
276
 
282
277
  # @return [Integer] protocol version
@@ -332,7 +327,7 @@ class MysqlPR
332
327
  # @param [String] db database name that may contain wild card
333
328
  # @return [Array<String>] database list
334
329
  def list_dbs(db = nil)
335
- db &&= db.gsub(/[\\\']/) { "\\#{$&}" }
330
+ db &&= db.gsub(/[\\']/) { "\\#{::Regexp.last_match(0)}" }
336
331
  query(db ? "show databases like '#{db}'" : "show databases").map(&:first)
337
332
  end
338
333
 
@@ -360,11 +355,9 @@ class MysqlPR
360
355
  end
361
356
  return self
362
357
  end
363
- if @query_with_result
364
- return @fields ? store_result : nil
365
- else
366
- return self
367
- end
358
+ return @fields ? store_result : nil if @query_with_result
359
+
360
+ self
368
361
  rescue ServerError => e
369
362
  @last_error = e
370
363
  @sqlstate = e.sqlstate
@@ -595,14 +588,14 @@ class MysqlPR
595
588
  # @return [Hash] field information
596
589
  def to_hash
597
590
  {
598
- "name" => @name,
599
- "table" => @table,
600
- "def" => @default,
601
- "type" => @type,
602
- "length" => @length,
591
+ "name" => @name,
592
+ "table" => @table,
593
+ "def" => @default,
594
+ "type" => @type,
595
+ "length" => @length,
603
596
  "max_length" => max_length,
604
- "flags" => @flags,
605
- "decimals" => @decimals
597
+ "flags" => @flags,
598
+ "decimals" => @decimals
606
599
  }
607
600
  end
608
601
  alias hash to_hash
@@ -689,9 +682,7 @@ class MysqlPR
689
682
  row = fetch
690
683
  return nil unless row
691
684
 
692
- if with_table && @fieldname_with_table.nil?
693
- @fieldname_with_table = @fields.map { |f| "#{f.table}.#{f.name}" }
694
- end
685
+ @fieldname_with_table = @fields.map { |f| "#{f.table}.#{f.name}" } if with_table && @fieldname_with_table.nil?
695
686
  ret = {}
696
687
  @fields.each_index do |i|
697
688
  fname = with_table ? @fieldname_with_table[i] : @fields[i].name
@@ -853,8 +844,7 @@ class MysqlPR
853
844
  class Stmt
854
845
  include Enumerable
855
846
 
856
- attr_reader :affected_rows, :insert_id, :server_status, :warning_count
857
- attr_reader :param_count, :fields, :sqlstate
847
+ attr_reader :affected_rows, :insert_id, :server_status, :warning_count, :param_count, :fields, :sqlstate
858
848
 
859
849
  def self.finalizer(protocol, statement_id)
860
850
  proc do
data/mysql-pr.gemspec CHANGED
@@ -32,5 +32,4 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "rake", "~> 13.0"
33
33
  spec.add_development_dependency "rspec", "~> 3.0"
34
34
  spec.add_development_dependency "rubocop", "~> 1.0"
35
- spec.add_development_dependency "rubocop-rspec", "~> 2.0"
36
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql-pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomita Masahiro
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.0'
70
- - !ruby/object:Gem::Dependency
71
- name: rubocop-rspec
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '2.0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '2.0'
84
70
  description: A pure Ruby MySQL client library. No native extensions required.
85
71
  email:
86
72
  - tommy@tmtm.org