Class: Usmu::MetadataService
- Inherits:
-
Object
- Object
- Usmu::MetadataService
- Defined in:
- lib/usmu/metadata_service.rb
Instance Attribute Summary collapse
-
#base ⇒ void
readonly
private
Returns the value of attribute base.
Instance Method Summary collapse
-
#initialize(folder) ⇒ MetadataService
constructor
A new instance of MetadataService.
- #metadata(file) ⇒ void
Constructor Details
#initialize(folder) ⇒ MetadataService
Returns a new instance of MetadataService.
6 7 8 |
# File 'lib/usmu/metadata_service.rb', line 6 def initialize(folder) @base = folder end |
Instance Attribute Details
#base ⇒ void (readonly, private)
Returns the value of attribute base.
35 36 37 |
# File 'lib/usmu/metadata_service.rb', line 35 def base @base end |
Instance Method Details
#metadata(file) ⇒ void
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/usmu/metadata_service.rb', line 10 def (file) last_folder = file.rindex('/') = last_folder ? (file[0..(last_folder - 1)]) : {} = if File.directory?(File.join(@base, file)) file + '/meta.yml' else dot_position = File.basename(file).rindex('.') if (!dot_position.nil?) && dot_position > 0 file[0, file.rindex('.')] + '.meta.yml' else file + '.meta.yml' end end = File.join(@base, ) if File.exist? .deep_merge! YAML.load_file() else end end |