duct_tape 0.0.4 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -2
- data/Gemfile.lock +68 -18
- data/LICENSE +1 -1
- data/README.md +17 -0
- data/REQUIRED_FILES +6 -0
- data/Rakefile +111 -4
- data/VERSION +1 -1
- data/duct_tape.gemspec +19 -14
- data/ext/mkrf_conf.rb +18 -4
- data/lib/duct_tape.rb +84 -1
- data/lib/ext/kernel.rb +65 -34
- data/lib/ext/pathname.rb +51 -9
- data/lib/ext/time.rb +10 -1
- data/lib/ext/uri.rb +6 -1
- data/spec/duct_tape/autoassociative_array_spec.rb +6 -6
- data/spec/ext/array_spec.rb +63 -63
- data/spec/ext/boolean_spec.rb +2 -2
- data/spec/ext/numeric_spec.rb +13 -13
- data/spec/ext/pathname_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +54 -10
- data/git_hooks/env_vars.sh +0 -287
- data/git_hooks/post-commit +0 -43
- data/git_hooks/post-merge +0 -8
- data/git_hooks/pre-commit +0 -273
- data/install_git_hooks +0 -17
data/git_hooks/env_vars.sh
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
#
|
4
|
-
# Determine Platform
|
5
|
-
#
|
6
|
-
uname_output=`uname -s`
|
7
|
-
if [[ "$uname_output" =~ "Linux" ]]; then
|
8
|
-
my_platform="linux"
|
9
|
-
elif [[ "$uname_output" =~ "Darwin" ]]; then
|
10
|
-
my_platform="darwin"
|
11
|
-
elif [[ "$uname_output" =~ "Solaris" || "$uname_output" =~ "SunOS" ]]; then
|
12
|
-
my_platform="solaris"
|
13
|
-
elif [[ "$uname_output" =~ "BSD" || "$uname_output" =~ "DragonFly" ]]; then
|
14
|
-
my_platform="bsd"
|
15
|
-
elif [[ "$uname_output" =~ "Haiku" ]]; then
|
16
|
-
my_platform="beos"
|
17
|
-
else
|
18
|
-
echo "ERROR: Unknown Platform '$uname_output'"
|
19
|
-
exit 1
|
20
|
-
fi
|
21
|
-
|
22
|
-
#
|
23
|
-
# Determine CPU info
|
24
|
-
#
|
25
|
-
if [[ -e "/proc/cpuinfo" ]]; then
|
26
|
-
# Linux
|
27
|
-
num_cpus=`cat /proc/cpuinfo | grep processor | wc -l`
|
28
|
-
elif [[ -n `which lscpu 2> /dev/null` ]]; then
|
29
|
-
# Linux Alternative
|
30
|
-
num_cpus=`lscpu | grep -i "CPU(s):" | awk '{print $2}'`
|
31
|
-
elif [[ -n `which psrinfo 2> /dev/null` ]]; then
|
32
|
-
# Solaris
|
33
|
-
num_cpus=`psrinfo | wc -l`
|
34
|
-
elif [[ -n `which sysinfo 2> /dev/null` ]]; then
|
35
|
-
# Haiku/BeOS
|
36
|
-
num_cpus=`sysinfo | grep -i "CPU #[0-9]*:" | wc -l`
|
37
|
-
elif [[ -n `which sysctl 2> /dev/null` ]]; then
|
38
|
-
# BSD
|
39
|
-
num_cpus=`sysctl -a 2> /dev/null | egrep -i 'hw.ncpu' | awk '{print $2}'`
|
40
|
-
fi
|
41
|
-
|
42
|
-
if [[ -n `which arch 2> /dev/null` ]]; then
|
43
|
-
# Linux
|
44
|
-
my_arch=`arch`
|
45
|
-
elif [[ -n `which lscpu 2> /dev/null` ]]; then
|
46
|
-
# Linux Alternative
|
47
|
-
my_arch=`lscpu | grep -i "Architecture" | awk '{print $2}'`
|
48
|
-
elif [[ -n `which sysinfo 2> /dev/null` ]]; then
|
49
|
-
# Haiku/BeOS
|
50
|
-
my_arch=`sysinfo | grep -o "kernel_\\w*"`
|
51
|
-
else
|
52
|
-
# BSD/Solaris
|
53
|
-
my_arch=`uname -p 2> /dev/null`
|
54
|
-
[[ -n "$my_arch" ]] || my_arch=`uname -m 2> /dev/null`
|
55
|
-
fi
|
56
|
-
|
57
|
-
if [[ -n `echo $my_arch | grep -i "sparc\\|sun4u"` ]]; then
|
58
|
-
my_arch_family="sparc"
|
59
|
-
elif [[ -n `echo $my_arch | grep -i "^ppc\\|powerpc"` ]]; then
|
60
|
-
my_arch_family="powerpc"
|
61
|
-
elif [[ "$my_arch" =~ mips ]]; then
|
62
|
-
my_arch_family="mips"
|
63
|
-
elif [[ "$my_arch" =~ s390 ]]; then
|
64
|
-
my_arch_family="s390x"
|
65
|
-
elif [[ -n `echo $my_arch | grep -i "ia64\\|itanium"` ]]; then
|
66
|
-
my_arch_family="itanium"
|
67
|
-
elif [[ "$my_arch" =~ 64 ]]; then
|
68
|
-
my_arch_family="x86_64"
|
69
|
-
elif [[ -n `echo $my_arch | grep -i "\\(i[3-6]\\?\\|x\\)86\\|ia32"` ]]; then
|
70
|
-
my_arch_family="i386"
|
71
|
-
elif [[ "$my_arch" =~ arm ]]; then
|
72
|
-
my_arch_family="arm"
|
73
|
-
fi
|
74
|
-
|
75
|
-
#
|
76
|
-
# Setup Build Env
|
77
|
-
#
|
78
|
-
if [[ -z `echo "$PATH" | grep "/usr/local/bin"` ]]; then
|
79
|
-
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
|
80
|
-
fi
|
81
|
-
if [[ "$PATH" =~ "rvm/bin" ]]; then
|
82
|
-
if [[ `whoami` == "root" ]]; then
|
83
|
-
rvm_home=/usr/local/rvm
|
84
|
-
else
|
85
|
-
rvm_home=$HOME/.rvm
|
86
|
-
fi
|
87
|
-
export PATH=$PATH:$rvm_home/bin # Add RVM to PATH for scripting
|
88
|
-
fi
|
89
|
-
|
90
|
-
if [[ "$my_platform" == "linux" ]]; then
|
91
|
-
|
92
|
-
# PLEASE tell me you have lsb_release installed.
|
93
|
-
if [[ -z `which lsb_release 2> /dev/null` ]]; then
|
94
|
-
if [[ -n `which apt-get 2> /dev/null` ]]; then # Debian/Ubuntu/Linux Mint/PCLinuxOS
|
95
|
-
sudo apt-get install -y lsb
|
96
|
-
elif [[ -n `which up2date 2> /dev/null` ]]; then # RHEL/Oracle
|
97
|
-
sudo up2date -i lsb
|
98
|
-
elif [[ -n `which yum 2> /dev/null` ]]; then # CentOS/Fedora/RHEL/Oracle
|
99
|
-
sudo yum install -y lsb
|
100
|
-
elif [[ -n `which zypper 2> /dev/null` ]]; then # OpenSUSE/SLES
|
101
|
-
sudo zypper --non-interactive install lsb
|
102
|
-
elif [[ -n `which pacman 2> /dev/null` ]]; then # ArchLinux
|
103
|
-
sudo pacman -S --noconfirm lsb-release
|
104
|
-
elif [[ -n `which urpmi 2> /dev/null` ]]; then # Mandriva/Mageia
|
105
|
-
sudo urpmi --auto lsb-release
|
106
|
-
elif [[ -n `which emerge 2> /dev/null` ]]; then # Gentoo
|
107
|
-
sudo emerge lsb
|
108
|
-
elif [[ -n `which slackpkg 2> /dev/null` ]]; then # Slackware
|
109
|
-
echo "" > /dev/null # Slackware doesn't use LSB
|
110
|
-
else
|
111
|
-
echo "ERROR: Unknown Package manager in use (what ARE you using??)"
|
112
|
-
exit 1
|
113
|
-
fi
|
114
|
-
fi
|
115
|
-
|
116
|
-
my_method="install"
|
117
|
-
my_major_release=`lsb_release -r 2> /dev/null | awk '{print $2}' | grep -o "[0-9]\+" | head -1`
|
118
|
-
my_nickname=`lsb_release -c 2> /dev/null | awk '{print $2}'`
|
119
|
-
my_pkg_arch="$my_arch_family"
|
120
|
-
lsb_release_output=`lsb_release -a 2> /dev/null`
|
121
|
-
if [[ -n `echo $lsb_release_output | grep -i "debian"` ]]; then
|
122
|
-
my_distro="debian"
|
123
|
-
my_pkg_fmt="deb"
|
124
|
-
my_install="apt-get install -y"
|
125
|
-
my_local_install="dpkg -i"
|
126
|
-
if [[ "$my_arch_family" == "x86_64" ]]; then my_pkg_arch="amd64"; fi
|
127
|
-
elif [[ -n `echo $lsb_release_output | grep -i "ubuntu"` ]]; then
|
128
|
-
my_distro="ubuntu"
|
129
|
-
my_pkg_fmt="deb"
|
130
|
-
my_install="apt-get install -y"
|
131
|
-
my_local_install="dpkg -i"
|
132
|
-
if [[ "$my_arch_family" == "x86_64" ]]; then my_pkg_arch="amd64"; fi
|
133
|
-
elif [[ -n `echo $lsb_release_output | grep -i "mint"` ]]; then
|
134
|
-
my_distro="mint"
|
135
|
-
my_pkg_fmt="deb"
|
136
|
-
my_install="apt-get install -y"
|
137
|
-
my_local_install="dpkg -i"
|
138
|
-
if [[ "$my_arch_family" == "x86_64" ]]; then my_pkg_arch="amd64"; fi
|
139
|
-
elif [[ -n `echo $lsb_release_output | grep -i "centos"` ]]; then
|
140
|
-
my_distro="centos"
|
141
|
-
my_pkg_fmt="rpm"
|
142
|
-
my_install="yum install -y"
|
143
|
-
my_local_install="yum localinstall -y"
|
144
|
-
elif [[ -n `echo $lsb_release_output | grep -i "fedora"` ]]; then
|
145
|
-
my_distro="fedora"
|
146
|
-
my_pkg_fmt="rpm"
|
147
|
-
my_install="yum install -y"
|
148
|
-
my_local_install="yum localinstall -y"
|
149
|
-
elif [[ -n `echo $lsb_release_output | grep -i "redhat\|rhel"` ]]; then
|
150
|
-
my_distro="rhel"
|
151
|
-
my_pkg_fmt="rpm"
|
152
|
-
my_install="up2date -i"
|
153
|
-
my_local_install="rpm -Uvh"
|
154
|
-
elif test -e "/etc/oracle-release" -o -e "/etc/enterprise-release"; then
|
155
|
-
my_distro="oracle"
|
156
|
-
if test -e "/etc/oracle-release"; then
|
157
|
-
my_nickname=`cat /etc/oracle-release`
|
158
|
-
else
|
159
|
-
my_nickname=`cat /etc/enterprise-release`
|
160
|
-
fi
|
161
|
-
my_major_release=`echo $my_nickname | grep -o "[0-9]\+" | head -1`
|
162
|
-
my_pkg_fmt="rpm"
|
163
|
-
my_install="up2date -i"
|
164
|
-
my_local_install="rpm -Uvh"
|
165
|
-
elif [[ -n `echo $lsb_release_output | grep -i "open\s*suse"` ]]; then
|
166
|
-
my_distro="opensuse"
|
167
|
-
my_pkg_fmt="rpm"
|
168
|
-
my_install="zypper --non-interactive install"
|
169
|
-
my_local_install="rpm -Uvh"
|
170
|
-
elif [[ -n `echo $lsb_release_output | grep -i "suse" | grep -i "enterprise"` ]]; then
|
171
|
-
my_distro="sles"
|
172
|
-
my_pkg_fmt="rpm"
|
173
|
-
my_install="zypper --non-interactive install"
|
174
|
-
my_local_install="rpm -Uvh"
|
175
|
-
elif [[ -n `echo $lsb_release_output | grep -i "archlinux"` ]]; then
|
176
|
-
my_distro="arch"
|
177
|
-
my_pkg_fmt="pkg.tar.xz"
|
178
|
-
my_install="pacman -S --noconfirm"
|
179
|
-
my_local_install="pacman -U --noconfirm"
|
180
|
-
elif test -e "/etc/slackware-version"; then
|
181
|
-
my_distro="slackware"
|
182
|
-
my_nickname=`cat /etc/slackware-version`
|
183
|
-
my_major_release=`echo $my_nickname | grep -o "[0-9]\+" | head -1`
|
184
|
-
if [[ "$my_major_release" -lt "13" ]]; then
|
185
|
-
my_pkg_fmt="tgz"
|
186
|
-
else
|
187
|
-
my_pkg_fmt="txz"
|
188
|
-
fi
|
189
|
-
my_install="slackpkg -batch=on -default_answer=y install"
|
190
|
-
my_local_install="installpkg"
|
191
|
-
elif [[ -n `echo $lsb_release_output | grep -i "mandriva"` ]]; then
|
192
|
-
my_distro="mandriva"
|
193
|
-
my_pkg_fmt="rpm"
|
194
|
-
my_install="urpmi --auto "
|
195
|
-
my_local_install="rpm -Uvh"
|
196
|
-
elif [[ -n `echo $lsb_release_output | grep -i "mageia"` ]]; then
|
197
|
-
my_distro="mageia"
|
198
|
-
my_pkg_fmt="rpm"
|
199
|
-
my_install="urpmi --auto "
|
200
|
-
my_local_install="rpm -Uvh"
|
201
|
-
elif [[ -n `echo $lsb_release_output | grep -i "gentoo"` ]]; then
|
202
|
-
my_distro="gentoo"
|
203
|
-
my_pkg_fmt="tgz"
|
204
|
-
my_install="emerge"
|
205
|
-
my_local_install=""
|
206
|
-
else
|
207
|
-
echo "Warning: Unsupported Linux Distribution, any packages will be compiled from source"
|
208
|
-
my_method="build"
|
209
|
-
my_distro=`lsb_release -d 2> /dev/null`
|
210
|
-
fi
|
211
|
-
|
212
|
-
elif [[ "$my_platform" == "darwin" ]]; then
|
213
|
-
|
214
|
-
my_distro="Mac OSX"
|
215
|
-
my_install=""
|
216
|
-
|
217
|
-
if [[ -z `which brew 2> /dev/null` ]]; then # Homebrew
|
218
|
-
my_method="install"
|
219
|
-
my_install="brew install"
|
220
|
-
elif [[ -z `which port 2> /dev/null` ]]; then # MacPorts
|
221
|
-
my_method="install"
|
222
|
-
my_install="port install"
|
223
|
-
else
|
224
|
-
my_method="build"
|
225
|
-
fi
|
226
|
-
my_major_release=`sw_vers -productVersion | grep -o "[0-9]\+\.[0-9]\+" | head -1`
|
227
|
-
case "$my_major_release" in
|
228
|
-
"10.0") my_nickname="Cheetah";;
|
229
|
-
"10.1") my_nickname="Puma";;
|
230
|
-
"10.2") my_nickname="Jaguar";;
|
231
|
-
"10.3") my_nickname="Panther";;
|
232
|
-
"10.4") my_nickname="Tiger";;
|
233
|
-
"10.5") my_nickname="Leopard";;
|
234
|
-
"10.6") my_nickname="Snow Leopard";;
|
235
|
-
"10.7") my_nickname="Lion";;
|
236
|
-
"10.8") my_nickname="Mountain Lion";;
|
237
|
-
*)
|
238
|
-
echo "Unknown Version of OSX Detected: $my_major_release"
|
239
|
-
my_nickname="Unknown"
|
240
|
-
;;
|
241
|
-
esac
|
242
|
-
|
243
|
-
my_pkg_fmt=""
|
244
|
-
my_local_install=""
|
245
|
-
|
246
|
-
elif [[ "$my_platform" == "solaris" ]]; then
|
247
|
-
|
248
|
-
my_major_release=`uname -r | grep -o "[0-9]\+" | head -2 | tail -1`
|
249
|
-
if [[ -n `uname -a | grep -i "open\s*solaris"` ]]; then
|
250
|
-
my_distro="OpenSolaris"
|
251
|
-
my_nickname="$my_distro `cat /etc/release | grep -o "OpenSolaris [a-zA-Z0-9.]\\+"`"
|
252
|
-
else
|
253
|
-
my_distro="Solaris"
|
254
|
-
my_nickname="$my_distro $my_major_release"
|
255
|
-
fi
|
256
|
-
my_method="install"
|
257
|
-
# NOTE - `pfexec pkg set-publisher -O http://pkg.openindiana.org/legacy opensolaris.org`
|
258
|
-
# NOTE - SUNWruby18, SUNWgcc, SUNWgnome-common-devel
|
259
|
-
my_install="pkg install"
|
260
|
-
|
261
|
-
my_pkg_fmt=""
|
262
|
-
my_local_install=""
|
263
|
-
|
264
|
-
elif [[ "$my_platform" == "bsd" ]]; then
|
265
|
-
|
266
|
-
my_distro=`uname -s`
|
267
|
-
my_pkg_fmt="tgz"
|
268
|
-
my_nickname="$my_distro `uname -r`"
|
269
|
-
my_major_release=`uname -r | grep -o "[0-9]\+" | head -1`
|
270
|
-
my_method="install"
|
271
|
-
# NOTE - `portsnap fetch extract` to update snapshot
|
272
|
-
my_install="pkg_add -r"
|
273
|
-
|
274
|
-
my_local_install=""
|
275
|
-
|
276
|
-
elif [[ "$my_platform" == "beos" ]]; then
|
277
|
-
|
278
|
-
my_distro=`uname -s`
|
279
|
-
my_major_release=`uname -r | grep -o "[0-9]\+" | head -1`
|
280
|
-
my_method="build"
|
281
|
-
my_nickname="$my_distro $my_major_release"
|
282
|
-
|
283
|
-
my_pkg_fmt=""
|
284
|
-
my_local_install=""
|
285
|
-
my_install=""
|
286
|
-
|
287
|
-
fi
|
data/git_hooks/post-commit
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
cat << 'EOS'
|
3
|
-
..,ONMMMMMO.
|
4
|
-
NM8~:~:.,+NMM=
|
5
|
-
MO .MM:
|
6
|
-
NM. ,MN
|
7
|
-
.. .7MN . . 8M,
|
8
|
-
==. ?N: .MMN .,,.. 8$ZZ.~MN
|
9
|
-
.$. N8 ,DD. ,MMN ...+:. .MMM
|
10
|
-
D 8D.Z= .$. NMMM..,~8I ,88+. MMMM:.
|
11
|
-
,~... ,MM .N . MMMM7. .... MMMMM,
|
12
|
-
DZ.. .:OZ.:M. ..8= .MMMM. .OMMMMM
|
13
|
-
:7 . 8+$M:.D+ +MMMM, .:N+,MMD: 7MMMMM.
|
14
|
-
.MM7:.... 8 .M. 7MMMMM. MMMMZMMMMO.7MMMMM.
|
15
|
-
,?. .. ..8 ,M =MMMMM MMN8$7O8DMM.OMMM~ +.
|
16
|
-
N.. . .+ M, .MMMMMOM M8. .OM.MIMMMZ =,.
|
17
|
-
=NZI+~, + I8 .MMMMMMM= .=DD, MMMMMI ~~
|
18
|
-
O. .N + M. IMMMMMMMMMD ~MN 7MMMMMMM .Z
|
19
|
-
.MNZZNMZ. . MM 7MMMMMMMMMMMMMMMMMMMMMMMM, .~M,.
|
20
|
-
ID=. . . MMI MMMMMMMMMMMMMMMMMMMMMMMMMD. .+N
|
21
|
-
.DMO,ZND+. MMM. :MMMMMMMMN =MMMMMMMMN:ZMMM,. +M~,$OD$
|
22
|
-
.MMO... MMM OMMMMMMMM~ . ,I++O7. OMMM= .IM7 . .=..+MNI.
|
23
|
-
.8MO :MMM .MMMMMMMMMM. MMMMM= ~D ?MO:7MN...
|
24
|
-
+$ON. $NMM .NMMMMMMMMM7. .MMMMM. .8Z. :7N...MM:
|
25
|
-
O7?N M+MMNMMMMMMMMMMMMMMMMMN MMMMMM8D. . $, .$8 M ..,$MN~,,.
|
26
|
-
N$:=M. .NM.MM. ?MMMMMMO. .. D IO$IM:D.,$O, ,. O.I,Z :M: .+MI
|
27
|
-
MO, MMI ..NM8.MM. =. MM..IMN7,. .,IDN7~MMMMMM, N .Z N.M. ,M. =N.
|
28
|
-
.MO. MMMMMMMM::MM .: . .M :+I?=D.~.MMMMMMM?,,~INMMNNM+ ~ ~. D8. ,8.
|
29
|
-
.M8. MMMMMMMM ZM$. 8 7. ~ M,MM+MMMMMMMMMMMMMMM.. , : ,M. .O+
|
30
|
-
.MO. MMMMMMMI.MM, N = .....,IDI. MMMMMMMM8MMMMMM.. = M+ .M.
|
31
|
-
.MZ~.MMMMMMM..MM . N .=. ?M,NMMMMMM?~MM$IMMM7MMMMM7 :O M
|
32
|
-
M7I.NMMMMM8.$MZ.~ 8 .~, : MMMMMMMMMMMMM.~OOIMMM+MMMMM, .N M
|
33
|
-
N=D OMMMMM, MM O .I .7. MMMMMMMMMMMMMMMMMMMMMD7NMM:MMMMN D .M
|
34
|
-
O:M,~MMMMD NM? D.=, 8 OMMMMMMMMMMMMMMMMMMMMMZZMM?MMMM: ... Z .M
|
35
|
-
+=M$ MMMZ :MN ~, D. I. ~MMMMMMM+,,~I, .NMMMMMZ.MDNMM7 I. . .M.
|
36
|
-
.$NM .,.. MM .M :N. :~ .MMMMMM. MMMMMMZ=M,MM. .M. 7M
|
37
|
-
.N.MM~ $MZ. O. N? N. ,MMMMMMM. MMMMMMMM+8Z: NZ. . .MI.
|
38
|
-
.M.=MMMMN.. .+=..M. M. NMMMMMMMD 8MMMMMMM.MMM. $M. . ?, ~M.
|
39
|
-
+. ~MM .. $, M: N: . 7MMMMMMN .~MMMMMM8,MMMMMMMMMMM ..M. :MM
|
40
|
-
D N . ,M N NN. I8. $MMMMMMM?.. .?MMMMMMM?OMMMMMMMMMMMMMMMMMMMMI . ...MM$
|
41
|
-
7? .?N.7O DM ,M ZMMMMMMMMMM7.IMMMMMMMMD$MMMMMMMMMMMMMMMMMMMMMMMMZ: IMMN.
|
42
|
-
.~MM?.=NM~DM8.. M 8MMMMMMMMMMMMMMMMM7=MMMMMMMMMMMMMMMMMD.IMMMNZZNMMN~
|
43
|
-
EOS
|
data/git_hooks/post-merge
DELETED
data/git_hooks/pre-commit
DELETED
@@ -1,273 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
lod_message() {
|
4
|
-
cat <<EOS
|
5
|
-
|
6
|
-
OMM MM$
|
7
|
-
MMMM MMMM
|
8
|
-
MMM MMO
|
9
|
-
=MM MMM
|
10
|
-
MMM MMD
|
11
|
-
MMMMMMMMMMMMMMMMMMMMM NMMMMMMMMMMMMMMMMMMMMM
|
12
|
-
MMMMMMMMMMMMMMMMMMMM NMMMMMMMMMMMMMMMMMMM,
|
13
|
-
MMMM? ?MMMM =MMMM MMMMD
|
14
|
-
=MMM ?MMM MMMM MMMN
|
15
|
-
:MMM MMM NMM= =MMD
|
16
|
-
MMM ,MMO MMM DMM
|
17
|
-
MMM MMMD MMM DMM? ,MMM, MMD
|
18
|
-
MMM MMM$ MMM NMM? MMM MMN
|
19
|
-
MMM MMM OMMM =MMO
|
20
|
-
MMMN NMM$ MMM MMM
|
21
|
-
MMM? MMMM DMMM MMM$
|
22
|
-
MMMM: :MMMM DMMMM MMMM$
|
23
|
-
=MMMMMMMMMMMMMM? MMMMMMMMMMMMMMM
|
24
|
-
MMMMMMMMMMM MMMMMMMMMMM
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
DMMMMMMMMMMMMMMMMMMMMMMM
|
30
|
-
|
31
|
-
EOS
|
32
|
-
}
|
33
|
-
|
34
|
-
lod_exit() {
|
35
|
-
lod_message
|
36
|
-
echo $1
|
37
|
-
exit 1
|
38
|
-
}
|
39
|
-
|
40
|
-
#
|
41
|
-
# Platform-specific features
|
42
|
-
#
|
43
|
-
git_root=`git rev-parse --show-toplevel`
|
44
|
-
source "$git_root/git_hooks/env_vars.sh"
|
45
|
-
|
46
|
-
if [[ "$my_platform" != "linux" ]]; then
|
47
|
-
echo "Non-linux platform detected ($my_platform) so whitespace modification logic suppressed..."
|
48
|
-
whitespace_modification=""
|
49
|
-
stat_flag=-f
|
50
|
-
else
|
51
|
-
whitespace_modification="true"
|
52
|
-
stat_flag=-c
|
53
|
-
fi
|
54
|
-
|
55
|
-
#
|
56
|
-
# Required Project Files
|
57
|
-
#
|
58
|
-
|
59
|
-
REQUIRED_FILES="Gemfile README.md VERSION .gitignore Rakefile LICENSE"
|
60
|
-
|
61
|
-
#
|
62
|
-
# Whitespace and syntax checks
|
63
|
-
#
|
64
|
-
|
65
|
-
whitespace=""
|
66
|
-
echo "Checking for syntax errors..."
|
67
|
-
commited_files=`git diff-index --name-only HEAD -- 2>&1`
|
68
|
-
exit_status=$?
|
69
|
-
if [[ "exit_status" -ne 0 && "$commited_files" == "fatal: bad revision 'HEAD'" ]]; then
|
70
|
-
commited_files=`find "$git_root" -type f | grep -v ".git/"`
|
71
|
-
fi
|
72
|
-
for FILE in $commited_files; do
|
73
|
-
if test -f "$FILE"; then
|
74
|
-
filetype=`file -b $FILE`
|
75
|
-
if [[ -n "$whitespace_modification" ]]; then
|
76
|
-
if [[ "$filetype" =~ "text" ]]; then
|
77
|
-
if [[ -n `grep "\\s\\s*$" $FILE` ]]; then whitespace="$whitespace $FILE"; fi
|
78
|
-
# Remove trailing whitespace
|
79
|
-
sed -i "s/\\s\\s*$//g" $FILE
|
80
|
-
# Remove tabs
|
81
|
-
sed -i "s/\t/ /g" $FILE
|
82
|
-
# Remove empty line at EOF
|
83
|
-
sed -i '${/^ *$/d;}' $FILE
|
84
|
-
fi
|
85
|
-
fi
|
86
|
-
|
87
|
-
# If a file is a bash script, check for syntax errors using bash
|
88
|
-
if [[ "$FILE" =~ .*\.sh$ || "$filetype" =~ "shell script" ]]; then
|
89
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
90
|
-
bash -n "$FILE" 1> /dev/null; fail=$?
|
91
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
92
|
-
else
|
93
|
-
bash -n "$FILE" 1> /dev/null
|
94
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
95
|
-
fi
|
96
|
-
fi
|
97
|
-
|
98
|
-
# If a file is ruby, check for syntax errors using ruby
|
99
|
-
if [[ "$FILE" =~ .*\.rb$ ]]; then
|
100
|
-
if [[ -n `which ruby 2> /dev/null` ]]; then
|
101
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
102
|
-
ruby -c "$FILE" 1> /dev/null; fail=$?
|
103
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
104
|
-
else
|
105
|
-
ruby -c "$FILE" 1> /dev/null
|
106
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
107
|
-
fi
|
108
|
-
else
|
109
|
-
echo "WARNING: Ruby file found, but syntax cannot be checked without 'ruby' binary"
|
110
|
-
fi
|
111
|
-
fi
|
112
|
-
|
113
|
-
# If a file is python, check for syntax errors using python or pypy
|
114
|
-
if [[ "$FILE" =~ .*\.py$ ]]; then
|
115
|
-
if [[ -n `which python 2> /dev/null` ]]; then
|
116
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
117
|
-
python -m py_compile "$FILE" 1> /dev/null; fail=$?
|
118
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
119
|
-
else
|
120
|
-
python -m py_compile "$FILE" 1> /dev/null
|
121
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
122
|
-
fi
|
123
|
-
elif [[ -n `which pypy 2> /dev/null` ]]; then
|
124
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
125
|
-
pypy -m py_compile "$FILE" 1> /dev/null; fail=$?
|
126
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
127
|
-
else
|
128
|
-
pypy -m py_compile "$FILE" 1> /dev/null
|
129
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
130
|
-
fi
|
131
|
-
else
|
132
|
-
echo "WARNING: Python file found, but syntax cannot be checked without 'python' or 'pypy' binary"
|
133
|
-
fi
|
134
|
-
fi
|
135
|
-
|
136
|
-
# If a file is javascript, check for syntax errors using js
|
137
|
-
if [[ "$FILE" =~ .*\.js$ ]]; then
|
138
|
-
if [[ -n `which js 2> /dev/null` ]]; then
|
139
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
140
|
-
js -C "$FILE" 1> /dev/null; fail=$?
|
141
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
142
|
-
else
|
143
|
-
js -C "$FILE" 1> /dev/null
|
144
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
145
|
-
fi
|
146
|
-
else
|
147
|
-
echo "WARNING: Javascript file found, but syntax cannot be checked without 'js' binary"
|
148
|
-
fi
|
149
|
-
fi
|
150
|
-
|
151
|
-
# If a file is css, check for syntax errors using lessc
|
152
|
-
if [[ "$FILE" =~ .*\.css$ ]]; then
|
153
|
-
if [[ -n `which lessc 2> /dev/null` ]]; then
|
154
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
155
|
-
lessc "$FILE" 1> /dev/null; fail=$?
|
156
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
157
|
-
else
|
158
|
-
lessc "$FILE" 1> /dev/null
|
159
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
160
|
-
fi
|
161
|
-
else
|
162
|
-
echo "WARNING: CSS file found, but syntax cannot be checked without 'less' npm package"
|
163
|
-
fi
|
164
|
-
fi
|
165
|
-
|
166
|
-
# If a file is json, check for syntax errors
|
167
|
-
if [[ "$FILE" =~ .*\.json$ ]]; then
|
168
|
-
if [[ -n `gem list | grep "json" 2> /dev/null` ]]; then
|
169
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
170
|
-
ruby -rrubygems -rjson -e "JSON::parse(IO.read('$FILE'))" 1> /dev/null; fail=$?
|
171
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
172
|
-
else
|
173
|
-
ruby -rrubygems -rjson -e "JSON::parse(IO.read('$FILE'))" 1> /dev/null
|
174
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
175
|
-
fi
|
176
|
-
else
|
177
|
-
echo "WARNING: JSON file found, but syntax cannot be checked without 'json' rubygem"
|
178
|
-
fi
|
179
|
-
fi
|
180
|
-
|
181
|
-
# If a file is yaml, check for syntax errors
|
182
|
-
if [[ "$FILE" =~ .*\.yaml$ ]]; then
|
183
|
-
if [[ -n `which ruby 2> /dev/null` ]]; then
|
184
|
-
if [[ "$fail" -eq 0 || -z "$fail" ]]; then
|
185
|
-
ruby -ryaml -e "begin; YAML::load(IO.read('$FILE')); rescue Exception => e; raise if e.is_a?(SyntaxError); end" 1> /dev/null; fail=$?
|
186
|
-
if [[ "$fail" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
187
|
-
else
|
188
|
-
ruby -ryaml -e "begin; YAML::load(IO.read('$FILE')); rescue Exception => e; raise if e.is_a?(SyntaxError); end" 1> /dev/null
|
189
|
-
if [[ "$?" -ne 0 ]]; then echo "Syntax Error found in '$FILE'"; fi
|
190
|
-
fi
|
191
|
-
else
|
192
|
-
echo "WARNING: YAML file found, but syntax cannot be checked without 'ruby' binary"
|
193
|
-
fi
|
194
|
-
fi
|
195
|
-
fi
|
196
|
-
done
|
197
|
-
echo "Syntax check complete."
|
198
|
-
|
199
|
-
#
|
200
|
-
# Built-in git checks
|
201
|
-
#
|
202
|
-
git diff-index --check HEAD -- 2> /dev/null
|
203
|
-
|
204
|
-
#
|
205
|
-
# Check for Syntax Errors
|
206
|
-
#
|
207
|
-
[[ "$fail" -ne 0 && -n "$fail" ]] && lod_exit "Syntax Errors Found. Aborting commit"
|
208
|
-
|
209
|
-
#
|
210
|
-
# Check for warnings
|
211
|
-
#
|
212
|
-
fail=0
|
213
|
-
for FILE in $commited_files ; do
|
214
|
-
if test -e $FILE; then
|
215
|
-
# If a file is ruby, check for syntax errors
|
216
|
-
if [[ -n `find $FILE -regex ".*\.rb$"` ]]; then
|
217
|
-
warnings=`ruby -c "$FILE" 2>&1 | grep -i warn`
|
218
|
-
if [[ -n "$warnings" ]]; then fail=1; fi
|
219
|
-
fi
|
220
|
-
fi
|
221
|
-
done
|
222
|
-
|
223
|
-
[[ "$fail" -ne 0 && -n "$fail" ]] && lod_exit "Syntax Warnings Found. Aborting commit"
|
224
|
-
|
225
|
-
#
|
226
|
-
# Was whitespace modified?
|
227
|
-
#
|
228
|
-
if [[ -n "$whitespace_modification" ]]; then
|
229
|
-
[[ -n "$whitespace" ]] && lod_message
|
230
|
-
for FILE in $whitespace; do
|
231
|
-
echo "Whitespace problem fixed. Please re-add '$FILE' to your commit"
|
232
|
-
done
|
233
|
-
[[ -n "$whitespace" ]] && exit 1
|
234
|
-
fi
|
235
|
-
|
236
|
-
#
|
237
|
-
# Check that project metadata files exist
|
238
|
-
#
|
239
|
-
for FILE in $REQUIRED_FILES; do
|
240
|
-
test ! -e $FILE && lod_exit "$FILE not present. Aborting commit"
|
241
|
-
done
|
242
|
-
|
243
|
-
#
|
244
|
-
# Check that if Gemfile exists, Gemfile.lock exists and is up to date
|
245
|
-
#
|
246
|
-
if [[ "$REQUIRED_FILES" =~ "Gemfile" ]]; then
|
247
|
-
# Bundler
|
248
|
-
old_mod_time="0"
|
249
|
-
if [[ -e "Gemfile.lock" ]]; then
|
250
|
-
old_mod_time=`stat $stat_flag %Z Gemfile.lock`
|
251
|
-
fi
|
252
|
-
|
253
|
-
echo -n Bundling Gemfile...
|
254
|
-
bundle install &> /dev/null
|
255
|
-
echo Bundle Complete.
|
256
|
-
|
257
|
-
[[ ! -e "Gemfile.lock" ]] && lod_exit "Gemfile.lock not present. Aborting commit"
|
258
|
-
[[ `stat $stat_flag %Z Gemfile.lock` -ne $old_mod_time ]] && lod_exit "Gemfile.lock updated. Please re-add 'Gemfile.lock' to your commit"
|
259
|
-
fi
|
260
|
-
|
261
|
-
#
|
262
|
-
# Check that username and user emails are filled properly
|
263
|
-
#
|
264
|
-
username=`git config --get user.name`
|
265
|
-
useremail=`git config --get user.email`
|
266
|
-
emaildomain=`echo $useremail | grep -o "[^@]*$"`
|
267
|
-
if [[ "$username" == "" ]]; then
|
268
|
-
lod_exit "Please set your git user.name by running 'git config user.name <your github username>'"
|
269
|
-
elif [[ "$useremail" == "" ]] || ! host "$emaildomain" &> /dev/null; then
|
270
|
-
lod_exit "Please set your git user.email by running 'git config user.email <your github email>'"
|
271
|
-
fi
|
272
|
-
|
273
|
-
exit 0
|
data/install_git_hooks
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
if [[ "$SHELL" =~ bash ]]; then
|
4
|
-
test -d ".git" || git init
|
5
|
-
git_root=`git rev-parse --show-toplevel`
|
6
|
-
source "$git_root/git_hooks/env_vars.sh"
|
7
|
-
|
8
|
-
if test ! -L "$git_root/.git/hooks"; then
|
9
|
-
test -d "$git_root/.git/hooks" && rm -rf "$git_root/.git/hooks"
|
10
|
-
ln -s "$git_root/git_hooks" "$git_root/.git/hooks"
|
11
|
-
echo "Git Hooks installed"
|
12
|
-
else
|
13
|
-
echo "Git Hooks already installed; nothing to do"
|
14
|
-
fi
|
15
|
-
else
|
16
|
-
echo "ERROR: Please run using bash, not $SHELL"
|
17
|
-
fi
|