jim 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/HISTORY +28 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +2 -1
  4. data/jim.gemspec +67 -9
  5. data/lib/jim/bundler.rb +14 -11
  6. data/lib/jim/cli.rb +51 -9
  7. data/lib/jim/index.rb +3 -7
  8. data/lib/jim/installer.rb +140 -22
  9. data/lib/jim/templates/commands +21 -6
  10. data/lib/jim/version_parser.rb +2 -3
  11. data/lib/jim.rb +19 -2
  12. data/test/fixtures/jimfile +3 -3
  13. data/test/fixtures/sammy-0.5.0/HISTORY.md +135 -0
  14. data/test/fixtures/sammy-0.5.0/LICENSE +22 -0
  15. data/test/fixtures/sammy-0.5.0/README.md +81 -0
  16. data/test/fixtures/sammy-0.5.0/Rakefile +174 -0
  17. data/test/fixtures/sammy-0.5.0/examples/backend/README.md +23 -0
  18. data/test/fixtures/sammy-0.5.0/examples/backend/Rakefile +15 -0
  19. data/test/fixtures/sammy-0.5.0/examples/backend/app.rb +17 -0
  20. data/test/fixtures/sammy-0.5.0/examples/backend/app.ru +3 -0
  21. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/app.js +106 -0
  22. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/jquery.cloudkit.js +840 -0
  23. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/jquery.js +19 -0
  24. data/test/fixtures/sammy-0.5.0/examples/backend/public/javascripts/sammy.js +1013 -0
  25. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/index.html.erb +11 -0
  26. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/task.html.erb +4 -0
  27. data/test/fixtures/sammy-0.5.0/examples/backend/public/templates/task_details.html.erb +4 -0
  28. data/test/fixtures/sammy-0.5.0/examples/backend/views/app.sass +63 -0
  29. data/test/fixtures/sammy-0.5.0/examples/backend/views/index.haml +18 -0
  30. data/test/fixtures/sammy-0.5.0/examples/form_handling/files/form.html +12 -0
  31. data/test/fixtures/sammy-0.5.0/examples/form_handling/index.html +65 -0
  32. data/test/fixtures/sammy-0.5.0/examples/hello_world/index.html +50 -0
  33. data/test/fixtures/sammy-0.5.0/examples/location_override/README.md +15 -0
  34. data/test/fixtures/sammy-0.5.0/examples/location_override/data.html +110 -0
  35. data/test/fixtures/sammy-0.5.0/examples/location_override/index.html +79 -0
  36. data/test/fixtures/sammy-0.5.0/examples/location_override/test.html +121 -0
  37. data/test/fixtures/sammy-0.5.0/lib/min/sammy-0.5.0.min.js +5 -0
  38. data/test/fixtures/sammy-0.5.0/lib/min/sammy-lastest.min.js +5 -0
  39. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.cache.js +117 -0
  40. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.haml.js +539 -0
  41. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.json.js +362 -0
  42. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.mustache.js +415 -0
  43. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.nested_params.js +118 -0
  44. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.storage.js +515 -0
  45. data/test/fixtures/sammy-0.5.0/lib/plugins/sammy.template.js +117 -0
  46. data/test/fixtures/sammy-0.5.0/lib/sammy.js +1367 -0
  47. data/test/fixtures/sammy-0.5.0/test/fixtures/partial +1 -0
  48. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.html +1 -0
  49. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.noengine +1 -0
  50. data/test/fixtures/sammy-0.5.0/test/fixtures/partial.template +1 -0
  51. data/test/fixtures/sammy-0.5.0/test/index.html +84 -0
  52. data/test/fixtures/sammy-0.5.0/test/test_sammy_application.js +953 -0
  53. data/test/fixtures/sammy-0.5.0/test/test_sammy_event_context.js +252 -0
  54. data/test/fixtures/sammy-0.5.0/test/test_sammy_location_proxy.js +91 -0
  55. data/test/fixtures/sammy-0.5.0/test/test_sammy_plugins.js +296 -0
  56. data/test/fixtures/sammy-0.5.0/test/test_sammy_storage.js +175 -0
  57. data/test/fixtures/sammy-0.5.0/test/test_server +27 -0
  58. data/test/fixtures/sammy-0.5.0/vendor/jquery-1.4.1.js +6078 -0
  59. data/test/fixtures/sammy-0.5.0/vendor/jquery-1.4.1.min.js +152 -0
  60. data/test/fixtures/sammy-0.5.0/vendor/jsdoc/doc.haml +58 -0
  61. data/test/fixtures/sammy-0.5.0/vendor/jsdoc/jsdoc.rb +143 -0
  62. data/test/fixtures/sammy-0.5.0/vendor/jslitmus.js +670 -0
  63. data/test/fixtures/sammy-0.5.0/vendor/qunit/qunit.css +119 -0
  64. data/test/fixtures/sammy-0.5.0/vendor/qunit/qunit.js +1043 -0
  65. data/test/fixtures/sammy-0.5.0/vendor/qunit-spec.js +127 -0
  66. data/test/helper.rb +23 -3
  67. data/test/test_jim_bundler.rb +9 -8
  68. data/test/test_jim_cli.rb +21 -12
  69. data/test/test_jim_installer.rb +152 -35
  70. data/test/test_jim_version_parser.rb +4 -0
  71. metadata +117 -27
  72. data/.document +0 -5
