discerner 2.0.6 → 2.0.7

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
  SHA1:
3
- metadata.gz: 152d1ee5ab4203b8e029b97857a9597929036fb7
4
- data.tar.gz: 8b2b268454d31fbd708b46df3775be727115e416
3
+ metadata.gz: 3476a1439a17068f33eb8cf1996b1ad007dec278
4
+ data.tar.gz: 1fd944b53a9116ab86a5137bc71d443c71007240
5
5
  SHA512:
6
- metadata.gz: 9ce4a79a3ccc095d2207c80f8e412073661677f338d4dcbc3b5478cb52c1a39d752b9440a1c94a4ff1a9d02136642683494244c5e0a10cb667924fe74ab89ca0
7
- data.tar.gz: e8b84675a1a3ab72da72ecafbde6d27cab590f6445bee82e5045c2429dadffc74e78b318114454774b599d9dcc7fa6895da23acd36bb12d99041519965bae1b2
6
+ metadata.gz: 41ae1bcbe6ba8fda2278c2b38300bca455aa16e6cccd843dcaf7e0ac7752c7f9677e1e725840243dcbe78fd9fb901359443ad3edfd6a05b1f0e9755beb810b17
7
+ data.tar.gz: a37122ec487ecbdca468ec86652bc8edc3737c7a6cf1c41143ea697095c02639192a266b37975071cab601560381254206c4b6212f967d55c30bc8edb6d0cf28
@@ -1,6 +1,7 @@
1
1
  module Discerner
2
2
  class Parser
3
- attr_accessor :options, :errors, :updated_dictionaries, :updated_categories, :updated_parameters, :updated_parameter_value_categories, :updated_parameter_values, :blank_parameter_values
3
+ attr_accessor :options, :errors, :updated_dictionaries, :updated_categories, :updated_parameters, :updated_parameter_value_categories, :updated_parameter_values, :blank_parameter_values,
4
+ :abandoned_dictionaries
4
5
 
5
6
  def initialize(options={})
6
7
  self.options = options
@@ -15,6 +16,7 @@ module Discerner
15
16
  self.updated_parameter_values = []
16
17
  self.updated_parameter_value_categories = []
17
18
  self.blank_parameter_values = []
19
+ self.abandoned_dictionaries = []
18
20
  end
19
21
 
20
22
  def parse_dictionaries(str)
@@ -348,7 +350,7 @@ module Discerner
348
350
  parameter_value.deleted_at = nil
349
351
  error_message "parameter value #{search_value} could not be saved: #{parameter_value.errors.full_messages}" unless parameter_value.save
350
352
  notification_message 'parameter value saved'
351
- updated_parameter_values << parameter_value unless silent
353
+ updated_parameter_values << parameter_value
352
354
  parameter_value
353
355
  end
354
356
 
@@ -402,6 +404,7 @@ module Discerner
402
404
 
403
405
  private
404
406
  def cleanup
407
+ self.abandoned_dictionaries = Discerner::Dictionary.order(:id).to_a - updated_dictionaries
405
408
  cleanup_parameter_value_categories
406
409
  cleanup_parameter_values
407
410
  cleanup_parameters
@@ -411,9 +414,8 @@ module Discerner
411
414
 
412
415
  def cleanup_dictionaries
413
416
  if self.options[:prune_dictionaries].blank?
414
- notification_message "if option --prune_dictionaries is not specified, dictionaries removed from the definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
417
+ notification_message "if option --prune_dictionaries is not specified, dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
415
418
  else
416
- abandoned_dictionaries = Discerner::Dictionary.order(:id).to_a - updated_dictionaries
417
419
  used_dictionaries = abandoned_dictionaries.reject{|d| d.searches.blank?}
418
420
  not_used_dictionaries = abandoned_dictionaries - used_dictionaries
419
421
 
@@ -432,6 +434,12 @@ module Discerner
432
434
 
433
435
  def cleanup_categories
434
436
  abandoned_categories = Discerner::ParameterCategory.order(:id).to_a - updated_categories
437
+
438
+ if self.options[:prune_dictionaries].blank?
439
+ notification_message "if option --prune_dictionaries is not specified, caterories for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
440
+ abandoned_categories = abandoned_categories.reject{|c| abandoned_dictionaries.include?(c.dictionary)}
441
+ end
442
+
435
443
  used_categories = abandoned_categories.reject{|c| c.parameters.blank? || c.parameters.select{|p| p.used_in_search?}.blank?}
436
444
  not_used_categories = abandoned_categories - used_categories
437
445
 
@@ -449,6 +457,12 @@ module Discerner
449
457
 
450
458
  def cleanup_parameters
451
459
  abandoned_parameters = Discerner::Parameter.order(:id).to_a - updated_parameters
460
+
461
+ if self.options[:prune_dictionaries].blank?
462
+ notification_message "if option --prune_dictionaries is not specified, parameters for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
463
+ abandoned_parameters = abandoned_parameters.reject{|p| abandoned_dictionaries.include?(p.parameter_category.dictionary)}
464
+ end
465
+
452
466
  used_parameters = abandoned_parameters.select{|p| p.used_in_search?}
453
467
  not_used_parameters = abandoned_parameters - used_parameters
454
468
 
@@ -466,6 +480,12 @@ module Discerner
466
480
 
467
481
  def cleanup_parameter_value_categories
468
482
  abandoned_categories = Discerner::ParameterValueCategory.order(:id).to_a - updated_parameter_value_categories
483
+
484
+ if self.options[:prune_dictionaries].blank?
485
+ notification_message "if option --prune_dictionaries is not specified, parameter value categories for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
486
+ abandoned_categories = abandoned_categories.reject{|c| abandoned_dictionaries.include?(c.parameter.parameter_category.dictionary)}
487
+ end
488
+
469
489
  used_categories = abandoned_categories.reject{|c| c.parameter_values.blank? || c.parameter_values.select{|v| v.used_in_search?}.blank?}
470
490
  not_used_categories = abandoned_categories - used_categories
471
491
 
@@ -480,10 +500,17 @@ module Discerner
480
500
  not_used_categories.each{|r| r.destroy}
481
501
  end
482
502
  end
503
+
483
504
  # this also marks search_parameter_values that reference this value and are chosen as deleted
484
505
  # and destroys search_parameter_values that reference this value but are not chosen (list options)
485
506
  def cleanup_parameter_values
486
507
  abandoned_parameter_values = Discerner::ParameterValue.order(:id).to_a - updated_parameter_values - blank_parameter_values
508
+
509
+ if self.options[:prune_dictionaries].blank?
510
+ notification_message "if option --prune_dictionaries is not specified, parameter values for dictionaries that are not in parsed definition file should be deleted manually. Use `rake discerner:delete_dictionary' NAME='My dictionary name'"
511
+ abandoned_parameter_values = abandoned_parameter_values.reject{|v| abandoned_dictionaries.include?(v.parameter.parameter_category.dictionary)}
512
+ end
513
+
487
514
  used_parameter_values = abandoned_parameter_values.select{|p| p.used_in_search?}
488
515
  not_used_parameter_values = abandoned_parameter_values - used_parameter_values
489
516
 
@@ -1,3 +1,3 @@
1
1
  module Discerner
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discerner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Gurley, Yulia Bushmanova
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-20 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails