docbook_status 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +61 -0
- data/LICENSE.md +9 -0
- data/{README.rdoc → README.md} +29 -29
- data/bin/docbook_status +41 -42
- data/lib/docbook_status.rb +1 -1
- data/lib/docbook_status/history.rb +28 -27
- data/lib/docbook_status/version.rb +3 -0
- metadata +83 -72
- data/.gitignore +0 -7
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -22
- data/History.txt +0 -50
- data/Rakefile +0 -21
- data/spec/docbook_status_spec.rb +0 -6
- data/spec/spec_helper.rb +0 -15
- data/test/fixtures/book-remarks.xml +0 -29
- data/test/fixtures/book.xml +0 -27
- data/test/fixtures/bookxi.xml +0 -15
- data/test/fixtures/chapter2.xml +0 -8
- data/test/fixtures/chapter2xi.xml +0 -11
- data/test/fixtures/chapter3xi.xml +0 -8
- data/test/fixtures/section1xi.xml +0 -9
- data/test/test_docbook_status.rb +0 -134
- data/test/test_history.rb +0 -74
- data/version.txt +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff89229faac026ad1c014784ae685be82f095c203c887215923b039207913284
|
4
|
+
data.tar.gz: 06b33266a54dcbe668988f95645e46380bac5baf51e967f2adc40bdb476bad39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5fbe0c7273333071059feedfc66c0aae8345de3ebae29fc9fddcb582a16e49769467ceae52b42e9613aa858ccfea8d230f37499ecfd68d9d067ed1277aeb4c5
|
7
|
+
data.tar.gz: 7eb5937444ad99cb1f58c3d4d7ac76567f6c627bbcbed87bf28e0826b3388ba47959662a05e8ee78d0a6d05cdaa54a160f213643ba73c2afc372d7d8b123ecf0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
* Updated dependencies for Ruby 2.5
|
10
|
+
* Updated tests
|
11
|
+
|
12
|
+
## [1.0.1] - 2012-12-23
|
13
|
+
|
14
|
+
* Updated documentation url
|
15
|
+
|
16
|
+
## [1.0.0] - 2012-07-04
|
17
|
+
|
18
|
+
* Updated version to 1.0, 0.5 had few and tiny bug reports
|
19
|
+
* Empty remarks are now properly handled and signaled.
|
20
|
+
* Improved Ruby 1.8.7 support for status history.
|
21
|
+
|
22
|
+
## [0.5.0] - 2011-10-15
|
23
|
+
|
24
|
+
* Removed the daemon functionality, it didn't work across platforms. Use Guard instead.
|
25
|
+
* Improved the platform compatibility. Should now work better on Windows.
|
26
|
+
* Color support is now optional on Windows. Is switched on if gem 'win32console' is available.
|
27
|
+
* JSON support is now optional. Is switched on if the json library (1.9) or gem (1.8) is available.
|
28
|
+
|
29
|
+
## [0.4.0] - 2011-10-04
|
30
|
+
|
31
|
+
* Minor changes
|
32
|
+
* The word counts displayed are now the totals of the respective section, including all its children
|
33
|
+
* Changed remarks output, more space for file names and content
|
34
|
+
* Changed the homepage to GitHub
|
35
|
+
|
36
|
+
## [0.3.0] - 2011-09-28
|
37
|
+
|
38
|
+
* Writing goals (total and daily) can be defined and tracked
|
39
|
+
* Added YAML and JSON output formats, available with option --outputformat
|
40
|
+
* Minor fixes
|
41
|
+
* Removed daemon state persistence file dw_state.yml
|
42
|
+
* Colorized screen output
|
43
|
+
* Reorganized library
|
44
|
+
|
45
|
+
## [0.2.1] - 2011-09-18
|
46
|
+
|
47
|
+
* Minor fixes for Gem packaging
|
48
|
+
|
49
|
+
## [0.2.0] - 2011-09-18
|
50
|
+
|
51
|
+
* Added remarks listing.
|
52
|
+
* Minor fixes
|
53
|
+
* removed _formalpara_ from the list of countable text elements because they contain _para_ elements
|
54
|
+
|
55
|
+
## [0.1.1] - 2011-09-07
|
56
|
+
|
57
|
+
* Documentation corrections
|
58
|
+
|
59
|
+
## 0.1.0 / 2011-09-07
|
60
|
+
|
61
|
+
* Initial version
|
data/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright © 2011-19 Rainer Volz
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# docbook_status
|
2
2
|
|
3
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
|
|
7
7
|
* lists the section hierarchy (set, book, ... section, simplesect) of a DocBook file
|
8
8
|
* calculates a word count for each section (words in paras, simparas and formalparas)
|
@@ -11,116 +11,116 @@ A utility for DocBook authors/publishers showing the document structure (section
|
|
11
11
|
* output in YAML and JSON format (optional)
|
12
12
|
* tracks writing progress
|
13
13
|
|
14
|
-
|
14
|
+
## Synopsis
|
15
15
|
|
16
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
18
|
To run docbook_status:
|
19
19
|
|
20
|
-
docbook_status myproject.xml
|
20
|
+
`docbook_status myproject.xml`
|
21
21
|
|
22
22
|
This will show the section hierarchy and the word count of the individual sections of myproject.xml.
|
23
23
|
|
24
24
|
If the file contains editing remarks, you could list them, too:
|
25
25
|
|
26
|
-
docbook_status --remarks myproject.xml
|
26
|
+
`docbook_status --remarks myproject.xml`
|
27
27
|
|
28
28
|
Here docbook_status looks for all _remark_ elements. The application uses the same convention as many source code tools: if the content of the remark element starts with a all-uppercase word, like FIXME or TODO, this will be listed as the remark type, otherwise just REMARK will be used.
|
29
29
|
|
30
30
|
If there are many remarks and you just want to concentrate on the most important ones, let's say the FIXMEs, you could restrict the listing with:
|
31
31
|
|
32
|
-
docbook_status --remarks=FIXME myproject.xml
|
32
|
+
`docbook_status --remarks=FIXME myproject.xml`
|
33
33
|
|
34
34
|
If you need to preprocess the XML before feeding it to docbook_status, there is an option for that:
|
35
35
|
|
36
|
-
docbook_status --pre "asciddoc -bdocbook50 myproject.txt" myproject.xml
|
36
|
+
`docbook_status --pre "asciddoc -bdocbook50 myproject.txt" myproject.xml`
|
37
37
|
|
38
38
|
--pre takes shell commands as arguments and executes them before starting the analysis on the XML file.
|
39
39
|
|
40
|
-
|
40
|
+
## Tracking writing progress
|
41
41
|
|
42
42
|
As an experiment docbook_status provides features to define and track writing goals/schedules. Currently there are the following options:
|
43
43
|
|
44
|
-
* an end date, or deadline, with option --end
|
45
|
-
* a total word count goal, with option --total
|
46
|
-
* a daily word count goal, with option --daily
|
44
|
+
* an end date, or deadline, with option --end=\[YYYY-MM-DD\]
|
45
|
+
* a total word count goal, with option --total=\[number\]
|
46
|
+
* a daily word count goal, with option --daily=\[number\]
|
47
47
|
|
48
48
|
These features are currently not related, you can use any combination of them. When an end date is defined the application will simply remind you on every run of how many days are left.
|
49
49
|
|
50
50
|
If one of this options is used, a file called 'dbs_work.yml' is created in the working directory. This file is used to store the goals and the tracking information. If you want to get rid of all tracking, simply delete this file. To disable a specific kind of tracking, just call the options mentioned above with no arguments. That would delete the defined value. An example:
|
51
51
|
|
52
|
-
docbook_status --end=2099-01-01 --total=1000000 endofworld.xml
|
52
|
+
`docbook_status --end=2099-01-01 --total=1000000 endofworld.xml`
|
53
53
|
|
54
54
|
This call would define the goals: scheduled delivery date of 2099-01-01, and a total document size of one million words. To disable the time tracking call it again with no argument:
|
55
55
|
|
56
|
-
docbook_status --end endofworld.xml
|
56
|
+
`docbook_status --end endofworld.xml`
|
57
57
|
|
58
58
|
This would delete the defined delivery date but not the total. Once defined the goal options must not be repeated, since they are stored in the 'dbs_work.yml' file.
|
59
59
|
|
60
60
|
|
61
|
-
|
61
|
+
## Integration, Customization
|
62
62
|
|
63
63
|
In the unlikely case that you don't like the standard screen output and would prefer to replace it, there are other output formats available, JSON and YAML, which make that possible. Normally all output is formatted for output on a terminal screen, but the option _--outputformat_ alllows to specify a different output format, that is printed to STDOUT. Using that you could create your own frontend or integrate the application with other tools (like editors).
|
64
64
|
|
65
65
|
Use
|
66
66
|
|
67
|
-
docbook_status --outputformat=yaml
|
67
|
+
`docbook_status --outputformat=yaml`
|
68
68
|
or
|
69
|
-
docbook_status --outputformat=json
|
69
|
+
`docbook_status --outputformat=json`
|
70
70
|
|
71
71
|
to get YAML or JSON structures back. The structure returned is equivalent to the normal terminal output:
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
* file - path to XML file
|
74
|
+
* modified - the modification time of the XML file
|
75
75
|
|
76
|
-
|
76
|
+
* sections - an array of section entries, each with
|
77
77
|
* title - section name
|
78
78
|
* words - word count
|
79
79
|
* level - section level in the document hierarchy
|
80
80
|
* tag - the section's DocBook tag
|
81
81
|
|
82
|
-
|
82
|
+
* remarks - (optional) an array of remark entries, each with
|
83
83
|
* keyword - uppercase keyword, e.g. REMARK, FIXME
|
84
84
|
* text - remark text
|
85
85
|
* file - file name, location of the remark
|
86
86
|
* line - line number, location of the remark
|
87
87
|
|
88
|
-
|
88
|
+
* goals - (optional) information about the defined writing goals
|
89
89
|
* start - start date of the tracking
|
90
90
|
* end - scheduled end date or nil
|
91
91
|
* goal_total - planned total word count or 0
|
92
92
|
* goal_daily - planned daily word count or 0
|
93
93
|
|
94
|
-
|
94
|
+
* today - (optional) document size information
|
95
95
|
* min - minimum no. of words
|
96
96
|
* max - maximum no. of words
|
97
97
|
* start - first word count
|
98
98
|
* end - last (current) word count
|
99
99
|
* ctr - number of runs
|
100
100
|
|
101
|
-
|
101
|
+
## Download
|
102
102
|
|
103
103
|
https://rubygems.org/gems/docbook_status
|
104
104
|
|
105
|
-
|
105
|
+
## Requirements
|
106
106
|
|
107
107
|
* libxml2
|
108
108
|
* json (optional, install the gem if you want JSON output for Ruby 1.8)
|
109
109
|
* win32console (optional, install the gem if you want color support on MS Windows)
|
110
110
|
|
111
|
-
|
111
|
+
## Install
|
112
112
|
|
113
113
|
* gem install docbook_status
|
114
114
|
|
115
|
-
|
115
|
+
## Homepage
|
116
116
|
|
117
|
-
|
117
|
+
https://github.com/rvolz/docbook_status/
|
118
118
|
|
119
|
-
|
119
|
+
## License
|
120
120
|
|
121
121
|
The MIT License
|
122
122
|
|
123
|
-
Copyright (c) 2011-
|
123
|
+
Copyright (c) 2011-19 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
|
data/bin/docbook_status
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'optparse'
|
11
11
|
require 'yaml'
|
12
|
-
require '
|
13
|
-
# For Windows
|
12
|
+
require 'os'
|
13
|
+
# For Windows
|
14
14
|
begin
|
15
15
|
require 'json'
|
16
16
|
@json_available = true
|
@@ -58,9 +58,9 @@ NOVAL = -1
|
|
58
58
|
@end_date = NOVAL
|
59
59
|
|
60
60
|
banner = <<EOB
|
61
|
-
docbook_status, Version #{DocbookStatus
|
61
|
+
docbook_status, Version #{DocbookStatus::VERSION}
|
62
62
|
|
63
|
-
|
63
|
+
Show DocBook5 document structure and word counts.
|
64
64
|
|
65
65
|
Usage: docbook_status [options] <DOCBOOK-FILE>
|
66
66
|
EOB
|
@@ -75,25 +75,25 @@ opts.on('--remarks[=FILTER]', String, 'Show the remarks, comments. Use a keyword
|
|
75
75
|
end
|
76
76
|
}
|
77
77
|
opts.on('--end[=DATE]', String, 'Goal: planned delivery date, YYYY-MM-DD') {|val|
|
78
|
-
if val.nil?
|
79
|
-
|
78
|
+
@end_date = if val.nil?
|
79
|
+
nil
|
80
80
|
else
|
81
|
-
|
82
|
-
|
81
|
+
Date.parse(val)
|
82
|
+
end
|
83
83
|
}
|
84
|
-
opts.on('--total[=WORDS]',Integer, 'Goal: total number of words') {|val|
|
85
|
-
if val.nil?
|
86
|
-
|
84
|
+
opts.on('--total[=WORDS]', Integer, 'Goal: total number of words') {|val|
|
85
|
+
@total_words = if val.nil?
|
86
|
+
0
|
87
87
|
else
|
88
|
-
|
89
|
-
|
90
|
-
opts.on('--daily[=WORDS]',Integer, 'Goal: daily number of words') {|val|
|
91
|
-
if val.nil?
|
92
|
-
|
88
|
+
val.abs
|
89
|
+
end}
|
90
|
+
opts.on('--daily[=WORDS]', Integer, 'Goal: daily number of words') {|val|
|
91
|
+
@daily_words = if val.nil?
|
92
|
+
0
|
93
93
|
else
|
94
|
-
|
95
|
-
|
96
|
-
opts.on('--outputformat=yaml|json',['json','yaml'],'Return the result in YAML or JSON format') {|format|
|
94
|
+
val.abs
|
95
|
+
end}
|
96
|
+
opts.on('--outputformat=yaml|json', ['json', 'yaml'], 'Return the result in YAML or JSON format') {|format|
|
97
97
|
case
|
98
98
|
when format == 'yaml'
|
99
99
|
@output_format = :yaml
|
@@ -125,20 +125,19 @@ end
|
|
125
125
|
# * magenta if >70 and < 100%
|
126
126
|
# * green if >= 100%
|
127
127
|
#
|
128
|
-
def meter(actual,goal)
|
128
|
+
def meter(actual, goal)
|
129
129
|
ad = actual.to_f / goal.to_f
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
[actual.to_s,"%3.0f\%" % (ad*100)].map {|s| fct.call(s)}
|
130
|
+
fct = case
|
131
|
+
when ad <= 0.3
|
132
|
+
->(s) { s.red.bold}
|
133
|
+
when ad > 0.3 && ad <= 0.7
|
134
|
+
->(s) { s.red}
|
135
|
+
when ad > 0.7 && ad < 1.0
|
136
|
+
->(s) { s.magenta}
|
137
|
+
else
|
138
|
+
->(s) { s.green}
|
139
|
+
end
|
140
|
+
[actual.to_s, format("%3.0f\%%", (ad*100))].map {|s| fct.call(s)}
|
142
141
|
end
|
143
142
|
|
144
143
|
# Format the output for the screen and print it
|
@@ -157,12 +156,12 @@ def output_terminal(doc_info)
|
|
157
156
|
gwdaily = doc_info[:goals][:goal_daily]
|
158
157
|
unless gwtotal == 0
|
159
158
|
tactual = doc_info[:sections][0][:words]
|
160
|
-
(tactuals,tactperc) = meter(tactual,gwtotal)
|
159
|
+
(tactuals, tactperc) = meter(tactual, gwtotal)
|
161
160
|
end
|
162
161
|
unless gwdaily == 0
|
163
162
|
# Coloring the actuals
|
164
163
|
dactual = doc_info[:today][:end] - doc_info[:today][:start]
|
165
|
-
(dactuals,dactperc) = meter(dactual,gwdaily)
|
164
|
+
(dactuals, dactperc) = meter(dactual, gwdaily)
|
166
165
|
end
|
167
166
|
unless gdend.nil?
|
168
167
|
dstart = doc_info[:goals][:start]
|
@@ -184,20 +183,20 @@ def output_terminal(doc_info)
|
|
184
183
|
# Structure
|
185
184
|
puts
|
186
185
|
puts "Document structure".bold
|
187
|
-
puts "%-57.57s %-16s %5s"
|
186
|
+
puts format("%-57.57s %-16s %5s", 'Title', 'Tag', 'Words')
|
188
187
|
puts "-"*80
|
189
188
|
doc_info[:sections].each do |s|
|
190
|
-
puts "%-57.57s %-16s %5d"
|
189
|
+
puts format("%-57.57s %-16s %5d", (' ' * s[:level])+s[:title], s[:tag], s[:words])
|
191
190
|
end
|
192
191
|
#Remarks
|
193
192
|
if doc_info[:remarks]
|
194
193
|
puts
|
195
194
|
puts "Remarks".bold
|
196
|
-
puts "%-10.10s %20.20s %5s %-52s"
|
195
|
+
puts format("%-10.10s %20.20s %5s %-52s", Type, File, Line, Content)
|
197
196
|
puts "-"*80
|
198
197
|
doc_info[:remarks].each do |r|
|
199
|
-
puts "%-10.10s %20.20s %5d %-42.42s"
|
200
|
-
puts "%s %-42.42s"
|
198
|
+
puts format("%-10.10s %20.20s %5d %-42.42s", "#{r[:keyword]}", r[:file], r[:line], r[:text])
|
199
|
+
puts format("%s %-42.42s", ' '*37, r[:text][42..84]) if r[:text].length > 42
|
201
200
|
end
|
202
201
|
end
|
203
202
|
end
|
@@ -227,14 +226,14 @@ def run(file)
|
|
227
226
|
dbs_h.planned_end(@end_date) if @end_date != NOVAL
|
228
227
|
dbs_h.total_words(@total_words) if @total_words != NOVAL
|
229
228
|
dbs_h.daily_words(@daily_words) if @daily_words != NOVAL
|
230
|
-
dbs_h.add(DateTime.now,doc_info[:sections][0][:words])
|
229
|
+
dbs_h.add(DateTime.now, doc_info[:sections][0][:words])
|
231
230
|
dbs_h.save
|
232
231
|
doc_info[:goals] = dbs_h.goals
|
233
232
|
doc_info[:today] = dbs_h.today
|
234
233
|
end
|
235
234
|
case
|
236
235
|
when @output_format == :yaml
|
237
|
-
YAML.dump(doc_info,STDOUT)
|
236
|
+
YAML.dump(doc_info, STDOUT)
|
238
237
|
when @output_format == :json
|
239
238
|
STDOUT.puts doc_info.to_json
|
240
239
|
else
|
@@ -254,7 +253,7 @@ unless File.exists?(rest[0])
|
|
254
253
|
end
|
255
254
|
|
256
255
|
# The main routine
|
257
|
-
puts("docbook_status, Version #{DocbookStatus
|
256
|
+
puts("docbook_status, Version #{DocbookStatus::VERSION}") if @output_format == :screen
|
258
257
|
run(rest[0])
|
259
258
|
exit 0
|
260
259
|
|
data/lib/docbook_status.rb
CHANGED
@@ -9,7 +9,7 @@ module DocbookStatus
|
|
9
9
|
# Returns the version string for the library.
|
10
10
|
#
|
11
11
|
def self.version
|
12
|
-
@version ||=
|
12
|
+
@version ||= DocbookStatus::VERSION
|
13
13
|
end
|
14
14
|
|
15
15
|
# Returns the library path for the module. If any arguments are given,
|
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
|
4
|
+
require 'date'
|
5
5
|
|
6
|
+
module DocbookStatus
|
6
7
|
# Manages the history of writing progress in two modes. In session
|
7
8
|
# or demon mode the history shows progress for the user session. In
|
8
9
|
# normal mode the history is only maintained for calendar days,
|
@@ -32,64 +33,64 @@ module DocbookStatus
|
|
32
33
|
# * ctr (number of entries for the day)
|
33
34
|
#
|
34
35
|
class History
|
35
|
-
|
36
36
|
# History file, YAML format
|
37
37
|
HISTORY_FILE = 'dbs_work.yml'
|
38
38
|
|
39
39
|
# Does the history file exist?
|
40
|
-
def self.exists?
|
41
|
-
File.
|
40
|
+
def self.exists?
|
41
|
+
File.exist?(HISTORY_FILE)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Load the exisiting writing history
|
45
|
-
def initialize(name,end_planned=nil,goal_total=0,goal_daily=0)
|
46
|
-
if File.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
45
|
+
def initialize(name, end_planned = nil, goal_total = 0, goal_daily = 0)
|
46
|
+
@history = if File.exist?(HISTORY_FILE)
|
47
|
+
YAML.load_file(HISTORY_FILE)
|
48
|
+
else
|
49
|
+
{ file: name,
|
50
|
+
goal: {
|
51
|
+
start: Date.today,
|
52
|
+
end: end_planned,
|
53
|
+
goal_total: goal_total,
|
54
|
+
goal_daily: goal_daily
|
55
|
+
},
|
56
|
+
current: [],
|
57
|
+
archive: {} }
|
58
|
+
end
|
58
59
|
end
|
59
60
|
|
60
61
|
def planned_end(date)
|
61
|
-
@history[:goal][:end]=date
|
62
|
+
@history[:goal][:end] = date
|
62
63
|
end
|
63
64
|
|
64
65
|
def total_words(tw)
|
65
|
-
@history[:goal][:goal_total]=tw
|
66
|
+
@history[:goal][:goal_total] = tw
|
66
67
|
end
|
67
68
|
|
68
69
|
def daily_words(tw)
|
69
|
-
@history[:goal][:goal_daily]=tw
|
70
|
+
@history[:goal][:goal_daily] = tw
|
70
71
|
end
|
71
72
|
|
72
73
|
# Add to the history
|
73
|
-
def add(ts,word_count)
|
74
|
+
def add(ts, word_count)
|
74
75
|
# Ruby 1.8 doesn't have DateTime#to_date, so we check that here
|
75
76
|
begin
|
76
77
|
k = ts.to_date
|
77
78
|
rescue NoMethodError
|
78
79
|
k = Date.parse(ts.to_s)
|
79
80
|
end
|
80
|
-
|
81
|
+
if @history[:archive][k].nil?
|
82
|
+
@history[:archive][k] = { min: word_count, max: word_count, start: word_count, end: word_count, ctr: 1 }
|
83
|
+
else
|
81
84
|
@history[:archive][k][:min] = word_count if @history[:archive][k][:min] > word_count
|
82
85
|
@history[:archive][k][:max] = word_count if @history[:archive][k][:max] < word_count
|
83
86
|
@history[:archive][k][:end] = word_count
|
84
87
|
@history[:archive][k][:ctr] += 1
|
85
|
-
else
|
86
|
-
@history[:archive][k] = {:min => word_count, :max => word_count, :start => word_count, :end => word_count, :ctr => 1}
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
91
|
# Is there already a history?
|
91
92
|
def history?
|
92
|
-
|
93
|
+
!@history[:archive].empty?
|
93
94
|
end
|
94
95
|
|
95
96
|
# Convenience - returns the statistics for today
|
@@ -104,7 +105,7 @@ module DocbookStatus
|
|
104
105
|
|
105
106
|
# Save the writing history
|
106
107
|
def save
|
107
|
-
File.open(HISTORY_FILE, 'w') {|f| YAML.dump(@history,f)}
|
108
|
+
File.open(HISTORY_FILE, 'w') { |f| YAML.dump(@history, f) }
|
108
109
|
end
|
109
110
|
end
|
110
111
|
end
|
metadata
CHANGED
@@ -1,141 +1,152 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docbook_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Rainer Volz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2019-04-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: libxml-ruby
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
19
|
+
version: '2.9'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
26
|
+
version: '2.9'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: term-ansicolor
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1
|
33
|
+
version: '1'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1
|
40
|
+
version: '1'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: os
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '1'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '1'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
56
|
+
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
61
|
+
version: '1.16'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: gem-release
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- dev@textmulch.de
|
82
114
|
executables:
|
83
115
|
- docbook_status
|
84
116
|
extensions: []
|
85
|
-
extra_rdoc_files:
|
86
|
-
- History.txt
|
87
|
-
- README.rdoc
|
88
|
-
- bin/docbook_status
|
117
|
+
extra_rdoc_files: []
|
89
118
|
files:
|
90
|
-
- .
|
91
|
-
-
|
92
|
-
-
|
93
|
-
- History.txt
|
94
|
-
- README.rdoc
|
95
|
-
- Rakefile
|
119
|
+
- CHANGELOG.md
|
120
|
+
- LICENSE.md
|
121
|
+
- README.md
|
96
122
|
- bin/docbook_status
|
97
123
|
- lib/docbook_status.rb
|
98
124
|
- lib/docbook_status/history.rb
|
99
125
|
- lib/docbook_status/status.rb
|
100
|
-
-
|
101
|
-
- spec/spec_helper.rb
|
102
|
-
- test/fixtures/book-remarks.xml
|
103
|
-
- test/fixtures/book.xml
|
104
|
-
- test/fixtures/bookxi.xml
|
105
|
-
- test/fixtures/chapter2.xml
|
106
|
-
- test/fixtures/chapter2xi.xml
|
107
|
-
- test/fixtures/chapter3xi.xml
|
108
|
-
- test/fixtures/section1xi.xml
|
109
|
-
- test/test_docbook_status.rb
|
110
|
-
- test/test_history.rb
|
111
|
-
- version.txt
|
126
|
+
- lib/docbook_status/version.rb
|
112
127
|
homepage: http://projekte.textmulch.de/docbook_status/
|
113
|
-
licenses:
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata:
|
131
|
+
allowed_push_host: https://rubygems.org
|
114
132
|
post_install_message:
|
115
|
-
rdoc_options:
|
116
|
-
- --main
|
117
|
-
- README.rdoc
|
133
|
+
rdoc_options: []
|
118
134
|
require_paths:
|
119
135
|
- lib
|
120
136
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
137
|
requirements:
|
123
|
-
- -
|
138
|
+
- - "~>"
|
124
139
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
140
|
+
version: '2.5'
|
126
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
requirements: []
|
133
|
-
rubyforge_project:
|
134
|
-
rubygems_version:
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.7.3
|
135
149
|
signing_key:
|
136
|
-
specification_version:
|
137
|
-
summary:
|
138
|
-
|
139
|
-
test_files:
|
140
|
-
- test/test_docbook_status.rb
|
141
|
-
- test/test_history.rb
|
150
|
+
specification_version: 4
|
151
|
+
summary: DocBook utility showing document structure and word count
|
152
|
+
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
bones (3.8.0)
|
5
|
-
little-plugger (~> 1.1.3)
|
6
|
-
loquacious (~> 1.9.1)
|
7
|
-
rake (>= 0.8.7)
|
8
|
-
libxml-ruby (2.2.2)
|
9
|
-
little-plugger (1.1.3)
|
10
|
-
loquacious (1.9.1)
|
11
|
-
rake (10.0.3)
|
12
|
-
term-ansicolor (1.0.7)
|
13
|
-
zucker (12.1)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
bones
|
20
|
-
libxml-ruby (~> 2.2.2)
|
21
|
-
term-ansicolor
|
22
|
-
zucker
|
data/History.txt
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
== 1.0.1 / 2012-12-23
|
2
|
-
|
3
|
-
* Updated documentation url
|
4
|
-
|
5
|
-
== 1.0.0 / 2012-07-04
|
6
|
-
|
7
|
-
* Updated version to 1.0, 0.5 had few and tiny bug reports
|
8
|
-
* Empty remarks are now properly handled and signaled.
|
9
|
-
* Improved Ruby 1.8.7 support for status history.
|
10
|
-
|
11
|
-
== 0.5.0 / 2011-10-15
|
12
|
-
|
13
|
-
* Removed the daemon functionality, it didn't work across platforms. Use Guard instead.
|
14
|
-
* Improved the platform compatibility. Should now work better on Windows.
|
15
|
-
* Color support is now optional on Windows. Is switched on if gem 'win32console' is available.
|
16
|
-
* JSON support is now optional. Is switched on if the json library (1.9) or gem (1.8) is available.
|
17
|
-
|
18
|
-
== 0.4.0 / 2011-10-04
|
19
|
-
|
20
|
-
* Minor changes
|
21
|
-
** The word counts displayed are now the totals of the respective section, including all its children
|
22
|
-
** Changed remarks output, more space for file names and content
|
23
|
-
** Changed the homepage to GitHub
|
24
|
-
|
25
|
-
== 0.3.0 / 2011-09-28
|
26
|
-
|
27
|
-
* Writing goals (total and daily) can be defined and tracked
|
28
|
-
* Added YAML and JSON output formats, available with option --outputformat
|
29
|
-
* Minor fixes
|
30
|
-
** Removed daemon state persistence file dw_state.yml
|
31
|
-
** Colorized screen output
|
32
|
-
** Reorganized library
|
33
|
-
|
34
|
-
== 0.2.1 / 2011-09-18
|
35
|
-
|
36
|
-
* Minor fixes for Gem packaging
|
37
|
-
|
38
|
-
== 0.2.0 / 2011-09-18
|
39
|
-
|
40
|
-
* Added remarks listing.
|
41
|
-
* Minor fixes
|
42
|
-
** removed _formalpara_ from the list of countable text elements because they contain _para_ elements
|
43
|
-
|
44
|
-
== 0.1.1 / 2011-09-07
|
45
|
-
|
46
|
-
* Documentation corrections
|
47
|
-
|
48
|
-
== 0.1.0 / 2011-09-07
|
49
|
-
|
50
|
-
* Initial version
|
data/Rakefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#-*- encoding: utf-8 ; mode:ruby -*-
|
2
|
-
begin
|
3
|
-
require 'bones'
|
4
|
-
rescue LoadError
|
5
|
-
abort '### Please install the "bones" gem ###'
|
6
|
-
end
|
7
|
-
|
8
|
-
task :default => 'test:run'
|
9
|
-
task 'gem:release' => 'test:run'
|
10
|
-
|
11
|
-
Bones {
|
12
|
-
name 'docbook_status'
|
13
|
-
authors 'Rainer Volz'
|
14
|
-
email 'dev@textmulch.de'
|
15
|
-
url 'http://projekte.textmulch.de/docbook_status/'
|
16
|
-
ignore_file '.gitignore'
|
17
|
-
exclude << 'dbs-about.org'
|
18
|
-
depend_on 'libxml-ruby'
|
19
|
-
depend_on 'term-ansicolor'
|
20
|
-
depend_on 'zucker'
|
21
|
-
}
|
data/spec/docbook_status_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.expand_path(
|
3
|
-
File.join(File.dirname(__FILE__), %w[.. lib docbook_status]))
|
4
|
-
|
5
|
-
Spec::Runner.configure do |config|
|
6
|
-
# == Mock Framework
|
7
|
-
#
|
8
|
-
# RSpec uses it's own mocking framework by default. If you prefer to
|
9
|
-
# use mocha, flexmock or RR, uncomment the appropriate line:
|
10
|
-
#
|
11
|
-
# config.mock_with :mocha
|
12
|
-
# config.mock_with :flexmock
|
13
|
-
# config.mock_with :rr
|
14
|
-
end
|
15
|
-
|
@@ -1,29 +0,0 @@
|
|
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>
|
data/test/fixtures/book.xml
DELETED
@@ -1,27 +0,0 @@
|
|
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
|
-
<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>
|
25
|
-
</chapter>
|
26
|
-
<xi:include href="chapter2.xml"/>
|
27
|
-
</book>
|
data/test/fixtures/bookxi.xml
DELETED
@@ -1,15 +0,0 @@
|
|
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>
|
data/test/fixtures/chapter2.xml
DELETED
@@ -1,11 +0,0 @@
|
|
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>
|
data/test/test_docbook_status.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'minitest/spec'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require "docbook_status"
|
5
|
-
|
6
|
-
describe DocbookStatus do
|
7
|
-
it "works" do
|
8
|
-
true
|
9
|
-
end
|
10
|
-
|
11
|
-
it "complains if the input is not DocBook 5" do
|
12
|
-
non5 = XML::Document.string '<?xml version="1.0"?><article/>'
|
13
|
-
dbs = DocbookStatus::Status.new()
|
14
|
-
status = dbs.is_docbook?(non5)
|
15
|
-
status.must_be :==, false
|
16
|
-
end
|
17
|
-
|
18
|
-
it "input is DocBook 5" do
|
19
|
-
non5 = XML::Document.string '<?xml version="1.0"?><article xmlns="http://docbook.org/ns/docbook"/>'
|
20
|
-
dbs = DocbookStatus::Status.new()
|
21
|
-
status = dbs.is_docbook?(non5)
|
22
|
-
status.must_be :==, true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "counts correctly" do
|
26
|
-
input = <<EOI
|
27
|
-
<?xml version="1.0" ?>
|
28
|
-
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
|
29
|
-
<title>A1</title>
|
30
|
-
<section>
|
31
|
-
<title>S1</title>
|
32
|
-
<para>
|
33
|
-
Dies ist ein Test .. Dies ist ein Test.
|
34
|
-
In den Jahren 1900-1901 geschahen viele Überfälle von O`Reillys.
|
35
|
-
</para>
|
36
|
-
</section>
|
37
|
-
</article>
|
38
|
-
EOI
|
39
|
-
dbs = DocbookStatus::Status.new()
|
40
|
-
ind = XML::Document.string(input)
|
41
|
-
sections = dbs.analyze_document(ind)
|
42
|
-
sections.must_equal([{:title => 'A1', :words => 17, :level => 0, :tag => 'article'},
|
43
|
-
{:title => 'S1', :words => 17, :level => 1, :tag => 'section'}])
|
44
|
-
end
|
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
|
-
|
78
|
-
it "processes includes" do
|
79
|
-
dbs = DocbookStatus::Status.new()
|
80
|
-
ind = XML::Document.file('test/fixtures/book.xml')
|
81
|
-
if (dbs.has_xinclude?(ind))
|
82
|
-
ind.xinclude
|
83
|
-
end
|
84
|
-
sections = dbs.analyze_document(ind)
|
85
|
-
sections.must_equal([{:title => 'B1', :words => 71, :level => 0, :tag => 'book'},
|
86
|
-
{:title => 'C1', :words => 54, :level => 1, :tag => 'chapter'},
|
87
|
-
{:title => 'C2', :words => 17, :level => 1, :tag => 'chapter'}])
|
88
|
-
end
|
89
|
-
|
90
|
-
it "returns the full file name and time" do
|
91
|
-
dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
|
92
|
-
info = dbs.analyze_file
|
93
|
-
info[:file].must_equal(File.expand_path('.')+'/test/fixtures/book.xml')
|
94
|
-
end
|
95
|
-
|
96
|
-
it "filters remarks while counting" do
|
97
|
-
dbs = DocbookStatus::Status.new()
|
98
|
-
ind = XML::Document.file('test/fixtures/chapter2.xml')
|
99
|
-
sections = dbs.analyze_document(ind)
|
100
|
-
sections.must_equal([{:title => 'C2', :words => 17, :level => 0, :tag => 'chapter'}])
|
101
|
-
end
|
102
|
-
|
103
|
-
it "finds and collects all XIncludes URLs in a document" do
|
104
|
-
dbs = DocbookStatus::Status.new()
|
105
|
-
ind = XML::Document.file('test/fixtures/bookxi.xml')
|
106
|
-
xinc = dbs.has_xinclude?(ind)
|
107
|
-
xinc.must_equal(true)
|
108
|
-
xincs = dbs.find_xincludes(ind)
|
109
|
-
xincs.must_equal(["chapter2xi.xml", "chapter3xi.xml", "section1xi.xml"])
|
110
|
-
end
|
111
|
-
|
112
|
-
it "finds remarks" do
|
113
|
-
dbs = DocbookStatus::Status.new('test/fixtures/book.xml')
|
114
|
-
all_remarks = dbs.find_remarks
|
115
|
-
all_remarks.must_equal([{:keyword=>"REMARK", :text=>"Blindtext auswechseln", :file=>"book.xml", :line=>15}, {:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
|
116
|
-
fixmes = dbs.remarks('FIXME')
|
117
|
-
fixmes.must_equal([{:keyword=>"FIXME", :text=>"Ausbauen.", :file=>"chapter2.xml", :line=>6}])
|
118
|
-
end
|
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
|
-
|
134
|
-
end
|
data/test/test_history.rb
DELETED
@@ -1,74 +0,0 @@
|
|
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
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.1
|