16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/generators/hydra/remote_identifier/doi_generator.rb', line 16
def insert_doi
inject_into_file(
"config/initializers/hydra-remote_identifier_config.rb",
after: /Hydra::RemoteIdentifier.*/
) do
data = []
data << ""
data << %( doi_credentials = Psych.load_file(Rails.root.join("#{credentials_path}")))
data << %( config.remote_service(:doi, doi_credentials) do |doi|)
data << %( doi.register(#{normalized_targets}) do |map|)
data << %( map.target #{options.fetch('target')})
data << %( map.creator #{options.fetch('creator')})
data << %( map.title #{options.fetch('title')})
data << %( map.publisher #{options.fetch('publisher')})
data << %( map.publicationyear #{options.fetch('publication_year')})
data << %( # Make sure that this method both sets the identifier and persists the change!)
data << %( map.set_identifier #{options.fetch('set_identifier')})
data << %( end)
data << %( end)
data << ""
data.join("\n")
end
end
|