Module: Export::Coldp::Files::Reference

Defined in:
lib/export/coldp/files/reference.rb

Overview

Class Method Summary collapse

Class Method Details

.add_reference_rows(sources = [], reference_csv, project_members) ⇒ Object



18
19
20
21
22
# File 'lib/export/coldp/files/reference.rb', line 18

def self.add_reference_rows(sources = [], reference_csv, project_members)
  sources.each do |s|
    reference_csv[s.id] = ref_row(s, project_members)
  end 
end

.generate(project_id, project_members) ⇒ Object

This default method dumps the whole of project sources, as an alternate way to generate the reference file.

!! It is not integrated yet.



10
11
12
13
14
15
16
# File 'lib/export/coldp/files/reference.rb', line 10

def self.generate(project_id, project_members)
  ::CSV.generate do |csv|
    Source.joins(:project_sources).where(project_sources: {project_id: project_id} ).each do |source|
      csv << ref_row(source, project_members)
    end
  end
end

.ref_row(source, project_members) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/export/coldp/files/reference.rb', line 24

def self.ref_row(source, project_members)
  [
    source.id,
    source.cached,
#     source.cached_author_string,
#     source.year,
#     source.journal,                # source.source
#     reference_details(source),     # details (pages, volume, year)
    source.doi,
    Export::Coldp.modified(source[:updated_at]),                        # modified
    Export::Coldp.modified_by(source[:updated_by_id], project_members)  # modifiedBy 
  ]
end

.reference_details(source) ⇒ Object

TODO: this makes little sense without more structure, just spam stuff in until we understand more



39
40
41
# File 'lib/export/coldp/files/reference.rb', line 39

def self.reference_details(source)
  [source.volume, source.number, source.pages, source.bibtex_type].compact.join(';')
end