discerner 2.0.5 → 2.0.6

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: d003dc673d344a81ba57493c85359cb204d4ec25
4
- data.tar.gz: e640b76a3ac01c8651a0daf029fbced903dccac4
3
+ metadata.gz: 152d1ee5ab4203b8e029b97857a9597929036fb7
4
+ data.tar.gz: 8b2b268454d31fbd708b46df3775be727115e416
5
5
  SHA512:
6
- metadata.gz: 965d91c637899dd9d029de35bb03181605bccc6ae5bd76c0742a41f179ebb3b0fc2f747d4e0f853d158ffbd685a253c0edae7fab75f55d097733bea966c7ee23
7
- data.tar.gz: 218fb8fdcc5d94e91bb2056214f86f137749ab79d8f157ebb468abd50b230aed202659a61a4209f3b32f297f7e46ae68124df42a7bb4ba96fb54bf37bcd4880b
6
+ metadata.gz: 9ce4a79a3ccc095d2207c80f8e412073661677f338d4dcbc3b5478cb52c1a39d752b9440a1c94a4ff1a9d02136642683494244c5e0a10cb667924fe74ab89ca0
7
+ data.tar.gz: e8b84675a1a3ab72da72ecafbde6d27cab590f6445bee82e5045c2429dadffc74e78b318114454774b599d9dcc7fa6895da23acd36bb12d99041519965bae1b2
@@ -1,29 +1,20 @@
1
1
  /* Link styles */
2
2
  #discerner_searches, #discerner_search
3
- .icon_link
3
+ .discerner-icon-link
4
4
  :padding 2px 2px 2px 20px
5
- :text-decoration none !important
5
+ :text-decoration none
6
6
 
7
- .add_link, .add_link:hover
8
- :background url(add.png) 0 2px no-repeat !important
7
+ .discerner-add-link, .discerner-add-link:hover
8
+ :background url(add.png) 0 2px no-repeat
9
9
 
10
- .add_person_link, .add_person_link:hover
11
- :background url(user_add.png) 0 2px no-repeat !important
10
+ .discerner-edit-link, .discerner-edit-link:hover
11
+ :background url(edit.png) 0 2px no-repeat
12
12
 
13
- .edit_link, .edit_link:hover
14
- :background url(edit.png) 0 2px no-repeat !important
13
+ .discerner-show-link, .discerner-show-link:hover
14
+ :background url(show.png) 0 2px no-repeat
15
15
 
16
- .search_link, .search_link:hover
17
- :background url(find.png) 0 2px no-repeat !important
16
+ .discerner-delete-link, .discerner-delete-link:hover
17
+ :background url(delete.png) 0 2px no-repeat
18
18
 
19
- .show_link, .show_link:hover
20
- :background url(show.png) 0 2px no-repeat !important
21
-
22
- .list_link, .list_link:hover
23
- :background url(list.png) 0 2px no-repeat !important
24
-
25
- .delete_link, .delete_link:hover
26
- :background url(delete.png) 0 2px no-repeat !important
27
-
28
- .options_link, .options_link:hover
29
- :background url(cog.png) 0 2px no-repeat !important
19
+ .discerner-options-link, .discerner-options-link:hover
20
+ :background url(cog.png) 0 2px no-repeat
@@ -15,7 +15,7 @@
15
15
  %span.discerner_search_name
16
16
  = @discerner_search.display_name
17
17
  %span.discerner_search_name_edit
18
- = link_to 'Edit', '#', class: "edit_link icon_link"
18
+ = link_to 'Edit', '#', class: "discerner-edit-link discerner-icon-link"
19
19
 
20
20
  - else
21
21
  .discerner_dictionary_required_message
@@ -12,6 +12,6 @@
12
12
  %td
13
13
  = discerner_format_datetime(search.updated_at)
14
14
  %td
15
- = link_to 'Open', edit_search_path(search), class: 'show_link icon_link'
16
- = link_to 'Export options', export_parameters_path(search), class: 'options_link icon_link' if export_discerner_results?
17
- = link_to 'Delete', search_path(search), data: {confirm: 'Are you sure?'}, method: :delete, class: "icon_link delete_link"
15
+ = link_to 'Open', edit_search_path(search), class: 'discerner-show-link discerner-icon-link'
16
+ = link_to 'Export options', export_parameters_path(search), class: 'discerner-options-link discerner-icon-link' if export_discerner_results?
17
+ = link_to 'Delete', search_path(search), data: {confirm: 'Are you sure?'}, method: :delete, class: "discerner-icon-link discerner-delete-link"
@@ -19,13 +19,13 @@ module Discerner
19
19
 
20
20
  def discerner_link_to_add_fields(name, association, html_options={})
21
21
  css_class = html_options[:class] || ' '
