cdmbl 0.2.29 → 0.2.31

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: b442ddb62ccccf2cf8367b4f32378a5cb496a671
4
- data.tar.gz: 306943b0184756fc11a9f8887f96b69d73c425bb
3
+ metadata.gz: 449bb4f0e7151290ff5ca7e688533c5e91b56893
4
+ data.tar.gz: ec2262161507fc093b68aed1b866f12b1b4645c1
5
5
  SHA512:
6
- metadata.gz: bdadc18e3facd134fa03c6f0ddf44d4f682b1e634468d7597870d3a244839741e31b716967b022f2599a753b16c5ec5dbce5506cf58815bd07fb439b6131346c
7
- data.tar.gz: 11e5ef014bfcf6fcf2b9f68fbaf7fcf89e57d10e9f3d51e56a80f9ef84aa5769937005361fc359a40072b37b39aed248cc4e84bbd6b7bce91974f3d173a25dd0
6
+ metadata.gz: 705862665b66d5e06d475736009de158dfc55a4f70df3fd26292dee02834e3790b4792bce96af824b3f83934aa084105306af5f46b70bb04732dbb5a44fe54dc
7
+ data.tar.gz: 3fc1850f0ffc825115f4e83fa6314fcc851ad7287d3461f3743ea84aef7817bfd278fdb6fb3850c16b2e3c42d9bc2b25ec0dbf0cf2c607d8f052452ee66426a3
data/README.md CHANGED
@@ -28,6 +28,15 @@ Add the CDMBL rake task to your project Rakefile:
28
28
  require 'cdmbl/rake_task'
29
29
  ```
30
30
 
31
+ ### GeoNames (optional)
32
+
33
+ In order to make use of the GeoNames service, you must purchase a [GeoNames Premium Webservices Account](http://www.geonames.org/commercial-webservices.html). If you do not have a `geonam` field in your CONTENTdm schema, you may ignore this instruction. Add your credentials to your shell environment once you have secured a GeoNames user:
34
+
35
+ ```
36
+ # e.g. within your .bash_profile or .zprofile file
37
+ export export GEONAMES_USER="yourusernamehere"
38
+ ```
39
+
31
40
  ## Usage
32
41
 
33
42
  Run the ingester
@@ -84,7 +93,7 @@ end
84
93
  |origin_path| Where to get the field data from the original record for this mapping. |
85
94
  |formatters| [Formatters](https://github.com/UMNLibraries/cdmbl/blob/master/lib/cdmbl/formatters.rb) perform tasks such as stripping white space or splitting CONTENTdm multi-valued fields (delimited by semicolons) into JSON arrays. |
86
95
 
87
- **Note:** The first formatter receives the value found at the declared `origin_path`. Each formatter declared after the initial formatter will receive a value produced by the preceding formatter.
96
+ **Note:** The first formatter receives the value found at the declared `origin_path`. Each formatter declared after the initial formatter will receive a value produced by the preceding formatter.
88
97
 
89
98
  Formatters are very simple stateless classes that take a value, do something to it, and respond with a modified version of this value via a class method called `format`. Examples of other formatters may be found in the [Formatters file](https://github.com/UMNLibraries/cdmbl/blob/master/lib/cdmbl/formatters.rb). For Example:
90
99
 
@@ -103,13 +112,13 @@ mappings = CDMBL::Transformer.default_mappings.merge(your_custom_field_mappings)
103
112
  ```
104
113
  ## A Custom Post-indexing Callback
105
114
 
106
- If you would like to perform some action (e.g. send an email) following the completion of the CDMBL indexing process, you may declare your own callback hook (anything with "Callback" in the class name declared within the CDMBL module space will be used). To do so in Rails, create a Rails initializer file `config/initializers/cdmbl.rb`:
115
+ If you would like to perform some action (e.g. send an email) following the completion of the CDMBL indexing process, you may declare your own callback hook (anything with "Callback" in the class name declared within the CDMBL module space will be used). To do so in Rails, create a Rails initializer file `config/initializers/cdmbl.rb`:
107
116
 
