-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall_mysql_functions.rb
More file actions
90 lines (81 loc) · 2.15 KB
/
all_mysql_functions.rb
File metadata and controls
90 lines (81 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /usr/bin/ruby
files = []
files << 'Control Flow Functions'
files << 'String Functions'
files << "Numeric Functions"
files << 'Date and Time Functions'
files << 'Cast Functions and Operators'
files << 'Encryption and Compression Functions'
files << 'Information Functions'
files << 'Miscellaneous Functions'
files << 'Group By Aggregate Functions'
regex = Regexp.new('([^\(\)]*)(.*){0,1}')
plist = <<-PLIST
<?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>category</key>
<string>CATEGORY</string>
<key>command</key>
<string>#! /usr/bin/ruby
tmp = "FUNCTION"
regex = Regexp.new('([^\(\)]*)(.*){0,1}')
md = regex.match(tmp)
v = gets
if v
print md[1]+"("+v+")"
else
print md[0]
end
</string>
<key>input</key>
<string>selectedtext</string>
<key>input_fallback</key>
<string>currentword</string>
<key>name</key>
<string>NAME</string>
<key>output</key>
<string>insertastext</string>
<key>scope</key>
<string>inputfield</string>
<key>tooltip</key>
<string><![CDATA[TOOLTIP]]></string>
<key>trigger</key>
<string>none</string>
<key>uuid</key>
<string>UUID</string>
</dict>
</plist>
PLIST
bundlenames = []
files.each do |title|
value = File.open(title).read()
value.split("∞").each do |fnc|
l = fnc.lines
k = l.first
v = fnc
k.strip!
# v.strip!
tooltip = v
uuid = `uuidgen`
md = regex.match(k)
name = md[1]
dirname = name.gsub(/ +/,"_")
dirname = dirname + ".spBundle"
succ = `mkdir "#{dirname}"`
plist_copy = String.new(str=plist)
plist_copy.gsub!(/UUID/,uuid)
plist_copy.gsub!(/FUNCTION/,md[0])
plist_copy.gsub!(/TOOLTIP/,tooltip)
plist_copy.gsub!(/NAME/,name)
plist_copy.gsub!(/CATEGORY/,title)
File.open(dirname+"/command.plist", "w+") do |f|
f.write plist_copy
bundlenames << dirname
end
end
end
# Comment this out if you want to see all 200 bundles
bundlenames.each {|x| `rm -rf "/Users/$USER/Library/Application Support/Sequel Pro/Bundles/#{x}";`}
`mv -f *.spBundle "/Users/$USER/Library/Application Support/Sequel Pro/Bundles"`