marty 2.5.2 → 2.5.4

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.
Files changed (181) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +11 -589
  5. data/Gemfile +9 -9
  6. data/Gemfile.lock +1 -1
  7. data/Rakefile +1 -3
  8. data/app/components/marty/api_auth_view.rb +3 -3
  9. data/app/components/marty/api_config_view.rb +8 -8
  10. data/app/components/marty/api_log_view.rb +16 -20
  11. data/app/components/marty/auth_app.rb +6 -6
  12. data/app/components/marty/base_rule_view.rb +27 -19
  13. data/app/components/marty/config_view.rb +12 -9
  14. data/app/components/marty/data_grid_view.rb +26 -26
  15. data/app/components/marty/delorean_rule_view.rb +0 -1
  16. data/app/components/marty/event_view.rb +27 -27
  17. data/app/components/marty/extras/layout.rb +26 -26
  18. data/app/components/marty/extras/misc.rb +2 -2
  19. data/app/components/marty/grid.rb +13 -13
  20. data/app/components/marty/grid_append_only.rb +0 -1
  21. data/app/components/marty/import_type_view.rb +13 -13
  22. data/app/components/marty/import_view.rb +17 -16
  23. data/app/components/marty/log_view.rb +16 -14
  24. data/app/components/marty/main_auth_app.rb +59 -59
  25. data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
  26. data/app/components/marty/mcfly_grid_panel.rb +10 -10
  27. data/app/components/marty/new_posting_form.rb +11 -11
  28. data/app/components/marty/new_posting_window.rb +0 -1
  29. data/app/components/marty/posting_grid.rb +12 -13
  30. data/app/components/marty/promise_view.rb +6 -6
  31. data/app/components/marty/report_form.rb +50 -53
  32. data/app/components/marty/report_select.rb +27 -27
  33. data/app/components/marty/reporting.rb +4 -4
  34. data/app/components/marty/script_form.rb +40 -42
  35. data/app/components/marty/script_grid.rb +24 -24
  36. data/app/components/marty/script_tester.rb +40 -42
  37. data/app/components/marty/scripting.rb +25 -27
  38. data/app/components/marty/simple_app.rb +24 -9
  39. data/app/components/marty/tag_grid.rb +12 -13
  40. data/app/components/marty/user_view.rb +35 -35
  41. data/app/controllers/marty/application_controller.rb +3 -4
  42. data/app/controllers/marty/components_controller.rb +1 -1
  43. data/app/controllers/marty/delayed_job_controller.rb +1 -0
  44. data/app/controllers/marty/diagnostic/controller.rb +4 -6
  45. data/app/controllers/marty/job_controller.rb +6 -6
  46. data/app/controllers/marty/report_controller.rb +11 -11
  47. data/app/controllers/marty/rpc_controller.rb +15 -16
  48. data/app/helpers/marty/script_set.rb +4 -4
  49. data/app/models/marty/api_auth.rb +4 -5
  50. data/app/models/marty/api_config.rb +1 -1
  51. data/app/models/marty/base.rb +9 -8
  52. data/app/models/marty/base_rule.rb +18 -13
  53. data/app/models/marty/config.rb +4 -5
  54. data/app/models/marty/data_grid.rb +157 -181
  55. data/app/models/marty/delorean_rule.rb +63 -62
  56. data/app/models/marty/enum.rb +1 -1
  57. data/app/models/marty/event.rb +56 -59
  58. data/app/models/marty/helper.rb +38 -6
  59. data/app/models/marty/import_type.rb +6 -6
  60. data/app/models/marty/log.rb +3 -2
  61. data/app/models/marty/name_validator.rb +3 -2
  62. data/app/models/marty/pg_enum.rb +3 -4
  63. data/app/models/marty/posting.rb +20 -24
  64. data/app/models/marty/promise.rb +28 -30
  65. data/app/models/marty/script.rb +30 -28
  66. data/app/models/marty/tag.rb +8 -8
  67. data/app/models/marty/token.rb +2 -2
  68. data/app/models/marty/user.rb +24 -23
  69. data/app/models/marty/vw_promise.rb +10 -11
  70. data/config/routes.rb +2 -2
  71. data/delorean/blame_report.dl +268 -0
  72. data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
  73. data/delorean/table_report.dl +34 -0
  74. data/docker-compose.dummy.yml +2 -3
  75. data/lib/marty/aws/base.rb +8 -8
  76. data/lib/marty/aws/request.rb +4 -4
  77. data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
  78. data/lib/marty/content_handler.rb +25 -25
  79. data/lib/marty/data_change.rb +49 -71
  80. data/lib/marty/data_conversion.rb +20 -28
  81. data/lib/marty/data_exporter.rb +25 -28
  82. data/lib/marty/data_importer.rb +25 -27
  83. data/lib/marty/engine.rb +1 -2
  84. data/lib/marty/json_schema.rb +22 -24
  85. data/lib/marty/logger.rb +6 -9
  86. data/lib/marty/mcfly_model.rb +20 -24
  87. data/lib/marty/migrations.rb +37 -35
  88. data/lib/marty/monkey.rb +33 -33
  89. data/lib/marty/permissions.rb +18 -18
  90. data/lib/marty/promise_job.rb +17 -17
  91. data/lib/marty/promise_proxy.rb +6 -6
  92. data/lib/marty/relation.rb +6 -7
  93. data/lib/marty/rpc_call.rb +13 -12
  94. data/lib/marty/rule_script_set.rb +32 -28
  95. data/lib/marty/schema_helper.rb +37 -51
  96. data/lib/marty/util.rb +25 -24
  97. data/lib/marty/version.rb +1 -1
  98. data/lib/marty/xl.rb +121 -115
  99. data/make-dummy.mk +3 -0
  100. data/marty.gemspec +21 -21
  101. data/other/marty/api/base.rb +34 -35
  102. data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
  103. data/other/marty/diagnostic/base.rb +13 -14
  104. data/other/marty/diagnostic/collection.rb +2 -1
  105. data/other/marty/diagnostic/connections.rb +8 -6
  106. data/other/marty/diagnostic/database.rb +1 -0
  107. data/other/marty/diagnostic/delayed_job_version.rb +7 -9
  108. data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
  109. data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
  110. data/other/marty/diagnostic/environment_variables.rb +17 -15
  111. data/other/marty/diagnostic/fatal.rb +1 -1
  112. data/other/marty/diagnostic/node.rb +5 -9
  113. data/other/marty/diagnostic/nodes.rb +7 -5
  114. data/other/marty/diagnostic/packer.rb +7 -7
  115. data/other/marty/diagnostic/reporter.rb +24 -27
  116. data/other/marty/diagnostic/version.rb +3 -5
  117. data/script/rails +2 -1
  118. data/spec/controllers/application_controller_spec.rb +6 -6
  119. data/spec/controllers/delayed_job_controller_spec.rb +4 -4
  120. data/spec/controllers/diagnostic/controller_spec.rb +59 -60
  121. data/spec/controllers/job_controller_spec.rb +68 -69
  122. data/spec/controllers/rpc_controller_spec.rb +353 -359
  123. data/spec/controllers/rpc_import_spec.rb +15 -16
  124. data/spec/dummy/delorean/blame_report.dl +110 -15
  125. data/spec/dummy/delorean/data_report.dl +4 -4
  126. data/spec/dummy/delorean/marty_fields.dl +63 -0
  127. data/spec/dummy/delorean/table_report.dl +34 -0
  128. data/spec/features/auth_app_spec.rb +1 -2
  129. data/spec/features/data_import_spec.rb +2 -3
  130. data/spec/features/enum_spec.rb +42 -46
  131. data/spec/features/jobs_dashboard_spec.rb +14 -8
  132. data/spec/features/log_view_spec.rb +40 -43
  133. data/spec/features/reporting_spec.rb +15 -15
  134. data/spec/features/rule_spec.rb +195 -190
  135. data/spec/features/scripting_spec.rb +17 -20
  136. data/spec/features/scripting_test_spec.rb +32 -33
  137. data/spec/features/user_view_spec.rb +15 -17
  138. data/spec/job_helper.rb +11 -11
  139. data/spec/lib/data_blame_spec.rb +82 -0
  140. data/spec/lib/data_exporter_spec.rb +31 -32
  141. data/spec/lib/data_importer_spec.rb +382 -395
  142. data/spec/lib/delorean_query_spec.rb +117 -119
  143. data/spec/lib/json_schema_spec.rb +382 -392
  144. data/spec/lib/logger_spec.rb +23 -24
  145. data/spec/lib/mcfly_model_spec.rb +112 -109
  146. data/spec/lib/migrations_spec.rb +10 -10
  147. data/spec/lib/struct_compare_spec.rb +6 -6
  148. data/spec/lib/table_report_spec.rb +90 -0
  149. data/spec/lib/xl_spec.rb +63 -65
  150. data/spec/lib/xl_styles_spec.rb +16 -19
  151. data/spec/models/api_auth_spec.rb +30 -30
  152. data/spec/models/config_spec.rb +32 -32
  153. data/spec/models/data_grid_spec.rb +642 -655
  154. data/spec/models/event_spec.rb +96 -88
  155. data/spec/models/import_type_spec.rb +20 -20
  156. data/spec/models/posting_spec.rb +35 -35
  157. data/spec/models/promise_spec.rb +5 -5
  158. data/spec/models/rule_spec.rb +280 -269
  159. data/spec/models/script_spec.rb +27 -18
  160. data/spec/models/user_spec.rb +9 -9
  161. data/spec/other/diagnostic/base_spec.rb +20 -19
  162. data/spec/other/diagnostic/collection_spec.rb +6 -5
  163. data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
  164. data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
  165. data/spec/other/diagnostic/reporter_spec.rb +31 -33
  166. data/spec/spec_helper.rb +5 -5
  167. data/spec/support/chromedriver.rb +3 -5
  168. data/spec/support/components/netzke_combobox.rb +1 -1
  169. data/spec/support/components/netzke_grid.rb +17 -17
  170. data/spec/support/custom_matchers.rb +2 -2
  171. data/spec/support/download_helper.rb +1 -1
  172. data/spec/support/helper.rb +1 -2
  173. data/spec/support/netzke.rb +31 -31
  174. data/spec/support/performance_helper.rb +8 -8
  175. data/spec/support/post_run_logger.rb +1 -2
  176. data/spec/support/setup.rb +1 -4
  177. data/spec/support/shared_connection.rb +2 -2
  178. data/spec/support/structure_compare.rb +21 -22
  179. data/spec/support/suite.rb +1 -2
  180. data/spec/support/users.rb +5 -6
  181. metadata +32 -26
