inochi 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CREDITS +5 -12
- data/bin/inochi +2 -10
- data/lib/inochi/engine.rb +75 -1
- data/lib/inochi/inochi.rb +7 -8
- data/lib/inochi/tasks/2-api.rake +1 -4
- data/lib/inochi/tasks/3-man.rake +55 -54
- data/lib/inochi/tasks/3-man.rake.css +49 -0
- data/lib/inochi/tasks/4-ann.rake +33 -41
- data/lib/inochi/tasks/5-gem.rake +3 -5
- data/lib/inochi/tasks/6-pub.rake +3 -10
- data/lib/inochi/templates/BEYOND.rbs +14 -13
- data/lib/inochi/templates/CREDITS.rbs +7 -14
- data/lib/inochi/templates/HACKING.rbs +48 -50
- data/lib/inochi/templates/HISTORY.rbs +24 -31
- data/lib/inochi/templates/INSTALL.rbs +27 -0
- data/lib/inochi/templates/MANUAL.rbs +8 -34
- data/lib/inochi/templates/README.rbs +14 -40
- data/lib/inochi/templates/SYNOPSIS.rbs +21 -0
- data/lib/inochi/templates/USAGE.rbs +8 -20
- data/lib/inochi/templates/command.rbs +2 -10
- data/lib/inochi/templates/{inochi.opts.rbs → inochi.conf.rbs} +8 -0
- data/lib/inochi/templates/inochi.rb.rbs +11 -11
- data/man/man1/inochi.1 +2807 -0
- metadata +14 -36
- data/lib/inochi/tasks/0-project.rake +0 -25
- data/lib/inochi/tasks/1-init.rake +0 -38
- data/lib/inochi/templates/EXAMPLES.rbs +0 -24
- data/logo/inochi.png +0 -0
- data/man.html +0 -1229
- data/man/man1/inochi.1.gz +0 -0
data/CREDITS
CHANGED
@@ -1,21 +1,14 @@
|
|
1
|
-
|
2
|
-
## AUTHORS
|
3
|
-
%#----------------------------------------------------------------------------
|
1
|
+
== AUTHORS
|
4
2
|
|
5
3
|
Suraj N. Kurapati
|
6
4
|
|
7
|
-
|
8
|
-
## CREDITS
|
9
|
-
%#----------------------------------------------------------------------------
|
5
|
+
=== Credits
|
10
6
|
|
11
7
|
Florian Gilcher,
|
12
8
|
Peileppe Production
|
13
9
|
|
14
|
-
%<
|
10
|
+
%< 'logo/README'
|
15
11
|
|
16
|
-
|
17
|
-
## LICENSE
|
18
|
-
%#----------------------------------------------------------------------------
|
12
|
+
=== License
|
19
13
|
|
20
|
-
|
21
|
-
%< "LICENSE"
|
14
|
+
%< 'LICENSE'
|
data/bin/inochi
CHANGED
@@ -3,16 +3,8 @@
|
|
3
3
|
require 'inochi'
|
4
4
|
|
5
5
|
if ARGV.delete('-h') or ARGV.delete('--help')
|
6
|
-
|
7
|
-
|
8
|
-
unless system 'man', '-M', man_path, '-a', 'inochi'
|
9
|
-
# try to display HTML version of help manual
|
10
|
-
man_html = man_path + '.html'
|
11
|
-
unless %w[$BROWSER open start].any? {|b| system "#{b} #{man_html}" }
|
12
|
-
# no luck; direct user to project website
|
13
|
-
puts "See #{Inochi::WEBSITE}"
|
14
|
-
end
|
15
|
-
end
|
6
|
+
system 'man', '-M', File.join(Inochi::INSTDIR, 'man'), 'inochi' or
|
7
|
+
warn "Could not display the help manual.\nSee #{Inochi::WEBSITE} instead."
|
16
8
|
exit
|
17
9
|
elsif ARGV.delete('-v') or ARGV.delete('--version')
|
18
10
|
puts Inochi::VERSION
|
data/lib/inochi/engine.rb
CHANGED
@@ -11,7 +11,13 @@ module Inochi
|
|
11
11
|
include Inochi::Generate
|
12
12
|
|
13
13
|
def run
|
14
|
-
|
14
|
+
register_init_task
|
15
|
+
|
16
|
+
if has_project_config?
|
17
|
+
load_project_config
|
18
|
+
register_rake_tasks
|
19
|
+
end
|
20
|
+
|
15
21
|
run_rake_tasks
|
16
22
|
end
|
17
23
|
|
@@ -42,6 +48,74 @@ module Inochi
|
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
51
|
+
def register_init_task
|
52
|
+
desc 'Instill Inochi into current directory.'
|
53
|
+
task :init do
|
54
|
+
unless project_name = ENV['project']
|
55
|
+
raise ArgumentError, 'project name not specified'
|
56
|
+
end
|
57
|
+
|
58
|
+
library_name = Engine.calc_library_name(project_name)
|
59
|
+
package_name = ENV['package'] || Engine.calc_package_name(library_name)
|
60
|
+
|
61
|
+
project_version = '0.0.0'
|
62
|
+
project_release = Time.now.strftime('%F')
|
63
|
+
|
64
|
+
command_file = "bin/#{package_name}"
|
65
|
+
create_from_rbs binding, command_file, 'command'
|
66
|
+
chmod 0755, command_file
|
67
|
+
|
68
|
+
create_from_rbs binding, PROJECT_CONFIG_FILE
|
69
|
+
|
70
|
+
create_from_rbs binding, "lib/#{package_name}.rb", 'library'
|
71
|
+
create_from_rbs binding, "lib/#{package_name}/inochi.rb"
|
72
|
+
|
73
|
+
create_from_rbs binding, 'test/runner', 'test_runner'
|
74
|
+
chmod 0755, 'test/runner'
|
75
|
+
create_from_rbs binding, 'test/helper.rb', 'test_helper.rb'
|
76
|
+
create_from_rbs binding, "test/#{package_name}_test.rb", 'library_test.rb'
|
77
|
+
|
78
|
+
create_from_rbs binding, 'LICENSE'
|
79
|
+
create_from_rbs binding, 'MANUAL'
|
80
|
+
create_from_rbs binding, 'SYNOPSIS'
|
81
|
+
create_from_rbs binding, 'README'
|
82
|
+
create_from_rbs binding, 'INSTALL'
|
83
|
+
create_from_rbs binding, 'USAGE'
|
84
|
+
create_from_rbs binding, 'HACKING'
|
85
|
+
create_from_rbs binding, 'HISTORY'
|
86
|
+
create_from_rbs binding, 'CREDITS'
|
87
|
+
create_from_rbs binding, 'BEYOND'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
PROJECT_CONFIG_FILE = 'inochi.conf'
|
92
|
+
|
93
|
+
def has_project_config?
|
94
|
+
File.exist? PROJECT_CONFIG_FILE
|
95
|
+
end
|
96
|
+
|
97
|
+
def load_project_config
|
98
|
+
@project_config = YAML.load_file(PROJECT_CONFIG_FILE).to_hash
|
99
|
+
|
100
|
+
# load the project module
|
101
|
+
library_file = Dir['lib/*/inochi.rb'].first
|
102
|
+
package_name = File.basename(File.dirname(library_file))
|
103
|
+
library_name = File.read(library_file)[/\b(module|class)\b\s+(\w+)/, 2]
|
104
|
+
|
105
|
+
$LOAD_PATH.unshift 'lib'
|
106
|
+
require "#{package_name}/inochi"
|
107
|
+
|
108
|
+
@project_module = Object.const_get(library_name)
|
109
|
+
@project_package_name = package_name
|
110
|
+
@project_library_name = library_name
|
111
|
+
@project_gem_file = "#{@project_package_name}-#{@project_module::VERSION}.gem"
|
112
|
+
|
113
|
+
rescue => error
|
114
|
+
error.message.insert 0,
|
115
|
+
"Could not load project configuration file #{PROJECT_CONFIG_FILE.inspect}: "
|
116
|
+
raise error
|
117
|
+
end
|
118
|
+
|
45
119
|
TEMPLATE_DIR = File.join(File.dirname(__FILE__), 'templates')
|
46
120
|
|
47
121
|
##
|
data/lib/inochi/inochi.rb
CHANGED
@@ -18,12 +18,12 @@ module Inochi
|
|
18
18
|
##
|
19
19
|
# Number of this release of this project.
|
20
20
|
#
|
21
|
-
VERSION = '
|
21
|
+
VERSION = '5.0.0'
|
22
22
|
|
23
23
|
##
|
24
24
|
# Date of this release of this project.
|
25
25
|
#
|
26
|
-
RELDATE = '2010-07
|
26
|
+
RELDATE = '2010-08-07'
|
27
27
|
|
28
28
|
##
|
29
29
|
# Description of this release of this project.
|
@@ -44,14 +44,14 @@ module Inochi
|
|
44
44
|
#
|
45
45
|
# RUNTIME = {
|
46
46
|
# # this project needs exactly version 1.2.3 of the "an_example" gem
|
47
|
-
#
|
47
|
+
# 'an_example' => [ '1.2.3' ],
|
48
48
|
#
|
49
49
|
# # this project needs at least version 1.2 (but not
|
50
50
|
# # version 1.2.4 or newer) of the "another_example" gem
|
51
|
-
#
|
51
|
+
# 'another_example' => [ '>= 1.2' , '< 1.2.4' ],
|
52
52
|
#
|
53
53
|
# # this project needs any version of the "yet_another_example" gem
|
54
|
-
#
|
54
|
+
# 'yet_another_example' => [],
|
55
55
|
# }
|
56
56
|
#
|
57
57
|
RUNTIME = {
|
@@ -60,7 +60,6 @@ module Inochi
|
|
60
60
|
'mechanize' => [ '~> 1' , '< 2' ], # for publishing announcements
|
61
61
|
'nokogiri' => [ '>= 1.4' , '< 2' ], # for parsing HTML and XML
|
62
62
|
'rake' => [ '>= 0.8.4' , '< 1' ], # for Inochi::Engine
|
63
|
-
'ronn' => [ '>= 0.7.0' , '< 1' ], # for making UNIX man pages
|
64
63
|
'yard' => [ '>= 0.5.8' , '< 1' ], # for making API documentation
|
65
64
|
}
|
66
65
|
|
@@ -71,11 +70,11 @@ module Inochi
|
|
71
70
|
#
|
72
71
|
# DEVTIME = {
|
73
72
|
# # this project needs exactly version 1.2.3 of the "an_example" gem
|
74
|
-
#
|
73
|
+
# 'an_example' => [ '1.2.3' ],
|
75
74
|
#
|
76
75
|
# # this project needs at least version 1.2 (but not
|
77
76
|
# # version 1.2.4 or newer) of the "another_example" gem
|
78
|
-
#
|
77
|
+
# 'another_example' => [ '>= 1.2' , '< 1.2.4' ],
|
79
78
|
#
|
80
79
|
# # this project needs any version of the "yet_another_example" gem
|
81
80
|
# "yet_another_example" => [],
|
data/lib/inochi/tasks/2-api.rake
CHANGED
@@ -12,10 +12,7 @@ file @api_dst => FileList['lib/**/*.rb'].include('LICENSE') do
|
|
12
12
|
YARD::Rake::YardocTask.new(inner_task_name) do |yardoc|
|
13
13
|
yardoc.options = [
|
14
14
|
'--output-dir', @api_dir,
|
15
|
-
'--title',
|
16
|
-
Rake::Task[:@project].invoke
|
17
|
-
@project_module.inspect
|
18
|
-
),
|
15
|
+
'--title', @project_module.inspect,
|
19
16
|
'--readme', 'LICENSE',
|
20
17
|
'--no-private'
|
21
18
|
]
|
data/lib/inochi/tasks/3-man.rake
CHANGED
@@ -1,70 +1,72 @@
|
|
1
|
-
@
|
1
|
+
@man_asciidoc_src = FileList['MANUAL', '[A-Z]*[A-Z]']
|
2
|
+
@man_asciidoc_dst = 'man.txt'
|
3
|
+
|
2
4
|
@man_html_dst = 'man.html'
|
3
|
-
@
|
4
|
-
@man_roff_dst_glob = 'man/man*/*.?{,.gz}'
|
5
|
+
@man_roff_dst = "man/man1/#{@project_package_name}.1"
|
5
6
|
|
6
7
|
desc 'Build the help manual.'
|
7
|
-
task :man => @man_html_dst
|
8
|
+
task :man => [@man_html_dst, @man_roff_dst]
|
8
9
|
|
9
|
-
|
10
|
-
Rake::Task[:@man_doc].invoke
|
10
|
+
#-----------------------------------------------------------------------------
|
11
11
|
|
12
|
-
|
12
|
+
# Run manual through Ember to produce a single input file for AsciiDoc.
|
13
|
+
file @man_asciidoc_dst => @man_asciidoc_src do
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
input = [
|
16
|
+
":revdate: #{@project_module::RELDATE}",
|
17
|
+
":revnumber: #{@project_module::VERSION}",
|
18
|
+
"= #{@project_package_name}(1)",
|
19
|
+
'== NAME',
|
20
|
+
"#{@project_package_name} - #{@project_module::TAGLINE}",
|
21
|
+
"%+ #{@man_asciidoc_src.first.inspect}",
|
22
|
+
].join("\n\n")
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
options = {
|
25
|
+
:shorthand => true,
|
26
|
+
:unindent => true,
|
27
|
+
:infer_end => true
|
28
|
+
}
|
22
29
|
|
23
|
-
|
24
|
-
|
30
|
+
require 'ember'
|
31
|
+
output = Ember::Template.new(input, options).render
|
32
|
+
|
33
|
+
File.write @man_asciidoc_dst, output
|
25
34
|
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
require 'date'
|
52
|
-
ronn_opts = {
|
53
|
-
:date => Date.parse(@project_module::RELDATE),
|
54
|
-
:manual => "Version #{@project_module::VERSION}",
|
55
|
-
:styles => %w[ man toc 80c ]
|
56
|
-
}
|
57
|
-
ronn_file = "#{@project_package_name}.1.ronn"
|
58
|
-
|
59
|
-
require 'ronn'
|
60
|
-
@man_doc = Ronn::Document.new(ronn_file, ronn_opts) { ronn_input }
|
61
|
-
end
|
36
|
+
CLEAN.include @man_asciidoc_dst
|
37
|
+
|
38
|
+
#-----------------------------------------------------------------------------
|
39
|
+
|
40
|
+
build_asciidoc_args = lambda do
|
41
|
+
[('-v' if Rake.application.options.trace), @man_asciidoc_dst].compact
|
42
|
+
end
|
43
|
+
|
44
|
+
file @man_html_dst => @man_asciidoc_dst do
|
45
|
+
atts = %W[data-uri toc stylesheet=#{__FILE__}.css] +
|
46
|
+
Array(@project_config[:man_asciidoc_attributes])
|
47
|
+
|
48
|
+
opts = atts.map {|a| ['-a', a] }.flatten
|
49
|
+
args = opts + build_asciidoc_args.call
|
50
|
+
|
51
|
+
sh 'asciidoc', '-o', @man_html_dst, *args
|
52
|
+
end
|
53
|
+
|
54
|
+
CLOBBER.include @man_html_dst
|
55
|
+
|
56
|
+
file @man_roff_dst => @man_asciidoc_dst do
|
57
|
+
args = build_asciidoc_args.call
|
58
|
+
mkdir_p dir = File.dirname(@man_roff_dst)
|
59
|
+
sh 'a2x', '-f', 'manpage', '-D', dir, *args
|
62
60
|
end
|
63
61
|
|
62
|
+
CLOBBER.include @man_roff_dst
|
63
|
+
|
64
|
+
#-----------------------------------------------------------------------------
|
65
|
+
|
64
66
|
task :@man_html do
|
65
67
|
unless @man_html
|
66
|
-
Rake::Task[
|
67
|
-
@man_html = @
|
68
|
+
Rake::Task[@man_html_dst].invoke
|
69
|
+
@man_html = File.read(@man_html_dst)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
@@ -76,4 +78,3 @@ task :@man_html_dom do
|
|
76
78
|
@man_html_dom = Nokogiri::HTML(@man_html)
|
77
79
|
end
|
78
80
|
end
|
79
|
-
|
@@ -0,0 +1,49 @@
|
|
1
|
+
div.sectionbody, body {
|
2
|
+
font-family: sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
div.sectionbody {
|
6
|
+
line-height: 1.5em;
|
7
|
+
}
|
8
|
+
|
9
|
+
a {
|
10
|
+
text-decoration: none;
|
11
|
+
}
|
12
|
+
|
13
|
+
a:hover {
|
14
|
+
text-decoration: underline;
|
15
|
+
}
|
16
|
+
|
17
|
+
a:visited {
|
18
|
+
color: #800080;
|
19
|
+
}
|
20
|
+
|
21
|
+
body {
|
22
|
+
max-width: 48em; /* approximately 80 characters wide */
|
23
|
+
margin-left: 15em;
|
24
|
+
}
|
25
|
+
|
26
|
+
#toc {
|
27
|
+
position: fixed;
|
28
|
+
top: 0;
|
29
|
+
left: 0;
|
30
|
+
bottom: 0;
|
31
|
+
width: 13em;
|
32
|
+
padding: 0.5em;
|
33
|
+
padding-bottom: 1.5em;
|
34
|
+
margin: 0 !important;
|
35
|
+
overflow: auto;
|
36
|
+
}
|
37
|
+
|
38
|
+
#toc a {
|
39
|
+
color: #083194 !important;
|
40
|
+
}
|
41
|
+
|
42
|
+
#toc .toclevel1 {
|
43
|
+
margin-top: 1.25em;
|
44
|
+
}
|
45
|
+
|
46
|
+
#toc .toclevel2 {
|
47
|
+
margin-top: 0.25em;
|
48
|
+
display: list-item;
|
49
|
+
}
|
data/lib/inochi/tasks/4-ann.rake
CHANGED
@@ -7,7 +7,6 @@ task :ann => %w[ ann:html ann:text ann:feed ]
|
|
7
7
|
|
8
8
|
task :@ann_subject do
|
9
9
|
unless @ann_subject
|
10
|
-
Rake::Task[:@project].invoke
|
11
10
|
@ann_subject = @ann_subject_prefix +
|
12
11
|
@project_module::PROJECT + ' ' + @project_module::VERSION
|
13
12
|
end
|
@@ -17,10 +16,12 @@ end
|
|
17
16
|
task :@ann_nfo_html_nodes do
|
18
17
|
unless @ann_nfo_html_nodes
|
19
18
|
begin
|
20
|
-
head, body = fetch_nodes_between(
|
19
|
+
head, body = fetch_nodes_between(
|
20
|
+
'h2#_description + div', 'h1,h2,h3,h4,h5,h6'
|
21
|
+
)
|
21
22
|
rescue => error
|
22
23
|
error.message.insert 0,
|
23
|
-
"The manual lacks a <
|
24
|
+
"The manual lacks a <h2> DESCRIPTION heading.\n"
|
24
25
|
raise error
|
25
26
|
end
|
26
27
|
|
@@ -39,10 +40,12 @@ end
|
|
39
40
|
task :@ann_rel_html_body_nodes do
|
40
41
|
unless @ann_rel_html_body_nodes
|
41
42
|
begin
|
42
|
-
head, body = fetch_nodes_between(
|
43
|
+
head, body = fetch_nodes_between(
|
44
|
+
'h2#_history + div > h3', 'h1,h2,h3'
|
45
|
+
)
|
43
46
|
rescue => error
|
44
47
|
error.message.insert 0,
|
45
|
-
"The manual lacks a <
|
48
|
+
"The manual lacks a <h3> heading beneath the <h2> HISTORY heading.\n"
|
46
49
|
raise error
|
47
50
|
end
|
48
51
|
|
@@ -55,10 +58,12 @@ end
|
|
55
58
|
task :@project_authors_html_nodes do
|
56
59
|
unless @project_authors_html_nodes
|
57
60
|
begin
|
58
|
-
head, body = fetch_nodes_between(
|
61
|
+
head, body = fetch_nodes_between(
|
62
|
+
'h2#_authors + div', 'h1,h2,h3,h4,h5,h6'
|
63
|
+
)
|
59
64
|
rescue => error
|
60
65
|
error.message.insert 0,
|
61
|
-
"The manual lacks content under a <
|
66
|
+
"The manual lacks content under a <h2> AUTHORS heading.\n"
|
62
67
|
raise error
|
63
68
|
end
|
64
69
|
|
@@ -87,10 +92,13 @@ task :@ann_html do
|
|
87
92
|
</center>
|
88
93
|
#{@ann_nfo_html_nodes.join}
|
89
94
|
#{@ann_rel_html_title_node}
|
90
|
-
#{@ann_rel_html_body_nodes.map(&:
|
91
|
-
}.
|
92
|
-
|
93
|
-
|
95
|
+
#{@ann_rel_html_body_nodes.map(&:to_html).join}
|
96
|
+
}.
|
97
|
+
strip.
|
98
|
+
#
|
99
|
+
# resolve internal hyperlinks to the project website
|
100
|
+
#
|
101
|
+
gsub(/<a href=['"]?(?=#)/) { $& + @project_module::WEBSITE }
|
94
102
|
end
|
95
103
|
end
|
96
104
|
|
@@ -110,7 +118,7 @@ end
|
|
110
118
|
desc 'Build HTML announcement.'
|
111
119
|
task 'ann:html' => @ann_html_dst
|
112
120
|
|
113
|
-
file @ann_html_dst => @
|
121
|
+
file @ann_html_dst => @man_asciidoc_src do
|
114
122
|
Rake::Task[:@ann_html].invoke
|
115
123
|
File.write @ann_html_dst, @ann_html
|
116
124
|
end
|
@@ -126,7 +134,7 @@ CLOBBER.include @ann_html_dst
|
|
126
134
|
desc 'Build plain text announcement.'
|
127
135
|
task 'ann:text' => @ann_text_dst
|
128
136
|
|
129
|
-
file @ann_text_dst => @
|
137
|
+
file @ann_text_dst => @man_asciidoc_src do
|
130
138
|
Rake::Task[:@ann_text].invoke
|
131
139
|
File.write @ann_text_dst, @ann_text
|
132
140
|
end
|
@@ -142,8 +150,7 @@ CLOBBER.include @ann_text_dst
|
|
142
150
|
desc 'Build RSS feed announcement.'
|
143
151
|
task 'ann:feed' => @ann_feed_dst
|
144
152
|
|
145
|
-
file @ann_feed_dst => @
|
146
|
-
Rake::Task[:@project].invoke
|
153
|
+
file @ann_feed_dst => @man_asciidoc_src do
|
147
154
|
Rake::Task[:@ann_nfo_html_nodes].invoke
|
148
155
|
Rake::Task[:@ann_rel_html_body_nodes].invoke
|
149
156
|
|
@@ -158,7 +165,7 @@ file @ann_feed_dst => @man_src do
|
|
158
165
|
require 'time'
|
159
166
|
item.date = Time.parse(@project_module::RELDATE)
|
160
167
|
item.title = @ann_rel_html_title_node.inner_text
|
161
|
-
item.description = @ann_rel_html_body_nodes.join
|
168
|
+
item.description = @ann_rel_html_body_nodes.map(&:to_html).join
|
162
169
|
end
|
163
170
|
|
164
171
|
File.write @ann_feed_dst, rss
|
@@ -180,13 +187,13 @@ end
|
|
180
187
|
def fetch_nodes_between head_selector, tail_selector
|
181
188
|
Rake::Task[:@man_html_dom].invoke
|
182
189
|
|
183
|
-
head = @man_html_dom.at(head_selector)
|
190
|
+
head = @man_html_dom.at(head_selector) or raise head_selector
|
184
191
|
body = []
|
185
192
|
|
186
193
|
tail = head
|
187
|
-
|
188
|
-
|
189
|
-
|
194
|
+
body << tail while
|
195
|
+
tail = tail.next_sibling and
|
196
|
+
not tail.matches? tail_selector
|
190
197
|
|
191
198
|
[head, body, tail]
|
192
199
|
end
|
@@ -197,34 +204,19 @@ end
|
|
197
204
|
# in the HTML document and (2) it runs on all major platforms
|
198
205
|
#
|
199
206
|
def convert_html_to_text html
|
200
|
-
# lynx's -dump option requires a
|
207
|
+
# lynx's -dump option requires a *.html file
|
201
208
|
require 'tempfile'
|
202
209
|
tmp_file = Tempfile.new('inochi').path + '.html'
|
203
210
|
|
204
211
|
begin
|
205
|
-
File.write tmp_file, html
|
206
|
-
|
207
|
-
`lynx -dump #{tmp_file} -width 70`.
|
212
|
+
File.write tmp_file, html.to_s.
|
208
213
|
#
|
209
|
-
#
|
210
|
-
# by adding a blank line between them
|
214
|
+
# add space between subsections and list items to improve readability
|
211
215
|
#
|
212
|
-
gsub(/(
|
216
|
+
gsub(/(?=<div class="title">|<li>)/, '<p> </p>')
|
217
|
+
|
218
|
+
`lynx -dump #{tmp_file} -width 70`
|
213
219
|
ensure
|
214
220
|
File.delete tmp_file
|
215
221
|
end
|
216
222
|
end
|
217
|
-
|
218
|
-
##
|
219
|
-
# Converts relative URLs in the given HTML into
|
220
|
-
# absolute URLs bound to the given base URL.
|
221
|
-
#
|
222
|
-
# http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax
|
223
|
-
#
|
224
|
-
def resolve_html_links html, base_url = nil
|
225
|
-
Rake::Task[:@project].invoke
|
226
|
-
base_url ||= @project_module::WEBSITE
|
227
|
-
|
228
|
-
require 'cgi'
|
229
|
-
"<base href='#{CGI.escapeHTML base_url}'/> #{html}"
|
230
|
-
end
|