abstractor 4.3.0 → 4.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e12e1a6577e6efe1216cce735b4bf8430bb6d2c6
4
- data.tar.gz: d92a5873f58d49d1bb637b604d5a9e387b437b7f
3
+ metadata.gz: d36a4ea709f125c6e0645f86a4ed3b465e636d21
4
+ data.tar.gz: f15970922eafe5c42cfcc3ac4ee3963d21e338cf
5
5
  SHA512:
6
- metadata.gz: 9dbc5beb80be2775fa9776557fc565d6fed3480a891c893c4252df7297facff07f5c17c46a15f03d9fecb0c1ec2fc97b6e417938bc1a9c9ccfec4e4ee6708705
7
- data.tar.gz: 764ae53872aafc7c7aac5628609d8f208a60f2cb24ac3468d90903555e74b6fac565120f1d0721e2e28454d7ef50bce4d12ea40a8a5b4780d923ed249411db11
6
+ metadata.gz: 827b8ec3e819dfad2c5730f5a3f006480e30b581f0fde61d065e640eee227bcb85df97abb3e3be4a196a6032b63e28c3932ef42bbded2d1156f98aaa8ef1cb49
7
+ data.tar.gz: 5a14b265e150a75900ff975526b41d5d6636ce24994cb8f4565d5babdb5dae33972c557044601165e84b2ea814c53ce8d6bf3419750207a5d16265776656a9b7
@@ -32,7 +32,7 @@ module Abstractor
32
32
  end
33
33
 
34
34
  ##
35
- # Returns all abstractions for the abstractable entity by abstraction schemas.
35
+ # Returns all abstractions for the abstractable entity by abstraction options.
36
36
  #
37
37
  # @param [Hash] options the options to filter the list of abstractions to a namespace.
38
38
  # @option options [Array] :abstractor_abstraction_schema_ids List of [Abstractor::AbstractorAbstractionSchema] ids
@@ -194,6 +194,42 @@ module Abstractor
194
194
  end
195
195
 
196
196
  module ClassMethods
197
+ ##
198
+ # Returns all abstractable entities filtered by the parameter abstractor_suggestion_type:
199
+ #
200
+ # * 'unknown': Filter abstractable entites having at least one suggestion withat a suggested value of 'unknown'
201
+ # * 'not unknown': Filter abstractable entites having at least one suggestion with an acutal value
202
+ #
203
+ # @param [String] abstractor_suggestion_type Filter abstactable entities that have a least one 'unknwon' or at least one 'not unknown' suggestion
204
+ # @param [Hash] options The options to filter the entities returned.
205
+ # @option options [String] :namespace_type The type parameter of the namespace to filter the entities.
206
+ # @option options [Integer] :namespace_id The instance parameter of the namespace to filter the entities.
207
+ # @option options [List of Integer, List of ActiveRecord::Relation] :abstractor_abstraction_schemas The list of abstractor abstraction schemas to filter upon. Defaults to all abstractor abstraction schemas if not specified.
208
+ # @return [ActiveRecord::Relation] List of abstractable entities.
209
+ def by_abstractor_suggestion_type(abstractor_suggestion_type, options = {})
210
+ options = { namespace_type: nil, namespace_id: nil }.merge(options)
211
+ options = { abstractor_abstraction_schemas: abstractor_abstraction_schemas }.merge(options)
212
+ if options[:namespace_type] || options[:namespace_id]
213
+ case abstractor_suggestion_type
214
+ when Abstractor::Enum::ABSTRACTION_SUGGESTION_TYPE_UNKNOWN
215
+ where(["EXISTS (SELECT 1 FROM abstractor_abstractions aa JOIN abstractor_subjects sub ON aa.abstractor_subject_id = sub.id AND sub.namespace_type = ? AND sub.namespace_id = ? AND sub.abstractor_abstraction_schema_id IN (?) JOIN abstractor_suggestions sug ON aa.id = sug.abstractor_abstraction_id WHERE aa.deleted_at IS NULL AND aa.about_type = '#{self.to_s}' AND #{self.table_name}.id = aa.about_id AND sug.unknown = ?)", options[:namespace_type], options[:namespace_id], options[:abstractor_abstraction_schemas], true])
216
+ when Abstractor::Enum::ABSTRACTION_SUGGESTION_TYPE_NOT_UNKNOWN
217
+ where(["EXISTS (SELECT 1 FROM abstractor_abstractions aa JOIN abstractor_subjects sub ON aa.abstractor_subject_id = sub.id AND sub.namespace_type = ? AND sub.namespace_id = ? AND sub.abstractor_abstraction_schema_id IN (?) JOIN abstractor_suggestions sug ON aa.id = sug.abstractor_abstraction_id WHERE aa.deleted_at IS NULL AND aa.about_type = '#{self.to_s}' AND #{self.table_name}.id = aa.about_id AND COALESCE(sug.unknown, ?) = ? AND sug.suggested_value IS NOT NULL AND COALESCE(sug.suggested_value, '') != '' )", options[:namespace_type], options[:namespace_id], options[:abstractor_abstraction_schemas], false, false])
218
+ else
219
+ where(["EXISTS (SELECT 1 FROM abstractor_abstractions aa JOIN abstractor_subjects sub ON aa.abstractor_subject_id = sub.id AND sub.namespace_type = ? AND sub.namespace_id = ? AND sub.abstractor_abstraction_schema_id IN (?) WHERE aa.deleted_at IS NULL AND aa.about_type = '#{self.to_s}' AND #{self.table_name}.id = aa.about_id)", options[:namespace_type], options[:namespace_id], options[:abstractor_abstraction_schemas]])
220
+ end
221
+ else
222
+ case abstractor_suggestion_type
223
+ when Abstractor::Enum::ABSTRACTION_SUGGESTION_TYPE_UNKNOWN
224
+ where(["EXISTS (SELECT 1 FROM abstractor_abstractions aa JOIN abstractor_subjects sub ON aa.abstractor_subject_id = sub.id AND sub.abstractor_abstraction_schema_id IN (?) JOIN abstractor_suggestions sug ON aa.id = sug.abstractor_abstraction_id WHERE aa.deleted_at IS NULL AND aa.about_type = '#{self.to_s}' AND #{self.table_name}.id = aa.about_id AND sug.unknown = ?)", options[:abstractor_abstraction_schemas], true])
225
+ when Abstractor::Enum::ABSTRACTION_SUGGESTION_TYPE_NOT_UNKNOWN
226
+ where(["EXISTS (SELECT 1 FROM abstractor_abstractions aa JOIN abstractor_subjects sub ON aa.abstractor_subject_id = sub.id AND sub.abstractor_abstraction_schema_id IN (?) JOIN abstractor_suggestions sug ON aa.id = sug.abstractor_abstraction_id WHERE aa.deleted_at IS NULL AND aa.about_type = '#{self.to_s}' AND #{self.table_name}.id = aa.about_id AND COALESCE(sug.unknown, ?) = ? AND sug.suggested_value IS NOT NULL AND COALESCE(sug.suggested_value, '') != '' )", options[:abstractor_abstraction_schemas], false, false])
227
+ else
228
+ where(nil)
229
+ end
230
+ end
231
+ end
232
+
197
233
  ##