@@ -20,10 +20,13 @@ dummy-app-console:
20
20
  docker-compose --file=docker-compose.dummy.yml run --rm app bin/rails c
21
21
 
22
22
  dummy-app-initialise-docker:
23
+ touch .bash_history.docker
24
+ touch .pry_history.docker
23
25
  make dummy-app-install
24
26
  make dummy-app-db-prepare
25
27
 
26
28
  dummy-app-install:
29
+ docker-compose --file=docker-compose.dummy.yml run --rm app gem install bundler
27
30
  make dummy-app-install-bundle
28
31
 
29
32
  dummy-app-install-bundle:
@@ -1,32 +1,32 @@
1
- $:.push File.expand_path("../lib", __FILE__)
1
+ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
- require "marty/version"
4
- require "digest/md5"
5
- require "base64"
6
- require "zlib"
7
- require "csv"
3
+ require 'marty/version'
4
+ require 'digest/md5'
5
+ require 'base64'
6
+ require 'zlib'
7
+ require 'csv'
8
8
 
9
9
  Gem::Specification.new do |s|
10
- s.name = "marty"
10
+ s.name = 'marty'
11
11
  s.version = Marty::VERSION
12
12
  s.authors = [
13
- "Arman Bostani",
14
- "Brian VanLoo",
15
- "Chad Edie",
16
- "Eric Litwin",
17
- "Iliana Toneva",
18
- "Jock Cooper",
19
- "Masaki Matsuo",
13
+ 'Arman Bostani',
14
+ 'Brian VanLoo',
15
+ 'Chad Edie',
16
+ 'Eric Litwin',
17
+ 'Iliana Toneva',
18
+ 'Jock Cooper',
19
+ 'Masaki Matsuo',
20
20
  ]