108
117
  ```ruby
109
118
  module CDMBL
110
119
  class Callback
111
120
  def self.call!
112
- Rails.logger.info("My Custom CDMBL Callback")
121
+ Rails.logger.info("My Custom CDMBL Callback")
113
122
  end
114
123
  end
115
124
  end
@@ -1,7 +1,42 @@
1
1
  require 'titleize'
2
+ require 'json'
3
+ require 'net/http'
2
4
  # A handful of very simple formatters to clean up CONTENTdm API metadata
3
5
  module CDMBL
4
6
 
7
+
8
+ class GeoNameID
9
+ def self.format(value)
10
+ value.split('/').last
11
+ end
12
+ end
13
+
14
+ class GeoNameIDToJson
15
+ URL = "http://ws.geonames.net/getJSON?username=#{ENV['GEONAMES_USER']}"
16
+ def self.format(value)
17
+ JSON.parse(Net::HTTP.get_response(URI.parse("#{URL}&geonameId=#{value}")).body)
18
+ end
19
+ end
20
+
21
+ class GeoNameToLocation
22
+ def self.format(value)
23
+ return if !value.respond_to?(:fetch)
24
+ return if !value['lat'] || !value['lng']
25
+ "#{value['lat']},#{value['lng']}"
26
+ end
27
+ end
28
+
29
+ class GeoNameToPlaceName
30
+ def self.format(value)
31
+ return if !value.respond_to?(:fetch)
32
+ [
33
+ value['name'],
34
+ value['adminName1'],
35
+ value['adminName2']
36
+ ].select { |place| place != 'Minnesota'}.compact.uniq
37
+ end
38
+ end
39
+
5
40
  class DefaultFormatter
6
41
  def self.format(value)
7
42
  value
@@ -36,15 +36,6 @@ module CDMBL
36
36
  end
37
37
  end
38
38
 
39
- #TODO: Make a
40
- def with_location(dest_record, record)
41
- if record['latitu'] && record['longit'] && record['latitu'] != '' && record['longit'] != ''
42
- dest_record.merge({'location_llsi': "#{record['latitu']}, #{record['longit']}"})
43
- else
44
- dest_record
45
- end
46
- end
47
-
48
39
  def self.default_mappings
49
40
  [
50
41
  {dest_path: 'location_llsi', origin_path: '/', formatters: [LocationFormatter]},
@@ -149,7 +140,10 @@ module CDMBL
149
140
  {dest_path: 'geonam_ssi', origin_path: 'geonam', formatters: [StripFormatter]},
150
141
  {dest_path: 'kaltura_audio_ssi', origin_path: 'audio', formatters: [StripFormatter]},
151
142
  {dest_path: 'kaltura_audio_playlist_ssi', origin_path: 'audioa', formatters: [StripFormatter]},
152
- {dest_path: 'kaltura_video_ssi', origin_path: 'video', formatters: [StripFormatter]}
143
+ {dest_path: 'kaltura_video_ssi', origin_path: 'video', formatters: [StripFormatter]},
144
+ {dest_path: 'coordinates_llsi', origin_path: 'geonam', formatters: [GeoNameID, GeoNameIDToJson, GeoNameToLocation]},
145
+ {dest_path: 'placename_ssim', origin_path: 'geonam', formatters: [GeoNameID, GeoNameIDToJson, GeoNameToPlaceName]},
146
+ {dest_path: 'placename_unstem_search', origin_path: 'geonam', formatters: [GeoNameID, GeoNameIDToJson, GeoNameToPlaceName]}
153
147
  ]
154
148
  end
155
149
  end
data/lib/cdmbl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CDMBL
2
- VERSION = "0.2.29"
2
+ VERSION = "0.2.31"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdmbl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.29
4
+ version: 0.2.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - chadfennell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-23 00:00:00.000000000 Z
11
+ date: 2017-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hash_at_path