onlyoffice_mysql_helper 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e45241a0729e8f4cfd398e86f8e9db10f367c4e7f6fa3f29baec5bd3fd993cc
|
4
|
+
data.tar.gz: 56aa406ba03ea18c088946a3ffd2361bd3507e85c021bf8daf6b391f68d20bf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1605b39c83e3a5627d6a12b1ecda3016c3554e02a8af75f823c79c609be3e9e81eb856caa800373efa32dd935dd3f81ac29fd91d3d21a7e734fecc89a78dd6b8
|
7
|
+
data.tar.gz: 07ff87464a0a6eddbe7c87265503ed49634825fce091601674325deb36146dfec0b10dc729afe3e6bb454b28dd1c1fda330ec8794c6c6c23de2c007258bf7b77
|
@@ -4,22 +4,33 @@ require 'mysql2'
|
|
4
4
|
module OnlyofficeMysqlHelper
|
5
5
|
# Class for using mysql
|
6
6
|
class MySQLHelper
|
7
|
-
|
7
|
+
# @return [String] database name
|
8
8
|
attr_accessor :database
|
9
|
+
|
10
|
+
# @return [String] default sql address
|
9
11
|
SQL_SERVER_ADDRESS_LOCAL = '127.0.0.1'
|
12
|
+
# @return [String] default sql user
|
10
13
|
SQL_SERVER_USER_LOCAL = 'root'
|
14
|
+
# @return [String] default sql password
|
11
15
|
SQL_SERVER_PASSWORD_LOCAL = ''
|
12
16
|
|
13
17
|
def initialize(address: SQL_SERVER_ADDRESS_LOCAL,
|
14
18
|
database: 'performance_test',
|
15
19
|
user: SQL_SERVER_USER_LOCAL,
|
16
20
|
password: SQL_SERVER_PASSWORD_LOCAL)
|
21
|
+
port = ENV['DB_PORT'] || 3306
|
17
22
|
@connection = Mysql2::Client.new(host: address,
|
23
|
+
port: port,
|
18
24
|
username: user,
|
19
|
-
password: password,
|
25
|
+
password: password,
|
26
|
+
database: database)
|
20
27
|
@database = database
|
21
28
|
end
|
22
29
|
|
30
|
+
# Add hash record to table
|
31
|
+
# @param [String] table_name to add hash
|
32
|
+
# @param [Hash] hash to add
|
33
|
+
# @return [nil]
|
23
34
|
def add_record(table_name, hash)
|
24
35
|
send_query do
|
25
36
|
"INSERT INTO `#{table_name}` (`id`, #{from_query_keys(hash)}) "\
|
@@ -27,26 +38,43 @@ module OnlyofficeMysqlHelper
|
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
41
|
+
# Create specific table if not exists
|
42
|
+
# @param [String] name of table
|
43
|
+
# @param [String] columns of table
|
44
|
+
# @return [nil]
|
30
45
|
def create_table(name, columns = 'id INT PRIMARY KEY AUTO_INCREMENT')
|
31
46
|
send_query { "CREATE TABLE IF NOT EXISTS `#{name}`(#{columns});" }
|
32
47
|
end
|
33
48
|
|
49
|
+
# Select table records
|
50
|
+
# @param [String] table_name of table
|
51
|
+
# @param [String] condition to filter
|
52
|
+
# @return [Object] result of select
|
34
53
|
def select_records(table_name, condition = '')
|
35
54
|
send_query do
|
36
55
|
query = "SELECT * FROM `#{table_name}`"
|
37
56
|
query += " #{condition}" unless condition == ''
|
38
|
-
query
|
57
|
+
"#{query};"
|
39
58
|
end
|
40
59
|
end
|
41
60
|
|
61
|
+
# List all tables in base
|
62
|
+
# @return [Object] table list
|
42
63
|
def tables
|
43
64
|
send_query { 'SHOW TABLES;' }
|
44
65
|
end
|
45
66
|
|
67
|
+
# Delete record by condition
|
68
|
+
# @param [String] table_name of table
|
69
|
+
# @param [String] condition to delete
|
70
|
+
# @return [nil]
|
46
71
|
def delete_record(table_name, condition)
|
47
72
|
send_query { "DELETE FROM `#{table_name}` WHERE #{condition};" }
|
48
73
|
end
|
49
74
|
|
75
|
+
# Drop whole table
|
76
|
+
# @param [String] table_name of table
|
77
|
+
# @return [nil]
|
50
78
|
def drop_table(table_name)
|
51
79
|
send_query { "DROP TABLE `#{table_name}`;" }
|
52
80
|
end
|
@@ -3,8 +3,11 @@
|
|
3
3
|
module OnlyofficeMysqlHelper
|
4
4
|
# Log action in mysql
|
5
5
|
class MySQLLogger
|
6
|
+
# @return [MySQLHelper] instance of helper
|
6
7
|
attr_accessor :mysql
|
8
|
+
# @return [String] table name
|
7
9
|
attr_accessor :table
|
10
|
+
# @return [Hash] hash to add to DB
|
8
11
|
attr_accessor :hash
|
9
12
|
|
10
13
|
def initialize(mysql = MySQLHelper.new, table = nil, hash = {})
|
@@ -24,6 +27,10 @@ module OnlyofficeMysqlHelper
|
|
24
27
|
@mysql.create_table(table_name, table_command)
|
25
28
|
end
|
26
29
|
|
30
|
+
# Log ant actions in DB
|
31
|
+
# @param [String] action name for log
|
32
|
+
# @param [Hash] hash with additional options
|
33
|
+
# @return [nil]
|
27
34
|
def log_actions(action, hash)
|
28
35
|
mysql_hash = hash.merge(@hash)
|
29
36
|
mysql_hash[:time] = Time.now
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_mysql_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mysql2
|
@@ -39,20 +39,132 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: codecov
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: overcommit
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
42
70
|
- !ruby/object:Gem::Dependency
|
43
71
|
name: rake
|
44
72
|
requirement: !ruby/object:Gem::Requirement
|
45
73
|
requirements:
|
46
74
|
- - "~>"
|
47
75
|
- !ruby/object:Gem::Version
|
48
|
-
version: '13
|
76
|
+
version: '13'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '13'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.49.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.49.0
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop-performance
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-rake
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
49
133
|
type: :development
|
50
134
|
prerelease: false
|
51
135
|
version_requirements: !ruby/object:Gem::Requirement
|
52
136
|
requirements:
|
53
137
|
- - "~>"
|
54
138
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-rspec
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '2'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: yard
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.9.20
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.9.20
|
56
168
|
description: Simple MySQL wrapper. Used in QA of ONLYOFFICE
|
57
169
|
email:
|
58
170
|
- shockwavenn@gmail.com
|
@@ -65,15 +177,15 @@ files:
|
|
65
177
|
- lib/onlyoffice_mysql_helper/mysql_logger.rb
|
66
178
|
- lib/onlyoffice_mysql_helper/name.rb
|
67
179
|
- lib/onlyoffice_mysql_helper/version.rb
|
68
|
-
homepage: https://github.com/
|
180
|
+
homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_mysql_helper
|
69
181
|
licenses:
|
70
182
|
- AGPL-3.0
|
71
183
|
metadata:
|
72
|
-
bug_tracker_uri: https://github.com/
|
73
|
-
changelog_uri: https://github.com/
|
184
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_mysql_helper/issues
|
185
|
+
changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_mysql_helper/blob/master/CHANGELOG.md
|
74
186
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_mysql_helper
|
75
|
-
homepage_uri: https://github.com/
|
76
|
-
source_code_uri: https://github.com/
|
187
|
+
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_mysql_helper
|
188
|
+
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_mysql_helper
|
77
189
|
post_install_message:
|
78
190
|
rdoc_options: []
|
79
191
|
require_paths:
|
@@ -82,14 +194,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
194
|
requirements:
|
83
195
|
- - ">="
|
84
196
|
- !ruby/object:Gem::Version
|
85
|
-
version: '2.
|
197
|
+
version: '2.5'
|
86
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
199
|
requirements:
|
88
200
|
- - ">="
|
89
201
|
- !ruby/object:Gem::Version
|
90
202
|
version: '0'
|
91
203
|
requirements: []
|
92
|
-
rubygems_version: 3.1.
|
204
|
+
rubygems_version: 3.1.4
|
93
205
|
signing_key:
|
94
206
|
specification_version: 4
|
95
207
|
summary: Simple MySQL wrapper
|