legion-data 0.1.0 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +98 -71
  3. data/.gitignore +0 -1
  4. data/.rubocop.yml +10 -7
  5. data/CHANGELOG.md +16 -0
  6. data/Gemfile +0 -3
  7. data/Gemfile.lock +100 -0
  8. data/README.md +13 -11
  9. data/legion-data.gemspec +22 -10
  10. data/lib/legion/data.rb +51 -33
  11. data/lib/legion/data/connection.rb +55 -19
  12. data/lib/legion/data/migration.rb +7 -20
  13. data/lib/legion/data/migrations/001_add_schema_columns.rb +1 -1
  14. data/lib/legion/data/migrations/002_add_users.rb +17 -0
  15. data/lib/legion/data/migrations/003_add_groups.rb +16 -0
  16. data/lib/legion/data/migrations/004_add_chains.rb +25 -0
  17. data/lib/legion/data/migrations/005_add_envs.rb +24 -0
  18. data/lib/legion/data/migrations/006_add_dcs.rb +24 -0
  19. data/lib/legion/data/migrations/007_add_nodes.rb +26 -0
  20. data/lib/legion/data/migrations/008_add_settings.rb +18 -0
  21. data/lib/legion/data/migrations/009_add_extensions.rb +25 -0
  22. data/lib/legion/data/migrations/010_add_runners.rb +21 -0
  23. data/lib/legion/data/migrations/011_add_functions.rb +29 -0
  24. data/lib/legion/data/migrations/012_add_tasks.rb +28 -0
  25. data/lib/legion/data/migrations/013_add_task_logs.rb +23 -0
  26. data/lib/legion/data/migrations/014_add_relationships.rb +27 -0
  27. data/lib/legion/data/migrations/015_add_default_extensions.rb +24 -0
  28. data/lib/legion/data/migrations/016_change_task_args.rb +7 -0
  29. data/lib/legion/data/migrations/017_add_payload_task.rb +7 -0
  30. data/lib/legion/data/migrations/018_add_migration_column.rb +7 -0
  31. data/lib/legion/data/model.rb +26 -25
  32. data/lib/legion/data/models/chain.rb +0 -1
  33. data/lib/legion/data/models/datacenter.rb +0 -1
  34. data/lib/legion/data/models/environment.rb +0 -1
  35. data/lib/legion/data/models/extension.rb +11 -0
  36. data/lib/legion/data/models/function.rb +5 -4
  37. data/lib/legion/data/models/group.rb +10 -0
  38. data/lib/legion/data/models/node.rb +1 -1
  39. data/lib/legion/data/models/relationship.rb +1 -1
  40. data/lib/legion/data/models/runner.rb +15 -0
  41. data/lib/legion/data/models/setting.rb +10 -0
  42. data/lib/legion/data/models/task.rb +0 -1
  43. data/lib/legion/data/models/task_log.rb +0 -1
  44. data/lib/legion/data/models/user.rb +10 -0
  45. data/lib/legion/data/settings.rb +68 -0
  46. data/lib/legion/data/version.rb +1 -1
  47. data/sonar-project.properties +12 -0
  48. metadata +119 -54
  49. data/lib/legion/data/connections/base.rb +0 -45
  50. data/lib/legion/data/connections/jdbc.rb +0 -21
  51. data/lib/legion/data/connections/mysql.rb +0 -26
  52. data/lib/legion/data/connections/mysql2.rb +0 -26
  53. data/lib/legion/data/connections/mysql_base.rb +0 -19
  54. data/lib/legion/data/migrations/002_add_chains_table.rb +0 -21
  55. data/lib/legion/data/migrations/003_add_datacenters_table.rb +0 -21
  56. data/lib/legion/data/migrations/004_add_envs_table.rb +0 -21
  57. data/lib/legion/data/migrations/005_add_functions_table.rb +0 -25
  58. data/lib/legion/data/migrations/006_add_namespaces_table.rb +0 -24
  59. data/lib/legion/data/migrations/007_add_nodes_table.rb +0 -22
  60. data/lib/legion/data/migrations/008_add_relationships_table.rb +0 -28
  61. data/lib/legion/data/migrations/009_add_task_logs_table.rb +0 -17
  62. data/lib/legion/data/migrations/010_add_tasks_table.rb +0 -20
  63. data/lib/legion/data/migrations/011_add_users_and_groups.rb +0 -28
  64. data/lib/legion/data/migrations/012_foreign_keys_users_and_groups.rb +0 -42
  65. data/lib/legion/data/migrations/013_function_foreign_keys.rb +0 -10
  66. data/lib/legion/data/migrations/014_nodes_foreign_keys.rb +0 -12
  67. data/lib/legion/data/migrations/015_relationships_foreign_keys.rb +0 -14
  68. data/lib/legion/data/migrations/016_tasks_foreign_keys.rb +0 -22
  69. data/lib/legion/data/migrations/017_add_relationship_to_tasks.rb +0 -14
  70. data/lib/legion/data/models/namespace.rb +0 -12
