docbook_status 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.*~
2
+ coverage
3
+ rdoc
4
+ doc
5
+ pkg
6
+ #*.*
7
+ /test/.DS_Store
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.0 / 2012-07-04
2
+
3
+ * Updated version to 1.0, 0.5 had few and tiny bug reports
4
+ * Empty remarks are now properly handled and signaled.
5
+ * Improved Ruby 1.8.7 support for status history.
6
+
1
7
  == 0.5.0 / 2011-10-15
2
8
 
3
9
  * Removed the daemon functionality, it didn't work across platforms. Use Guard instead.
data/README.rdoc CHANGED
@@ -120,7 +120,7 @@ http://rvolz.github.com/docbook_status/
120
120
 
121
121
  The MIT License
122
122
 
123
- Copyright (c) 2011 Rainer Volz
123
+ Copyright (c) 2011-12 Rainer Volz
124
124
 
125
125
  Permission is hereby granted, free of charge, to any person obtaining
126
126
  a copy of this software and associated documentation files (the
@@ -71,10 +71,12 @@ module DocbookStatus
71
71
 
72
72
  # Add to the history
73
73
  def add(ts,word_count)
74
- # FIXME add demon mode
75
- #@history[:current] << progress
76
- #archive
77
- k = ts.to_date
74
+ # Ruby 1.8 doesn't have DateTime#to_date, so we check that here
75
+ begin
76
+ k = ts.to_date
77
+ rescue NoMethodError
78
+ k = Date.parse(ts.to_s)
79
+ end
78
80
  unless (@history[:archive][k].nil?)
79
81
  @history[:archive][k][:min] = word_count if @history[:archive][k][:min] > word_count
80
82
  @history[:archive][k][:max] = word_count if @history[:archive][k][:max] < word_count
@@ -15,6 +15,14 @@ module DocbookStatus
15
15
  #
16
16
  XINCLUDE_NS = 'http://www.w3.org/2001/XInclude'
17
17
 
18
+ # Standard remark keyword, if there is none entered
19
+ #
20
+ STD_REMARK = 'REMARK'
21
+
22
+ # Standard remark text for remarks without content
23
+ #
24
+ EMPTY_REMARK = '-- EMPTY REMARK --'
25
+
18
26
  # Elements whose contents is counted as text. The _formalpara_
19
27
  # elements are included implicitly because they contain _para_ child
20
28
  # elements.
@@ -168,13 +176,15 @@ module DocbookStatus
168
176
  rems = doc.find('//db:remark')
169
177
  rems.map {|rem|
170
178
  c = rem.content.strip
171
- kw = 'REMARK'
172
- if rem.first.text?
179
+ kw = STD_REMARK
180
+ unless c.empty?
173
181
  kw1 = c.match('^([[:upper:]]+)([[:space:][:punct:]]|$)')
174
182
  unless kw1.nil?
175
183
  kw = kw1[1]
176
184
  c = kw1.post_match.lstrip
177
185
  end
186
+ else
187
+ c = EMPTY_REMARK
178
188
  end
179
189
  # TODO XPath integrieren? :path => rem.path, :parent => rem.parent.path,
180
190
  {:keyword => kw, :text => c, :file=>source, :line => rem.line_num}
@@ -182,6 +192,9 @@ module DocbookStatus
182
192
  end
183
193
 
184
194
  # Finds the remarks by looking through all the Xincluded files
195
+ #
196
+ # The remarks returned can be filtered by keyword if an keyword array is
197
+ # passed as an argument.
185
198
  #
186
199
  def find_remarks(filter=[])
187
200
  if (@source.nil?)
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <book xmlns="http://docbook.org/ns/docbook"
3
+ xmlns:xi="http://www.w3.org/2001/XInclude"
4
+ version="5.0">
5
+ <title>B1</title>
6
+ <chapter>
7
+ <title>C1</title>
8
+ <para>
9
+ Dies ist ein Test .. Dies ist ein Test.
10
+ In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
11
+ </para>
12
+ <formalpara>
13
+ <title>Titel</title>
14
+ <para>
15
+ <remark>Blindtext auswechseln</remark>
16
+ Lorem ipsum dolor sit amet, consectetuer adipiscing
17
+ elit. Aenean commodo ligula eget dolor. Aenean massa.
18
+ </para>
19
+ </formalpara>
20
+ <remark/>
21
+ <simpara>
22
+ Cum sociis natoque penatibus et magnis dis parturient montes,
23
+ nascetur ridiculus mus. Donec quam felis, ultricies nec,
24
+ pellentesque eu, pretium quis, sem.
25
+ </simpara>
26
+ <remark></remark>
27
+ <remark> </remark>
28
+ </chapter>
29
+ </book>
@@ -91,7 +91,6 @@ EOI
91
91
  dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
92
92
  info = dbs.analyze_file
93
93
  info[:file].must_equal(File.expand_path('.')+'/test/fixtures/book.xml')
94
- #info[:modified].to_s.must_equal('2011-09-09 18:20:15 +0200')
95
94
  end
96
95
 
97
96
  it "filters remarks while counting" do
@@ -113,10 +112,23 @@ EOI
113
112
  it "finds remarks" do
114
113
  dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
115
114
  all_remarks = dbs.find_remarks
116
- #all_remarks = dbs.remarks()
117
115
  all_remarks.must_equal([{:keyword=>"REMARK", :text=>"Blindtext auswechseln", :file=>"book.xml", :line=>15}, {:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
118
116
  fixmes = dbs.remarks('FIXME')
119
117
  fixmes.must_equal([{:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
120
118
  end
121
119
 
120
+ describe "with problematic remarks" do
121
+ it "can deal with empty remarks" do
122
+ dbs = DocbookStatus::Status.new('test/fixtures/book-remarks.xml')
123
+ all_remarks = dbs.find_remarks
124
+ all_remarks.length.must_equal(4)
125
+ end
126
+ it "signals empty remarks" do
127
+ dbs = DocbookStatus::Status.new('test/fixtures/book-remarks.xml')
128
+ all_remarks = dbs.find_remarks
129
+ empties = all_remarks.select {|r| r[:text] == DocbookStatus::Status::EMPTY_REMARK}
130
+ empties.length.must_equal(3)
131
+ end
132
+ end
133
+
122
134
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 1.0.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.5.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-15 00:00:00.000000000Z
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: libxml-ruby
16
- requirement: &2167250780 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.2.2
21
+ version: 2.3.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2167250780
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.2
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: term-ansicolor
27
- requirement: &2167250280 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,29 +37,44 @@ dependencies:
32
37
  version: 1.0.7
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2167250280
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.7
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: zucker
38
- requirement: &2167249780 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
42
52
  - !ruby/object:Gem::Version
43
- version: '11'
53
+ version: '12.1'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *2167249780
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '12.1'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bones
49
- requirement: &2167249140 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
53
68
  - !ruby/object:Gem::Version
54
- version: 3.7.1
69
+ version: 3.8.0
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2167249140
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.8.0
58
78
  description: A utility for DocBook authors/publishers showing the document structure
59
79
  (sections) and word count of a DocBook project. It is intended to provide an overview
60
80
  of a DocBook project's structure and size while you are writing or editing it.
@@ -67,6 +87,7 @@ extra_rdoc_files:
67
87
  - README.rdoc
68
88
  - bin/docbook_status
69
89
  files:
90
+ - .gitignore
70
91
  - Gemfile
71
92
  - Gemfile.lock
72
93
  - History.txt
@@ -78,7 +99,7 @@ files:
78
99
  - lib/docbook_status/status.rb
79
100
  - spec/docbook_status_spec.rb
80
101
  - spec/spec_helper.rb
81
- - test/.DS_Store
102
+ - test/fixtures/book-remarks.xml
82
103
  - test/fixtures/book.xml
83
104
  - test/fixtures/bookxi.xml
84
105
  - test/fixtures/chapter2.xml
@@ -110,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
131
  version: '0'
111
132
  requirements: []
112
133
  rubyforge_project: docbook_status
113
- rubygems_version: 1.8.11
134
+ rubygems_version: 1.8.24
114
135
  signing_key:
115
136
  specification_version: 3
116
137
  summary: A utility for DocBook authors/publishers showing the document structure (sections)
data/test/.DS_Store DELETED
Binary file