abstractor 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWMyMmU4Y2Q1ZWVjMDk1YjY1MzQ2MmI4OGMwNjQ2ZGNlNTY1MGQ0Mg==
4
+ ODE2ODcyZDAyMTdjM2I5ODg3ZjExMTZkMTVkM2QwMGUzNzZiNmFiYg==
5
5
  data.tar.gz: !binary |-
6
- M2MxOThhYzIzYmY1YTBkNTE4OWYwMmE5YmI5MGQ3NjA1YmJhYzYwMA==
6
+ YTU1NzA5OGM3MTI5MjUyYThiNTc0MDAyYjU4MGViZmU3MTkyMTliNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjMxNzBhNjU5MDBiN2I1NDZkNjVkZTcwMDc5ZWVlYTZhNDIxODUyY2E0YzQ1
10
- YjM0YmNhNTQxYWRlNGMxZTczY2Q5N2M4NjlmYzliMTUxYTA1MjE0ZGM5NjI4
11
- Mjk0ZDEyNDFkZmQyMDI1MzM2MjI1ZTc4OWRmNjVhMDZiYTU0NGI=
9
+ MWRkMGRjZTRkMWZhZDYyMzUyYWEwYjJlZDhiYThhYTA1MmVlNjZjMDFiMjYz
10
+ MDFmNTQ1OWFlZGQ3Mzg3NWM3YzQ2ZjViMWI4NzU1OTdmYTk4ZjBmNWIwMmUw
11
+ YjFmZjQ3YTZjYzI3OGM3MmQ0YWE0YmUwMDIxMDAzN2M5ZGMxMzY=
12
12
  data.tar.gz: !binary |-
13
- OGY0ZTMzZThhNGI3MDdhMTAwN2QyZGE1YmQxYzEyNmRiZmRlMzE0MDNiNGY3
14
- NjIyODNhNzg2ZTkyYzI5MzIzYzhkMjQ3NDFiMTFmM2ZjMzk5M2QwMmE5MmE0
15
- YzQyMGU2ZGRmMGYwZWMzYzQ0ZTQ0MWQ4ZWM1ZTQ3MzBmOGRlNzc=
13
+ MWI3N2ZhMDdlOWYzM2JmNWE2YmYxYTNlMDZjNDkzZTBkZGI1OTQ0NzdkNzM4
14
+ NzZhZTdmMjM4ZWRiZTJlYWU2OWE3OTUzNTZjNjFlZjQ2OGIzMjQwNDk3ZjRl
15
+ OTdjNmJkNWIzYWQxMTNlNzhiYWIwMjQxMzNmNzFhNGFjMjZmZWI=
@@ -79,24 +79,47 @@ module Abstractor
79
79
  end
80
80
  end
81
81
 
82
- def abstractor_subjects
83
- Abstractor::AbstractorSubject.where(subject_type: self.to_s)
82
+ ##
83
+ # Reports the abstractor subjects associated with the abstractable entity.
84
+ # By default, the method will return all abstractor subjects.
85
+ # The :grouped option allows the filtration to grouped or non-grouped
86
+ # abstractor subjects.
87
+ # grouped: true filters to only grouped abstractor subjects.
88
+ # grouped: false filters to only nont-grouped abstractor subjects.
89
+ #
90
+ # @param [Hash] options to filter the the list of abstractor subjects
91
+ # @return ActiveRecord::Relation list of Abstactor::AbstractorSubject objects
92
+ def abstractor_subjects(options = {})
93
+ options = { grouped: nil }.merge(options)
94
+ subjects = Abstractor::AbstractorSubject.where(subject_type: self.to_s)
95
+ subjects = case options[:grouped]
96
+ when true
97
+ subjects.select{ |s| s.abstractor_subject_group_member}
98
+ when false
99
+ subjects.reject{ |s| s.abstractor_subject_group_member}
100
+ when nil
101
+ subjects
102
+ end
103
+ subjects
84
104
  end
85
105
 
86
- def abstractor_abstraction_schemas
87
- abstractor_subjects.map(&:abstractor_abstraction_schema)
106
+ ##
107
+ # Reports the abstractor abstraction schemas associated with the abstractable entity.
108
+ # By default, the method will return all abstractor abstraction schemas.
109
+ # the :grouped options allows the filtration to grouped or non-grouped
110
+ # abstractor abstraction schemas.
111
+ # grouped: true filters to only grouped abstractor abstraction schemas.
112
+ # grouped: false filters to only nont-grouped abstractor abstraction schemas.
113
+ #
114
+ # @param [Hash] options to filter the the list of abstractor abstractions schemas
115
+ # @return ActiveRecord::Relation list of Abstactor::AbstractorAbstractionSchema objects
116
+ def abstractor_abstraction_schemas(options= {})
117
+ options = { grouped: nil }.merge(options)
118
+ abstractor_subjects(options).map(&:abstractor_abstraction_schema)
88
119
  end
