collin-lucky7 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. data/README +65 -0
  2. data/Rakefile.rb +55 -0
  3. data/config/environment.rb +9 -0
  4. data/lib/jabs.rb +9 -0
  5. data/lib/jass.rb +23 -0
  6. data/lib/jsspec/example.html.jass +180 -0
  7. data/lib/jsspec/layout.html.haml +14 -0
  8. data/lib/lucky7.rb +5 -0
  9. data/lib/lucky7/builder.rb +140 -0
  10. data/lib/lucky7/renders.rb +9 -0
  11. data/rspec/fixtures/lucky7/build/app/layout.html +4 -0
  12. data/rspec/fixtures/lucky7/src/app/_category.html.haml +2 -0
  13. data/rspec/fixtures/lucky7/src/app/_header.html.haml +7 -0
  14. data/rspec/fixtures/lucky7/src/app/_page_link.html.haml +2 -0
  15. data/rspec/fixtures/lucky7/src/app/_pagination.html.haml +3 -0
  16. data/rspec/fixtures/lucky7/src/app/_result.html.haml +3 -0
  17. data/rspec/fixtures/lucky7/src/app/_result_set.html.haml +4 -0
  18. data/rspec/fixtures/lucky7/src/app/_side_bar.html.haml +3 -0
  19. data/rspec/fixtures/lucky7/src/app/behavior.css.sass +3 -0
  20. data/rspec/fixtures/lucky7/src/app/controller.js.jabs +3 -0
  21. data/rspec/fixtures/lucky7/src/app/fixture_spec.html.jass +6 -0
  22. data/rspec/fixtures/lucky7/src/app/layout.html.haml +4 -0
  23. data/rspec/fixtures/lucky7/src/app/no_results.html.haml +10 -0
  24. data/rspec/fixtures/lucky7/src/app/results.html.haml +5 -0
  25. data/rspec/jabs/jabs_engine_spec.rb +3 -0
  26. data/rspec/jabs/jabs_precompiler_spec.rb +50 -0
  27. data/rspec/jabs_spec.rb +15 -0
  28. data/rspec/jabs_spec_helper.rb +2 -0
  29. data/rspec/jass/jass_engine_spec.rb +1 -0
  30. data/rspec/jass/jass_precompiler_spec.rb +49 -0
  31. data/rspec/jass_spec.rb +15 -0
  32. data/rspec/lucky7/builder_spec.rb +322 -0
  33. data/rspec/lucky7/renders_spec.rb +13 -0
  34. data/rspec/lucky7_spec.rb +19 -0
  35. data/rspec/lucky7_spec_helper.rb +1 -0
  36. data/rspec/spec_helper.rb +3 -0
  37. data/templates/environment/[environment].rb +1 -0
  38. data/templates/skeleton/[application]/README +1 -0
  39. data/templates/skeleton/[application]/Rakefile.rb +1 -0
  40. data/templates/skeleton/[application]/environment/environment.rb +1 -0
  41. data/vendor/jquery/jquery-1.2.6.js +3549 -0
  42. data/vendor/jquery/jquery-1.2.6.min.js +32 -0
  43. data/vendor/jquery/jquery-1.2.6.pack.js.gz +11 -0
  44. data/vendor/jquery/jquery.simulate.js +152 -0
  45. data/vendor/js_spec/JSSpec.css +224 -0
  46. data/vendor/js_spec/JSSpec.js +1548 -0
  47. data/vendor/js_spec/copying +459 -0
  48. data/vendor/js_spec/demo.html +210 -0
  49. data/vendor/js_spec/diff_match_patch.js +1 -0
  50. data/vendor/js_spec/example.spec.html +198 -0
  51. data/vendor/js_spec/exp/build.properties +1 -0
  52. data/vendor/js_spec/exp/build.xml +9 -0
  53. data/vendor/js_spec/exp/lib/diff_match_patch.js +1 -0
  54. data/vendor/js_spec/exp/lib/js.jar +0 -0
  55. data/vendor/js_spec/exp/src/JSSpec2.js +356 -0
  56. data/vendor/js_spec/exp/src/JSSpec2_spec.js +238 -0
  57. data/vendor/js_spec/sample/datetime/String_Parser.html +22 -0
  58. data/vendor/js_spec/sample/datetime/datetime.js +24 -0
  59. data/vendor/orbited/ez_setup.py +272 -0
  60. data/vendor/orbited/pyevent-0.3/Makefile +18 -0
  61. data/vendor/orbited/pyevent-0.3/build/lib.linux-i686-2.5/event.so +0 -0
  62. data/vendor/orbited/pyevent-0.3/build/temp.linux-i686-2.5/event.o +0 -0
  63. data/vendor/orbited/pyevent-0.3/changes +9 -0
  64. data/vendor/orbited/pyevent-0.3/cvs/Entries +9 -0
  65. data/vendor/orbited/pyevent-0.3/cvs/Repository +1 -0
  66. data/vendor/orbited/pyevent-0.3/cvs/Root +1 -0
  67. data/vendor/orbited/pyevent-0.3/event.c +2516 -0
  68. data/vendor/orbited/pyevent-0.3/event.pyx +280 -0
  69. data/vendor/orbited/pyevent-0.3/license +29 -0
  70. data/vendor/orbited/pyevent-0.3/readme +12 -0
  71. data/vendor/orbited/pyevent-0.3/setup.py +61 -0
  72. data/vendor/orbited/pyevent-0.3/test.py +73 -0
  73. data/vendor/orbited/ruby-orbited.rb +84 -0
  74. metadata +188 -0