198
234
  # Returns all abstractable entities filtered by the parameter abstractor_abstraction_status:
199
235
  #
@@ -8,8 +8,13 @@ module Abstractor
8
8
  ABSTRACTION_STATUS_REVIEWED = 'reviewed'
9
9
  ABSTRACTION_STATUSES = [ABSTRACTION_STATUS_NEEDS_REVIEW, ABSTRACTION_STATUS_REVIEWED]
10
10
 
11
+ ABSTRACTION_SUGGESTION_TYPE_UNKNOWN = 'unknown'
12
+ ABSTRACTION_SUGGESTION_TYPE_NOT_UNKNOWN = 'not unknown'
13
+ ABSTRACTION_SUGGESTION_TYPES = [ABSTRACTION_SUGGESTION_TYPE_UNKNOWN, ABSTRACTION_SUGGESTION_TYPE_NOT_UNKNOWN]
14
+
11
15
  ABSTRACTOR_SECTION_TYPE_CUSTOM = 'custom'
12
16
  ABSTRACTOR_SECTION_TYPE_NAME_VALUE = 'name/value'
17
+ ABSTRACTOR_SECTION_TYPES = [ABSTRACTOR_SECTION_TYPE_CUSTOM, ABSTRACTOR_SECTION_TYPE_NAME_VALUE]
13
18
 
14
19
  ABSTRACTOR_SUGGESTION_STATUS_NEEDS_REVIEW = 'Needs review'
15
20
  ABSTRACTOR_SUGGESTION_STATUS_ACCEPTED = 'Accepted'
@@ -1,3 +1,3 @@
1
1
  module Abstractor
2
- VERSION = '4.3.0'
2
+ VERSION = '4.3.1'
3
3
  end
@@ -10,7 +10,7 @@ module Abstractor
10
10
  class_option "customize-helpers", :type => :boolean
11
11
  class_option "customize-layout", :type => :boolean
12
12
  class_option "current-user-helper", :type => :string
13
- class_option "install-stanford-core-nlp", :type => :boolean
13
+ class_option "no-install-stanford-core-nlp", :type => :boolean
14
14
 
15
15
  def self.source_paths
16
16
  paths = self.superclass.source_paths
@@ -55,7 +55,7 @@ module Abstractor
55
55
  end
56
56
 
57
57
  def setup_stanford_core_nlp
58
- unless options["install-stanford-core-nlp"]
58
+ unless options["no-install-stanford-core-nlp"]
59
59
  puts "Running rake abstractor:setup:stanford_core_nlp"
60
60
  puts 'Please be patient...this could take a while.'
61
61
  `rake abstractor:setup:stanford_core_nlp`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.3.1
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: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails