memcached-manager 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.rspec +2 -0
  2. data/.travis.yml +19 -0
  3. data/CONTRIBUTING.md +28 -0
  4. data/Gemfile +26 -0
  5. data/Gemfile.lock +143 -0
  6. data/README.rdoc +15 -1
  7. data/Rakefile +60 -0
  8. data/VERSION +1 -0
  9. data/config.ru +2 -6
  10. data/features/api/create_memcached_key.feature +6 -0
  11. data/features/api/delete_memcached_key.feature +6 -0
  12. data/features/api/list_memcached_keys.feature +6 -0
  13. data/features/api/set_memcached_info.feature +5 -0
  14. data/features/api/show_memcached_key.feature +10 -0
  15. data/features/api/show_memcached_stats.feature +5 -0
  16. data/features/api/update_memcached_key.feature +7 -0
  17. data/features/step_definitions/api/create_memcached_key.rb +21 -0
  18. data/features/step_definitions/api/delete_memcached_key.rb +7 -0
  19. data/features/step_definitions/api/list_memcached_keys.rb +16 -0
  20. data/features/step_definitions/api/show_memcached_key.rb +18 -0
  21. data/features/step_definitions/api/show_memcached_stats.rb +3 -0
  22. data/features/step_definitions/api/update_memcached_key.rb +18 -0
  23. data/features/step_definitions/set_memcached_info.rb +25 -0
  24. data/features/step_definitions/webapp/create_memcached_key.rb +10 -0
  25. data/features/step_definitions/webapp/delete_memcached_key.rb +16 -0
  26. data/features/step_definitions/webapp/edit_memcached_key.rb +3 -0
  27. data/features/step_definitions/webapp/list_memcached_keys.rb +4 -0
  28. data/features/step_definitions/webapp/show_memcached_key.rb +4 -0
  29. data/features/step_definitions/webapp/show_memcached_stats.rb +5 -0
  30. data/features/support/env.rb +28 -0
  31. data/features/support/hooks.rb +3 -0
  32. data/features/webapp/create_memcached_key.feature +9 -0
  33. data/features/webapp/delete_memcached_key.feature +8 -0
  34. data/features/webapp/edit_memcached_key.feature +9 -0
  35. data/features/webapp/list_memcached_keys.feature +8 -0
  36. data/features/webapp/show_memcached_key.feature +7 -0
  37. data/features/webapp/show_memcached_stats.feature +6 -0
  38. data/lib/api.rb +85 -0
  39. data/lib/extensions/api_response.rb +15 -0
  40. data/lib/extensions/errors.rb +19 -0
  41. data/lib/extensions/memcached_connection.rb +15 -0
  42. data/lib/extensions/memcached_inspector.rb +49 -0
  43. data/lib/extensions/memcached_settings.rb +18 -0
  44. data/lib/extensions.rb +14 -0
  45. data/lib/memcached-manager.rb +4 -0
  46. data/lib/public/images/glyphicons-halflings-white.png +0 -0
  47. data/lib/public/images/glyphicons-halflings.png +0 -0
  48. data/lib/public/javascripts/angular/controllers.js +89 -0
  49. data/lib/public/javascripts/angular/routes.js +66 -0
  50. data/lib/public/javascripts/angular/services/notification.js +16 -0
  51. data/lib/public/javascripts/angular/services/resources.js +20 -0
  52. data/lib/public/javascripts/angular/services/response.js +10 -0
  53. data/lib/public/javascripts/angular-resource.min.js +10 -0
  54. data/lib/public/javascripts/angular-ui-states.min.js +7 -0
  55. data/lib/public/javascripts/angular.min.js +161 -0
  56. data/lib/public/javascripts/application.js +18 -0
  57. data/lib/public/javascripts/jquery-1.9.1.min.js +4 -0
  58. data/lib/public/javascripts/noty/jquery.noty.js +547 -0
  59. data/lib/public/javascripts/noty/layouts/top.js +34 -0
  60. data/lib/public/javascripts/noty/themes/default.js +156 -0
  61. data/lib/public/javascripts/noty_config.js +25 -0
  62. data/lib/public/stylesheets/app.css +50 -0
  63. data/lib/public/stylesheets/base.css +269 -0
  64. data/lib/public/stylesheets/icons.css +492 -0
  65. data/lib/public/stylesheets/layout.css +58 -0
  66. data/lib/public/stylesheets/skeleton.css +242 -0
  67. data/lib/public/templates/edit.html.erb +6 -0
  68. data/lib/public/templates/keys.html.erb +36 -0
  69. data/lib/public/templates/new.html.erb +6 -0
  70. data/lib/public/templates/show.html.erb +2 -0
  71. data/lib/public/templates/stats.html.erb +8 -0
  72. data/lib/routes.rb +4 -0
  73. data/lib/views/index.erb +13 -0
  74. data/lib/views/layout.erb +55 -0
  75. data/lib/webapp.rb +15 -0
  76. data/memcached-manager.gemspec +154 -0
  77. data/spec/javascripts/angular/controllers/list_keys_controller_spec.js +1 -0
  78. data/spec/javascripts/angular/services/notification_spec.js +2 -0
  79. data/spec/javascripts/angular/services/resource_spec.js +2 -0
  80. data/spec/javascripts/angular/services/response_spec.js +2 -0
  81. metadata +80 -6