89
120
 
90
121
  def abstractor_subject_groups
91
- abstractor_subjects.map(&:abstractor_subject_group).uniq
92
- end
93
-
94
- def prepare_pivot_select
95
- select =[]
96
- abstractor_abstraction_schemas.map(&:predicate).each do |predicate|
97
- select << "MAX(CASE WHEN data.predicate = '#{predicate}' THEN data.value ELSE NULL END) AS #{predicate}"
98
- end
99
- select = select.join(',')
122
+ abstractor_subjects.map(&:abstractor_subject_group).compact.uniq
100
123
  end
101
124
 
102
125
  ##
@@ -113,8 +136,8 @@ module Abstractor
113
136
  #
114
137
  # @return ActiveRecord::Relation
115
138
  def pivot_abstractions
116
- select = prepare_pivot_select
117
- joins = "JOIN
139
+ select = prepare_pivot_select(grouped: false)
140
+ joins = "LEFT JOIN
118
141
  (
119
142
  SELECT #{self.table_name}.id AS subject_id,
120
143
  #{select}
@@ -157,11 +180,10 @@ module Abstractor
157
180
  #
158
181
  # @param [String] abstractor_subject_groups_name name of {Abstractor::Methods::Models:AbtractorSubjectGroup}
159
182
  # @return ActiveRecord::Relation
160
- # @see Abstractor::Methods::Models:AbtractorSubjectGroup
161
-
183
+ # @see Abstractor::Methods::Models:AbstractorSubjectGroup
162
184
  def pivot_grouped_abstractions(abstractor_subject_groups_name)
163
185
  abstractor_subject_group = abstractor_subject_groups.detect { |abstractor_subject_group| abstractor_subject_group.name == abstractor_subject_groups_name }
164
- select = prepare_pivot_select
186
+ select = prepare_pivot_select(grouped: true)
165
187
  joins = "JOIN
166
188
  (
167
189
  SELECT #{self.table_name}.id AS subject_id,
@@ -185,6 +207,18 @@ module Abstractor
185
207
  "
186
208
  joins(joins).select("#{self.table_name}.*, pivoted_abstractions.*")
187
209
  end
210
+
211
+ private
212
+
213
+ def prepare_pivot_select(options= {})
214
+ options.reverse_merge!({ grouped: nil })
215
+ options = { grouped: nil }.merge(options)
216
+ select =[]
217
+ abstractor_abstraction_schemas(options).map(&:predicate).each do |predicate|
218
+ select << "MAX(CASE WHEN data.predicate = '#{predicate}' THEN data.value ELSE NULL END) AS #{predicate}"
219
+ end
220
+ select = select.join(',')
221
+ end
188
222
  end
189
223
  end
190
224
  end
@@ -1,3 +1,3 @@
1
1
  module Abstractor
2
- VERSION = '1.0.12'
2
+ VERSION = '1.0.13'
3
3
  end
@@ -3,6 +3,7 @@ require "rails/generators"
3
3
 
4
4
  module Abstractor
5
5
  class InstallGenerator < Rails::Generators::Base
6
+ class_option "no-migrations", :type => :boolean
6
7
  class_option "customize-all", :type => :boolean
7
8
  class_option "customize-controllers", :type => :boolean
8
9
  class_option "customize-models", :type => :boolean
@@ -8,7 +8,7 @@ namespace :abstractor do
8
8
  Abstractor::Setup.system
9
9
  end
10
10
 
11
- desc "Setup Stanford CoreNLP library in lib/stanford-core-nlp directory"
11
+ desc "Setup Stanford CoreNLP library in lib/stanford-corenlp-full-2014-01-04/ directory"
12
12
  task :stanford_core_nlp => :environment do
13
13
  puts 'Please be patient...This could take a while.'
14
14
  file = "#{Rails.root}/lib/stanford-corenlp-full-2014-01-04.zip"
@@ -23,7 +23,7 @@ namespace :abstractor do
23
23
 
24
24
  file = "#{Rails.root}/lib/stanford-corenlp-full-2014-01-04/bridge.jar"
25
25
  open(file, 'wb') do |fo|
26
- fo.print open('https://github.com/louismullie/stanford-core-nlp/blob/master/bin/bridge.jar').read
26
+ fo.print open('https://github.com/louismullie/stanford-core-nlp/blob/master/bin/bridge.jar?raw=true').read
27
27
  end
28
28
  end
29
29
  end
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: 1.0.12
4
+ version: 1.0.13
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-05-15 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails