@@ -19,58 +19,60 @@ def export_as_mla
19
19
cp . render ( :bibliography , id :) . first
20
20
end
21
21
22
- def properties
23
- props = { }
24
- props [ :id ] = id
25
- props [ :edition ] = mla_edition if mla_edition
26
- props [ :type ] = mla_type if mla_type
27
- props [ :author ] = mla_author if mla_author
28
- props [ :title ] = mla_title if mla_title
29
- props [ :publisher ] = mla_publisher if mla_publisher
30
- props [ :'publisher-place' ] = mla_publisher_place if mla_publisher_place
31
- props [ :issued ] = mla_issued if mla_issued
32
- props
33
- end
22
+ private
34
23
35
- def mla_type
36
- self [ :format ] &.first &.downcase
37
- end
24
+ def properties
25
+ props = { }
26
+ props [ :id ] = id
27
+ props [ :edition ] = mla_edition if mla_edition
28
+ props [ :type ] = mla_type if mla_type
29
+ props [ :author ] = mla_author if mla_author
30
+ props [ :title ] = mla_title if mla_title
31
+ props [ :publisher ] = mla_publisher if mla_publisher
32
+ props [ :'publisher-place' ] = mla_publisher_place if mla_publisher_place
33
+ props [ :issued ] = mla_issued if mla_issued
34
+ props
35
+ end
38
36
39
- def mla_author
40
- @mla_author ||= begin
41
- family , given = citation_fields_from_solr [ :author_citation_display ] &.first &.split ( ', ' )
42
- CiteProc ::Name . new ( family :, given :) if family || given
37
+ def mla_type
38
+ self [ :format ] &.first &.downcase
43
39
end
44
- end
45
40
46
- def mla_edition
47
- @mla_edition ||= begin
48
- str = citation_fields_from_solr [ :edition_display ] &.first
49
- str &.dup &.sub! ( /[[:punct:]]?$/ , '' )
41
+ def mla_author
42
+ @mla_author ||= begin
43
+ family , given = citation_fields_from_solr [ :author_citation_display ] &.first &.split ( ', ' )
44
+ CiteProc ::Name . new ( family :, given :) if family || given
45
+ end
50
46
end
51
- end
52
47
53
- def mla_title
54
- @mla_title ||= citation_fields_from_solr [ :title_citation_display ] &.first
55
- end
48
+ def mla_edition
49
+ @mla_edition ||= begin
50
+ str = citation_fields_from_solr [ :edition_display ] &.first
51
+ str &.dup &.sub! ( /[[:punct:]]?$/ , '' )
52
+ end
53
+ end
56
54
57
- def mla_publisher
58
- @mla_publisher ||= citation_fields_from_solr [ :pub_citation_display ] &.first &. split ( ': ' ) . try ( :[] , 1 )
59
- end
55
+ def mla_title
56
+ @mla_title ||= citation_fields_from_solr [ :title_citation_display ] &.first
57
+ end
60
58
61
- def mla_publisher_place
62
- @mla_publisher_place ||= citation_fields_from_solr [ :pub_citation_display ] &.first &.split ( ': ' ) . try ( :[] , 0 )
63
- end
59
+ def mla_publisher
60
+ @mla_publisher ||= citation_fields_from_solr [ :pub_citation_display ] &.first &.split ( ': ' ) . try ( :[] , 1 )
61
+ end
64
62
65
- def mla_issued
66
- @mla_issued ||= citation_fields_from_solr [ :pub_date_start_sort ]
67
- end
63
+ def mla_publisher_place
64
+ @mla_publisher_place ||= citation_fields_from_solr [ :pub_citation_display ] &. first &. split ( ': ' ) . try ( :[] , 0 )
65
+ end
68
66
69
- def citation_fields_from_solr
70
- @citation_fields_from_solr ||= begin
71
- params = { q : "id:#{ RSolr . solr_escape ( id ) } " , fl : "author_citation_display, title_citation_display, pub_citation_display, number_of_pages_citation_display, pub_date_start_sort, edition_display" }
72
- solr_response = Blacklight . default_index . connection . get ( 'select' , params :)
73
- solr_response [ "response" ] [ "docs" ] . first . with_indifferent_access
67
+ def mla_issued
68
+ @mla_issued ||= citation_fields_from_solr [ :pub_date_start_sort ]
69
+ end
70
+
71
+ def citation_fields_from_solr
72
+ @citation_fields_from_solr ||= begin
73
+ params = { q : "id:#{ RSolr . solr_escape ( id ) } " , fl : "author_citation_display, title_citation_display, pub_citation_display, number_of_pages_citation_display, pub_date_start_sort, edition_display" }
74
+ solr_response = Blacklight . default_index . connection . get ( 'select' , params :)
75
+ solr_response [ "response" ] [ "docs" ] . first . with_indifferent_access
76
+ end
74
77
end
75
- end
76
78
end
0 commit comments