root/lang/ruby/Chemr/mkchmbundle.rb

Revision 1294, 1.3 kB (checked in by cho45, 13 months ago)

lang/ruby/Chemr/mkchmbundle.rb:

ちゃんとファイルとしてダウンロードできるようにチェックイン

  • Property svn:executable set to *
Line 
1
2require "pathname"
3require "yaml"
4
5def mkchmbundle(bundle_name, title, home="/index.html", keywords=[], toc={})
6        root = Pathname.new(bundle_name)
7        root.rmtree rescue nil
8        root.mkpath
9
10        contents  = root + "Contents"
11        contents.mkpath
12        (contents + "PkgInfo").open("w") {|f| f << "BNDL????" }
13        (contents + "Info.plist").open("w") {|f| f << <<-InfoPlist.gsub(/^\t{2}/, "") }
14                <?xml version="1.0" encoding="UTF-8"?>
15                <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
16                <plist version="1.0">
17                <dict>
18                                <key>CFBundleName</key>
19                                <string></string>
20                                <key>CFBundleInfoDictionaryVersion</key>
21                                <string>6.0</string>
22                                <key>CFBundlePackageType</key>
23                                <string>BNDL</string>
24                                <key>CFBundleSignature</key>
25                                <string>????</string>
26
27                                <key>CHMTitle</key>
28                                <string>#{title}</string>
29                                <key>CHMHome</key>
30                                <string>#{home}</string>
31                                <key>CHMKeyword</key>
32                                <string>/keyword.yaml</string>
33                                <key>CHMTOC</key>
34                                <string>/toc.yaml</string>
35                </dict>
36                </plist>
37        InfoPlist
38
39        resources = contents + "Resources"
40        resources.mkpath
41
42        (resources + "keyword.yaml").open("w") {|f| f << keywords.to_yaml }
43        (resources + "toc.yaml").open("w") {|f| f << toc.to_yaml }
44
45        [root, resources]
46end
47
48if $0 == __FILE__
49        mkchmbundle("Test.chm", "Test", "/index.html", ["hoge", ["aaaa.html"]], {})
50end
Note: See TracBrowser for help on using the browser.