@@ -1,5 +1,5 @@
1
1
  module Legion
2
2
  module Data
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '1.1.4'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ sonar.projectKey=legion-io_legion-data
2
+ sonar.organization=legion-io
3
+ sonar.projectName=Legion::Data
4
+ sonar.sources=.
5
+ sonar.exclusions=vendor/**
6
+ sonar.coverage.exclusions=spec/**
7
+ sonar.ruby.coverage.reportPath=coverage/.resultset.json
8
+ sonar.ruby.file.suffixes=rb,ruby
9
+ sonar.ruby.coverage.framework=RSpec
10
+ sonar.ruby.rubocopConfig=.rubocop.yml
11
+ sonar.ruby.rubocop.reportPath=rubocop-result.json
12
+ sonar.ruby.rubocop.filePath=.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-27 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,100 +28,156 @@ dependencies:
28
28
  name: codecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec_junit_formatter
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-md
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-sequel
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
95
151
  - !ruby/object:Gem::Version
96
152
  version: '0'
97
153
  - !ruby/object:Gem::Dependency
98
154
  name: legion-logging
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
- - - "~>"
157
+ - - ">="
102
158
  - !ruby/object:Gem::Version
103
- version: '0.1'
159
+ version: '0'
104
160
  type: :runtime
105
161
  prerelease: false
106
162
  version_requirements: !ruby/object:Gem::Requirement
107
163
  requirements:
108
- - - "~>"
164
+ - - ">="
109
165
  - !ruby/object:Gem::Version
110
- version: '0.1'
166
+ version: '0'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: legion-settings
113
169
  requirement: !ruby/object:Gem::Requirement
114
170
  requirements:
115
- - - "~>"
171
+ - - ">="
116
172
  - !ruby/object:Gem::Version
117
- version: '0.1'
173
+ version: '0'
118
174
  type: :runtime
119
175
  prerelease: false
120
176
  version_requirements: !ruby/object:Gem::Requirement
121
177
  requirements:
122
- - - "~>"
178
+ - - ">="
123
179
  - !ruby/object:Gem::Version
124
- version: '0.1'
180
+ version: '0'
125
181
  - !ruby/object:Gem::Dependency
126
182
  name: mysql2
127
183
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +217,9 @@ files:
161
217
  - ".gitignore"
162
218
  - ".rspec"
163
219
  - ".rubocop.yml"
220
+ - CHANGELOG.md
164
221
  - Gemfile
222
+ - Gemfile.lock
165
223
  - README.md
166
224
  - Rakefile
167
225
  - bin/console
@@ -170,44 +228,52 @@ files:
170
228
  - legion-data.gemspec
171
229
  - lib/legion/data.rb
172
230
  - lib/legion/data/connection.rb
173
- - lib/legion/data/connections/base.rb
174
- - lib/legion/data/connections/jdbc.rb
175
- - lib/legion/data/connections/mysql.rb
176
- - lib/legion/data/connections/mysql2.rb
177
- - lib/legion/data/connections/mysql_base.rb
178
231
  - lib/legion/data/migration.rb
179
232
  - lib/legion/data/migrations/001_add_schema_columns.rb
180
- - lib/legion/data/migrations/002_add_chains_table.rb
181
- - lib/legion/data/migrations/003_add_datacenters_table.rb
182
- - lib/legion/data/migrations/004_add_envs_table.rb
183
- - lib/legion/data/migrations/005_add_functions_table.rb
184
- - lib/legion/data/migrations/006_add_namespaces_table.rb
185
- - lib/legion/data/migrations/007_add_nodes_table.rb
186
- - lib/legion/data/migrations/008_add_relationships_table.rb
187
- - lib/legion/data/migrations/009_add_task_logs_table.rb
188
- - lib/legion/data/migrations/010_add_tasks_table.rb
189
- - lib/legion/data/migrations/011_add_users_and_groups.rb
190
- - lib/legion/data/migrations/012_foreign_keys_users_and_groups.rb
191
- - lib/legion/data/migrations/013_function_foreign_keys.rb
192
- - lib/legion/data/migrations/014_nodes_foreign_keys.rb
193
- - lib/legion/data/migrations/015_relationships_foreign_keys.rb
194
- - lib/legion/data/migrations/016_tasks_foreign_keys.rb
195
- - lib/legion/data/migrations/017_add_relationship_to_tasks.rb
233
+ - lib/legion/data/migrations/002_add_users.rb
234
+ - lib/legion/data/migrations/003_add_groups.rb
235
+ - lib/legion/data/migrations/004_add_chains.rb
236
+ - lib/legion/data/migrations/005_add_envs.rb
237
+ - lib/legion/data/migrations/006_add_dcs.rb
238
+ - lib/legion/data/migrations/007_add_nodes.rb
239
+ - lib/legion/data/migrations/008_add_settings.rb
240
+ - lib/legion/data/migrations/009_add_extensions.rb
241
+ - lib/legion/data/migrations/010_add_runners.rb
242
+ - lib/legion/data/migrations/011_add_functions.rb
243
+ - lib/legion/data/migrations/012_add_tasks.rb
244
+ - lib/legion/data/migrations/013_add_task_logs.rb
245
+ - lib/legion/data/migrations/014_add_relationships.rb
246
+ - lib/legion/data/migrations/015_add_default_extensions.rb
247
+ - lib/legion/data/migrations/016_change_task_args.rb
248
+ - lib/legion/data/migrations/017_add_payload_task.rb
249
+ - lib/legion/data/migrations/018_add_migration_column.rb
196
250
  - lib/legion/data/model.rb
197
251
  - lib/legion/data/models/chain.rb
198
252
  - lib/legion/data/models/datacenter.rb
199
253
  - lib/legion/data/models/environment.rb
254
+ - lib/legion/data/models/extension.rb
200
255
  - lib/legion/data/models/function.rb
201
- - lib/legion/data/models/namespace.rb
256
+ - lib/legion/data/models/group.rb
202
257
  - lib/legion/data/models/node.rb
203
258
  - lib/legion/data/models/relationship.rb
259
+ - lib/legion/data/models/runner.rb
260
+ - lib/legion/data/models/setting.rb
204
261
  - lib/legion/data/models/task.rb
205
262
  - lib/legion/data/models/task_log.rb
263
+ - lib/legion/data/models/user.rb
264
+ - lib/legion/data/settings.rb
206
265
  - lib/legion/data/version.rb
266
+ - sonar-project.properties
207
267
  homepage: https://bitbucket.org/legion-io/legion-data
208
268
  licenses: []
209
- metadata: {}
210
- post_install_message:
269
+ metadata:
270
+ bug_tracker_uri: https://bitbucket.org/legion-io/legion-data/issues?status=new&status=open
271
+ changelog_uri: https://bitbucket.org/legion-io/legion-data/src/CHANGELOG.md
272
+ documentation_uri: https://bitbucket.org/legion-io/legion-data
273
+ homepage_uri: https://bitbucket.org/legion-io/legion-data
274
+ source_code_uri: https://bitbucket.org/legion-io/legion-data
275
+ wiki_uri: https://bitbucket.org/legion-io/legion-data/wiki/Home
276
+ post_install_message:
211
277
  rdoc_options: []
212
278
  require_paths:
213
279
  - lib
@@ -215,16 +281,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
281
  requirements:
216
282
  - - ">="
217
283
  - !ruby/object:Gem::Version
218
- version: '0'
284
+ version: 2.5.0
219
285
  required_rubygems_version: !ruby/object:Gem::Requirement
220
286
  requirements:
221
287
  - - ">="
222
288
  - !ruby/object:Gem::Version
223
289
  version: '0'
224
290
  requirements: []
225
- rubyforge_project:
226
- rubygems_version: 2.7.8
227
- signing_key:
291
+ rubygems_version: 3.1.2
292
+ signing_key:
228
293
  specification_version: 4
229
294
  summary: Used by Legion to connect to the database
230
295
  test_files: []
@@ -1,45 +0,0 @@
1
- module Legion
2
- module Data
3
- module Connections
4
- class Base
5
- def check_gem(gem = adapter)
6
- Gem::Specification.find_by_name(gem)
7
- rescue Gem::MissingSpecError, ArgumentError
8
- false
9
- end
10
-
11
- def creds_builder(credentials = {})
12
- creds = {}
13
- creds = creds.merge(default_creds) if creds.is_a? Hash
14
- creds = creds.merge(Legion::Settings[:data][:mysql]) if Legion::Settings[:data][:mysql].is_a? Hash
15
- creds = creds.merge(credentials) if credentials.is_a? Hash
16
- creds
17
- end
18
-
19
- def connect(adapter, creds, _options = {})
20
- creds[:adapter] = adapter
21
- Sequel.connect(creds)
22
- end
23
-
24
- def settings(options, _connection = @connection)
25
- raise ArgumentError unless options.is_a? Hash
26
- end
27
-
28
- def debug_logging(enabled = true, connection = @connection, _options = {})
29
- if enabled
30
- connection.loggers = Legion::Logging
31
- connection.sql_log_level = :debug
32
- elsif enabled == false
33
- connection.loggers = nil
34
- connection.sql_log_level = :debug
35
- end
36
- connection
37
- end
38
-
39
- def adapter
40
- 'mysql2'
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,21 +0,0 @@
1
- module Legion
2
- module Data
3
- module Connections
4
- class JDBC
5
- attr_accessor :connection
6
- def initialize
7
- Legion::Logging.debug('Connecting to MySQL with JBDC Connector')
8
- connection_string = build_connection_string
9
- @connection = Sequel.connect(connection_string, max_connetions: @args[:max_connections])
10
- Legion::Logging.info("Legion is connected to database #{args[:database]}")
11
- end
12
-
13
- def build_connection_string
14
- set = Legion::Settings[:data][:mysql]
15
- con_string = "jdbc:mysql://#{set[:host]}/#{set[:database]}?user=#{set[:user]}&password=#{set[:password]}"
16
- con_string
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- require 'legion/data/connections/mysql_base'
2
-
3
- module Legion
4
- module Data
5
- module Connections
6
- class MySQL < Legion::Data::Connections::MySQLBase
7
- attr_accessor :connection
8
- def initialize(_options = {})
9
- Legion::Logging.debug('Connecting to MySQL with MySQL2 Connector')
10
- @connection = connect
11
-
12
- Legion::Logging.info("Legion is connected to database #{Legion::Settings[:data][:mysql][:database]}")
13
- Legion::Settings[:data][:connected] = true
14
- end
15
-
16
- def adapter
17
- 'mysql2'
18
- end
19
-
20
- def connect
21
- super(adapter, creds_builder)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- require 'legion/data/connections/mysql_base'
2
-
3
- module Legion
4
- module Data
5
- module Connections
6
- class MySQL2 < Legion::Data::Connections::MySQLBase
7
- attr_accessor :connection
8
- def initialize(_options = {})
9
- Legion::Logging.debug('Connecting to MySQL with MySQL2 Connector')
10
- @connection = connect
11
-
12
- Legion::Logging.info("Legion is connected to database #{Legion::Settings[:data][:mysql][:database]}")
13
- Legion::Settings[:data][:connected] = true
14
- end
15
-
16
- def adapter
17
- 'mysql2'
18
- end
19
-
20
- def connect
21
- super(adapter, creds_builder)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,19 +0,0 @@
1
- require 'legion/data/connections/base'
2
-
3
- module Legion
4
- module Data
5
- module Connections
6
- class MySQLBase < Legion::Data::Connections::Base
7
- def default_creds
8
- { data: { mysql: {
9
- host: '127.0.0.1',
10
- user: 'legion',
11
- password: 'legion',
12
- max_connections: 10,
13
- database: 'legion'
14
- } } }
15
- end
16
- end
17
- end
18
- end
19
- end