21
- s.email = ["arman.bostani@pnmac.com"]
22
- s.homepage = "https://github.com/arman000/marty"
23
- s.summary = "A framework for working with versioned data"
21
+ s.email = ['arman.bostani@pnmac.com']
22
+ s.homepage = 'https://github.com/arman000/marty'
23
+ s.summary = 'A framework for working with versioned data'
24
24
  s.description =
25
- "Marty is a framework for viewing and reporting on versioned data."
25
+ 'Marty is a framework for viewing and reporting on versioned data.'
26
26
  s.files = `git ls-files`.split($\)
27
27
  s.licenses = ['MIT']
28
28
 
29
- s.add_dependency "pg", "~> 0.21"
29
+ s.add_dependency 'pg', '~> 0.21'
30
30
 
31
31
  s.add_dependency 'netzke', '6.5.0.0'
32
32
 
@@ -36,14 +36,14 @@ Gem::Specification.new do |s|
36
36
  s.add_dependency 'mcfly', '0.0.20'
37
37
 
38
38
  s.add_dependency 'coderay'
39
+ s.add_dependency 'json-schema'
39
40
  s.add_dependency 'net-ldap', '~> 0.16.1'
40
41
  s.add_dependency 'rubyzip'
41
42
  s.add_dependency 'sqlite3'
