diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Info.plist | 14 | ||||
-rw-r--r-- | src/icon.png | bin | 0 -> 1617 bytes | |||
-rwxr-xr-x | src/index.rb | 27 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/Info.plist b/src/Info.plist new file mode 100644 index 0000000..b95b162 --- /dev/null +++ b/src/Info.plist @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleIdentifier</key> + <string>gnumake</string> + <key>CFBundleName</key> + <string>GNU Make</string> + <key>DocSetPlatformFamily</key> + <string>make</string> + <key>isDashDocset</key> + <true/> +</dict> +</plist> diff --git a/src/icon.png b/src/icon.png Binary files differnew file mode 100644 index 0000000..9b18522 --- /dev/null +++ b/src/icon.png diff --git a/src/index.rb b/src/index.rb new file mode 100755 index 0000000..c719fcc --- /dev/null +++ b/src/index.rb @@ -0,0 +1,27 @@ +require 'pathname' + +puts %Q[ + CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); + CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); +] + +INSERT_SQL = %Q[ + INSERT INTO searchIndex(name, type, path) VALUES ('%s','%s','%s'); +] + +PATTERN = %r[<title>GNU make: (.+)</title>] + +def quote(s) + s.gsub(/&/, '&').gsub(/'/, "\\'") +end + +ARGV.each do |arg| + Pathname.glob(arg) do |path| + match = path.each_line.lazy.map { |line| PATTERN.match(line) }.find { |m| m } + if match + printf INSERT_SQL, quote(match[1]), 'Guide', path.basename + else + $stderr.puts "%{path.basename}: no title found" + end + end +end |