@@ -0,0 +1,280 @@
1
+ #
2
+ # event.pyx
3
+ #
4
+ # libevent Python bindings
5
+ #
6
+ # Copyright (c) 2004 Dug Song <dugsong@monkey.org>
7
+ # Copyright (c) 2003 Martin Murray <murrayma@citi.umich.edu>
8
+ #
9
+ # $Id: event.pyx,v 1.12 2005/09/12 03:16:15 dugsong Exp $
10
+
11
+ """event library
12
+
13
+ This module provides a mechanism to execute a function when a
14
+ specific event on a file handle, file descriptor, or signal occurs,
15
+ or after a given time has passed.
16
+ """
17
+
18
+ __author__ = ( 'Dug Song <dugsong@monkey.org>',
19
+ 'Martin Murray <mmurray@monkey.org>' )
20
+ __copyright__ = ( 'Copyright (c) 2004 Dug Song',
21
+ 'Copyright (c) 2003 Martin Murray' )
22
+ __license__ = 'BSD'
23
+ __url__ = 'http://monkey.org/~dugsong/pyevent/'
24
+ __version__ = '0.3'
25
+
26
+ import sys
27
+
28
+ cdef extern from "Python.h":
29
+ void Py_INCREF(object o)
30
+ void Py_DECREF(object o)
31
+
32
+ ctypedef void (*event_handler)(int fd, short evtype, void *arg)
33
+
34
+ cdef extern from "event.h":
35
+ struct timeval:
36
+ unsigned int tv_sec
37
+ unsigned int tv_usec
38
+
39
+ struct event_t "event":
40
+ int ev_fd
41
+ int ev_flags
42
+ void *ev_arg
43
+
44
+ void event_init()
45
+ void event_set(event_t *ev, int fd, short event,
46
+ event_handler handler, void *arg)
47
+ void evtimer_set(event_t *ev, event_handler handler, void *arg)
48
+ int event_add(event_t *ev, timeval *tv)
49
+ int event_del(event_t *ev)
50
+ int event_dispatch()
51
+ int event_loop(int loop)
52
+ int event_pending(event_t *ev, short, timeval *tv)
53
+
54
+ int EVLOOP_ONCE
55
+ int EVLOOP_NONBLOCK
56
+
57
+ EV_TIMEOUT = 0x01
58
+ EV_READ = 0x02
59
+ EV_WRITE = 0x04
60
+ EV_SIGNAL = 0x08
61
+ EV_PERSIST = 0x10
62
+
63
+ __event_exc = None
64
+
65
+ cdef int __event_sigcb():
66
+ return -1
67
+
68
+ cdef void __event_handler(int fd, short evtype, void *arg):
69
+ (<object>arg).__callback(evtype)
70
+
71
+ cdef void __simple_event_handler(int fd, short evtype, void *arg):
72
+ (<object>arg).__simple_callback(evtype)
73
+
74
+ cdef class event:
75
+ """event(callback, arg=None, evtype=0, handle=None) -> event object
76
+
77
+ Create a new event object with a user callback.
78
+
79
+ Arguments:
80
+
81
+ callback -- user callback with (ev, handle, evtype, arg) prototype
82
+ arg -- optional callback arguments
83
+ evtype -- bitmask of EV_READ or EV_WRITE, or EV_SIGNAL
84
+ handle -- for EV_READ or EV_WRITE, a file handle, descriptor, or socket
85
+ for EV_SIGNAL, a signal number
86
+ """
87
+ cdef event_t ev
88
+ cdef object handle, evtype, callback, args
89
+ cdef float timeout
90
+ cdef timeval tv
91
+
92
+ def __init__(self, callback, arg=None, short evtype=0, handle=-1,
93
+ simple=0):
94
+ cdef event_handler handler
95
+
96
+ self.callback = callback
97
+ self.args = arg
98
+ self.evtype = evtype
99
+ self.handle = handle
100
+ if simple:
101
+ handler = __simple_event_handler
102
+ else:
103
+ handler = __event_handler
104
+ if evtype == 0 and not handle:
105
+ evtimer_set(&self.ev, handler, <void *>self)
106
+ else:
107
+ if not isinstance(handle, int):
108
+ handle = handle.fileno()
109
+ event_set(&self.ev, handle, evtype, handler, <void *>self)
110
+
111
+ def __simple_callback(self, short evtype):
112
+ cdef extern int event_gotsig
113
+ cdef extern int (*event_sigcb)()
114
+ global __event_exc
115
+ try:
116
+ if self.callback(*self.args) != None:
117
+ if self.tv.tv_sec or self.tv.tv_usec:
118
+ event_add(&self.ev, &self.tv)
119
+ else:
120
+ event_add(&self.ev, NULL)
121
+ except:
122
+ __event_exc = sys.exc_info()
123
+ event_sigcb = __event_sigcb
124
+ event_gotsig = 1
125
+ # XXX - account for event.signal() EV_PERSIST
126
+ if not (evtype & EV_SIGNAL) and \
127
+ not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
128
+ Py_DECREF(self)
129
+
130
+ def __callback(self, short evtype):
131
+ cdef extern int event_gotsig
132
+ cdef extern int (*event_sigcb)()
133
+ global __event_exc
134
+ try:
135
+ self.callback(self, self.handle, evtype, self.args)
136
+ except:
137
+ __event_exc = sys.exc_info()
138
+ event_sigcb = __event_sigcb
139
+ event_gotsig = 1
140
+ if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT, NULL):
141
+ Py_DECREF(self)
142
+
143
+ def add(self, float timeout=-1):
144
+ """Add event to be executed after an optional timeout.
145
+
146
+ Arguments:
147
+
148
+ timeout -- seconds after which the event will be executed
149
+ """
150
+ if not event_pending(&self.ev, EV_READ|EV_WRITE|EV_SIGNAL|EV_TIMEOUT,
151
+ NULL):
152
+ Py_INCREF(self)
153
+ self.timeout = timeout
154
+ if timeout >= 0.0:
155
+ self.tv.tv_sec = <long>timeout
156
+ self.tv.tv_usec = (timeout - <float>self.tv.tv_sec) * 1000000.0
157
+ event_add(&self.ev, &self.tv)
158
+ else:
159
+ self.tv.tv_sec = self.tv.tv_usec = 0
160
+ event_add(&self.ev, NULL)
161
+
162
+ def pending(self):
163
+ """Return 1 if the event is scheduled to run, or else 0."""
164
+ return event_pending(&self.ev, EV_TIMEOUT|EV_SIGNAL|EV_READ|EV_WRITE, NULL)
165
+
166
+ def delete(self):
167
+ """Remove event from the event queue."""
168
+ if self.pending():
169
+ event_del(&self.ev)
170
+ Py_DECREF(self)
171
+
172
+ def __dealloc__(self):
173
+ self.delete()
174
+
175
+ def __repr__(self):
176
+ return '<event flags=0x%x, handle=%s, callback=%s, arg=%s>' % \
177
+ (self.ev.ev_flags, self.handle, self.callback, self.args)
178
+
179
+ cdef class read(event):
180
+ """read(handle, callback, *args) -> event object
181
+
182
+ Simplified event interface:
183
+ Create a new read event, and add it to the event queue.
184
+
185
+ Arguments:
186
+
187
+ handle -- file handle, descriptor, or socket
188
+ callback -- user callback with (*args) prototype, which can return
189
+ a non-None value to be rescheduled
190
+ *args -- optional callback arguments
191
+ """
192
+ def __init__(self, handle, callback, *args):
193
+ event.__init__(self, callback, args, EV_READ, handle, simple=1)
194
+ self.args = args # XXX - incref
195
+ self.add()
196
+
197
+ cdef class write(event):
198
+ """write(handle, callback, *args) -> event object
199
+
200
+ Simplified event interface:
201
+ Create a new write event, and add it to the event queue.
202
+
203
+ Arguments:
204
+
205
+ handle -- file handle, descriptor, or socket
206
+ callback -- user callback with (*args) prototype, which can return
207
+ a non-None value to be rescheduled
208
+ *args -- optional callback arguments
209
+ """
210
+ def __init__(self, handle, callback, *args):
211
+ event.__init__(self, callback, args, EV_WRITE, handle, simple=1)
212
+ self.args = args # XXX - incref
213
+ self.add()
214
+
215
+ cdef class signal(event):
216
+ """signal(sig, callback, *args) -> event object
217
+
218
+ Simplified event interface:
219
+ Create a new signal event, and add it to the event queue.
220
+ XXX - persistent event is added with EV_PERSIST, like signal_set()
221
+
222
+ Arguments:
223
+
224
+ sig -- signal number
225
+ callback -- user callback with (*args) prototype, which can return
226
+ a non-None value to be rescheduled
227
+ *args -- optional callback arguments
228
+ """
229
+ def __init__(self, sig, callback, *args):
230
+ event.__init__(self, callback, args, EV_SIGNAL|EV_PERSIST,
231
+ sig, simple=1)
232
+ self.args = args # XXX - incref
233
+ self.add()
234
+
235
+ cdef class timeout(event):
236
+ """timeout(secs, callback, *args) -> event object
237
+
238
+ Simplified event interface:
239
+ Create a new timer event, and add it to the event queue.
240
+
241
+ Arguments:
242
+
243
+ secs -- event timeout in seconds
244
+ callback -- user callback with (*args) prototype, which can return
245
+ a non-None value to be rescheduled
246
+ *args -- optional callback arguments
247
+ """
248
+ def __init__(self, secs, callback, *args):
249
+ event.__init__(self, callback, args, simple=1)
250
+ self.args = args # XXX - incref
251
+ self.add(secs)
252
+
253
+ def init():
254
+ """Initialize event queue."""
255
+ event_init()
256
+
257
+ def dispatch():
258
+ """Dispatch all events on the event queue."""
259
+ global __event_exc
260
+ event_dispatch()
261
+ if __event_exc:
262
+ raise __event_exc[0], __event_exc[1], __event_exc[2]
263
+
264
+ def loop(nonblock=False):
265
+ """Dispatch all pending events on queue in a single pass."""
266
+ cdef int flags
267
+ flags = EVLOOP_ONCE
268
+ if nonblock:
269
+ flags = EVLOOP_ONCE|EVLOOP_NONBLOCK
270
+ event_loop(flags)
271
+
272
+ def abort():
273
+ """Abort event dispatch loop."""
274
+ cdef extern int event_gotsig
275
+ cdef extern int (*event_sigcb)()
276
+ event_sigcb = __event_sigcb
277
+ event_gotsig = 1
278
+
279
+ # XXX - make sure event queue is always initialized.
280
+ init()
@@ -0,0 +1,29 @@
1
+
2
+ Copyright (c) 2004 Dug Song <dugsong@monkey.org>
3
+ Copyright (c) 2003 Martin Murray <murrayma@citi.umich.edu>
4
+ All rights reserved, all wrongs reversed.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions
8
+ are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright
11
+ notice, this list of conditions and the following disclaimer.
12
+ 2. Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+ 3. The names of the authors and copyright holders may not be used to
16
+ endorse or promote products derived from this software without
17
+ specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
@@ -0,0 +1,12 @@
1
+
2
+ pyevent
3
+ -------
4
+
5
+ Python extension module for Niels Provos' libevent:
6
+
7
+ http://monkey.org/~provos/libevent/
8
+
9
+ -d.
10
+
11
+ ---
12
+ http://monkey.org/~dugsong/
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # $Id: setup.py,v 1.7 2005/09/12 03:44:04 dugsong Exp $
4
+
5
+ from distutils.core import setup, Extension
6
+ import glob, os, sys
7
+
8
+ if glob.glob('/usr/lib/libevent.*'):
9
+ print 'found system libevent for', sys.platform
10
+ event = Extension(name='event',
11
+ sources=[ 'event.c' ],
12
+ libraries=[ 'event' ])
13
+ elif glob.glob('%s/lib/libevent.*' % sys.prefix):
14
+ print 'found installed libevent in', sys.prefix
15
+ event = Extension(name='event',
16
+ sources=[ 'event.c' ],
17
+ include_dirs=[ '%s/include' % sys.prefix ],
18
+ library_dirs=[ '%s/lib' % sys.prefix ],
19
+ libraries=[ 'event' ])
20
+ else:
21
+ ev_dir = None
22
+ l = glob.glob('../libevent*')
23
+ l.reverse()
24
+ for dir in l:
25
+ if os.path.isdir(dir):
26
+ ev_dir = dir
27
+ break
28
+ if not ev_dir:
29
+ raise "couldn't find libevent installation or build directory"
30
+
31
+ print 'found libevent build directory', ev_dir
32
+ ev_srcs = [ 'event.c' ]
33
+ ev_incdirs = [ ev_dir ]
34
+ ev_extargs = []
35
+ ev_extobjs = []
36
+ ev_libraries = []
37
+
38
+ if sys.platform == 'win32':
39
+ ev_incdirs.extend([ '%s/WIN32-Code' % ev_dir,
40
+ '%s/compat' % ev_dir ])
41
+ ev_srcs.extend([ '%s/%s' % (ev_dir, x) for x in [
42
+ 'WIN32-Code/misc.c', 'WIN32-Code/win32.c',
43
+ 'log.c', 'event.c' ]])
44
+ ev_extargs = [ '-DWIN32', '-DHAVE_CONFIG_H' ]
45
+ ev_libraries = [ 'wsock32' ]
46
+ else:
47
+ ev_extobjs = glob.glob('%s/*.o' % dir)
48
+
49
+ event = Extension(name='event',
50
+ sources=ev_srcs,
51
+ include_dirs=ev_incdirs,
52
+ extra_compile_args=ev_extargs,
53
+ extra_objects=ev_extobjs,
54
+ libraries=ev_libraries)
55
+
56
+ setup(name='event',
57
+ version='0.3',
58
+ author='Dug Song, Martin Murray',
59
+ url='http://monkey.org/~dugsong/pyevent',
60
+ description='event library',
61
+ ext_modules = [ event ])
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env python
2
+
3
+ import glob, os, signal, sys, time, unittest
4
+ sys.path.insert(0, glob.glob('./build/lib.*')[0])
5
+ import event
6
+
7
+ class EventTest(unittest.TestCase):
8
+ def setUp(self):
9
+ event.init()
10
+
11
+ def test_timeout(self):
12
+ def __timeout_cb(ev, handle, evtype, ts):
13
+ now = time.time()
14
+ assert int(now - ts['start']) == ts['secs'], 'timeout failed'
15
+ print 'test_timeout'
16
+ ts = { 'start':time.time(), 'secs':5 }
17
+ ev = event.event(__timeout_cb, arg=ts)
18
+ ev.add(ts['secs'])
19
+ event.dispatch()
20
+
21
+ def test_timeout2(self):
22
+ def __timeout2_cb(start, secs):
23
+ dur = int(time.time() - start)
24
+ assert dur == secs, 'timeout2 failed'
25
+ print 'test_timeout2'
26
+ event.timeout(5, __timeout2_cb, time.time(), 5)
27
+ event.dispatch()
28
+
29
+ def test_signal(self):
30
+ def __signal_cb(ev, sig, evtype, arg):
31
+ if evtype == event.EV_SIGNAL:
32
+ ev.delete()
33
+ elif evtype == event.EV_TIMEOUT:
34
+ os.kill(os.getpid(), signal.SIGUSR1)
35
+ print 'test_signal'
36
+ event.event(__signal_cb, handle=signal.SIGUSR1,
37
+ evtype=event.EV_SIGNAL).add()
38
+ event.event(__signal_cb).add(2)
39
+ event.dispatch()
40
+
41
+ def test_signal2(self):
42
+ def __signal2_cb(sig):
43
+ if sig:
44
+ event.abort()
45
+ else:
46
+ os.kill(os.getpid(), signal.SIGUSR1)
47
+ print 'test_signal2'
48
+ event.signal(signal.SIGUSR1, __signal2_cb, signal.SIGUSR1)
49
+ event.timeout(2, __signal2_cb)
50
+
51
+ def test_read(self):
52
+ def __read_cb(ev, fd, evtype, pipe):
53
+ buf = os.read(fd, 1024)
54
+ assert buf == 'hi niels', 'read event failed'
55
+ print 'test_read'
56
+ pipe = os.pipe()
57
+ event.event(__read_cb, handle=pipe[0],
58
+ evtype=event.EV_READ).add()
59
+ os.write(pipe[1], 'hi niels')
60
+ event.dispatch()
61
+
62
+ def test_read2(self):
63
+ def __read2_cb(fd, msg):
64
+ assert os.read(fd, 1024) == msg, 'read2 event failed'
65
+ print 'test_read2'
66
+ msg = 'hello world'
67
+ pipe = os.pipe()
68
+ event.read(pipe[0], __read2_cb, pipe[0], msg)
69
+ os.write(pipe[1], msg)
70
+ event.dispatch()
71
+
72
+ if __name__ == '__main__':
73
+ unittest.main()