research_metadata_announcement 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +12 -12
- data/lib/research_metadata_announcement/transformer/base.rb +8 -8
- data/lib/research_metadata_announcement/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf6041062e657458ff627bb4623ce6a408478c37
|
4
|
+
data.tar.gz: 06aace3883c44e456765a763cb8d08fb9922d836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5902442207fa4b7451ec68c46e338ec1949209392f097c9a0d2291b2dc40d6608eb22a6abef218649564c9312ae52bf0411bdacad6b4c0125282190234fa7e8a
|
7
|
+
data.tar.gz: a264bd7ea56ba82c434d1389872d737509d073274fe918a750d0635347e566c1779cfee2659d532aec4640144df11bd30be93bdc3a0677c2d4b69dd4e75f7465
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## 0.4.0 - 2017-10-10
|
8
|
+
### Changed
|
9
|
+
- Permutation keyword argument renamed to composition.
|
10
|
+
|
7
11
|
## 0.3.0 - 2017-10-09
|
8
12
|
### Changed
|
9
|
-
- Simplified API, allowing flexible
|
13
|
+
- Simplified API, allowing flexible compositions of announcement components.
|
10
14
|
|
11
15
|
## 0.2.0 - 2017-09-29
|
12
16
|
### Added
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ Give it a Pure identifier and get an announcement.
|
|
58
58
|
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
59
59
|
```
|
60
60
|
|
61
|
-
Optionally, use the ```:
|
61
|
+
Optionally, use the ```:composition``` keyword argument to pass in an array of
|
62
62
|
components (duplicates are ignored). The order of the components determines the
|
63
63
|
order of the metadata in the announcement.
|
64
64
|
|
@@ -71,16 +71,16 @@ Possible components:
|
|
71
71
|
Ideally, an announcement will be obtained using all the requested components,
|
72
72
|
with the following exceptions:
|
73
73
|
|
74
|
-
+ If the
|
74
|
+
+ If the composition includes ```:keywords``` or ```:hashtags``` and the
|
75
75
|
resource does not have any descriptors, the metadata is simply omitted.
|
76
76
|
|
77
|
-
+ If the
|
77
|
+
+ If the composition includes ```:uri```, the resource must have a URI for an
|
78
78
|
announcement to be returned.
|
79
79
|
|
80
80
|
+ If, after ```:title``` truncation/removal, the length still exceeds the
|
81
81
|
optional ```:max_length``` keyword argument, an announcement will not be returned.
|
82
82
|
|
83
|
-
If the
|
83
|
+
If the composition includes ```:new```, a phrase based upon the resource type
|
84
84
|
is generated e.g. New dataset. However, this gem does not determine whether
|
85
85
|
the resource is deemed to be new.
|
86
86
|
|
@@ -94,28 +94,28 @@ transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
|
94
94
|
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', max_length: 140
|
95
95
|
#=> "New publication. The Parting of Burroughs and... #americancounterculture #arthurrimbaud. dx.doi.org/10.1179/1477570013Z.00000000045."
|
96
96
|
|
97
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
97
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :hashtags] # resource has no descriptors
|
98
98
|
#=> "New publication. Deductive and inductive data collection for agent-based modelling."
|
99
99
|
|
100
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
100
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :keywords, :uri]
|
101
101
|
#=> "New publication. Torsion pairs in a triangulated category generated by a spherical object. Auslander–Reiten theory, Calabi–Yau triangulated category. dx.doi.org/10.1016/j.jalgebra.2015.09.011."
|
102
102
|
|
103
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
103
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :uri]
|
104
104
|
#=> "New dataset. Operating Nanobeams in a Quantum Fluid. dx.doi.org/10.17635/lancaster/researchdata/139."
|
105
105
|
|
106
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
106
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :title]
|
107
107
|
#=> "dx.doi.org/10.17635/lancaster/researchdata/29. Herpes simplex virus 1 (HSV-1) evolution."
|
108
108
|
|
109
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
109
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:keywords, :uri]
|
110
110
|
#=> "smart cities, sustainability. dx.doi.org/10.17635/lancaster/researchdata/35."
|
111
111
|
|
112
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
112
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:hashtags, :uri]
|
113
113
|
#=> "#treatedhypertension #microvascularbloodflow. dx.doi.org/10.17635/lancaster/researchdata/148."
|
114
114
|
|
115
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
115
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :keywords]
|
116
116
|
#=> "dx.doi.org/10.17635/lancaster/researchdata/134. metagenomics, deep sequencing."
|
117
117
|
|
118
|
-
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
118
|
+
transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :hashtags], max_descriptors: 4
|
119
119
|
#=> "dx.doi.org/10.17635/lancaster/researchdata/111. #influenza #nasopharynx #virology #virus."
|
120
120
|
|
121
121
|
```
|
@@ -16,16 +16,16 @@ module ResearchMetadataAnnouncement
|
|
16
16
|
|
17
17
|
# @param id [String] Pure ID.
|
18
18
|
# @param uuid [String] Pure UUID.
|
19
|
-
# @param
|
19
|
+
# @param composition [Array<Symbol>] Metadata presentation sequence e.g. [:new, :title, :hashtags, :uri].
|
20
20
|
# @param max_length [Fixnum] Maximum length of announcement.
|
21
21
|
# @param max_descriptors [Fixnum] Maximum number of descriptors (common name for keywords, tags, hashtags).
|
22
22
|
# @return [String, nil] Announcement returned if the metadata is available and the announcement length does not exceed the max_length argument.
|
23
|
-
def transform(uuid: nil, id: nil,
|
23
|
+
def transform(uuid: nil, id: nil, composition: [:new, :title, :hashtags, :uri],
|
24
24
|
max_length: nil, max_descriptors: 2)
|
25
|
-
|
25
|
+
composition.uniq!
|
26
26
|
extract uuid: uuid, id: id
|
27
27
|
return nil unless @resource
|
28
|
-
if
|
28
|
+
if composition.include? :uri
|
29
29
|
return nil unless prepare_uri
|
30
30
|
end
|
31
31
|
title = @resource.title
|
@@ -35,7 +35,7 @@ module ResearchMetadataAnnouncement
|
|
35
35
|
if length_constrained? max_length
|
36
36
|
chars_needed = 0
|
37
37
|
chars_component_end = 2
|
38
|
-
|
38
|
+
composition.each do |component|
|
39
39
|
case component
|
40
40
|
when :new
|
41
41
|
resource = self.class.name.sub('ResearchMetadataAnnouncement::Transformer::', '')
|
@@ -56,19 +56,19 @@ module ResearchMetadataAnnouncement
|
|
56
56
|
# determine if title needs truncating/removing before combining
|
57
57
|
if chars_needed > max_length
|
58
58
|
# truncate title
|
59
|
-
if
|
59
|
+
if composition.include? :title
|
60
60
|
excess_chars = chars_needed - max_length
|
61
61
|
truncated_title_length = title.size - excess_chars
|
62
62
|
truncated_title_length = 0 if truncated_title_length < 0
|
63
63
|
title = title[0..truncated_title_length - 2].strip + '..'
|
64
|
-
|
64
|
+
composition -= [:title] if title.size <= 5 # give up on title if just too small
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
# get data for combining
|
70
70
|
buffer = []
|
71
|
-
|
71
|
+
composition.each do |component|
|
72
72
|
case component
|
73
73
|
when :new
|
74
74
|
resource = self.class.name.sub('ResearchMetadataAnnouncement::Transformer::', '')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: research_metadata_announcement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Albin-Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puree
|