42
- s.add_dependency 'json-schema'
43
43
 
44
44
  # used for signing aws ec2 requests
45
45
  s.add_dependency 'aws-sigv4', '~> 1.0', '>= 1.0.2'
46
46
 
47
- s.add_dependency 'delayed_job_active_record'
48
47
  s.add_dependency 'daemons', '~> 1.3.1'
48
+ s.add_dependency 'delayed_job_active_record'
49
49
  end
@@ -11,11 +11,11 @@ class Marty::Api::Base
11
11
  result = yield
12
12
  controller.respond_to do |format|
13
13
  format.json { controller.send_data result.to_json }
14
- format.csv {
14
+ format.csv do
15
15
  # SEMI-HACKY: strip outer list if there's only one element.
16
- result = result[0] if result.is_a?(Array) && result.length==1
16
+ result = result[0] if result.is_a?(Array) && result.length == 1
17
17
  controller.send_data Marty::DataExporter.to_csv(result)
18
- }
18
+ end
19
19
  end
20
20
  end
21
21
 
@@ -60,27 +60,27 @@ class Marty::Api::Base
60
60
  # get_schema will either return a hash with the schema,
61
61
  # or a string with the error
62
62
  input_schema = @@schemas[schema_key] ||=
63
- Marty::JsonSchema.get_schema(*schema_key)
64
- rescue => e
65
- return {error: e.message}
63
+ Marty::JsonSchema.get_schema(*schema_key)
64
+ rescue StandardError => e
65
+ return { error: e.message }
66
66
  end
67
67
 
68
68
  # validate input schema
69
69
  if config[:input_validated]
70
70
 
71
71
  # must fail if schema not found or some other error
