Class: Fedora2To3PidRenamer::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/fedora_2_to_3_pid_renamer/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Config

Returns a new instance of Config.



14
15
16
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 14

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 8

def source
  @source
end

Class Method Details

.load(path) ⇒ Object



10
11
12
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 10

def self.load(path)
  new File.read(path)
end

Instance Method Details

#change_for(original) ⇒ Object



34
35
36
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 34

def change_for(original)
  changes[original]
end

#changeme_replacementObject



38
39
40
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 38

def changeme_replacement
  yaml['changeme']
end

#changesObject



26
27
28
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 26

def changes
  @changes ||= yaml['changes']
end

#foldersObject



30
31
32
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 30

def folders
  yaml['folders']
end

#input_folderObject



42
43
44
45
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 42

def input_folder
  return unless folders
  @input_folder ||= path_relative_to_working_directory folders['input']
end

#locationsObject



22
23
24
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 22

def locations
  @locations ||= yaml['locations']
end

#namespacesObject



18
19
20
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 18

def namespaces
  @namespaces ||= yaml['namespaces']
end

#output_folderObject



47
48
49
50
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 47

def output_folder
  return unless folders
  @output_folder ||= path_relative_to_working_directory folders['output']
end

#path_relative_to_working_directory(folder) ⇒ Object



56
57
58
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 56

def path_relative_to_working_directory(folder)
  File.expand_path folder, Dir.pwd
end

#yamlObject



52
53
54
# File 'lib/fedora_2_to_3_pid_renamer/config.rb', line 52

def yaml
  @yaml ||= YAML.load(source)
end