dpn-bagit 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Rakefile +11 -0
- data/dpn-bagit.gemspec +4 -0
- data/lib/dpn/bagit/serialized_bag.rb +30 -31
- data/lib/dpn/bagit/version.rb +1 -1
- metadata +59 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbf91f6917b14328e6c5baaab2d77a887757cdad
|
4
|
+
data.tar.gz: 9dbcae49067a6e4c4ea6e6bc94eacad033c1de18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e2a69e5c48e857317d2e6bf1baa7fe7d1589af7cdce99927e501d5ab695416d776f72ff62163b21ca5fa9f88680deb5b20e8406670b225eddea6122bf375bc8
|
7
|
+
data.tar.gz: f8fde7045d0ba19038fdcc6bc5cedc2a6fcb147dc134877082cce78639e4704db06ab49057e492e4cdfe15b816c12a7baa8b9ecbec89d22c4fd0d3480ff9125f
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -2,6 +2,8 @@ require "bundler/gem_tasks"
|
|
2
2
|
require "rake"
|
3
3
|
require "rake/testtask"
|
4
4
|
|
5
|
+
task :default => [:test]
|
6
|
+
|
5
7
|
desc "Run all tests."
|
6
8
|
Rake::TestTask.new(:test) do |t|
|
7
9
|
t.libs << "lib"
|
@@ -9,3 +11,12 @@ Rake::TestTask.new(:test) do |t|
|
|
9
11
|
t.test_files = FileList['test/**/*_test.rb']
|
10
12
|
end
|
11
13
|
|
14
|
+
# app_version_tasks
|
15
|
+
spec = Gem::Specification.find_by_name 'app_version_tasks'
|
16
|
+
load "#{spec.gem_dir}/lib/tasks/app_version_tasks.rake"
|
17
|
+
require 'app_version_tasks'
|
18
|
+
AppVersionTasks.configure do |config|
|
19
|
+
config.application_name = 'DPN::Bagit'
|
20
|
+
config.version_file_path = File.join(pwd, 'lib', 'dpn', 'bagit', 'version.rb')
|
21
|
+
config.git_working_directory = pwd
|
22
|
+
end
|
data/dpn-bagit.gemspec
CHANGED
@@ -18,11 +18,15 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_development_dependency "app_version_tasks", "~> 0.2"
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.8"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
24
|
spec.add_development_dependency "test-unit"
|
24
25
|
spec.add_development_dependency "yard", "~> 0.8"
|
25
26
|
spec.add_development_dependency "simplecov"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry-doc"
|
29
|
+
spec.add_development_dependency "rubocop"
|
26
30
|
|
27
31
|
spec.add_runtime_dependency "configliere"
|
28
32
|
spec.add_runtime_dependency "bagit", "~>0.3.2"
|
@@ -1,62 +1,61 @@
|
|
1
1
|
require "dpn/bagit/bag"
|
2
2
|
|
3
|
-
|
3
|
+
##
|
4
4
|
# A wrapper for a serialized Bag-It bag on disk.
|
5
5
|
# Once created, will not change with changes made to the underlying filesystem
|
6
6
|
# bag; in that case, a new object should be created.
|
7
|
+
# @!attribute [r] location
|
8
|
+
# @return [String] The location, which can be relative or absolute.
|
7
9
|
class DPN::Bagit::SerializedBag
|
8
10
|
|
9
|
-
|
10
|
-
# @param _location [String] Path to the file.
|
11
|
-
def initialize(_location)
|
12
|
-
if File.exists?(_location) == false
|
13
|
-
raise ArgumentError, "File does not exist!"
|
14
|
-
end
|
11
|
+
attr_reader :location
|
15
12
|
|
16
|
-
|
17
|
-
|
13
|
+
# Create a SerializedBag
|
14
|
+
# @param path [String] Path to the file.
|
15
|
+
def initialize(path)
|
16
|
+
raise ArgumentError, "File does not exist!" unless File.exist?(path)
|
17
|
+
@location = path
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
return File.size(@location)
|
20
|
+
# Returns the file name for the serialized bag, without it's extension.
|
21
|
+
# @return [String] name
|
22
|
+
def name
|
23
|
+
@name ||= File.basename(location, File.extname(location))
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
return @location
|
26
|
+
# Returns the directory path to the serialized bag.
|
27
|
+
# @return [String] path
|
28
|
+
def path
|
29
|
+
@path ||= File.dirname(location)
|
32
30
|
end
|
33
31
|
|
32
|
+
# Returns the size of the serialized bag (in bytes).
|
33
|
+
# @return [Fixnum] size
|
34
|
+
def size
|
35
|
+
File.size(location)
|
36
|
+
end
|
34
37
|
|
35
38
|
# Returns the fixity of the serialized version of the bag.
|
36
39
|
# @param algorithm [Symbol] The algorithm to use for calculation.
|
37
|
-
# @return [String]
|
40
|
+
# @return [String] fixity
|
38
41
|
def fixity(algorithm)
|
39
|
-
|
42
|
+
@cachedFixity ||= begin
|
40
43
|
case algorithm
|
41
44
|
when :sha256
|
42
45
|
digest = Digest::SHA256
|
43
46
|
else
|
44
47
|
raise ArgumentError, "Unknown algorithm."
|
45
48
|
end
|
46
|
-
|
47
|
-
@cachedFixity = digest.file(@location).hexdigest
|
49
|
+
digest.file(location).hexdigest
|
48
50
|
end
|
49
|
-
return @cachedFixity
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
53
|
# Unserialize the bag into the local filesystem. This object
|
54
54
|
# is unchanged. Requires sufficient permissions and disk space.
|
55
|
-
# @return [Bag] A bag made from the unserialized object.
|
56
|
-
def unserialize!
|
57
|
-
`/bin/tar -xf #{
|
58
|
-
raise RuntimeError, "cannot untar #{
|
59
|
-
|
60
|
-
return DPN::Bagit::Bag.new(File.join(File.dirname(@location), name))
|
55
|
+
# @return [DPN::Bagit::Bag] A bag made from the unserialized object.
|
56
|
+
def unserialize!
|
57
|
+
`/bin/tar -xf #{location} -C #{path} 2> /dev/null`
|
58
|
+
raise RuntimeError, "cannot untar #{location}" unless $?.success?
|
59
|
+
DPN::Bagit::Bag.new(File.join(path, name))
|
61
60
|
end
|
62
61
|
end
|
data/lib/dpn/bagit/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpn-bagit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Hockey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: app_version_tasks
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,48 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-doc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
83
139
|
- !ruby/object:Gem::Dependency
|
84
140
|
name: configliere
|
85
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
213
|
version: '0'
|
158
214
|
requirements: []
|
159
215
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.5.2
|
161
217
|
signing_key:
|
162
218
|
specification_version: 4
|
163
219
|
summary: An implementation of the DPN Bagit spec.
|