72
- return {"error": input_schema} if input_schema.is_a?(String)
72
+ return { "error": input_schema } if input_schema.is_a?(String)
73
73
 
74
74
  begin
75
75
  res = SchemaValidator::validate_schema(input_schema, params[:params])
76
76
  rescue NameError
77
- return {error: "Unrecognized PgEnum for attribute #{params[:attr]}"}
78
- rescue => e
79
- return {error: "#{params[:attr]}: #{e.message}"}
77
+ return { error: "Unrecognized PgEnum for attribute #{params[:attr]}" }
78
+ rescue StandardError => e
79
+ return { error: "#{params[:attr]}: #{e.message}" }
80
80
  end
81
81
 
82
82
  schema_errors = SchemaValidator::get_errors(res) unless res.empty?
83
- return {error: "Error(s) validating: #{schema_errors}"} if
83
+ return { error: "Error(s) validating: #{schema_errors}" } if
84
84
  schema_errors
85
85
  end
86
86
 
@@ -88,23 +88,23 @@ class Marty::Api::Base
88
88
  if input_schema.is_a?(Hash)
89
89
  # fix numbers types
90
90
  numbers = @@numbers[schema_key] ||=
91
- Marty::JsonSchema.get_numbers(input_schema)
91
+ Marty::JsonSchema.get_numbers(input_schema)
92
92
 
93
93
  # modify params in place
94
94
  Marty::JsonSchema.fix_numbers(params[:params], numbers)
95
- elsif !input_schema.include?("Schema not defined")
95
+ elsif !input_schema.include?('Schema not defined')
96
96
  # else if some error besides schema not defined, fail
97
- return {error: input_schema}
97
+ return { error: input_schema }
98
98
  end
99
99
 
100
100
  # get script engine
101
101
  begin
102
102
  engine = Marty::ScriptSet.new(params[:tag]).get_engine(params[:script])
103
- rescue => e
103
+ rescue StandardError => e
104
104
  error = "Can't get engine: #{params[:script] || 'nil'} with tag: " +
105
105
  "#{params[:tag] || 'nil'}; message: #{e.message}"
106
106
  Marty::Logger.info error
107
- return {error: error}
107
+ return { error: error }
108
108
  end
109
109
 
110
110
  retval = nil
@@ -116,7 +116,7 @@ class Marty::Api::Base
116
116
  params[:params],
117
117
  params[:attr])
118
118
 
119
- return retval = {"job_id" => res.__promise__.id}
119
+ return retval = { 'job_id' => res.__promise__.id }
120
120
  end
121
121
 
