docbook_status 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/.DS_Store ADDED
Binary file
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
- <book xmlns="http://docbook.org/ns/docbook"
2
+ <book xmlns="http://docbook.org/ns/docbook"
3
3
  xmlns:xi="http://www.w3.org/2001/XInclude"
4
4
  version="5.0">
5
5
  <title>B1</title>
@@ -9,6 +9,19 @@
9
9
  Dies ist ein Test .. Dies ist ein Test.
10
10
  In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
11
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
+ <simpara>
21
+ Cum sociis natoque penatibus et magnis dis parturient montes,
22
+ nascetur ridiculus mus. Donec quam felis, ultricies nec,
23
+ pellentesque eu, pretium quis, sem.
24
+ </simpara>
12
25
  </chapter>
13
26
  <xi:include href="chapter2.xml"/>
14
27
  </book>
@@ -0,0 +1,15 @@
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
+ </chapter>
13
+ <xi:include href="chapter2xi.xml"/>
14
+ <xi:include href="chapter3xi.xml"/>
15
+ </book>
@@ -3,5 +3,6 @@
3
3
  <para>
4
4
  Dies ist ein Test .. Dies ist ein Test.
5
5
  In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
6
+ <remark>FIXME Ausbauen.</remark>
6
7
  </para>
7
- </chapter>
8
+ </chapter>
@@ -0,0 +1,11 @@
1
+ <chapter xmlns="http://docbook.org/ns/docbook"
2
+ xmlns:xi="http://www.w3.org/2001/XInclude"
3
+ version="5.0">
4
+ <title>C2</title>
5
+ <para>
6
+ Dies ist ein Test .. Dies ist ein Test.
7
+ In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
8
+ <remark>FIXME Ausbauen.</remark>
9
+ </para>
10
+ <xi:include href="section1xi.xml"/>
11
+ </chapter>
@@ -0,0 +1,8 @@
1
+ <chapter xmlns="http://docbook.org/ns/docbook" version="5.0">
2
+ <title>C3</title>
3
+ <para>
4
+ Dies ist ein Test .. Dies ist ein Test.
5
+ In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
6
+ <remark>FIXME 3 Ausbauen.</remark>
7
+ </para>
8
+ </chapter>
@@ -0,0 +1,9 @@
1
+ <section xmlns="http://docbook.org/ns/docbook"
2
+ version="5.0">
3
+ <title>S1</title>
4
+ <para>
5
+ Dies ist ein Test .. Dies ist ein Test.
6
+ In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
7
+ <remark>TODO S1 Ausbauen.</remark>
8
+ </para>
9
+ </section>
@@ -10,14 +10,14 @@ describe DocbookStatus do
10
10
 
11
11
  it "complains if the input is not DocBook 5" do
12
12
  non5 = XML::Document.string '<?xml version="1.0"?><article/>'
13
- dbs = DocbookStatus.new()
13
+ dbs = DocbookStatus::Status.new()
14
14
  status = dbs.is_docbook?(non5)
15
15
  status.must_be :==, false
16
16
  end
17
17
 
18
18
  it "input is DocBook 5" do
19
19
  non5 = XML::Document.string '<?xml version="1.0"?><article xmlns="http://docbook.org/ns/docbook"/>'
20
- dbs = DocbookStatus.new()
20
+ dbs = DocbookStatus::Status.new()
21
21
  status = dbs.is_docbook?(non5)
22
22
  status.must_be :==, true
23
23
  end
@@ -36,20 +36,55 @@ describe DocbookStatus do
36
36
  </section>
37
37
  </article>
38
38
  EOI
39
- dbs = DocbookStatus.new()
39
+ dbs = DocbookStatus::Status.new()
40
40
  ind = XML::Document.string(input)
41
41
  sections = dbs.analyze_document(ind)
42
- sections.must_equal([['A1', 17, 0, 'article'],['S1', 17, 1, 'section']])
42
+ sections.must_equal([{:title => 'A1', :words => 17, :level => 0, :tag => 'article'},
43
+ {:title => 'S1', :words => 17, :level => 1, :tag => 'section'}])
43
44
  end
44
45
 
45
46
  it "processes includes" do
46
- dbs = DocbookStatus.new()
47
+ dbs = DocbookStatus::Status.new()
47
48
  ind = XML::Document.file('test/fixtures/book.xml')
48
49
  if (dbs.has_xinclude?(ind))
49
50
  ind.xinclude
50
51
  end
51
52
  sections = dbs.analyze_document(ind)
