Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 29237a7

Browse files
committed
Parse the manifest file and expose it as a Hash.
Parsed as plain json rather than json-ld as the json-ld parser has a bug that stops us from using it at present: ruby-rdf/json-ld#11
1 parent 2652291 commit 29237a7

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

lib/ro-bundle.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#------------------------------------------------------------------------------
88

99
require "bundler/setup"
10+
require "json"
1011
require "ucf"
1112

1213
require "ro-bundle/version"

lib/ro-bundle/file.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def initialize(filename)
2323
super(filename)
2424

2525
# Initialize the managed entries and register the .ro directory.
26-
initialize_managed_entries(RODir.new)
26+
@manifest = Manifest.new
27+
initialize_managed_entries(RODir.new(@manifest))
2728
end
2829
# :startdoc:
2930

@@ -44,5 +45,11 @@ def initialize(filename)
4445
def File.create(filename, mimetype = MIMETYPE, &block)
4546
super(filename, mimetype, &block)
4647
end
48+
49+
protected
50+
51+
def manifest
52+
@manifest.structure
53+
end
4754
end
4855
end

lib/ro-bundle/ro-dir.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@
88

99
module ROBundle
1010
class RODir < ZipContainer::ManagedDirectory
11-
def initialize
12-
super(".ro", false, [Manifest.new])
11+
12+
DIR_NAME = ".ro"
13+
14+
def initialize(manifest)
15+
super(DIR_NAME, false, [manifest])
1316
end
1417
end
1518

1619
class Manifest < ZipContainer::ManagedFile
20+
21+
FILE_NAME = "manifest.json"
22+
1723
def initialize
18-
super("manifest.json", false)
24+
super(FILE_NAME, false)
25+
end
26+
27+
# Need this because we can't access file contents in the constructor.
28+
def structure
29+
begin
30+
@structure ||= JSON.parse(contents)
31+
rescue
32+
@structure = {}
33+
end
1934
end
35+
2036
end
2137
end

ro-bundle.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
3737
spec.add_development_dependency("rdoc", "~> 4.1")
3838
spec.add_development_dependency "coveralls"
3939
spec.add_runtime_dependency "ucf", "~> 0.7"
40+
spec.add_runtime_dependency "json", "~> 1.8"
4041
end

0 commit comments

Comments
 (0)