22
- css_class += "add_#{association.to_s} add add_link icon_link"
22
+ css_class += "add_#{association.to_s} add discerner-add-link discerner-icon-link"
23
23
  html_options[:class] = css_class
24
24
  link_to(name, 'javascript:void(0);', html_options)
25
25
  end
26
26
 
27
27
  def discerner_link_to_remove_fields(name, f, association)
28
- f.hidden_field(:_destroy) + link_to(name, "javascript:void(0);", class: "delete_#{association.to_s} delete_link icon_link")
28
+ f.hidden_field(:_destroy) + link_to(name, "javascript:void(0);", class: "delete_#{association.to_s} discerner-delete-link discerner-icon-link")
29
29
  end
30
30
 
31
31
  def discerner_nested_record_id(builder, assocation)
@@ -410,19 +410,23 @@ module Discerner
410
410
  end
411
411
 
412
412
  def cleanup_dictionaries
413
- abandoned_dictionaries = Discerner::Dictionary.order(:id).to_a - updated_dictionaries
414
- used_dictionaries = abandoned_dictionaries.reject{|d| d.searches.blank?}
415
- not_used_dictionaries = abandoned_dictionaries - used_dictionaries
416
-
417
- used_dictionaries.each do |r|
418
- notification_message("marking dictionary #{r.name} as deleted");
419
- r.deleted_at = Time.now
420
- error_message "dictionary could not be updated: #{r.errors.full_messages}", r.name unless r.save
421
- end
413
+ 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'"
415
+ else
416
+ abandoned_dictionaries = Discerner::Dictionary.order(:id).to_a - updated_dictionaries
417
+ used_dictionaries = abandoned_dictionaries.reject{|d| d.searches.blank?}
418
+ not_used_dictionaries = abandoned_dictionaries - used_dictionaries
419
+
420
+ used_dictionaries.each do |r|
421
+ notification_message("marking dictionary #{r.name} as deleted");
422
+ r.deleted_at = Time.now
423
+ error_message "dictionary could not be updated: #{r.errors.full_messages}", r.name unless r.save
424
+ end
422
425
 
423
- unless not_used_dictionaries.blank?
424
- notification_message("permanently deleting dictionaries #{not_used_dictionaries.map{|r| r.name}.join(', ')}");
425
- not_used_dictionaries.each{|r| r.destroy}
426
+ unless not_used_dictionaries.blank?
427
+ notification_message("permanently deleting dictionaries #{not_used_dictionaries.map{|r| r.name}.join(', ')}");
428
+ not_used_dictionaries.each{|r| r.destroy}
429
+ end
426
430
  end
427
431
  end
428
432
 
@@ -1,3 +1,3 @@
1
1
  module Discerner
2
- VERSION = "2.0.5"
2
+ VERSION = "2.0.6"
3
3
  end
@@ -5,12 +5,12 @@
5
5
 
6
6
  namespace :discerner do
7
7
  namespace :setup do
8
- desc 'Load dictionaries (specify file to parse with FILE=myfile.yml) '
8
+ desc 'Load dictionaries (specify file to parse with FILE=myfile.yml), --trace gives back tracing messages, --prune_dictionaries removes dictionaries that are not specified in the definition file unless they are used in search'
9
9
  task dictionaries: :environment do
10
10
  file = ENV["FILE"]
11
11
  raise "File name has to be provided" if file.blank?
12
12
  raise "File does not exist: #{file}" unless FileTest.exists?(file)
13
- parser = Discerner::Parser.new(trace: Rake.application.options.trace)
13
+ parser = Discerner::Parser.new(trace: Rake.application.options.trace, prune_dictionaries: Rake.application.options.prune_dictionaries)
14
14
  parser.parse_dictionaries(File.read(file))
15
15
  end
16
16
 
@@ -27,4 +27,12 @@ namespace :discerner do
27
27
  Discerner::Search.destroy_all
28
28
  Discerner::Dictionary.destroy_all
29
29
  end
30
+
31
+ desc "Delete dictionary (specify dictionary to remove with NAME='My dictionary name')"
32
+ task delete_dictionary: :environment do
33
+ dictionary = Discerner::Dictionary.where(name: ENV["NAME"]).last
34
+ raise "Dictionary does not exist: #{ENV["NAME"]}" if dictionary.blank?
35
+ Discerner::Search.where(dictionary_id: dictionary.id).destroy_all
36
+ dictionary.delete
37
+ end
30
38
  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.5
4
+ version: 2.0.6
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-09-16 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -511,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
511
  version: '0'
512
512
  requirements: []
513
513
  rubyforge_project:
514
- rubygems_version: 2.4.1
514
+ rubygems_version: 2.2.2
515
515
  signing_key:
516
516
  specification_version: 4
517
517
  summary: Rails engine that provides dictionary-based search functionality