52
- sections.must_equal([['B1', 34, 0, 'book'],['C1', 17, 1, 'chapter'],['C2', 17, 1, 'chapter']])
53
+ sections.must_equal([{:title => 'B1', :words => 71, :level => 0, :tag => 'book'},
54
+ {:title => 'C1', :words => 54, :level => 1, :tag => 'chapter'},
55
+ {:title => 'C2', :words => 17, :level => 1, :tag => 'chapter'}])
56
+ end
57
+
58
+ it "returns the full file name and time" do
59
+ dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
60
+ info = dbs.analyze_file
61
+ info[:file].must_equal(File.expand_path('.')+'/test/fixtures/book.xml')
62
+ #info[:modified].to_s.must_equal('2011-09-27 18:17:10 +0200')
63
+ end
64
+
65
+ it "filters remarks while counting" do
66
+ dbs = DocbookStatus::Status.new()
67
+ ind = XML::Document.file('test/fixtures/chapter2.xml')
68
+ sections = dbs.analyze_document(ind)
69
+ sections.must_equal([{:title => 'C2', :words => 17, :level => 0, :tag => 'chapter'}])
70
+ end
71
+
72
+ it "finds and collects all XIncludes URLs in a document" do
73
+ dbs = DocbookStatus::Status.new()
74
+ ind = XML::Document.file('test/fixtures/bookxi.xml')
75
+ xinc = dbs.has_xinclude?(ind)
76
+ xinc.must_equal(true)
77
+ xincs = dbs.find_xincludes(ind)
78
+ xincs.must_equal(["chapter2xi.xml", "chapter3xi.xml", "section1xi.xml"])
79
+ end
80
+
81
+ it "finds remarks" do
82
+ dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
83
+ all_remarks = dbs.find_remarks
84
+ #all_remarks = dbs.remarks()
85
+ all_remarks.must_equal([{:keyword=>"REMARK", :text=>"Blindtext auswechseln", :file=>"book.xml", :line=>15}, {:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
86
+ fixmes = dbs.remarks('FIXME')
87
+ fixmes.must_equal([{:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
53
88
  end
54
89
 
55
90
  end
@@ -0,0 +1,74 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'minitest/spec'
3
+ require 'minitest/autorun'
4
+ require "docbook_status"
5
+
6
+ describe DocbookStatus::History do
7
+
8
+ after(:each) do
9
+ if File.exists?(DocbookStatus::History::HISTORY_FILE)
10
+ File.unlink(DocbookStatus::History::HISTORY_FILE)
11
+ end
12
+ end
13
+
14
+ it "initializes with minimal values" do
15
+ h = DocbookStatus::History.new('test.xml')
16
+ h.save
17
+ File.exists?(DocbookStatus::History::HISTORY_FILE).must_equal(true)
18
+ history = YAML.load_file(DocbookStatus::History::HISTORY_FILE)
19
+ history[:file].must_equal('test.xml')
20
+ history[:goal][:start].must_equal(Date.today)
21
+ history[:goal][:end].must_equal(nil)
22
+ history[:goal][:goal_total].must_equal(0)
23
+ history[:goal][:goal_daily].must_equal(0)
24
+ end
25
+
26
+ it "initializes with all values" do
27
+ h = DocbookStatus::History.new('test.xml',Date.today+10,10000,1000)
28
+ h.save
29
+ File.exists?(DocbookStatus::History::HISTORY_FILE).must_equal(true)
30
+ history = YAML.load_file(DocbookStatus::History::HISTORY_FILE)
31
+ history[:file].must_equal('test.xml')
32
+ history[:goal][:start].must_equal(Date.today)
33
+ history[:goal][:end].must_equal(Date.today+10)
34
+ history[:goal][:goal_total].must_equal(10000)
35
+ history[:goal][:goal_daily].must_equal(1000)
36
+ h.goals.must_equal({:start => Date.today, :end=>Date.today+10, :goal_total => 10000, :goal_daily=>1000})
37
+ end
38
+
39
+ it "knows when the history file exists" do
40
+ DocbookStatus::History.exists?.must_equal(false)
41
+ h = DocbookStatus::History.new('test.xml')
42
+ h.save
43
+ DocbookStatus::History.exists?.must_equal(true)
44
+ end
45
+
46
+ it "progress can be added" do
47
+ h = DocbookStatus::History.new('test.xml')
48
+ h.history?.must_equal(false)
49
+ h.add(DateTime.now,100)
50
+ h.history?.must_equal(true)
51
+ h.today.must_equal({:min => 100, :max => 100, :start=>100, :end => 100, :ctr => 1})
52
+ # add one word
53
+ h.add(DateTime.now,101)
54
+ h.today.must_equal({:min => 100, :max => 101, :start=>100, :end => 101, :ctr => 2})
55
+ # subtract two words
56
+ h.add(DateTime.now,99)
57
+ h.today.must_equal({:min => 99, :max => 101, :start=>100, :end => 99, :ctr => 3})
58
+ # add a progress from yesterday that should be ignored
59
+ h.add(DateTime.now()-1,10)
60
+ h.today.must_equal({:min => 99, :max => 101, :start=>100, :end => 99, :ctr => 3})
61
+ end
62
+
63
+ it "stores progress" do
64
+ h = DocbookStatus::History.new('test.xml')
65
+ h.history?.must_equal(false)
66
+ h.add(DateTime.now,100)
67
+ h.add(DateTime.now,101)
68
+ h.add(DateTime.now,99)
69
+ h.save
70
+ h = nil
71
+ i = DocbookStatus::History.new('test.xml')
72
+ i.today.must_equal({:min => 99, :max => 101, :start=>100, :end => 99, :ctr => 3})
73
+ end
74
+ end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.3.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.1.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,55 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-08 00:00:00.000000000 +02:00
13
- default_executable:
12
+ date: 2011-09-28 00:00:00.000000000Z
14
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: directory_watcher
16
+ requirement: &2154663180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2154663180
25
+ - !ruby/object:Gem::Dependency
26
+ name: libxml-ruby
27
+ requirement: &2154662400 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2154662400
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ requirement: &2154661680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.1
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2154661680
47
+ - !ruby/object:Gem::Dependency
48
+ name: term-ansicolor
49
+ requirement: &2154660920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.6
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2154660920
15
58
  - !ruby/object:Gem::Dependency
16
59
  name: bones
17
- requirement: &2166328320 !ruby/object:Gem::Requirement
60
+ requirement: &2154660120 !ruby/object:Gem::Requirement
18
61
  none: false
19
62
  requirements:
20
63
  - - ! '>='
@@ -22,7 +65,7 @@ dependencies:
22
65
  version: 3.7.1
23
66
  type: :development
24
67
  prerelease: false
25
- version_requirements: *2166328320
68
+ version_requirements: *2154660120
26
69
  description: A utility for DocBook authors/publishers showing the document structure
27
70
  (sections) and word count of a DocBook project. It is intended to provide an overview
28
71
  of a DocBook project's structure and volume while you are writing or editing it.
@@ -32,30 +75,37 @@ executables:
32
75
  extensions: []
33
76
  extra_rdoc_files:
34
77
  - History.txt
35
- - README.txt
78
+ - README.rdoc
36
79
  - bin/docbook_status
37
80
  files:
38
81
  - .bnsignore
39
82
  - Gemfile
40
83
  - Gemfile.lock
41
84
  - History.txt
42
- - README.txt
85
+ - README.rdoc
43
86
  - Rakefile
44
87
  - bin/docbook_status
45
88
  - lib/docbook_status.rb
89
+ - lib/docbook_status/history.rb
90
+ - lib/docbook_status/status.rb
46
91
  - spec/docbook_status_spec.rb
47
92
  - spec/spec_helper.rb
93
+ - test/.DS_Store
48
94
  - test/fixtures/book.xml
95
+ - test/fixtures/bookxi.xml
49
96
  - test/fixtures/chapter2.xml
97
+ - test/fixtures/chapter2xi.xml
98
+ - test/fixtures/chapter3xi.xml
99
+ - test/fixtures/section1xi.xml
50
100
  - test/test_docbook_status.rb
101
+ - test/test_history.rb
51
102
  - version.txt
52
- has_rdoc: true
53
103
  homepage: http://projekte.textmulch.de/docbook_status/
54
104
  licenses: []
55
105
  post_install_message:
56
106
  rdoc_options:
57
107
  - --main
58
- - README.txt
108
+ - README.rdoc
59
109
  require_paths:
60
110
  - lib
61
111
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -72,10 +122,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
122
  version: '0'
73
123
  requirements: []
74
124
  rubyforge_project: docbook_status
75
- rubygems_version: 1.6.2
125
+ rubygems_version: 1.8.10
76
126
  signing_key:
77
127
  specification_version: 3
78
128
  summary: A utility for DocBook authors/publishers showing the document structure (sections)
79
129
  and word count of a DocBook project.
80
130
  test_files:
81
131
  - test/test_docbook_status.rb
132
+ - test/test_history.rb
data/README.txt DELETED
@@ -1,59 +0,0 @@
1
- = docbook_status
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 volume while you are writing or editing it.
4
-
5
-
6
- == Features
7
-
8
- * lists all sections (set, book, ... section, simplesect) in a DocBook file
9
- * calculates a word count for each section (words in paras, simparas and formalparas)
10
- * works with included sections (XInclude)
11
-
12
- == Examples
13
-
14
- The package includes a comandline application, bin/docbook_status, that can be used in two ways:
15
-
16
- to run it manually, once:
17
- docbook_status <DocBook file>
18
-
19
- to run the application in demon mode, continually:
20
- docbook_status --demon --glob "*.xml" --dir "." <DocBook file>
21
-
22
- In demon-mode the application checks the files matched by the _glob_ pattern in the directory specified by _dir_ for changes, and redisplays the document analysis whenever a change occures. The demon can be termanted by simply pressing RETURN.
23
-
24
- == Download
25
-
26
- https://rubygems.org/gems/docbook_status
27
-
28
- == Requirements
29
-
30
- * libxml2
31
-
32
- == Install
33
-
34
- * gem install docbook_status
35
-
36
- == License
37
-
38
- The MIT License
39
-
40
- Copyright (c) 2011 Rainer Volz
41
-
42
- Permission is hereby granted, free of charge, to any person obtaining
43
- a copy of this software and associated documentation files (the
44
- 'Software'), to deal in the Software without restriction, including
45
- without limitation the rights to use, copy, modify, merge, publish,
46
- distribute, sublicense, and/or sell copies of the Software, and to
47
- permit persons to whom the Software is furnished to do so, subject to
48
- the following conditions:
49
-
50
- The above copyright notice and this permission notice shall be
51
- included in all copies or substantial portions of the Software.
52
-
53
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
54
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
57
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
58
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
59
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.