122
122
  res = engine.evaluate(params[:node],
@@ -126,37 +126,36 @@ class Marty::Api::Base
126
126
  # validate output schema
127
127
  if config[:output_validated] && !(res.is_a?(Hash) && res['error'])
128
128
  begin
129
- output_schema_params = params + {attr: params[:attr] + '_'}
129
+ output_schema_params = params + { attr: params[:attr] + '_' }
130
130
  schema = SchemaValidator::get_schema(output_schema_params)
131
- rescue => e
132
- return {error: e.message}
131
+ rescue StandardError => e
132
+ return { error: e.message }
133
133
  end
134
134
 
135
135
  begin
136
136
  schema_errors = SchemaValidator::validate_schema(schema, res)
137
137
  rescue NameError
138
- return {error: "Unrecognized PgEnum for attribute #{attr}"}
139
- rescue => e
140
- return {error: "#{attr}: #{e.message}"}
138
+ return { error: "Unrecognized PgEnum for attribute #{attr}" }
139
+ rescue StandardError => e
140
+ return { error: "#{attr}: #{e.message}" }
141
141
  end
142
142
 
143
143
  if schema_errors.present?
144
- errors = schema_errors.map{|e| e[:message]}
144
+ errors = schema_errors.map { |e| e[:message] }
145
145
 
146
146
  Marty::Logger.error(
147
147
  "API #{params[:script]}:#{params[:node]}.#{params[:attr]}",
148
- {error: errors, data: res}
148
+ error: errors, data: res
149
149
  )
150
150
 
151
151
  msg = "Error(s) validating: #{errors}"
152
- res = config[:strict_validate] ? {error: msg ,data: res} : res
152
+ res = config[:strict_validate] ? { error: msg, data: res } : res
153
153
  end
154
154
  end
155
155
 
156
156
  # if attr is an array, return result as an array
157
157
  return retval = params[:return_array] ? [res] : res
158
-
159
- rescue => e
158
+ rescue StandardError => e
160
159
  msg = Delorean::Engine.grok_runtime_exception(e).symbolize_keys
161
160
  Marty::Logger.info "Evaluation error: #{msg}"
162
161
  return retval = msg
@@ -167,6 +166,7 @@ class Marty::Api::Base
167
166
 
168
167
  def self.filter_hash hash, filter_params
169
168
  return unless hash
169
+
170
170
  pf = ActionDispatch::Http::ParameterFilter.new(filter_params)
171
171
  pf.filter(hash)
172
172
  end
@@ -175,7 +175,7 @@ class Marty::Api::Base
175
175
  res = result.is_a?(Hash) ? result.stringify_keys : result
176
176
  ret_arr = params[:return_array]
177
177
  input = filter_hash(params[:params], engine_params_filter)
178
- {script: params[:script],
178
+ { script: params[:script],
179
179
  node: params[:node],
180
180
  attrs: ret_arr ? [params[:attr]] : params[:attr],
181
181
  input: input,
@@ -197,21 +197,19 @@ class Marty::Api::Base
197
197
 
198
198
  class SchemaValidator
199
199
  def self.get_schema params
200
- begin
201
- Marty::ScriptSet.new(params[:tag]).get_engine(params[:script]+'Schemas').
200
+ Marty::ScriptSet.new(params[:tag]).get_engine(params[:script] + 'Schemas').
202
201
  evaluate(params[:node], params[:attr], {})
203
- rescue => e
202
+ rescue StandardError => e
204
203
  msg = e.message == 'No such script' ? 'Schema not defined' :
205
204
  'Problem with schema: ' + e.message
206
205
 
207
206
  raise "Schema error for #{params[:script]}/#{params[:node]} "\
208
207
  "attrs=#{params[:attr]}: #{msg}"
209
- end
210
208
  end
211
209
 
212
210
  def self.validate_schema schema, hash
213
211
  JSON::Validator.fully_validate(
214
- schema.merge({"\$schema" => Marty::JsonSchema::RAW_URI}),
212
+ schema.merge("\$schema" => Marty::JsonSchema::RAW_URI),
215
213
  hash,
216
214
  validate_schema: true,
217
215
  errors_as_objects: true,
@@ -224,6 +222,7 @@ class Marty::Api::Base
224
222
  match(msg)
225
223
 
226
224
  return msg unless m
225
+
227
226
  "disallowed parameter '#{m[1]}' of type #{m[2]} was received"
228
227
  end
229
228
 
@@ -237,7 +236,7 @@ class Marty::Api::Base
237
236
  fa, fragment, message, errors = errs.values_at(:failed_attribute,
238
237
  :fragment,
239
238
  :message, :errors)
240
- ((['AllOf','AnyOf','Not'].include?(fa) && fragment =='#/') ?
239
+ ((['AllOf', 'AnyOf', 'Not'].include?(fa) && fragment == '#/') ?
241
240
  [] : [massage_message(message)]) + _get_errors(errors || {})
242
241
  end
243
242
  end
@@ -11,8 +11,7 @@ class Marty::Diagnostic::Aws::Ec2Instance < Marty::Aws::Request
11
11
  attr_reader *STATES
12
12
 
13
13
  def get_state instances, state
14
- instances.map do
15
- |i|
14
+ instances.map do |i|
16
15
  i.except('state') if i['state']['name'] == state
17
16
  end.compact
18
17
  end
@@ -33,22 +32,23 @@ class Marty::Diagnostic::Aws::Ec2Instance < Marty::Aws::Request
33
32
  end
34
33
 
35
34
  private
35
+
36
36
  def ec2_request action, params = {}
37
- resp = request({action: action}, params)
37
+ resp = request({ action: action }, params)
38
38
  Hash.from_xml(resp)["#{action}Response"]
39
39
  end
40
40
 
41
41
  def get_tag
42
- params = {'Filter.1.Name' => 'resource-id',
42
+ params = { 'Filter.1.Name' => 'resource-id',
43
43
  'Filter.1.Value.1' => get_instance_id,
44
44
  'Filter.2.Name' => 'key',
45
- 'Filter.2.Value.1' => 'Name'}
45
+ 'Filter.2.Value.1' => 'Name' }
46
46
  ec2_request('DescribeTags', params)['tagSet']['item']['value']
47
47
  end
48
48
 
49
49
  def get_instances
50
- params = {'Filter.1.Name' => 'tag-value',
51
- 'Filter.1.Value.1' => @tag}
50
+ params = { 'Filter.1.Name' => 'tag-value',
51
+ 'Filter.1.Value.1' => @tag }
52
52
 
53
53
  resp = ec2_request('DescribeInstances', params)
54
54
 
@@ -65,6 +65,6 @@ class Marty::Diagnostic::Aws::Ec2Instance < Marty::Aws::Request
65
65
  end
66
66
 
67
67
  def get_private_ips
68
- @instances.running.map{|i| i['ip']}.compact
68
+ @instances.running.map { |i| i['ip'] }.compact
69
69
  end
70
70
  end
@@ -10,10 +10,10 @@ module Marty::Diagnostic; class Base < Request
10
10
 
11
11
  @@read_only = Marty::Util.db_in_recovery?
12
12
  @@template = ActionController::Base.new.lookup_context.
13
- find_template("marty/diagnostic/diag").identifier
13
+ find_template('marty/diagnostic/diag').identifier
14
14
 
15
- def self.diagnostic_fn opts={}
16
- opts.each do |k,v|
15
+ def self.diagnostic_fn opts = {}
16
+ opts.each do |k, v|
17
17
  send("#{k}=", v)
18
18
  end
19
19
  class << self
@@ -35,26 +35,24 @@ module Marty::Diagnostic; class Base < Request
35
35
 
36
36
  def self.process_status_only infos
37
37
  return infos unless status_only
38
- infos.map{|info| info.map{|test, result| [test, result['status']]}.to_h}
38
+
39
+ infos.map { |info| info.map { |test, result| [test, result['status']] }.to_h }
39
40
  end
40
41
 
41
42
  def self.get_difference data
42
43
  values = process_status_only(data.values)
43
- Marty::DataExporter.hash_array_merge(values, true).map{
44
- |test, values|
44
+ Marty::DataExporter.hash_array_merge(values, true).map do |test, values|
45
45
  test if values.uniq.count > 1
46
- }.compact
46
+ end.compact
47
47
  end
48
48
 
49
49
  def self.apply_consistency data
50
50
  diff = get_difference(data)
51
- data.each_with_object({}){
52
- |(node, diagnostic), new_data|
53
- new_data[node] = diagnostic.each_with_object({}){
54
- |(test, info), new_diagnostic|
55
- new_diagnostic[test] = info + {'consistent' => !diff.include?(test)}
56
- }
57
- }
51
+ data.each_with_object({}) do |(node, diagnostic), new_data|
52
+ new_data[node] = diagnostic.each_with_object({}) do |(test, info), new_diagnostic|
53
+ new_diagnostic[test] = info + { 'consistent' => !diff.include?(test) }
54
+ end
55
+ end
58
56
  end
59
57
 
60
58
  def self.consistent? data
@@ -71,6 +69,7 @@ module Marty::Diagnostic; class Base < Request
71
69
  return 'inconsistent' if info.nil? || (info['status'] &&
72
70
  info['consistent'] == false)
73
71
  return 'error' unless info['status']
72
+
74
73
  'passed'
75
74
  end
76
75
 
@@ -6,7 +6,8 @@ module Marty::Diagnostic; class Collection < Base
6
6
 
7
7
  def self.generate
8
8
  raise 'No diagnostics assigned to collection.' if diagnostics.empty?
9
- diagnostics.map{|d| d.generate}.reduce(:deep_merge)
9
+
10
+ diagnostics.map(&:generate).reduce(:deep_merge)
10
11
  end
11
12
  end
12
13
  end
@@ -2,18 +2,20 @@ module Marty::Diagnostic; class Connections < Base
2
2
  self.aggregatable = false
3
3
  diagnostic_fn do
4
4
  conns = Node.get_postgres_connections[Database.db_name].
5
- sort_by{|h| [h['application_name'],
6
- h['pid'],
7
- h['client_addr'],
8
- h['state']]}
5
+ sort_by do |h|
6
+ [h['application_name'],
7
+ h['pid'],
8
+ h['client_addr'],
9
+ h['state']]
10
+ end
9
11
 
10
12
  counts = Hash.new(0)
11
13
  conns.each_with_object({}) do |c, h|
12
14
  c['client_addr'] = 'localhost' unless c['client_addr']
13
15
  name = c['application_name']
14
16
  counts[name] += 1
15
- key = "#{name} #{'*' * (counts[name]-1)}"
16
- h[key] = c.except('application_name').map{|k,v| "<li>#{k}: #{v}</li>"}.join
17
+ key = "#{name} #{'*' * (counts[name] - 1)}"
18
+ h[key] = c.except('application_name').map { |k, v| "<li>#{k}: #{v}</li>" }.join
17
19
  end
18
20
  end
19
21
  end
@@ -23,6 +23,7 @@ module Marty::Diagnostic::Database
23
23
  current = ActiveRecord::Migrator.current_version
24
24
  raise "Migration is needed.\nCurrent Version: #{current}" if
25
25
  ActiveRecord::Migrator.needs_migration?
26
+
26
27
  current.to_s
27
28
  end
28
29
 
@@ -20,25 +20,23 @@ module Marty::Diagnostic; class DelayedJobVersion < Base
20
20
 
21
21
  # we will only iterate by half of the total delayed workers to avoid
22
22
  # excess use of delayed job time
23
- total_workers = (total_workers/2).zero? ? 1 : total_workers/2
23
+ total_workers = (total_workers / 2).zero? ? 1 : total_workers / 2
24
24
 
25
- d_engine = Marty::ScriptSet.new.get_engine("Diagnostics")
25
+ d_engine = Marty::ScriptSet.new.get_engine('Diagnostics')
26
26
  res = d_engine.
27
- evaluate('VersionDelay', 'result', {'count' => total_workers-1})
27
+ evaluate('VersionDelay', 'result', 'count' => total_workers - 1)
28
28
 
29
29
  # merge results, remove duplicates, and construct "aggregate" object
30
- res.each_with_object({}){
31
- |r, hash|
30
+ res.each_with_object({}) do |r, hash|
32
31
  hash[r[0]] ||= []
33
32
  hash[r[0]] << r[1]
34
- }.map {
35
- |node, result|
33
+ end.map do |node, result|
36
34
 
37
35
  versions = result.uniq
38
36
  status = versions.count == 1 && versions[0] == ENV['DELAYED_VER']
39
37
 
40
- {node => {'Version' => create_info(versions.join("\n"), status)}}
41
- }.reduce(:deep_merge)
38
+ { node => { 'Version' => create_info(versions.join("\n"), status) } }
39
+ end.reduce(:deep_merge)
42
40
  end
43
41
  end
44
42
  end