docbook_files 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +12 -4
- data/Gemfile.lock +9 -4
- data/History.txt +10 -0
- data/LICENSE +22 -0
- data/README.md +30 -18
- data/Rakefile +15 -1
- data/lib/docbook_files/app.rb +112 -79
- data/lib/docbook_files/docbook.rb +2 -2
- data/lib/docbook_files/file_data.rb +125 -83
- data/lib/docbook_files/file_ref.rb +98 -0
- data/lib/docbook_files/file_ref_types.rb +20 -0
- data/spec/docbook_files/app_spec.rb +69 -15
- data/spec/docbook_files/docbook_spec.rb +1 -1
- data/spec/docbook_files/file_data_spec.rb +59 -49
- data/spec/docbook_files/file_ref_spec.rb +97 -0
- data/version.txt +1 -1
- metadata +49 -16
@@ -7,7 +7,7 @@ module DocbookFiles
|
|
7
7
|
it "can cope with invalid xml files" do
|
8
8
|
dbf = DocbookFiles::Docbook.new("spec/fixtures/no-xml.xml")
|
9
9
|
actual = dbf.list()
|
10
|
-
actual.class.should == DocbookFiles::
|
10
|
+
actual.class.should == DocbookFiles::FileRef
|
11
11
|
actual.name.should == "no-xml.xml"
|
12
12
|
actual.size.should == 15
|
13
13
|
actual.docbook.should be_false
|
@@ -5,74 +5,84 @@ require 'time'
|
|
5
5
|
module DocbookFiles
|
6
6
|
describe FileData do
|
7
7
|
|
8
|
+
before(:each) do
|
9
|
+
FileData.reset()
|
10
|
+
end
|
11
|
+
|
8
12
|
it "calculates a checksum" do
|
9
|
-
f = FileData.
|
13
|
+
f = FileData.for("spec/fixtures/bookxi.xml")
|
10
14
|
f.checksum.should == "7d240e7a084c16665ac59e5b927acd6a06953897"
|
11
15
|
end
|
12
16
|
|
13
17
|
it "finds a XML MIME type" do
|
14
|
-
f = FileData.
|
18
|
+
f = FileData.for("spec/fixtures/bookxi.xml")
|
15
19
|
f.mime.should == "application/xml"
|
16
20
|
end
|
17
21
|
|
18
22
|
it "finds a plain text MIME type" do
|
19
23
|
pending("different MIME lib?") do
|
20
|
-
f = FileData.
|
24
|
+
f = FileData.for("spec/fixtures/no-xml.xml")
|
21
25
|
f.mime.should_not == "application/xml"
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
25
|
-
it "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
|
29
|
+
it "constructs file names (path) relative to the main file" do
|
30
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
31
|
+
f2 = FileData.for("spec/fixtures/chapter2xi.xml")
|
32
|
+
f3 = FileData.for("spec/fixtures/c4/chapter4xi.xml")
|
33
|
+
f1.add_includes([f2,f3])
|
34
|
+
f1.name.should == "bookxi.xml"
|
35
|
+
f1.path.should == "bookxi.xml"
|
36
|
+
f1.full_name.should == File.expand_path(".")+"/spec/fixtures/bookxi.xml"
|
37
|
+
f3.name.should == "chapter4xi.xml"
|
38
|
+
f3.path.should == "c4/chapter4xi.xml"
|
39
|
+
f3.full_name.should == File.expand_path(".")+"/spec/fixtures/c4/chapter4xi.xml"
|
36
40
|
end
|
37
41
|
|
38
|
-
it "
|
39
|
-
f1 = FileData.
|
40
|
-
f2 = FileData.
|
41
|
-
|
42
|
-
|
43
|
-
f2.
|
44
|
-
expected = [{:type => :main, :name=>"bookxi.xml", :mime=>"application/xml", :size=>481},
|
45
|
-
[{:type => :inc, :name=>"chapter2xi.xml", :mime=>"application/xml", :size=>366},
|
46
|
-
[{:type => :inc, :name=>"chapter3xi.xml", :mime=>"application/xml", :size=>286}]]]
|
47
|
-
actual = f1.traverse([:name,:mime,:size],FileData::TYPE_MAIN)
|
48
|
-
actual.should == expected
|
42
|
+
it "doesn't change absolute file names in path construction" do
|
43
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
44
|
+
f2 = FileData.for("/spec/fixtures/chapter2xi.xml")
|
45
|
+
f2.name.should == "chapter2xi.xml"
|
46
|
+
f2.path.should == "/spec/fixtures/chapter2xi.xml"
|
47
|
+
f2.full_name.should == "/spec/fixtures/chapter2xi.xml"
|
49
48
|
end
|
49
|
+
|
50
|
+
it "doesn't change file names outside the main dir in path construction" do
|
51
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
52
|
+
f2 = FileData.for("../spec2/fixtures/chapter2xi.xml")
|
53
|
+
f2.name.should == "chapter2xi.xml"
|
54
|
+
f2.path.should == File.expand_path("..")+"/spec2/fixtures/chapter2xi.xml"
|
55
|
+
f2.full_name.should == File.expand_path("..")+"/spec2/fixtures/chapter2xi.xml"
|
56
|
+
end
|
50
57
|
|
51
|
-
it "
|
52
|
-
f1 = FileData.
|
53
|
-
f2 = FileData.
|
54
|
-
|
55
|
-
f1.includes = [f2]
|
56
|
-
f2.includes = [f3]
|
57
|
-
expected = [{:type => :main, :name=>"bookxi.xml", :mime=>"application/xml", :size=>481, :level=>0},
|
58
|
-
{:type => :inc, :name=>"chapter2xi.xml", :mime=>"application/xml", :size=>366, :level=>1},
|
59
|
-
{:type => :inc, :name=>"chapter3xi.xml", :mime=>"application/xml", :size=>286, :level=>2}]
|
60
|
-
actual = f1.traverse_as_table([:name,:mime,:size])
|
61
|
-
actual.should == expected
|
58
|
+
it "stores only one instance per file" do
|
59
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
60
|
+
f2 = FileData.for("spec/fixtures/bookxi.xml")
|
61
|
+
FileData.files.size.should == 1
|
62
62
|
end
|
63
|
-
|
64
|
-
it "
|
65
|
-
f1 = FileData.
|
66
|
-
f2 = FileData.
|
67
|
-
f3 = FileData.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
actual.should == expected
|
63
|
+
|
64
|
+
it "stores includes" do
|
65
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
66
|
+
f2 = FileData.for("spec/fixtures/chapter2xi.xml")
|
67
|
+
f3 = FileData.for("spec/fixtures/chapter3xi.xml")
|
68
|
+
f1.add_includes([f2,f3])
|
69
|
+
f1s = FileData::storage[f1.key]
|
70
|
+
f1s.includes.should == [f2, f3]
|
71
|
+
f2s = FileData::storage[f2.key]
|
72
|
+
f2s.included_by.should == [f1]
|
74
73
|
end
|
75
|
-
|
74
|
+
|
75
|
+
it "stores references" do
|
76
|
+
f1 = FileData.for("spec/fixtures/bookxi.xml")
|
77
|
+
f2 = FileData.for("spec/fixtures/chapter2xi.xml")
|
78
|
+
f3 = FileData.for("spec/fixtures/chapter3xi.xml")
|
79
|
+
f1.add_references([f2,f3])
|
80
|
+
f1s = FileData::storage[f1.key]
|
81
|
+
f1s.references.should == [f2, f3]
|
82
|
+
f2s = FileData::storage[f2.key]
|
83
|
+
f2s.referenced_by.should == [f1]
|
84
|
+
end
|
85
|
+
|
76
86
|
end
|
77
87
|
end
|
78
88
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module DocbookFiles
|
6
|
+
describe FileRef do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
FileData.reset()
|
10
|
+
end
|
11
|
+
|
12
|
+
it "converts a single FileRef instance to a hash" do
|
13
|
+
f = FileRef.new("spec/fixtures/bookxi.xml")
|
14
|
+
actual = f.to_hash([:name,:mime,:size],FileRefTypes::TYPE_MAIN)
|
15
|
+
actual.should == {:type => :main, :name=>"bookxi.xml", :mime=>"application/xml", :size=>481}
|
16
|
+
actual = f.to_hash([:name, :full_name, :namespace, :docbook, :version,
|
17
|
+
:tag, :parent, :status, :ts, :size, :checksum, :mime],
|
18
|
+
FileRefTypes::TYPE_MAIN)
|
19
|
+
expected = {:type => :main, :name=>"bookxi.xml",
|
20
|
+
:full_name=>File.expand_path(".")+"/spec/fixtures/bookxi.xml",
|
21
|
+
:namespace=>"", :docbook=>false,
|
22
|
+
:version=>"", :tag=>"", :parent=>nil, :status=>FileData::STATUS_OK,
|
23
|
+
:ts=>File.mtime(File.expand_path(".")+"/spec/fixtures/bookxi.xml"), :size=>481,
|
24
|
+
:checksum=>"7d240e7a084c16665ac59e5b927acd6a06953897", :mime=>"application/xml"}
|
25
|
+
actual.should == expected
|
26
|
+
end
|
27
|
+
|
28
|
+
it "converts a FileRef tree to an array of hashes" do
|
29
|
+
f1 = FileRef.new("spec/fixtures/bookxi.xml")
|
30
|
+
f2 = FileRef.new("spec/fixtures/chapter2xi.xml")
|
31
|
+
f3 = FileRef.new("spec/fixtures/chapter3xi.xml")
|
32
|
+
f1.includes = [f2]
|
33
|
+
f2.includes = [f3]
|
34
|
+
expected = [{:type => :main, :name=>"bookxi.xml", :mime=>"application/xml", :size=>481},
|
35
|
+
[{:type => :inc, :name=>"chapter2xi.xml", :mime=>"application/xml", :size=>366},
|
36
|
+
[{:type => :inc, :name=>"chapter3xi.xml", :mime=>"application/xml", :size=>286}]]]
|
37
|
+
actual = f1.traverse([:name,:mime,:size],FileRefTypes::TYPE_MAIN)
|
38
|
+
actual.should == expected
|
39
|
+
end
|
40
|
+
|
41
|
+
it "converts a FileRef tree to a table of hashes" do
|
42
|
+
f1 = FileRef.new("spec/fixtures/bookxi.xml")
|
43
|
+
f2 = FileRef.new("spec/fixtures/chapter2xi.xml")
|
44
|
+
f3 = FileRef.new("spec/fixtures/chapter3xi.xml")
|
45
|
+
f1.includes = [f2]
|
46
|
+
f2.includes = [f3]
|
47
|
+
expected = [{:type => :main, :name=>"bookxi.xml", :mime=>"application/xml", :size=>481, :level=>0},
|
48
|
+
{:type => :inc, :name=>"chapter2xi.xml", :mime=>"application/xml", :size=>366, :level=>1},
|
49
|
+
{:type => :inc, :name=>"chapter3xi.xml", :mime=>"application/xml", :size=>286, :level=>2}]
|
50
|
+
actual = f1.traverse_as_table([:name,:mime,:size])
|
51
|
+
actual.should == expected
|
52
|
+
end
|
53
|
+
|
54
|
+
it "finds non-existing files" do
|
55
|
+
f1 = FileRef.new("spec/fixtures/bookxi.xml")
|
56
|
+
f2 = FileRef.new("spec/fixtures/chapter2xi.xml",".",f1)
|
57
|
+
f3 = FileRef.new("spec/fixtures/chapter3xi.xml",".",f2)
|
58
|
+
f5 = FileRef.new("spec/fixtures/non-existing.xml",".",f2)
|
59
|
+
f1.includes = [f2]
|
60
|
+
f2.includes = [f3,f5]
|
61
|
+
expected = [{:type => :inc, :name=>"non-existing.xml", :parent=>"chapter2xi.xml"}]
|
62
|
+
actual = f1.find_non_existing_files()
|
63
|
+
actual.should == expected
|
64
|
+
end
|
65
|
+
|
66
|
+
it "collects includes of all FileRef instances" do
|
67
|
+
f1 = FileRef.new("spec/fixtures/bookxi.xml")
|
68
|
+
f2 = FileRef.new("spec/fixtures/chapter2xi.xml",".",f1)
|
69
|
+
f3 = FileRef.new("spec/fixtures/chapter3xi.xml",".",f2)
|
70
|
+
f5 = FileRef.new("spec/fixtures/non-existing.xml",".",f2)
|
71
|
+
f6 = FileRef.new("spec/fixtures/c4/chapter4xi.xml",".",f1)
|
72
|
+
f7 = FileRef.new("spec/fixtures/non-existing.xml",".",f7)
|
73
|
+
f1.includes = [f2,f6]
|
74
|
+
f2.includes = [f3,f5]
|
75
|
+
f6.includes = [f7]
|
76
|
+
store = FileData.storage
|
77
|
+
fr = store[f7.file_data.key]
|
78
|
+
fr.included_by.map{|ib|ib.key}.should == [f2.file_data.key, f6.file_data.key]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "collects references of all FileRef instances" do
|
82
|
+
f1 = FileRef.new("spec/fixtures/bookxi.xml")
|
83
|
+
f2 = FileRef.new("spec/fixtures/chapter2xi.xml",".",f1)
|
84
|
+
f3 = FileRef.new("spec/fixtures/pic1.jpg",".",f2)
|
85
|
+
f5 = FileRef.new("spec/fixtures/pic2.jpg",".",f2)
|
86
|
+
f6 = FileRef.new("spec/fixtures/c4/chapter4xi.xml",".",f1)
|
87
|
+
f7 = FileRef.new("spec/fixtures/pic2.jpg",".",f7)
|
88
|
+
f1.includes = [f2,f6]
|
89
|
+
f2.refs = [f3,f5]
|
90
|
+
f6.refs = [f7]
|
91
|
+
store = FileData.storage
|
92
|
+
fr = store[f7.file_data.key]
|
93
|
+
fr.referenced_by.map{|ib|ib.key}.should == [f2.file_data.key, f6.file_data.key]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docbook_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libxml-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &2167029400 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2167029400
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: term-ansicolor
|
27
|
-
requirement: &
|
27
|
+
requirement: &2167028280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2167028280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: wand
|
38
|
-
requirement: &
|
38
|
+
requirement: &2167027500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,21 +43,32 @@ dependencies:
|
|
43
43
|
version: '0.4'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2167027500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: zucker
|
49
|
+
requirement: &2167026460 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '11'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2167026460
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &2167025840 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.7.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2167025840
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: bones
|
60
|
-
requirement: &
|
71
|
+
requirement: &2167025160 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,7 +76,7 @@ dependencies:
|
|
65
76
|
version: 3.7.1
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *2167025160
|
69
80
|
description: docbook_files lists and checks all files related to a DocBook writing
|
70
81
|
project.
|
71
82
|
email: dev@textmulch.de
|
@@ -80,6 +91,7 @@ files:
|
|
80
91
|
- Gemfile.lock
|
81
92
|
- Guardfile
|
82
93
|
- History.txt
|
94
|
+
- LICENSE
|
83
95
|
- README.md
|
84
96
|
- Rakefile
|
85
97
|
- bin/docbook_files
|
@@ -87,9 +99,12 @@ files:
|
|
87
99
|
- lib/docbook_files/app.rb
|
88
100
|
- lib/docbook_files/docbook.rb
|
89
101
|
- lib/docbook_files/file_data.rb
|
102
|
+
- lib/docbook_files/file_ref.rb
|
103
|
+
- lib/docbook_files/file_ref_types.rb
|
90
104
|
- spec/docbook_files/app_spec.rb
|
91
105
|
- spec/docbook_files/docbook_spec.rb
|
92
106
|
- spec/docbook_files/file_data_spec.rb
|
107
|
+
- spec/docbook_files/file_ref_spec.rb
|
93
108
|
- spec/docbook_files_spec.rb
|
94
109
|
- spec/fixtures/book-nonexisting.xml
|
95
110
|
- spec/fixtures/bookxi.xml
|
@@ -112,8 +127,26 @@ files:
|
|
112
127
|
- spec/spec_helper.rb
|
113
128
|
- version.txt
|
114
129
|
homepage: http://rvolz.github.com/docbook_files/
|
115
|
-
licenses:
|
116
|
-
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
post_install_message: ! '
|
133
|
+
|
134
|
+
Please note:
|
135
|
+
|
136
|
+
|
137
|
+
- docbook_files uses color to mark problematic files.
|
138
|
+
|
139
|
+
On Windows, you should additionally install the gem ''win32console''
|
140
|
+
|
141
|
+
to enable color output in the terminal.
|
142
|
+
|
143
|
+
|
144
|
+
- JSON output is optional for Ruby 1.8. Please install the gem ''json''
|
145
|
+
|
146
|
+
if you are running Ruby 1.8 and want JSON output.
|
147
|
+
|
148
|
+
|
149
|
+
'
|
117
150
|
rdoc_options:
|
118
151
|
- --main
|
119
152
|
- README.md
|