@@ -0,0 +1,547 @@
1
+ /**
2
+ * noty - jQuery Notification Plugin v2.1.0
3
+ * Contributors: https://github.com/needim/noty/graphs/contributors
4
+ *
5
+ * Examples and Documentation - http://needim.github.com/noty/
6
+ *
7
+ * Licensed under the MIT licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ **/
11
+
12
+ if (typeof Object.create !== 'function') {
13
+ Object.create = function (o) {
14
+ function F() {
15
+ }
16
+
17
+ F.prototype = o;
18
+ return new F();
19
+ };
20
+ }
21
+
22
+ (function ($) {
23
+
24
+ var NotyObject = {
25
+
26
+ init:function (options) {
27
+
28
+ // Mix in the passed in options with the default options
29
+ this.options = $.extend({}, $.noty.defaults, options);
30
+
31
+ this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
32
+ this.options.theme = $.noty.themes[this.options.theme];
33
+
34
+ delete options.layout;
35
+ delete options.theme;
36
+
37
+ this.options = $.extend({}, this.options, this.options.layout.options);
38
+ this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random() * 1000000));
39
+
40
+ this.options = $.extend({}, this.options, options);
41
+
42
+ // Build the noty dom initial structure
43
+ this._build();
44
+
45
+ // return this so we can chain/use the bridge with less code.
46
+ return this;
47
+ }, // end init
48
+
49
+ _build:function () {
50
+
51
+ // Generating noty bar
52
+ var $bar = $('<div class="noty_bar"></div>').attr('id', this.options.id);
53
+ $bar.append(this.options.template).find('.noty_text').html(this.options.text);
54
+
55
+ this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
56
+
57
+ // Set buttons if available
58
+ if (this.options.buttons) {
59
+
60
+ // If we have button disable closeWith & timeout options
61
+ this.options.closeWith = [];
62
+ this.options.timeout = false;
63
+
64
+ var $buttons = $('<div/>').addClass('noty_buttons');
65
+
66
+ (this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
67
+
68
+ var self = this;
69
+
70
+ $.each(this.options.buttons, function (i, button) {
71
+ var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text)
72
+ .appendTo(self.$bar.find('.noty_buttons'))
73
+ .bind('click', function () {
74
+ if ($.isFunction(button.onClick)) {
75
+ button.onClick.call($button, self);
76
+ }
77
+ });
78
+ });
79
+ }
80
+
81
+ // For easy access
82
+ this.$message = this.$bar.find('.noty_message');
83
+ this.$closeButton = this.$bar.find('.noty_close');
84
+ this.$buttons = this.$bar.find('.noty_buttons');
85
+
86
+ $.noty.store[this.options.id] = this; // store noty for api
87
+
88
+ }, // end _build
89
+
90
+ show:function () {
91
+
92
+ var self = this;
93
+
94
+ $(self.options.layout.container.selector).append(self.$bar);
95
+
96
+ self.options.theme.style.apply(self);
97
+
98
+ ($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
99
+
100
+ self.$bar.addClass(self.options.layout.addClass);
101
+
102
+ self.options.layout.container.style.apply($(self.options.layout.container.selector));
103
+
104
+ self.options.theme.callback.onShow.apply(this);
105
+
106
+ if ($.inArray('click', self.options.closeWith) > -1)
107
+ self.$bar.css('cursor', 'pointer').one('click', function (evt) {
108
+ self.stopPropagation(evt);
109
+ if (self.options.callback.onCloseClick) {
110
+ self.options.callback.onCloseClick.apply(self);
111
+ }
112
+ self.close();
113
+ });
114
+
115
+ if ($.inArray('hover', self.options.closeWith) > -1)
116
+ self.$bar.one('mouseenter', function () {
117
+ self.close();
118
+ });
119
+
120
+ if ($.inArray('button', self.options.closeWith) > -1)
121
+ self.$closeButton.one('click', function (evt) {
122
+ self.stopPropagation(evt);
123
+ self.close();
124
+ });
125
+
126
+ if ($.inArray('button', self.options.closeWith) == -1)
127
+ self.$closeButton.remove();
128
+
129
+ if (self.options.callback.onShow)
130
+ self.options.callback.onShow.apply(self);
131
+
132
+ self.$bar.animate(
133
+ self.options.animation.open,
134
+ self.options.animation.speed,
135
+ self.options.animation.easing,
136
+ function () {
137
+ if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
138
+ self.shown = true;
139
+ });
140
+
141
+ // If noty is have a timeout option
142
+ if (self.options.timeout)
143
+ self.$bar.delay(self.options.timeout).promise().done(function () {
144
+ self.close();
145
+ });
146
+
147
+ return this;
148
+
149
+ }, // end show
150
+
151
+ close:function () {
152
+
153
+ if (this.closed) return;
154
+ if (this.$bar && this.$bar.hasClass('i-am-closing-now')) return;
155
+
156
+ var self = this;
157
+
158
+ if (!this.shown) { // If we are still waiting in the queue just delete from queue
159
+ var queue = [];
160
+ $.each($.noty.queue, function (i, n) {
161
+ if (n.options.id != self.options.id) {
162
+ queue.push(n);
163
+ }
164
+ });
165
+ $.noty.queue = queue;
166
+ return;
167
+ }
168
+
169
+ self.$bar.addClass('i-am-closing-now');
170
+
171
+ if (self.options.callback.onClose) {
172
+ self.options.callback.onClose.apply(self);
173
+ }
174
+
175
+ self.$bar.clearQueue().stop().animate(
176
+ self.options.animation.close,
177
+ self.options.animation.speed,
178
+ self.options.animation.easing,
179
+ function () {
180
+ if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self);
181
+ })
182
+ .promise().done(function () {
183
+
184
+ // Modal Cleaning
185
+ if (self.options.modal) {
186
+ $.notyRenderer.setModalCount(-1);
187
+ if ($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function () {
188
+ $(this).remove();
189
+ });
190
+ }
191
+
192
+ // Layout Cleaning
193
+ $.notyRenderer.setLayoutCountFor(self, -1);
194
+ if ($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
195
+
196
+ // Make sure self.$bar has not been removed before attempting to remove it
197
+ if (typeof self.$bar !== 'undefined' && self.$bar !== null ) {
198
+ self.$bar.remove();
199
+ self.$bar = null;
200
+ self.closed = true;
201
+ }
202
+
203
+ delete $.noty.store[self.options.id]; // deleting noty from store
204
+
205
+ self.options.theme.callback.onClose.apply(self);
206
+
207
+ if (!self.options.dismissQueue) {
208
+ // Queue render
209
+ $.noty.ontap = true;
210
+
211
+ $.notyRenderer.render();
212
+ }
213
+
214
+ if (self.options.maxVisible > 0 && self.options.dismissQueue) {
215
+ $.notyRenderer.render();
216
+ }
217
+ })
218
+
219
+ }, // end close
220
+
221
+ setText:function (text) {
222
+ if (!this.closed) {
223
+ this.options.text = text;
224
+ this.$bar.find('.noty_text').html(text);
225
+ }
226
+ return this;
227
+ },
228
+
229
+ setType:function (type) {
230
+ if (!this.closed) {
231
+ this.options.type = type;
232
+ this.options.theme.style.apply(this);
233
+ this.options.theme.callback.onShow.apply(this);
234
+ }
235
+ return this;
236
+ },
237
+
238
+ setTimeout:function (time) {
239
+ if (!this.closed) {
240
+ var self = this;
241
+ this.options.timeout = time;
242
+ self.$bar.delay(self.options.timeout).promise().done(function () {
243
+ self.close();
244
+ });
245
+ }
246
+ return this;
247
+ },
248
+
249
+ stopPropagation:function (evt) {
250
+ evt = evt || window.event;
251
+ if (typeof evt.stopPropagation !== "undefined") {
252
+ evt.stopPropagation();
253
+ } else {
254
+ evt.cancelBubble = true;
255
+ }
256
+ },
257
+
258
+ closed:false,
259
+ shown:false
260
+
261
+ }; // end NotyObject
262
+
263
+ $.notyRenderer = {};
264
+
265
+ $.notyRenderer.init = function (options) {
266
+
267
+ // Renderer creates a new noty
268
+ var notification = Object.create(NotyObject).init(options);
269
+
270
+ (notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
271
+
272
+ $.notyRenderer.render();
273
+
274
+ return ($.noty.returns == 'object') ? notification : notification.options.id;
275
+ };
276
+
277
+ $.notyRenderer.render = function () {
278
+
279
+ var instance = $.noty.queue[0];
280
+
281
+ if ($.type(instance) === 'object') {
282
+ if (instance.options.dismissQueue) {
283
+ if (instance.options.maxVisible > 0) {
284
+ if ($(instance.options.layout.container.selector + ' li').length < instance.options.maxVisible) {
285
+ $.notyRenderer.show($.noty.queue.shift());
286
+ } else {
287
+
288
+ }
289
+ } else {
290
+ $.notyRenderer.show($.noty.queue.shift());
291
+ }
292
+ } else {
293
+ if ($.noty.ontap) {
294
+ $.notyRenderer.show($.noty.queue.shift());
295
+ $.noty.ontap = false;
296
+ }
297
+ }
298
+ } else {
299
+ $.noty.ontap = true; // Queue is over
300
+ }
301
+
302
+ };
303
+
304
+ $.notyRenderer.show = function (notification) {
305
+
306
+ if (notification.options.modal) {
307
+ $.notyRenderer.createModalFor(notification);
308
+ $.notyRenderer.setModalCount(+1);
309
+ }
310
+
311
+ // Where is the container?
312
+ if ($(notification.options.layout.container.selector).length == 0) {
313
+ if (notification.options.custom) {
314
+ notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
315
+ } else {
316
+ $('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
317
+ }
318
+ } else {
319
+ $(notification.options.layout.container.selector).removeClass('i-am-new');
320
+ }
321
+
322
+ $.notyRenderer.setLayoutCountFor(notification, +1);
323
+
324
+ notification.show();
325
+ };
326
+
327
+ $.notyRenderer.createModalFor = function (notification) {
328
+ if ($('.noty_modal').length == 0)
329
+ $('<div/>').addClass('noty_modal').data('noty_modal_count', 0).css(notification.options.theme.modal.css).prependTo($('body')).fadeIn('fast');
330
+ };
331
+
332
+ $.notyRenderer.getLayoutCountFor = function (notification) {
333
+ return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
334
+ };
335
+
336
+ $.notyRenderer.setLayoutCountFor = function (notification, arg) {
337
+ return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
338
+ };
339
+
340
+ $.notyRenderer.getModalCount = function () {
341
+ return $('.noty_modal').data('noty_modal_count') || 0;
342
+ };
343
+
344
+ $.notyRenderer.setModalCount = function (arg) {
345
+ return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
346
+ };
347
+
348
+ // This is for custom container
349
+ $.fn.noty = function (options) {
350
+ options.custom = $(this);
351
+ return $.notyRenderer.init(options);
352
+ };
353
+
354
+ $.noty = {};
355
+ $.noty.queue = [];
356
+ $.noty.ontap = true;
357
+ $.noty.layouts = {};
358
+ $.noty.themes = {};
359
+ $.noty.returns = 'object';
360
+ $.noty.store = {};
361
+
362
+ $.noty.get = function (id) {
363
+ return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
364
+ };
365
+
366
+ $.noty.close = function (id) {
367
+ return $.noty.get(id) ? $.noty.get(id).close() : false;
368
+ };
369
+
370
+ $.noty.setText = function (id, text) {
371
+ return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
372
+ };
373
+
374
+ $.noty.setType = function (id, type) {
375
+ return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
376
+ };
377
+
378
+ $.noty.clearQueue = function () {
379
+ $.noty.queue = [];
380
+ };
381
+
382
+ $.noty.closeAll = function () {
383
+ $.noty.clearQueue();
384
+ $.each($.noty.store, function (id, noty) {
385
+ noty.close();
386
+ });
387
+ };
388
+
389
+ var windowAlert = window.alert;
390
+
391
+ $.noty.consumeAlert = function (options) {
392
+ window.alert = function (text) {
393
+ if (options)
394
+ options.text = text;
395
+ else
396
+ options = {text:text};
397
+
398
+ $.notyRenderer.init(options);
399
+ };
400
+ };
401
+
402
+ $.noty.stopConsumeAlert = function () {
403
+ window.alert = windowAlert;
404
+ };
405
+
406
+ $.noty.defaults = {
407
+ layout:'top',
408
+ theme:'defaultTheme',
409
+ type:'alert',
410
+ text:'',
411
+ dismissQueue:true,
412
+ template:'<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
413
+ animation:{
414
+ open:{height:'toggle'},
415
+ close:{height:'toggle'},
416
+ easing:'swing',
417
+ speed:500
418
+ },
419
+ timeout:false,
420
+ force:false,
421
+ modal:false,
422
+ maxVisible:5,
423
+ closeWith:['click'],
424
+ callback:{
425
+ onShow:function () {
426
+ },
427
+ afterShow:function () {
428
+ },
429
+ onClose:function () {
430
+ },
431
+ afterClose:function () {
432
+ },
433
+ onCloseClick:function () {
434
+ }
435
+ },
436
+ buttons:false
437
+ };
438
+
439
+ $(window).resize(function () {
440
+ $.each($.noty.layouts, function (index, layout) {
441
+ layout.container.style.apply($(layout.container.selector));
442
+ });
443
+ });
444
+
445
+ })(jQuery);
446
+
447
+ // Helpers
448
+ window.noty = function noty(options) {
449
+
450
+ // This is for BC - Will be deleted on v2.2.0
451
+ var using_old = 0
452
+ , old_to_new = {
453
+ 'animateOpen':'animation.open',
454
+ 'animateClose':'animation.close',
455
+ 'easing':'animation.easing',
456
+ 'speed':'animation.speed',
457
+ 'onShow':'callback.onShow',
458
+ 'onShown':'callback.afterShow',
459
+ 'onClose':'callback.onClose',
460
+ 'onCloseClick':'callback.onCloseClick',
461
+ 'onClosed':'callback.afterClose'
462
+ };
463
+
464
+ jQuery.each(options, function (key, value) {
465
+ if (old_to_new[key]) {
466
+ using_old++;
467
+ var _new = old_to_new[key].split('.');
468
+
469
+ if (!options[_new[0]]) options[_new[0]] = {};
470
+
471
+ options[_new[0]][_new[1]] = (value) ? value : function () {
472
+ };
473
+ delete options[key];
474
+ }
475
+ });
476
+
477
+ if (!options.closeWith) {
478
+ options.closeWith = jQuery.noty.defaults.closeWith;
479
+ }
480
+
481
+ if (options.hasOwnProperty('closeButton')) {
482
+ using_old++;
483
+ if (options.closeButton) options.closeWith.push('button');
484
+ delete options.closeButton;
485
+ }
486
+
487
+ if (options.hasOwnProperty('closeOnSelfClick')) {
488
+ using_old++;
489
+ if (options.closeOnSelfClick) options.closeWith.push('click');
490
+ delete options.closeOnSelfClick;
491
+ }
492
+
493
+ if (options.hasOwnProperty('closeOnSelfOver')) {
494
+ using_old++;
495
+ if (options.closeOnSelfOver) options.closeWith.push('hover');
496
+ delete options.closeOnSelfOver;
497
+ }
498
+
499
+ if (options.hasOwnProperty('custom')) {
500
+ using_old++;
501
+ if (options.custom.container != 'null') options.custom = options.custom.container;
502
+ }
503
+
504
+ if (options.hasOwnProperty('cssPrefix')) {
505
+ using_old++;
506
+ delete options.cssPrefix;
507
+ }
508
+
509
+ if (options.theme == 'noty_theme_default') {
510
+ using_old++;
511
+ options.theme = 'defaultTheme';
512
+ }
513
+
514
+ if (!options.hasOwnProperty('dismissQueue')) {
515
+ options.dismissQueue = jQuery.noty.defaults.dismissQueue;
516
+ }
517
+
518
+ if (!options.hasOwnProperty('maxVisible')) {
519
+ options.maxVisible = jQuery.noty.defaults.maxVisible;
520
+ }
521
+
522
+ if (options.buttons) {
523
+ jQuery.each(options.buttons, function (i, button) {
524
+ if (button.click) {
525
+ using_old++;
526
+ button.onClick = button.click;
527
+ delete button.click;
528
+ }
529
+ if (button.type) {
530
+ using_old++;
531
+ button.addClass = button.type;
532
+ delete button.type;
533
+ }
534
+ });
535
+ }
536
+
537
+ if (using_old) {
538
+ if (typeof console !== "undefined" && console.warn) {
539
+ console.warn('You are using noty v2 with v1.x.x options. @deprecated until v2.2.0 - Please update your options.');
540
+ }
541
+ }
542
+
543
+ // console.log(options);
544
+ // End of the BC
545
+
546
+ return jQuery.notyRenderer.init(options);
547
+ }
@@ -0,0 +1,34 @@
1
+ ;(function($) {
2
+
3
+ $.noty.layouts.top = {
4
+ name: 'top',
5
+ options: {},
6
+ container: {
7
+ object: '<ul id="noty_top_layout_container" />',
8
+ selector: 'ul#noty_top_layout_container',
9
+ style: function() {
10
+ $(this).css({
11
+ top: 0,
12
+ left: '5%',
13
+ position: 'fixed',
14
+ width: '90%',
15
+ height: 'auto',
16
+ margin: 0,
17
+ padding: 0,
18
+ listStyleType: 'none',
19
+ zIndex: 9999999
20
+ });
21
+ }
22
+ },
23
+ parent: {
24
+ object: '<li />',
25
+ selector: 'li',
26
+ css: {}
27
+ },
28
+ css: {
29
+ display: 'none'
30
+ },
31
+ addClass: ''
32
+ };
33
+
34
+ })(jQuery);