sdr-replication 0.3.0 → 0.3.1

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: 11801a3c77b94dd4ef2c8af7992a033f8d9856c9
4
- data.tar.gz: d8f5d7e38d26f467d6ce3304d5ddff0b8b2aff88
3
+ metadata.gz: 8268fa7de43231b2863bff96d22b22bbf8b877a7
4
+ data.tar.gz: 6b16fd8fdc370dc7478427a325464b72f06f8002
5
5
  SHA512:
6
- metadata.gz: 44e904744f21d27d7ee036181964230b96fbcee1c3a65c21db9aac2678bf0b3e2f7c72a6b19220ba2f6411f60d0ea4a0d5f3df504c7b3b872e5095b313fc8c75
7
- data.tar.gz: 92fe706d2524991354ef61d2b9e63580754f8dd66c33939b62eac634e83cceaae55e225f67f304ded997acfb2a783537c195b2186dbeb7ffb417268306162809
6
+ metadata.gz: 95a66da7f71b2f1ab066d302db2224a5f0e45527902b6eaf4f969a8461df51a139a0a60c20fa34c782fdf05ca96e2ff90d7cafec2fb8e8458e7d2b7ea576132f
7
+ data.tar.gz: ce4c6952cd508364a15846c374d66f9ec84510010732d8ee970313bc544d07219a154c8b51a32160df77835a3adb2ab319ad43b399d6934ac1d88cd371c016d0
@@ -82,11 +82,11 @@ module Replication
82
82
  end
83
83
 
84
84
  # @param [Symbol] link_mode Specifies whether to :copy, :link, or :symlink the files to the payload directory
85
- # @param [Pathname] source_dir The source location of the directory whose contents are to be ingested
86
- # @return [Pathname] Generate file_fixity_hash and send it to #add_payload_files
87
- def add_payload_dir (link_mode, source_dir)
88
- file_fixity_hash = Fixity.generate_checksums(source_dir, nil ,bag_checksum_types)
89
- add_payload_files(link_mode, source_dir, file_fixity_hash)
85
+ # @param [Pathname] source_dir The source location of the directory whose contents are to be bagged
86
+ # @return [Pathname] Generate file_fixity_hash and send it to #add_files_to_payload
87
+ def add_dir_to_payload (link_mode, source_dir)
88
+ file_fixity_hash = Fixity.generate_checksums(source_dir, source_dir.find ,bag_checksum_types)
89
+ add_files_to_payload(link_mode, source_dir, file_fixity_hash)
90
90
  payload_pathname
91
91
  end
92
92
 
@@ -95,16 +95,27 @@ module Replication
95
95
  # @param [Hash<String,FileFixity>] file_fixity_hash The list of files (with fixity data) to be added to the payload
96
96
  # @return [Pathname] Copy or link the files specified in the file_fixity_hash to the payload directory,
97
97
  # then update the payload manifest files
98
- def add_payload_files(link_mode, source_basepath, file_fixity_hash)
98
+ def add_files_to_payload(link_mode, source_basepath, file_fixity_hash)
99
99
  file_fixity_hash.keys.each do |file_id|
100
100
  source_pathname = source_basepath.join(file_id)
101
101
  target_pathname = payload_pathname.join(file_id)
102
102
  copy_file(link_mode, source_pathname, target_pathname)
103
103
  end
104
- write_manifest_checksums('manifest', file_fixity_hash)
104
+ write_manifest_checksums('manifest', add_data_prefix(file_fixity_hash))
105
105
  payload_pathname
106
106
  end
107
107
 
108
+ # @param [Hash<String,FileFixity>] file_fixity_hash key is file_id, values are Fixity objects containing checksums
109
+ # @return [Hash<String,FileFixity>] A revised hash with file_id paths prefixed with 'data/'
110
+ def add_data_prefix(file_fixity_hash)
111
+ new_hash = Hash.new
112
+ file_fixity_hash.values.each do |fixity|
113
+ fixity.file_id = "data/#{fixity.file_id}"
114
+ new_hash[fixity.file_id] = fixity
115
+ end
116
+ new_hash
117
+ end
118
+
108
119
  # @param [Symbol] link_mode Specifies whether to :copy, :link, or :symlink the files to the payload directory
109
120
  # @param [Pathname] source_pathname The source location of the file to be ingested
110
121
  # @param [Pathname] target_pathname The location of the directory in which to place the file
@@ -135,7 +146,7 @@ module Replication
135
146
  tarfile.tarfile_basepath = payload_pathname
136
147
  tarfile.tarfile_fullpath = payload_pathname.join("#{tarfile_id}")
137
148
  tarfile.create_tarfile
138
- file_fixity_hash = Fixity.generate_checksums(tarfile.tarfile_basepath,[tarfile.tarfile_fullpath],bag_checksum_types)
149
+ file_fixity_hash = Fixity.generate_checksums(payload_pathname,[tarfile.tarfile_fullpath],bag_checksum_types)
139
150
  write_manifest_checksums('manifest', file_fixity_hash)
140
151
  tarfile
141
152
  end
@@ -211,13 +222,18 @@ module Replication
211
222
 
212
223
  # @return [Hash<String,FileFixity>] create hash containing ids and checksums for all files in the bag's root directory
213
224
  def generate_tagfile_checksums
225
+ # get list of all files in the bag home dir, except those starting with 'tagmanifest'
214
226
  tagfiles = bag_pathname.children.reject{|file| file.basename.to_s.start_with?('tagmanifest')}
227
+ # generate checksums, using bag home dir as the base directory for file ids (per bagit spec)
215
228
  Fixity.generate_checksums(bag_pathname, tagfiles, bag_checksum_types )
216
229
  end
217
230
 
218
231
  # @return [Hash<String,FileFixity>] create hash containing ids and checksums for all files in the bag's payload
219
232
  def generate_payload_checksums
220
- Fixity.generate_checksums(payload_pathname, nil, bag_checksum_types)
233
+ # get list of all files in the data directory
234
+ path_list = payload_pathname.find
235
+ # generate checksums, but use bag home dir as the base directory for file ids (per bagit spec)
236
+ Fixity.generate_checksums(bag_pathname, path_list, bag_checksum_types)
221
237
  end
222
238
 
223
239
  # @param [String] manifest_type The type of manifest file ('manifest' or 'tagmanifest') to be updated
@@ -99,7 +99,7 @@ module Replication
99
99
  path_list = base_pathname.find if path_list.nil?
100
100
  file_fixity_hash = Hash.new
101
101
  path_list.select{|pathname| pathname.file?}.each do |file|
102
- file_fixity = Fixity.fixity_from_file(file, base_pathname)
102
+ file_fixity = Fixity.fixity_from_file(file, base_pathname, checksum_types)
103
103
  file_fixity_hash[file_fixity.file_id] = file_fixity
104
104
  end
105
105
  file_fixity_hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr-replication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure