docbook_status 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/README.rdoc +7 -3
- data/Rakefile +1 -1
- data/bin/docbook_status +3 -2
- data/lib/docbook_status/status.rb +37 -4
- data/test/.DS_Store +0 -0
- data/test/test_docbook_status.rb +33 -1
- data/version.txt +1 -1
- metadata +14 -14
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.4.0 / 2011-10-??
|
2
|
+
|
3
|
+
* Minor changes
|
4
|
+
** The word counts displayed are now the totals of the respective section, including all its children
|
5
|
+
** Changed remarks output, more space for file names and content
|
6
|
+
** Changed the homepage to GitHub
|
7
|
+
|
1
8
|
== 0.3.0 / 2011-09-28
|
2
9
|
|
3
10
|
* Writing goals (total and daily) can be defined and tracked
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= docbook_status
|
2
2
|
|
3
|
-
A utility for DocBook authors/publishers showing the document structure (sections) and word count of a DocBook project. It is intended to provide an overview of a DocBook project's structure and
|
3
|
+
A utility for DocBook authors/publishers showing the document structure (sections) and word count of a DocBook project. It is intended to provide an overview of a DocBook project's structure and size while you are writing or editing it.
|
4
4
|
|
5
5
|
== Features
|
6
6
|
|
@@ -13,9 +13,9 @@ A utility for DocBook authors/publishers showing the document structure (section
|
|
13
13
|
|
14
14
|
== Synopsis
|
15
15
|
|
16
|
-
docbook_status is mainly a comandline application, bin/docbook_status,
|
16
|
+
docbook_status is mainly a comandline application, bin/docbook_status, which helps with writing and editing DocBook 5 documents. The application provides information about the content of a DocBook project. That project can consist of a single file or of several files that are included in the master file via XInclude.
|
17
17
|
|
18
|
-
To run docbook_status manually:
|
18
|
+
To run docbook_status once, manually:
|
19
19
|
|
20
20
|
docbook_status myproject.xml
|
21
21
|
|
@@ -116,6 +116,10 @@ https://rubygems.org/gems/docbook_status
|
|
116
116
|
|
117
117
|
* gem install docbook_status
|
118
118
|
|
119
|
+
== Homepage
|
120
|
+
|
121
|
+
http://rvolz.github.com/docbook_status/
|
122
|
+
|
119
123
|
== License
|
120
124
|
|
121
125
|
The MIT License
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ Bones {
|
|
12
12
|
name 'docbook_status'
|
13
13
|
authors 'Rainer Volz'
|
14
14
|
email 'dev@textmulch.de'
|
15
|
-
url 'http://
|
15
|
+
url 'http://rvolz.github.com/docbook_status/'
|
16
16
|
depend_on 'directory_watcher'
|
17
17
|
depend_on 'libxml-ruby'
|
18
18
|
depend_on 'json'
|
data/bin/docbook_status
CHANGED
@@ -168,10 +168,11 @@ def output_terminal(doc_info)
|
|
168
168
|
if doc_info[:remarks]
|
169
169
|
puts
|
170
170
|
puts "Remarks".bold
|
171
|
-
puts "%-10s %
|
171
|
+
puts "%-10.10s %20.20s %5s %-52s" % %w[Type File Line Content]
|
172
172
|
puts "-"*80
|
173
173
|
doc_info[:remarks].each do |r|
|
174
|
-
puts "%-10.10s %
|
174
|
+
puts "%-10.10s %20.20s %5d %-42.42s" % ["#{r[:keyword]}",r[:file],r[:line],r[:text]]
|
175
|
+
puts "%s %-42.42s" % [' '*37,r[:text][42..84]] if r[:text].length > 42
|
175
176
|
end
|
176
177
|
end
|
177
178
|
end
|
@@ -205,6 +205,34 @@ module DocbookStatus
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
+
# Helper for sum_sections
|
209
|
+
def sum_lower_sections(secs,start,level)
|
210
|
+
i=start
|
211
|
+
sum = 0
|
212
|
+
while (i < secs.length && secs[i][:level] > level)
|
213
|
+
sum += secs[i][:words]
|
214
|
+
i += 1
|
215
|
+
end
|
216
|
+
[sum,i]
|
217
|
+
end
|
218
|
+
|
219
|
+
# Sum the word counts of lower sections
|
220
|
+
def sum_sections(secs, max_level)
|
221
|
+
0.upto(max_level) do |cur_level|
|
222
|
+
i = 0
|
223
|
+
while i < secs.length
|
224
|
+
if (secs[i][:level] == cur_level)
|
225
|
+
(ctr,ni) = sum_lower_sections(secs, i+1,cur_level)
|
226
|
+
secs[i][:swords] = ctr
|
227
|
+
i = ni
|
228
|
+
else
|
229
|
+
i += 1
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
secs
|
234
|
+
end
|
235
|
+
|
208
236
|
# Searches the XML document for sections and word counts. Returns an
|
209
237
|
# array of sections (map) with title, word count, section level and DocBook tag.
|
210
238
|
#
|
@@ -218,8 +246,8 @@ module DocbookStatus
|
|
218
246
|
section_type = doc_maps[0][:name]
|
219
247
|
section_ctr = 0
|
220
248
|
section_level = 0
|
249
|
+
max_section_level = 0
|
221
250
|
doc_ctr = 0
|
222
|
-
#puts doc_maps.inspect
|
223
251
|
xms = doc_maps.drop(1)
|
224
252
|
# Compute word counts per section
|
225
253
|
xms.each do |m|
|
@@ -231,12 +259,17 @@ module DocbookStatus
|
|
231
259
|
section_name = m[:title]
|
232
260
|
section_ctr = 0
|
233
261
|
section_level = m[:level]
|
262
|
+
max_section_level = m[:level] if (m[:level] > max_section_level)
|
234
263
|
section_type = m[:name]
|
235
264
|
end
|
236
265
|
end
|
237
266
|
@sections << {:title => section_name, :words => section_ctr, :level => section_level, :tag => section_type}
|
238
|
-
#
|
239
|
-
@sections
|
267
|
+
# OPTIMIZE Not nice, but works
|
268
|
+
@sections = sum_sections(@sections,max_section_level).map {|s|
|
269
|
+
s[:words] = s[:words]+s[:swords];
|
270
|
+
s.delete(:swords)
|
271
|
+
s
|
272
|
+
}
|
240
273
|
@sections
|
241
274
|
end
|
242
275
|
|
@@ -246,7 +279,7 @@ module DocbookStatus
|
|
246
279
|
#
|
247
280
|
def analyze_file
|
248
281
|
full_name = File.expand_path(@source)
|
249
|
-
changed = File.
|
282
|
+
changed = File.mtime(@source)
|
250
283
|
@doc = XML::Document.file(@source)
|
251
284
|
raise ArgumentError, "Error: #{@source} is apparently not DocBook 5." unless is_docbook?(@doc)
|
252
285
|
@doc.xinclude if has_xinclude?(@doc)
|
data/test/.DS_Store
CHANGED
Binary file
|
data/test/test_docbook_status.rb
CHANGED
@@ -43,6 +43,38 @@ EOI
|
|
43
43
|
{:title => 'S1', :words => 17, :level => 1, :tag => 'section'}])
|
44
44
|
end
|
45
45
|
|
46
|
+
it "sums simple sections" do
|
47
|
+
ss = [{:level => 0, :words => 10},
|
48
|
+
{:level => 1, :words => 10},
|
49
|
+
{:level => 1, :words => 10}
|
50
|
+
]
|
51
|
+
dbs = DocbookStatus::Status.new()
|
52
|
+
sse = dbs.sum_sections(ss,1)
|
53
|
+
sse.must_equal([{:level => 0, :words => 10, :swords => 20},
|
54
|
+
{:level => 1, :words => 10, :swords => 0},
|
55
|
+
{:level => 1, :words => 10, :swords => 0}
|
56
|
+
])
|
57
|
+
end
|
58
|
+
|
59
|
+
it "sums sections" do
|
60
|
+
ss = [{:level => 0, :words => 10},
|
61
|
+
{:level => 1, :words => 10},
|
62
|
+
{:level => 2, :words => 10},
|
63
|
+
{:level => 2, :words => 10},
|
64
|
+
{:level => 3, :words => 10},
|
65
|
+
{:level => 1, :words => 10}
|
66
|
+
]
|
67
|
+
dbs = DocbookStatus::Status.new()
|
68
|
+
sse = dbs.sum_sections(ss,3)
|
69
|
+
sse.must_equal([{:level => 0, :words => 10, :swords => 50},
|
70
|
+
{:level => 1, :words => 10, :swords => 30},
|
71
|
+
{:level => 2, :words => 10, :swords => 0},
|
72
|
+
{:level => 2, :words => 10, :swords => 10},
|
73
|
+
{:level => 3, :words => 10, :swords => 0},
|
74
|
+
{:level => 1, :words => 10, :swords => 0}
|
75
|
+
])
|
76
|
+
end
|
77
|
+
|
46
78
|
it "processes includes" do
|
47
79
|
dbs = DocbookStatus::Status.new()
|
48
80
|
ind = XML::Document.file('test/fixtures/book.xml')
|
@@ -59,7 +91,7 @@ EOI
|
|
59
91
|
dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
|
60
92
|
info = dbs.analyze_file
|
61
93
|
info[:file].must_equal(File.expand_path('.')+'/test/fixtures/book.xml')
|
62
|
-
#info[:modified].to_s.must_equal('2011-09-
|
94
|
+
#info[:modified].to_s.must_equal('2011-09-09 18:20:15 +0200')
|
63
95
|
end
|
64
96
|
|
65
97
|
it "filters remarks while counting" do
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docbook_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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-
|
12
|
+
date: 2011-10-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: directory_watcher
|
16
|
-
requirement: &
|
16
|
+
requirement: &2165156720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.4.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2165156720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: libxml-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &2165156200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.2.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2165156200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &2165155600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2165155600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: term-ansicolor
|
49
|
-
requirement: &
|
49
|
+
requirement: &2165154960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2165154960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bones
|
60
|
-
requirement: &
|
60
|
+
requirement: &2165154300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 3.7.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2165154300
|
69
69
|
description: A utility for DocBook authors/publishers showing the document structure
|
70
70
|
(sections) and word count of a DocBook project. It is intended to provide an overview
|
71
|
-
of a DocBook project's structure and
|
71
|
+
of a DocBook project's structure and size while you are writing or editing it.
|
72
72
|
email: dev@textmulch.de
|
73
73
|
executables:
|
74
74
|
- docbook_status
|
@@ -100,7 +100,7 @@ files:
|
|
100
100
|
- test/test_docbook_status.rb
|
101
101
|
- test/test_history.rb
|
102
102
|
- version.txt
|
103
|
-
homepage: http://
|
103
|
+
homepage: http://rvolz.github.com/docbook_status/
|
104
104
|
licenses: []
|
105
105
|
post_install_message:
|
106
106
|
rdoc_options:
|