sufia-models 4.0.0.rc2 → 4.0.0

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: 82546f98afb1a657c9bfba8eafcaad863373a979
4
- data.tar.gz: 15a4dd50704723c213b51cf82b1de921609826a7
3
+ metadata.gz: ae36845b3a2212024c47f63c3f191ae3ddce2d44
4
+ data.tar.gz: 7156562bbb3c3a435beb3317ab420b597065b4ce
5
5
  SHA512:
6
- metadata.gz: 52bf6d0263f5cfbabb55ad19eb8c847f77e2a2b313cd07a9147622348940af4d6b926b0a789a052b6f48c8f84a34ca0f3d99aee6fd9d4eadc68585171b760d8b
7
- data.tar.gz: b34150a1691b2cd26c1a6b206e635105bb96b9676973ed898cc9dbc08220fad281c9f42c8b0e812cceb3fa832e719944407c199e245152b0e8bf9efc7f323a91
6
+ metadata.gz: 9a420c8a86700d0f47e3d9bf29b5f27a488340cb40561476d78d8cb73a267e4389f1e200a7e97ffcfc53c95026230c1b0a340b6ee1e71250198ac1a731082afa
7
+ data.tar.gz: ab6402e7739924eb275f012dadb3ce47af4e31d92277f6f747b3ca9d991bd2f665fdb5e246e7e4dfc775ad4dd35cb5a83b48c1a137036776fef6763618943898
@@ -28,7 +28,8 @@ module Sufia::GenericFile
28
28
  end
29
29
 
30
30
  def create_content(file, file_name, dsid)
31
- generic_file.add_file(file, dsid, file_name)
31
+ fname = generic_file.label.blank? ? file_name.truncate(255) : generic_file.label
32
+ generic_file.add_file(file, dsid, fname)
32
33
  save_characterize_and_record_committer do
33
34
  if Sufia.config.respond_to?(:after_create_content)
34
35
  Sufia.config.after_create_content.call(generic_file, user)
@@ -42,11 +42,10 @@ module Sufia
42
42
 
43
43
  ## Extract the metadata from the content datastream and record it in the characterization datastream
44
44
  def characterize
45
- metadata = self.content.extract_metadata
46
- self.characterization.ng_xml = metadata if metadata.present?
47
- self.append_metadata
45
+ metadata = content.extract_metadata
46
+ characterization.ng_xml = metadata if metadata.present?
47
+ append_metadata
48
48
  self.filename = [self.label]
49
- extract_content
50
49
  save
51
50
  end
52
51
 
@@ -7,21 +7,28 @@ module Sufia
7
7
  has_file_datastream 'full_text', versionable: false
8
8
  end
9
9
 
10
- def extract_content
11
- url = Blacklight.solr_config[:url] ? Blacklight.solr_config[:url] : Blacklight.solr_config["url"] ? Blacklight.solr_config["url"] : Blacklight.solr_config[:fulltext] ? Blacklight.solr_config[:fulltext]["url"] : Blacklight.solr_config[:default]["url"]
12
- uri = URI("#{url}/update/extract?extractOnly=true&wt=json&extractFormat=text")
13
- req = Net::HTTP.new(uri.host, uri.port)
14
- resp = req.post(uri.to_s, self.content.content, {
15
- 'Content-type' => "#{self.mime_type};charset=utf-8",
16
- 'Content-Length' => self.content.content.size.to_s
17
- })
18
- raise "URL '#{uri}' returned code #{resp.code}" unless resp.code == "200"
19
- self.content.content.rewind if self.content.content.respond_to?(:rewind)
20
- extracted_text = JSON.parse(resp.body)[''].rstrip
21
- full_text.content = extracted_text if extracted_text.present?
22
- rescue => e
23
- logger.error("Error extracting content from #{self.pid}: #{e.inspect}")
10
+ def append_metadata
11
+ super
12
+ extract_content
24
13
  end
14
+
15
+ private
16
+
17
+ def extract_content
18
+ url = Blacklight.solr_config[:url] ? Blacklight.solr_config[:url] : Blacklight.solr_config["url"] ? Blacklight.solr_config["url"] : Blacklight.solr_config[:fulltext] ? Blacklight.solr_config[:fulltext]["url"] : Blacklight.solr_config[:default]["url"]
19
+ uri = URI("#{url}/update/extract?extractOnly=true&wt=json&extractFormat=text")
20
+ req = Net::HTTP.new(uri.host, uri.port)
21
+ resp = req.post(uri.to_s, self.content.content, {
22
+ 'Content-type' => "#{self.mime_type};charset=utf-8",
23
+ 'Content-Length' => self.content.content.size.to_s
24
+ })
25
+ raise "URL '#{uri}' returned code #{resp.code}" unless resp.code == "200"
26
+ self.content.content.rewind if self.content.content.respond_to?(:rewind)
27
+ extracted_text = JSON.parse(resp.body)[''].rstrip
28
+ full_text.content = extracted_text if extracted_text.present?
29
+ rescue => e
30
+ logger.error("Error extracting content from #{self.pid}: #{e.inspect}")
31
+ end
25
32
  end
26
33
  end
27
34
  end
@@ -23,6 +23,10 @@ module Sufia
23
23
  self.class.office_document_mime_types.include? self.mime_type
24
24
  end
25
25
 
26
+ def collection?
27
+ false
28
+ end
29
+
26
30
  def file_format
27
31
  return nil if self.mime_type.blank? and self.format_label.blank?
28
32
  return self.mime_type.split('/')[1]+ " ("+self.format_label.join(", ")+")" unless self.mime_type.blank? or self.format_label.blank?
@@ -28,12 +28,16 @@ class FileUsage
28
28
 
29
29
  private
30
30
 
31
+ # Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
32
+ # see Legato::ProfileMethods.method_name_from_klass
31
33
  def download_statistics
32
- Sufia::Analytics.profile.download(sort: 'date').for_file(self.id)
34
+ Sufia::Analytics.profile.sufia__download(sort: 'date').for_file(self.id)
33
35
  end
34
36
 
37
+ # Sufia::Pageview is sent to Sufia::Analytics.profile as #sufia__pageview
38
+ # see Legato::ProfileMethods.method_name_from_klass
35
39
  def pageview_statistics
36
- Sufia::Analytics.profile.pageview(sort: 'date').for_path(self.path)
40
+ Sufia::Analytics.profile.sufia__pageview(sort: 'date').for_path(self.path)
37
41
  end
38
42
 
39
43
  def pageviews_to_flot values = Array.new
@@ -1,5 +1,5 @@
1
1
  module Sufia
2
2
  module Models
3
- VERSION = "4.0.0.rc2"
3
+ VERSION = "4.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sufia-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  version: '0'
394
394
  required_rubygems_version: !ruby/object:Gem::Requirement
395
395
  requirements:
396
- - - ">"
396
+ - - ">="
397
397
  - !ruby/object:Gem::Version
398
- version: 1.3.1
398
+ version: '0'
399
399
  requirements: []
400
400
  rubyforge_project:
401
401
  rubygems_version: 2.2.2