helpconverter 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +7 -0
- data/README +34 -0
- data/bin/jh2eh +75 -0
- data/demo/dog_breeds.jar +0 -0
- data/lib/eclipsehelp.rb +120 -0
- data/lib/helpconverter.rb +20 -0
- data/lib/javahelp.rb +134 -0
- data/tests/tc_javahelp.rb +21 -0
- data/tests/tc_jh2eh.rb +104 -0
- data/tests/tc_plugin.rb +134 -0
- data/tests/ts_help_converter.rb +7 -0
- metadata +74 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2006 Ryan L. Bell
|
2
|
+
|
3
|
+
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:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
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
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
= Help Converter
|
3
|
+
Converts help files from one format to another.
|
4
|
+
|
5
|
+
== Synopsis
|
6
|
+
Help Converter is used to convert help files from one format to another. Only one
|
7
|
+
conversion is currently supported: JavaHelp to Eclipse plugin. This can be useful
|
8
|
+
if you are moving an existing Java application from Swing to Eclipse RCP, or if you
|
9
|
+
are managing help for Eclipse Plugins using RoboHelp.
|
10
|
+
|
11
|
+
The intent is to support other help formats, I'm just not sure which ones yet.
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
jh2eh [OPTIONS] <javahelp.jar> <eclipse_versioned.jar>
|
15
|
+
|
16
|
+
== Limitations
|
17
|
+
=== Javahelp
|
18
|
+
- Only Javahelp jars are supported.
|
19
|
+
- Merged help files are not supported.
|
20
|
+
|
21
|
+
=== Eclipse
|
22
|
+
- No context help information is generated.
|
23
|
+
|
24
|
+
=== General
|
25
|
+
- You must have write access to the _source_ directory, as well as the destination directory.
|
26
|
+
Hopefully this requirement will be cleared up soon, but there you have it.
|
27
|
+
- Plugins generated are compatible with Eclipse version >= 3.1.
|
28
|
+
|
29
|
+
== License
|
30
|
+
License: http://www.opensource.org/licenses/mit-license.html
|
31
|
+
|
32
|
+
== Support
|
33
|
+
Support can be received at help converter site[http://helpconverter.rubyforge.org/] by entering a bug or support request on the {tracker page}[http://rubyforge.org/tracker/?group_id=1921]
|
34
|
+
|
data/bin/jh2eh
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# == Synpopsis
|
4
|
+
#
|
5
|
+
# jh2eh: Converts javahelp jar files to an Eclipse plugin jar
|
6
|
+
#
|
7
|
+
# == Usage
|
8
|
+
#
|
9
|
+
# jh2eh [OPTIONS] <javahelp.jar> <eclipse_versioned.jar>
|
10
|
+
#
|
11
|
+
# -n --eclipse_name::
|
12
|
+
# override user facing name of the eclipse plugin
|
13
|
+
#
|
14
|
+
# -r --eclipse_version::
|
15
|
+
# override version of the eclipse plugin
|
16
|
+
#
|
17
|
+
# -d --vendor::
|
18
|
+
# name of the vender that should appear in the help plugin
|
19
|
+
#
|
20
|
+
# -h -? --help::
|
21
|
+
# show this message
|
22
|
+
#
|
23
|
+
# -v --version::
|
24
|
+
# show version of this script
|
25
|
+
#
|
26
|
+
#
|
27
|
+
|
28
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
29
|
+
|
30
|
+
require 'helpconverter'
|
31
|
+
|
32
|
+
options = {}
|
33
|
+
|
34
|
+
begin
|
35
|
+
|
36
|
+
opts = OptionParser.new do |opts|
|
37
|
+
opts.banner = 'jh2eh [OPTIONS] <javahelp.jar> <eclipse_versioned.jar>'
|
38
|
+
|
39
|
+
opts.on("-r", "--eclipse_version [VERSION]", 'override version of the eclipse plugin') do |r|
|
40
|
+
options[:eclipse_version] = r
|
41
|
+
end
|
42
|
+
opts.on("-n", "--eclipse_name [NAME]",
|
43
|
+
'override user facing name of',
|
44
|
+
'the eclipse plugin') do |n|
|
45
|
+
options[:eclipse_name] = n
|
46
|
+
end
|
47
|
+
opts.on("-d", "--vendor [COMPANY]",
|
48
|
+
'name of the vender that should',
|
49
|
+
'appear in the help plugin') do |d|
|
50
|
+
options[:vendor] = d
|
51
|
+
end
|
52
|
+
opts.on_tail("-h", "--help", 'show this message') do
|
53
|
+
puts opts; exit
|
54
|
+
end
|
55
|
+
opts.on_tail("-v", "--version", 'show version of this script') do
|
56
|
+
puts "Help Converter: Javahelp to Eclipse Help: #@@version"; exit
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.parse!(ARGV)
|
62
|
+
|
63
|
+
java_help = ARGV.shift
|
64
|
+
eclipse_help = ARGV.shift
|
65
|
+
|
66
|
+
convert(:from => java_help, :to => eclipse_help) do |eh|
|
67
|
+
eh.name = options[:eclipse_name] unless options[:eclipse_name].nil?
|
68
|
+
eh.version = options[:eclipse_version] unless options[:eclipse_version].nil?
|
69
|
+
eh.vendor = options[:vendor] unless options[:vendor].nil?
|
70
|
+
end
|
71
|
+
rescue RuntimeError => err
|
72
|
+
print "\n#{err}\n"
|
73
|
+
#print err.backtrace.join("\n")
|
74
|
+
puts opts
|
75
|
+
end
|
data/demo/dog_breeds.jar
ADDED
Binary file
|
data/lib/eclipsehelp.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
#:title: Help Converter
|
2
|
+
# The Eclipse module contains the classes used to write out the Eclipse plugin
|
3
|
+
# files.
|
4
|
+
module Eclipse
|
5
|
+
|
6
|
+
# The plugin class generates the an Eclipse plugin jar. This plugin jar
|
7
|
+
# extends the eclipse help toc and can be used as drop-in help for any
|
8
|
+
# Eclipse based application.
|
9
|
+
#
|
10
|
+
# It is important to note that this generates a plugin compatable with
|
11
|
+
# Eclipse >=3.1.
|
12
|
+
#
|
13
|
+
# More information on Eclipse can be found at the Eclipse[http://eclipse.org/]
|
14
|
+
# web site.
|
15
|
+
class Plugin
|
16
|
+
attr_accessor :name, :id, :version, :vendor, :tocs
|
17
|
+
|
18
|
+
def initialize(plugin)
|
19
|
+
raise "Eclipse plugin is missing" if plugin.nil? or plugin.length == 0
|
20
|
+
@plugin = plugin
|
21
|
+
@tocs = []
|
22
|
+
@vendor = nil
|
23
|
+
parse(plugin)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Make Eclipse Plugin help from the old help object. old_help need to
|
27
|
+
# implement the methods convert_tocs and copyContentsTo(zipFile). An
|
28
|
+
# example of this implementation is JavaHelp::JarConverter
|
29
|
+
def make_file_from(old_help)
|
30
|
+
@tocs = old_help.convert_tocs
|
31
|
+
|
32
|
+
expanded_file = File.expand_path(@plugin)
|
33
|
+
parent_path = File.dirname(expanded_file)
|
34
|
+
FileUtils::mkpath(parent_path) unless File.exists?(parent_path)
|
35
|
+
if @version.nil?
|
36
|
+
puts "No plugin version set. Using 1.0.0"
|
37
|
+
@version = '1.0.0'
|
38
|
+
end
|
39
|
+
file_name = File.join(parent_path, "#{@id}_#{@version}.jar")
|
40
|
+
File.delete(file_name) if File.exists?(file_name)
|
41
|
+
|
42
|
+
f = Zip::ZipFile.new(file_name, Zip::ZipFile::CREATE)
|
43
|
+
begin
|
44
|
+
old_help.copyContentsTo(f) do |entry|
|
45
|
+
lower_name = entry.name.downcase
|
46
|
+
ext = File.extname(lower_name)
|
47
|
+
invalid_exts = ['.mf', '.hs', '.jhm']
|
48
|
+
entry.file? unless invalid_exts.include?(ext)
|
49
|
+
end
|
50
|
+
f.get_output_stream('META-INF/MANIFEST.MF') {|out| write_manifest(out)}
|
51
|
+
f.get_output_stream('plugin.xml') {|out| write_pluginxml(out)}
|
52
|
+
f.get_output_stream('toc_links.xml') {|out| write_toc_links(out)}
|
53
|
+
@tocs.each do |toc|
|
54
|
+
f.get_output_stream(toc.name) {|out| out.write(toc.xml)}
|
55
|
+
end
|
56
|
+
puts file_name
|
57
|
+
ensure
|
58
|
+
f.close unless f.nil?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Writes the plugin manifest with the name, id, version, and vendor of
|
63
|
+
# the plugin
|
64
|
+
def write_manifest(out)
|
65
|
+
out << "Manifest-Version: 1.0\n"
|
66
|
+
out << "Bundle-ManifestVersion: 2\n"
|
67
|
+
out << "Bundle-Name: #@name\n"
|
68
|
+
out << "Bundle-SymbolicName: #@id; singleton:=true\n"
|
69
|
+
out << "Bundle-Version: #@version\n"
|
70
|
+
out << "Bundle-Localization: plugin\n"
|
71
|
+
unless @vendor.nil?
|
72
|
+
out << "Bundle-Vendor: #@vendor\n"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Writes the plugin xml that extends org.eclipse.help.toc
|
77
|
+
def write_pluginxml(out)
|
78
|
+
raise "I couldn't find any table of contents." unless @tocs.size > 0
|
79
|
+
|
80
|
+
out << %Q{<?xml version="1.0" encoding="UTF-8"?>\n}
|
81
|
+
out << %Q{<?eclipse version="3.0"?>\n}
|
82
|
+
out << %Q{<plugin>\n}
|
83
|
+
out << %Q{ <extension point="org.eclipse.help.toc">\n}
|
84
|
+
@tocs.each do |toc|
|
85
|
+
out << %Q{ <toc file="#{toc.name}"/>\n}
|
86
|
+
end
|
87
|
+
out << %Q{ <toc file="toc_links.xml" primary="true"/>\n}
|
88
|
+
out << %Q{ </extension>\n}
|
89
|
+
out << %Q{</plugin>\n}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Writes toc_links.xml file.
|
93
|
+
#
|
94
|
+
# The purpose of this file is to assemble references to all of the
|
95
|
+
# converted table of contents files.
|
96
|
+
def write_toc_links(out)
|
97
|
+
out << %Q{<?xml version="1.0" encoding="UTF-8"?>\n}
|
98
|
+
out << %Q{<?NLS TYPE="org.eclipse.help.toc"?>\n\n}
|
99
|
+
out << %Q{<toc label="#{@name}">\n}
|
100
|
+
@tocs.each do |toc|
|
101
|
+
out << %Q{ <link toc="#{toc.name}"/>\n}
|
102
|
+
end
|
103
|
+
out << %Q{</toc>\n}
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
# Parses the name of the plugin to assert the name, id, and version number
|
109
|
+
# of the plugin.
|
110
|
+
def parse(plugin_name)
|
111
|
+
base_file = File.basename(plugin_name, '.jar')
|
112
|
+
id_candidate, version = base_file.split('_')
|
113
|
+
@id = id_candidate unless id_candidate.nil? or id_candidate.length == 0
|
114
|
+
@name = @id.split('.').pop.capitalize unless @id.nil?
|
115
|
+
@version = version unless version.nil? or version.length == 0
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'zip/zipfilesystem'
|
4
|
+
require 'eclipsehelp'
|
5
|
+
require 'javahelp'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'builder'
|
8
|
+
require 'optparse'
|
9
|
+
require 'stringio'
|
10
|
+
|
11
|
+
@@version = '0.1.0'
|
12
|
+
|
13
|
+
# Converts a Javahelp jar file to the specified Eclipse plugin.
|
14
|
+
def convert(options)
|
15
|
+
old_help = JavaHelp::JarConverter.new(options[:from])
|
16
|
+
new_help = Eclipse::Plugin.new(options[:to])
|
17
|
+
yield new_help
|
18
|
+
new_help.make_file_from(old_help)
|
19
|
+
end
|
20
|
+
|
data/lib/javahelp.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'helpconverter'
|
2
|
+
|
3
|
+
# Contains classes for converting Javahelp into TOC objects
|
4
|
+
# that can be used to generate help in other formats.
|
5
|
+
module JavaHelp
|
6
|
+
|
7
|
+
# This class converts Javahelp jar files to TOC objects.
|
8
|
+
class JarConverter
|
9
|
+
attr_reader :jar_file, :maps, :urls
|
10
|
+
|
11
|
+
def initialize(jar_file)
|
12
|
+
raise "Javehelp file must be supplied" unless jar_file
|
13
|
+
@jar_file = jar_file
|
14
|
+
init_maps
|
15
|
+
init_urls
|
16
|
+
end
|
17
|
+
|
18
|
+
# Converts the Javahelp table of contents files to TOC objects and
|
19
|
+
# returns them in an array.
|
20
|
+
def convert_tocs
|
21
|
+
tocs = []
|
22
|
+
|
23
|
+
Zip::ZipFile.open(@jar_file) do |zf|
|
24
|
+
zf.dir.foreach('.') do |entry|
|
25
|
+
if File.extname(entry).downcase.eql?('.hs')
|
26
|
+
contents = zf.file.read(entry)
|
27
|
+
doc = REXML::Document.new(contents)
|
28
|
+
doc.elements.each('helpset/view') do |e|
|
29
|
+
view_type = e.elements['type'].texts.join
|
30
|
+
if view_type.eql?('javax.help.TOCView')
|
31
|
+
toc_name = e.elements['data'].texts.join
|
32
|
+
tocs << TOC.new(toc_name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
tocs.each do |toc|
|
38
|
+
contents = zf.file.read(toc.name)
|
39
|
+
doc = REXML::Document.new(contents)
|
40
|
+
root = doc.root
|
41
|
+
io = StringIO.new
|
42
|
+
xml = Builder::XmlMarkup.new(:indent => 2, :target => io)
|
43
|
+
xml.instruct!
|
44
|
+
xml.toc(:label => 'toc') do
|
45
|
+
root.elements.each do |e|
|
46
|
+
assemble_tags(e, xml)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
toc.xml = io.string
|
50
|
+
end
|
51
|
+
end
|
52
|
+
return tocs
|
53
|
+
end
|
54
|
+
|
55
|
+
# Copy the contents of the Javahelp jar into the target ZipFile.
|
56
|
+
# The block is called for each entry in the Javahelp file. If the block
|
57
|
+
# returns false, the entry is not copied.
|
58
|
+
def copyContentsTo(target)
|
59
|
+
Zip::ZipFile.open(@jar_file) do |zf|
|
60
|
+
zf.each do |entry|
|
61
|
+
if (yield(entry))
|
62
|
+
target.get_output_stream(entry) do |out|
|
63
|
+
contents = zf.read(entry.name)
|
64
|
+
out.write(contents)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def assemble_tags(e, xml)
|
74
|
+
attributes = {}
|
75
|
+
label = e.attributes['text']
|
76
|
+
attributes['label'] = label if label
|
77
|
+
target = e.attributes['target']
|
78
|
+
href = @urls[target]
|
79
|
+
attributes['href'] = href if href
|
80
|
+
|
81
|
+
if e.has_elements?
|
82
|
+
xml.topic(attributes) do
|
83
|
+
e.elements.each do |child|
|
84
|
+
assemble_tags(child, xml)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
else
|
88
|
+
xml.topic(attributes)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def init_maps
|
93
|
+
@maps = []
|
94
|
+
Zip::ZipFile.open(@jar_file) do |zf|
|
95
|
+
zf.dir.foreach('.') do |entry|
|
96
|
+
if File.extname(entry).downcase.eql?('.hs')
|
97
|
+
contents = zf.file.read(entry)
|
98
|
+
doc = REXML::Document.new(contents)
|
99
|
+
doc.elements.each('helpset/maps/mapref') do |e|
|
100
|
+
@maps << e.attributes['location']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def init_urls
|
108
|
+
@urls = {}
|
109
|
+
Zip::ZipFile.open(@jar_file) do |zf|
|
110
|
+
@maps.each do |map_file|
|
111
|
+
contents = zf.file.read(map_file)
|
112
|
+
doc = REXML::Document.new(contents)
|
113
|
+
doc.elements.each('/map/mapID') do |e|
|
114
|
+
key = e.attributes['target']
|
115
|
+
value = e.attributes['url']
|
116
|
+
@urls[key] = value
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
# Data class for holding table of contents information.
|
125
|
+
class TOC
|
126
|
+
attr_accessor :xml
|
127
|
+
attr_reader :name
|
128
|
+
|
129
|
+
def initialize(name)
|
130
|
+
@name = name
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helpconverter'
|
3
|
+
|
4
|
+
class TestJavaHelpConverter < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_convert_tocs
|
7
|
+
assert_equal('dog_breeds.xml', @converted.convert_tocs[0].name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_url_maps
|
11
|
+
assert_equal(1, @converted.maps.length)
|
12
|
+
assert_equal(6, @converted.urls.length)
|
13
|
+
assert_not_nil(@converted.urls['jmed_v3_3_0user_manual_htm__toc136709160'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@converted = JavaHelp::JarConverter.new('demo/dog_breeds.jar')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
data/tests/tc_jh2eh.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'helpconverter'
|
4
|
+
|
5
|
+
class TestJavaHelpToEclipseHelp < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def teardown
|
8
|
+
FileUtils.rm_r(['jars']) if File.exists?('jars')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_simple_conversion
|
12
|
+
convert(:from => 'demo/dog_breeds.jar',
|
13
|
+
:to => 'jars/com.myplugin.dogbreeds_3.1.0') do |eh|
|
14
|
+
eh.vendor = "Dogs 'R' Us"
|
15
|
+
end
|
16
|
+
@looking_for = File.join('jars', 'com.myplugin.dogbreeds_3.1.0.jar')
|
17
|
+
assert(File.exists?(@looking_for), "#@looking_for doesn't exist")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_jar_creation
|
21
|
+
convert(:from => "demo/dog_breeds.jar",
|
22
|
+
:to => "jars/com.myplugin.dogbreeds_1.2.4.jar") do |eh|
|
23
|
+
eh.name = "name"
|
24
|
+
eh.id = "com.myplugin.dogbreeds"
|
25
|
+
eh.version = "1.0.0"
|
26
|
+
end
|
27
|
+
@looking_for = File.join('jars', 'com.myplugin.dogbreeds_1.0.0.jar')
|
28
|
+
assert File.exists?(@looking_for), "#{@looking_for} doesn't exist"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_creating_jar_in_subfolder
|
32
|
+
convert(:from => "demo/dog_breeds.jar",
|
33
|
+
:to => 'jars/subfolder/eclipse_help') do |eh|
|
34
|
+
eh.name = 'Dog Breed Help'
|
35
|
+
eh.id = "com.myplugin.dogbreeds"
|
36
|
+
eh.version = "2.0.0"
|
37
|
+
end
|
38
|
+
@looking_for = File.join('jars/subfolder', 'com.myplugin.dogbreeds_2.0.0.jar')
|
39
|
+
assert(File.exists?(@looking_for), "#{@looking_for} doesn't exist")
|
40
|
+
assert_manifest
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_default_place_in
|
44
|
+
convert(:from => "demo/dog_breeds.jar",
|
45
|
+
:to => 'id_0.2.5.jar') do |eh|
|
46
|
+
eh.name = 'Dogs Help'
|
47
|
+
eh.id = 'id'
|
48
|
+
eh.version = '0.2.5'
|
49
|
+
end
|
50
|
+
@looking_for = 'id_0.2.5.jar'
|
51
|
+
assert(File.exists?(@looking_for), "#{@looking_for} is missing")
|
52
|
+
File.delete(@looking_for)
|
53
|
+
assert(!File.exists?(@looking_for))
|
54
|
+
end
|
55
|
+
|
56
|
+
def assert_manifest
|
57
|
+
@zf = Zip::ZipFile.new(@looking_for)
|
58
|
+
manifest = 'META-INF/MANIFEST.MF'
|
59
|
+
manifest_entry = @zf.find_entry(manifest)
|
60
|
+
assert(manifest_entry, 'Manifest is missing')
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_pluginxml
|
64
|
+
test_jar_creation
|
65
|
+
assert_manifest
|
66
|
+
pluginxml = @zf.find_entry('plugin.xml')
|
67
|
+
assert(pluginxml)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_copy_resources
|
71
|
+
test_pluginxml
|
72
|
+
file_name = 'html/akita.html'
|
73
|
+
file_entry = @zf.find_entry(file_name)
|
74
|
+
assert(file_entry, "#{file_name} is missing")
|
75
|
+
|
76
|
+
hs_entry = @zf.find_entry('dog_breeds.hs')
|
77
|
+
assert_nil(hs_entry, "dog_breeds.hs shouldn't be here")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_toc_links_xml
|
81
|
+
test_copy_resources
|
82
|
+
file_name = 'toc_links.xml'
|
83
|
+
file_entry = @zf.find_entry(file_name)
|
84
|
+
assert(file_entry, "#{file_entry} is missing!")
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_id
|
88
|
+
test_simple_conversion
|
89
|
+
assert_manifest
|
90
|
+
manifest = @zf.read('META-INF/MANIFEST.MF')
|
91
|
+
assert_equal(@@expected_manifest, manifest)
|
92
|
+
end
|
93
|
+
|
94
|
+
@@expected_manifest = <<MANIFEST
|
95
|
+
Manifest-Version: 1.0
|
96
|
+
Bundle-ManifestVersion: 2
|
97
|
+
Bundle-Name: Dogbreeds
|
98
|
+
Bundle-SymbolicName: com.myplugin.dogbreeds; singleton:=true
|
99
|
+
Bundle-Version: 3.1.0
|
100
|
+
Bundle-Localization: plugin
|
101
|
+
Bundle-Vendor: Dogs 'R' Us
|
102
|
+
MANIFEST
|
103
|
+
|
104
|
+
end
|
data/tests/tc_plugin.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'helpconverter'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
module Eclipse
|
6
|
+
|
7
|
+
class TestPlugin < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@plugin = Eclipse::Plugin.new('demo/dog_breeds.jar')
|
11
|
+
@plugin.name = 'name'
|
12
|
+
@plugin.id = 'name.id'
|
13
|
+
@plugin.version = '1.0.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_new_plugin
|
17
|
+
assert_equal 'name', @plugin.name
|
18
|
+
assert_equal 'name.id', @plugin.id
|
19
|
+
assert_equal '1.0.0', @plugin.version
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_manifest_writing
|
23
|
+
test_new_plugin
|
24
|
+
string_io = StringIO.new
|
25
|
+
@plugin.write_manifest(string_io)
|
26
|
+
assert_equal @@expected_manifest, string_io.string
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_pluginxml
|
30
|
+
test_new_plugin
|
31
|
+
string_io = StringIO.new
|
32
|
+
assert_raise(RuntimeError) {@plugin.write_pluginxml(string_io)}
|
33
|
+
@plugin.tocs << JavaHelp::TOC.new('toc.xml')
|
34
|
+
@plugin.write_pluginxml(string_io)
|
35
|
+
assert_equal(@@expected_pluginxml, string_io.string)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_pluginxml_2tocs
|
39
|
+
test_pluginxml
|
40
|
+
stringio = StringIO.new
|
41
|
+
@plugin.tocs << JavaHelp::TOC.new('toc2.xml')
|
42
|
+
@plugin.write_pluginxml(stringio)
|
43
|
+
assert_equal(@@expected_pluginxml_2tocs, stringio.string)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_parse_filename
|
47
|
+
eclipse = Eclipse::Plugin.new("com.test.someplugin_1.3.4.jar")
|
48
|
+
assert_equal "com.test.someplugin", eclipse.id
|
49
|
+
assert_equal "1.3.4", eclipse.version
|
50
|
+
assert_equal "Someplugin", eclipse.name
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_parse_filename_noversion
|
54
|
+
eclipse = Eclipse::Plugin.new("com.test.someplugin.jar")
|
55
|
+
assert_equal "com.test.someplugin", eclipse.id
|
56
|
+
assert_nil eclipse.version
|
57
|
+
assert_equal "Someplugin", eclipse.name
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_parse_filename_emptystring
|
61
|
+
assert_raise(RuntimeError){eclipse = Eclipse::Plugin.new('')}
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_parse_filename_nodots
|
65
|
+
eclipse = Eclipse::Plugin.new("someplugin_1.2.jar")
|
66
|
+
assert_equal "someplugin", eclipse.id
|
67
|
+
assert_equal '1.2', eclipse.version
|
68
|
+
assert_equal "Someplugin", eclipse.name
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_parse_filename_noext
|
72
|
+
eclipse = Eclipse::Plugin.new("com.test.someplugin_1.3.4")
|
73
|
+
assert_equal "com.test.someplugin", eclipse.id
|
74
|
+
assert_equal '1.3.4', eclipse.version
|
75
|
+
assert_equal "Someplugin", eclipse.name
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_vendor
|
79
|
+
eclipse = Eclipse::Plugin.new("com.test.plugin_1.2.3")
|
80
|
+
eclipse.vendor = "Some Vendor"
|
81
|
+
assert_equal "com.test.plugin", eclipse.id
|
82
|
+
assert_equal "Plugin", eclipse.name
|
83
|
+
assert_equal "1.2.3", eclipse.version
|
84
|
+
assert_equal "Some Vendor", eclipse.vendor
|
85
|
+
|
86
|
+
out = StringIO.new
|
87
|
+
eclipse.write_manifest(out)
|
88
|
+
assert_equal @@vendor_manifest, out.string
|
89
|
+
end
|
90
|
+
|
91
|
+
@@expected_manifest = <<MANIFEST
|
92
|
+
Manifest-Version: 1.0
|
93
|
+
Bundle-ManifestVersion: 2
|
94
|
+
Bundle-Name: name
|
95
|
+
Bundle-SymbolicName: name.id; singleton:=true
|
96
|
+
Bundle-Version: 1.0.0
|
97
|
+
Bundle-Localization: plugin
|
98
|
+
MANIFEST
|
99
|
+
|
100
|
+
@@vendor_manifest = <<MANIFEST
|
101
|
+
Manifest-Version: 1.0
|
102
|
+
Bundle-ManifestVersion: 2
|
103
|
+
Bundle-Name: Plugin
|
104
|
+
Bundle-SymbolicName: com.test.plugin; singleton:=true
|
105
|
+
Bundle-Version: 1.2.3
|
106
|
+
Bundle-Localization: plugin
|
107
|
+
Bundle-Vendor: Some Vendor
|
108
|
+
MANIFEST
|
109
|
+
|
110
|
+
@@expected_pluginxml = <<PLUGIN_XML
|
111
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
112
|
+
<?eclipse version="3.0"?>
|
113
|
+
<plugin>
|
114
|
+
<extension point="org.eclipse.help.toc">
|
115
|
+
<toc file="toc.xml"/>
|
116
|
+
<toc file="toc_links.xml" primary="true"/>
|
117
|
+
</extension>
|
118
|
+
</plugin>
|
119
|
+
PLUGIN_XML
|
120
|
+
|
121
|
+
@@expected_pluginxml_2tocs = <<PLUGIN_XML
|
122
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
123
|
+
<?eclipse version="3.0"?>
|
124
|
+
<plugin>
|
125
|
+
<extension point="org.eclipse.help.toc">
|
126
|
+
<toc file="toc.xml"/>
|
127
|
+
<toc file="toc2.xml"/>
|
128
|
+
<toc file="toc_links.xml" primary="true"/>
|
129
|
+
</extension>
|
130
|
+
</plugin>
|
131
|
+
PLUGIN_XML
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: helpconverter
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2006-07-24 00:00:00 -04:00
|
8
|
+
summary: Convert help formats for easy reuse.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
homepage: http://helpconverter.rubyforge.org/
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire: helpconverter
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/eclipsehelp.rb
|
32
|
+
- lib/helpconverter.rb
|
33
|
+
- lib/javahelp.rb
|
34
|
+
- tests/ts_help_converter.rb
|
35
|
+
- tests/tc_javahelp.rb
|
36
|
+
- tests/tc_plugin.rb
|
37
|
+
- tests/tc_jh2eh.rb
|
38
|
+
- demo/dog_breeds.jar
|
39
|
+
- bin/jh2eh
|
40
|
+
- README
|
41
|
+
- MIT-LICENSE
|
42
|
+
test_files:
|
43
|
+
- tests/ts_help_converter.rb
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
extra_rdoc_files:
|
47
|
+
- README
|
48
|
+
- MIT-LICENSE
|
49
|
+
- bin/jh2eh
|
50
|
+
executables:
|
51
|
+
- jh2eh
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
dependencies:
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rubyzip
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.5.11
|
65
|
+
version:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: builder
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.0.0
|
74
|
+
version:
|