@@ -0,0 +1,362 @@
1
+ (function($) {
2
+
3
+ // json2.js - only included if native json does not exist
4
+ // http://www.json.org/js.html
5
+ if (!window.JSON) {
6
+ window.JSON = {};
7
+ }
8
+ (function () {
9
+
10
+ function f(n) {
11
+ // Format integers to have at least two digits.
12
+ return n < 10 ? '0' + n : n;
13
+ }
14
+
15
+ if (typeof Date.prototype.toJSON !== 'function') {
16
+
17
+ Date.prototype.toJSON = function (key) {
18
+
19
+ return this.getUTCFullYear() + '-' +
20
+ f(this.getUTCMonth() + 1) + '-' +
21
+ f(this.getUTCDate()) + 'T' +
22
+ f(this.getUTCHours()) + ':' +
23
+ f(this.getUTCMinutes()) + ':' +
24
+ f(this.getUTCSeconds()) + 'Z';
25
+ };
26
+
27
+ String.prototype.toJSON =
28
+ Number.prototype.toJSON =
29
+ Boolean.prototype.toJSON = function (key) {
30
+ return this.valueOf();
31
+ };
32
+ }
33
+
34
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
35
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
36
+ gap,
37
+ indent,
38
+ meta = { // table of character substitutions
39
+ '\b': '\\b',
40
+ '\t': '\\t',
41
+ '\n': '\\n',
42
+ '\f': '\\f',
43
+ '\r': '\\r',
44
+ '"' : '\\"',
45
+ '\\': '\\\\'
46
+ },
47
+ rep;
48
+
49
+
50
+ function quote(string) {
51
+
52
+ // If the string contains no control characters, no quote characters, and no
53
+ // backslash characters, then we can safely slap some quotes around it.
54
+ // Otherwise we must also replace the offending characters with safe escape
55
+ // sequences.
56
+
57
+ escapable.lastIndex = 0;
58
+ return escapable.test(string) ?
59
+ '"' + string.replace(escapable, function (a) {
60
+ var c = meta[a];
61
+ return typeof c === 'string' ? c :
62
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
63
+ }) + '"' :
64
+ '"' + string + '"';
65
+ }
66
+
67
+
68
+ function str(key, holder) {
69
+
70
+ // Produce a string from holder[key].
71
+
72
+ var i, // The loop counter.
73
+ k, // The member key.
74
+ v, // The member value.
75
+ length,
76
+ mind = gap,
77
+ partial,
78
+ value = holder[key];
79
+
80
+ // If the value has a toJSON method, call it to obtain a replacement value.
81
+
82
+ if (value && typeof value === 'object' &&
83
+ typeof value.toJSON === 'function') {
84
+ value = value.toJSON(key);
85
+ }
86
+
87
+ // If we were called with a replacer function, then call the replacer to
88
+ // obtain a replacement value.
89
+
90
+ if (typeof rep === 'function') {
91
+ value = rep.call(holder, key, value);
92
+ }
93
+
94
+ // What happens next depends on the value's type.
95
+
96
+ switch (typeof value) {
97
+ case 'string':
98
+ return quote(value);
99
+
100
+ case 'number':
101
+
102
+ // JSON numbers must be finite. Encode non-finite numbers as null.
103
+
104
+ return isFinite(value) ? String(value) : 'null';
105
+
106
+ case 'boolean':
107
+ case 'null':
108
+
109
+ // If the value is a boolean or null, convert it to a string. Note:
110
+ // typeof null does not produce 'null'. The case is included here in
111
+ // the remote chance that this gets fixed someday.
112
+
113
+ return String(value);
114
+
115
+ // If the type is 'object', we might be dealing with an object or an array or
116
+ // null.
117
+
118
+ case 'object':
119
+
120
+ // Due to a specification blunder in ECMAScript, typeof null is 'object',
121
+ // so watch out for that case.
122
+
123
+ if (!value) {
124
+ return 'null';
125
+ }
126
+
127
+ // Make an array to hold the partial results of stringifying this object value.
128
+
129
+ gap += indent;
130
+ partial = [];
131
+
132
+ // Is the value an array?
133
+
134
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
135
+
136
+ // The value is an array. Stringify every element. Use null as a placeholder
137
+ // for non-JSON values.
138
+
139
+ length = value.length;
140
+ for (i = 0; i < length; i += 1) {
141
+ partial[i] = str(i, value) || 'null';
142
+ }
143
+
144
+ // Join all of the elements together, separated with commas, and wrap them in
145
+ // brackets.
146
+
147
+ v = partial.length === 0 ? '[]' :
148
+ gap ? '[\n' + gap +
149
+ partial.join(',\n' + gap) + '\n' +
150
+ mind + ']' :
151
+ '[' + partial.join(',') + ']';
152
+ gap = mind;
153
+ return v;
154
+ }
155
+
156
+ // If the replacer is an array, use it to select the members to be stringified.
157
+
158
+ if (rep && typeof rep === 'object') {
159
+ length = rep.length;
160
+ for (i = 0; i < length; i += 1) {
161
+ k = rep[i];
162
+ if (typeof k === 'string') {
163
+ v = str(k, value);
164
+ if (v) {
165
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
166
+ }
167
+ }
168
+ }
169
+ } else {
170
+
171
+ // Otherwise, iterate through all of the keys in the object.
172
+
173
+ for (k in value) {
174
+ if (Object.hasOwnProperty.call(value, k)) {
175
+ v = str(k, value);
176
+ if (v) {
177
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ // Join all of the member texts together, separated with commas,
184
+ // and wrap them in braces.
185
+
186
+ v = partial.length === 0 ? '{}' :
187
+ gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
188
+ mind + '}' : '{' + partial.join(',') + '}';
189
+ gap = mind;
190
+ return v;
191
+ }
192
+ }
193
+
194
+ // If the JSON object does not yet have a stringify method, give it one.
195
+
196
+ if (typeof JSON.stringify !== 'function') {
197
+ JSON.stringify = function (value, replacer, space) {
198
+
199
+ // The stringify method takes a value and an optional replacer, and an optional
200
+ // space parameter, and returns a JSON text. The replacer can be a function
201
+ // that can replace values, or an array of strings that will select the keys.
202
+ // A default replacer method can be provided. Use of the space parameter can
203
+ // produce text that is more easily readable.
204
+
205
+ var i;
206
+ gap = '';
207
+ indent = '';
208
+
209
+ // If the space parameter is a number, make an indent string containing that
210
+ // many spaces.
211
+
212
+ if (typeof space === 'number') {
213
+ for (i = 0; i < space; i += 1) {
214
+ indent += ' ';
215
+ }
216
+
217
+ // If the space parameter is a string, it will be used as the indent string.
218
+
219
+ } else if (typeof space === 'string') {
220
+ indent = space;
221
+ }
222
+
223
+ // If there is a replacer, it must be a function or an array.
224
+ // Otherwise, throw an error.
225
+
226
+ rep = replacer;
227
+ if (replacer && typeof replacer !== 'function' &&
228
+ (typeof replacer !== 'object' ||
229
+ typeof replacer.length !== 'number')) {
230
+ throw new Error('JSON.stringify');
231
+ }
232
+
233
+ // Make a fake root object containing our value under the key of ''.
234
+ // Return the result of stringifying the value.
235
+
236
+ return str('', {'': value});
237
+ };
238
+ }
239
+
240
+
241
+ // If the JSON object does not yet have a parse method, give it one.
242
+
243
+ if (typeof JSON.parse !== 'function') {
244
+ JSON.parse = function (text, reviver) {
245
+
246
+ // The parse method takes a text and an optional reviver function, and returns
247
+ // a JavaScript value if the text is a valid JSON text.
248
+
249
+ var j;
250
+
251
+ function walk(holder, key) {
252
+
253
+ // The walk method is used to recursively walk the resulting structure so
254
+ // that modifications can be made.
255
+
256
+ var k, v, value = holder[key];
257
+ if (value && typeof value === 'object') {
258
+ for (k in value) {
259
+ if (Object.hasOwnProperty.call(value, k)) {
260
+ v = walk(value, k);
261
+ if (v !== undefined) {
262
+ value[k] = v;
263
+ } else {
264
+ delete value[k];
265
+ }
266
+ }
267
+ }
268
+ }
269
+ return reviver.call(holder, key, value);
270
+ }
271
+
272
+
273
+ // Parsing happens in four stages. In the first stage, we replace certain
274
+ // Unicode characters with escape sequences. JavaScript handles many characters
275
+ // incorrectly, either silently deleting them, or treating them as line endings.
276
+
277
+ cx.lastIndex = 0;
278
+ if (cx.test(text)) {
279
+ text = text.replace(cx, function (a) {
280
+ return '\\u' +
281
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
282
+ });
283
+ }
284
+
285
+ // In the second stage, we run the text against regular expressions that look
286
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
287
+ // because they can cause invocation, and '=' because it can cause mutation.
288
+ // But just to be safe, we want to reject all unexpected forms.
289
+
290
+ // We split the second stage into 4 regexp operations in order to work around
291
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
292
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
293
+ // replace all simple value tokens with ']' characters. Third, we delete all
294
+ // open brackets that follow a colon or comma or that begin the text. Finally,
295
+ // we look to see that the remaining characters are only whitespace or ']' or
296
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
297
+
298
+ if (/^[\],:{}\s]*$/.
299
+ test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
300
+ replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
301
+ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
302
+
303
+ // In the third stage we use the eval function to compile the text into a
304
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
305
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
306
+ // in parens to eliminate the ambiguity.
307
+
308
+ j = eval('(' + text + ')');
309
+
310
+ // In the optional fourth stage, we recursively walk the new structure, passing
311
+ // each name/value pair to a reviver function for possible transformation.
312
+
313
+ return typeof reviver === 'function' ?
314
+ walk({'': j}, '') : j;
315
+ }
316
+
317
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
318
+
319
+ throw new SyntaxError('JSON.parse');
320
+ };
321
+ }
322
+ }());
323
+
324
+ Sammy = Sammy || {};
325
+
326
+ // Sammy.JSON is a simple wrapper around Douglas Crockford's ever-useful json2.js
327
+ // (http://www.json.org/js.html]) Sammy.JSON includes the top level JSON object if
328
+ // it doesn't already exist (a.k.a. does not override the native implementation that
329
+ // some browsers include). It also adds a <tt>json()</tt> helper to a Sammy app when
330
+ // included.
331
+ Sammy.JSON = function(app) {
332
+
333
+ app.helpers({
334
+ // json is a polymorphic function that translates objects aback and forth
335
+ // from JSON to JS. If given a string, it will parse into JS, if given a JS
336
+ // object it will stringify into JSON.
337
+ //
338
+ // === Example
339
+ //
340
+ // var app = $.sammy(function() {
341
+ // this.use(Sammy.JSON);
342
+ //
343
+ // this.get('#/', function() {
344
+ // this.json({user_id: 123}); //=> "{\"user_id\":\"123\"}"
345
+ // this.json("{\"user_id\":\"123\"}"); //=> [object Object]
346
+ // this.json("{\"user_id\":\"123\"}").user_id; //=> "123"
347
+ // });
348
+ // })
349
+ //
350
+ //
351
+ json: function(object) {
352
+ if (typeof object == 'string') {
353
+ return JSON.parse(object);
354
+ } else {
355
+ return JSON.stringify(object);
356
+ }
357
+ }
358
+ });
359
+
360
+ }
361
+
362
+ })(jQuery);