bpm 1.0.0.beta.4 → 1.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/TODO.md +4 -10
  3. data/backbone/LICENSE +22 -0
  4. data/backbone/README +25 -0
  5. data/backbone/Rakefile +42 -0
  6. data/backbone/backbone-0.5.1.bpkg +0 -0
  7. data/backbone/examples/backbone-localstorage.js +84 -0
  8. data/backbone/examples/todos/destroy.png +0 -0
  9. data/backbone/examples/todos/index.html +87 -0
  10. data/backbone/examples/todos/todos.css +311 -0
  11. data/backbone/examples/todos/todos.js +258 -0
  12. data/backbone/index.html +2606 -0
  13. data/backbone/index.js +1 -0
  14. data/backbone/lib/backbone.js +1149 -0
  15. data/backbone/lib/index.js +1 -0
  16. data/backbone/package.json +14 -0
  17. data/backbone/test/collection.js +345 -0
  18. data/backbone/test/events.js +70 -0
  19. data/backbone/test/model.coffee +43 -0
  20. data/backbone/test/model.js +424 -0
  21. data/backbone/test/noconflict.js +12 -0
  22. data/backbone/test/router.js +116 -0
  23. data/backbone/test/speed.js +45 -0
  24. data/backbone/test/sync.js +133 -0
  25. data/backbone/test/test-zepto.html +30 -0
  26. data/backbone/test/test.html +31 -0
  27. data/backbone/test/vendor/jquery-1.5.js +8176 -0
  28. data/backbone/test/vendor/jslitmus.js +649 -0
  29. data/backbone/test/vendor/json2.js +481 -0
  30. data/backbone/test/vendor/qunit.css +196 -0
  31. data/backbone/test/vendor/qunit.js +1364 -0
  32. data/backbone/test/vendor/underscore-1.1.6.js +807 -0
  33. data/backbone/test/vendor/zepto-0.6.js +692 -0
  34. data/backbone/test/view.js +137 -0
  35. data/lib/bpm/cli/base.rb +22 -7
  36. data/lib/bpm/package.rb +17 -5
  37. data/lib/bpm/project.rb +49 -32
  38. data/lib/bpm/version.rb +1 -1
  39. data/spec/cli/add_spec.rb +22 -4
  40. data/spec/cli/fetch_spec.rb +0 -1
  41. data/spec/cli/init_spec.rb +25 -10
  42. data/spec/cli/list_spec.rb +103 -62
  43. data/spec/cli/pack_spec.rb +36 -4
  44. data/spec/fixtures/packages/backbone/LICENSE +22 -0
  45. data/spec/fixtures/packages/backbone/README +25 -0
  46. data/spec/fixtures/packages/backbone/Rakefile +42 -0
  47. data/spec/fixtures/packages/backbone/examples/backbone-localstorage.js +84 -0
  48. data/spec/fixtures/packages/backbone/examples/todos/destroy.png +0 -0
  49. data/spec/fixtures/packages/backbone/examples/todos/index.html +87 -0
  50. data/spec/fixtures/packages/backbone/examples/todos/todos.css +311 -0
  51. data/spec/fixtures/packages/backbone/examples/todos/todos.js +258 -0
  52. data/spec/fixtures/packages/backbone/index.html +2606 -0
  53. data/spec/fixtures/packages/backbone/lib/backbone.js +1149 -0
  54. data/spec/fixtures/packages/backbone/lib/index.js +1 -0
  55. data/spec/fixtures/packages/backbone/package.json +14 -0
  56. data/spec/fixtures/packages/backbone/test/collection.js +345 -0
  57. data/spec/fixtures/packages/backbone/test/events.js +70 -0
  58. data/spec/fixtures/packages/backbone/test/model.coffee +43 -0
  59. data/spec/fixtures/packages/backbone/test/model.js +424 -0
  60. data/spec/fixtures/packages/backbone/test/noconflict.js +12 -0
  61. data/spec/fixtures/packages/backbone/test/router.js +116 -0
  62. data/spec/fixtures/packages/backbone/test/speed.js +45 -0
  63. data/spec/fixtures/packages/backbone/test/sync.js +133 -0
  64. data/spec/fixtures/packages/backbone/test/test-zepto.html +30 -0
  65. data/spec/fixtures/packages/backbone/test/test.html +31 -0
  66. data/spec/fixtures/packages/backbone/test/vendor/jquery-1.5.js +8176 -0
  67. data/spec/fixtures/packages/backbone/test/vendor/jslitmus.js +649 -0
  68. data/spec/fixtures/packages/backbone/test/vendor/json2.js +481 -0
  69. data/spec/fixtures/packages/backbone/test/vendor/qunit.css +196 -0
  70. data/spec/fixtures/packages/backbone/test/vendor/qunit.js +1364 -0
  71. data/spec/fixtures/packages/backbone/test/vendor/underscore-1.1.6.js +807 -0
  72. data/spec/fixtures/packages/backbone/test/vendor/zepto-0.6.js +692 -0
  73. data/spec/fixtures/packages/backbone/test/view.js +137 -0
  74. data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
  75. data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
  76. data/spec/fixtures/projects/init_app/new_project.json +1 -10
  77. data/spec/pipeline_spec.rb +5 -5
  78. data/spec/plugins/minifier_spec.rb +1 -1
  79. data/spec/plugins/transport_spec.rb +1 -1
  80. metadata +116 -28
  81. data/spec/fixtures/projects/init_app/assets/new_project/bpm_libs.js +0 -6
  82. data/spec/fixtures/projects/init_app/assets/new_project/bpm_styles.css +0 -5
@@ -0,0 +1,258 @@
1
+ // An example Backbone application contributed by
2
+ // [Jérôme Gravel-Niquet](http://jgn.me/). This demo uses a simple
3
+ // [LocalStorage adapter](backbone-localstorage.html)
4
+ // to persist Backbone models within your browser.
5
+
6
+ // Load the application once the DOM is ready, using `jQuery.ready`:
7
+ $(function(){
8
+
9
+ // Todo Model
10
+ // ----------
11
+
12
+ // Our basic **Todo** model has `content`, `order`, and `done` attributes.
13
+ window.Todo = Backbone.Model.extend({
14
+
15
+ // Default attributes for the todo.
16
+ defaults: {
17
+ content: "empty todo...",
18
+ done: false
19
+ },
20
+
21
+ // Ensure that each todo created has `content`.
22
+ initialize: function() {
23
+ if (!this.get("content")) {
24
+ this.set({"content": this.defaults.content});
25
+ }
26
+ },
27
+
28
+ // Toggle the `done` state of this todo item.
29
+ toggle: function() {
30
+ this.save({done: !this.get("done")});
31
+ },
32
+
33
+ // Remove this Todo from *localStorage* and delete its view.
34
+ clear: function() {
35
+ this.destroy();
36
+ this.view.remove();
37
+ }
38
+
39
+ });
40
+
41
+ // Todo Collection
42
+ // ---------------
43
+
44
+ // The collection of todos is backed by *localStorage* instead of a remote
45
+ // server.
46
+ window.TodoList = Backbone.Collection.extend({
47
+
48
+ // Reference to this collection's model.
49
+ model: Todo,
50
+
51
+ // Save all of the todo items under the `"todos"` namespace.
52
+ localStorage: new Store("todos"),
53
+
54
+ // Filter down the list of all todo items that are finished.
55
+ done: function() {
56
+ return this.filter(function(todo){ return todo.get('done'); });
57
+ },
58
+
59
+ // Filter down the list to only todo items that are still not finished.
60
+ remaining: function() {
61
+ return this.without.apply(this, this.done());
62
+ },
63
+
64
+ // We keep the Todos in sequential order, despite being saved by unordered
65
+ // GUID in the database. This generates the next order number for new items.
66
+ nextOrder: function() {
67
+ if (!this.length) return 1;
68
+ return this.last().get('order') + 1;
69
+ },
70
+
71
+ // Todos are sorted by their original insertion order.
72
+ comparator: function(todo) {
73
+ return todo.get('order');
74
+ }
75
+
76
+ });
77
+
78
+ // Create our global collection of **Todos**.
79
+ window.Todos = new TodoList;
80
+
81
+ // Todo Item View
82
+ // --------------
83
+
84
+ // The DOM element for a todo item...
85
+ window.TodoView = Backbone.View.extend({
86
+
87
+ //... is a list tag.
88
+ tagName: "li",
89
+
90
+ // Cache the template function for a single item.
91
+ template: _.template($('#item-template').html()),
92
+
93
+ // The DOM events specific to an item.
94
+ events: {
95
+ "click .check" : "toggleDone",
96
+ "dblclick div.todo-content" : "edit",
97
+ "click span.todo-destroy" : "clear",
98
+ "keypress .todo-input" : "updateOnEnter"
99
+ },
100
+
101
+ // The TodoView listens for changes to its model, re-rendering. Since there's
102
+ // a one-to-one correspondence between a **Todo** and a **TodoView** in this
103
+ // app, we set a direct reference on the model for convenience.
104
+ initialize: function() {
105
+ _.bindAll(this, 'render', 'close');
106
+ this.model.bind('change', this.render);
107
+ this.model.view = this;
108
+ },
109
+
110
+ // Re-render the contents of the todo item.
111
+ render: function() {
112
+ $(this.el).html(this.template(this.model.toJSON()));
113
+ this.setContent();
114
+ return this;
115
+ },
116
+
117
+ // To avoid XSS (not that it would be harmful in this particular app),
118
+ // we use `jQuery.text` to set the contents of the todo item.
119
+ setContent: function() {
120
+ var content = this.model.get('content');
121
+ this.$('.todo-content').text(content);
122
+ this.input = this.$('.todo-input');
123
+ this.input.bind('blur', this.close);
124
+ this.input.val(content);
125
+ },
126
+
127
+ // Toggle the `"done"` state of the model.
128
+ toggleDone: function() {
129
+ this.model.toggle();
130
+ },
131
+
132
+ // Switch this view into `"editing"` mode, displaying the input field.
133
+ edit: function() {
134
+ $(this.el).addClass("editing");
135
+ this.input.focus();
136
+ },
137
+
138
+ // Close the `"editing"` mode, saving changes to the todo.
139
+ close: function() {
140
+ this.model.save({content: this.input.val()});
141
+ $(this.el).removeClass("editing");
142
+ },
143
+
144
+ // If you hit `enter`, we're through editing the item.
145
+ updateOnEnter: function(e) {
146
+ if (e.keyCode == 13) this.close();
147
+ },
148
+
149
+ // Remove this view from the DOM.
150
+ remove: function() {
151
+ $(this.el).remove();
152
+ },
153
+
154
+ // Remove the item, destroy the model.
155
+ clear: function() {
156
+ this.model.clear();
157
+ }
158
+
159
+ });
160
+
161
+ // The Application
162
+ // ---------------
163
+
164
+ // Our overall **AppView** is the top-level piece of UI.
165
+ window.AppView = Backbone.View.extend({
166
+
167
+ // Instead of generating a new element, bind to the existing skeleton of
168
+ // the App already present in the HTML.
169
+ el: $("#todoapp"),
170
+
171
+ // Our template for the line of statistics at the bottom of the app.
172
+ statsTemplate: _.template($('#stats-template').html()),
173
+
174
+ // Delegated events for creating new items, and clearing completed ones.
175
+ events: {
176
+ "keypress #new-todo": "createOnEnter",
177
+ "keyup #new-todo": "showTooltip",
178
+ "click .todo-clear a": "clearCompleted"
179
+ },
180
+
181
+ // At initialization we bind to the relevant events on the `Todos`
182
+ // collection, when items are added or changed. Kick things off by
183
+ // loading any preexisting todos that might be saved in *localStorage*.
184
+ initialize: function() {
185
+ _.bindAll(this, 'addOne', 'addAll', 'render');
186
+
187
+ this.input = this.$("#new-todo");
188
+
189
+ Todos.bind('add', this.addOne);
190
+ Todos.bind('reset', this.addAll);
191
+ Todos.bind('all', this.render);
192
+
193
+ Todos.fetch();
194
+ },
195
+
196
+ // Re-rendering the App just means refreshing the statistics -- the rest
197
+ // of the app doesn't change.
198
+ render: function() {
199
+ this.$('#todo-stats').html(this.statsTemplate({
200
+ total: Todos.length,
201
+ done: Todos.done().length,
202
+ remaining: Todos.remaining().length
203
+ }));
204
+ },
205
+
206
+ // Add a single todo item to the list by creating a view for it, and
207
+ // appending its element to the `<ul>`.
208
+ addOne: function(todo) {
209
+ var view = new TodoView({model: todo});
210
+ this.$("#todo-list").append(view.render().el);
211
+ },
212
+
213
+ // Add all items in the **Todos** collection at once.
214
+ addAll: function() {
215
+ Todos.each(this.addOne);
216
+ },
217
+
218
+ // Generate the attributes for a new Todo item.
219
+ newAttributes: function() {
220
+ return {
221
+ content: this.input.val(),
222
+ order: Todos.nextOrder(),
223
+ done: false
224
+ };
225
+ },
226
+
227
+ // If you hit return in the main input field, create new **Todo** model,
228
+ // persisting it to *localStorage*.
229
+ createOnEnter: function(e) {
230
+ if (e.keyCode != 13) return;
231
+ Todos.create(this.newAttributes());
232
+ this.input.val('');
233
+ },
234
+
235
+ // Clear all done todo items, destroying their models.
236
+ clearCompleted: function() {
237
+ _.each(Todos.done(), function(todo){ todo.clear(); });
238
+ return false;
239
+ },
240
+
241
+ // Lazily show the tooltip that tells you to press `enter` to save
242
+ // a new todo item, after one second.
243
+ showTooltip: function(e) {
244
+ var tooltip = this.$(".ui-tooltip-top");
245
+ var val = this.input.val();
246
+ tooltip.fadeOut();
247
+ if (this.tooltipTimeout) clearTimeout(this.tooltipTimeout);
248
+ if (val == '' || val == this.input.attr('placeholder')) return;
249
+ var show = function(){ tooltip.show().fadeIn(); };
250
+ this.tooltipTimeout = _.delay(show, 1000);
251
+ }
252
+
253
+ });
254
+
255
+ // Finally, we kick things off by creating the **App**.
256
+ window.App = new AppView;
257
+
258
+ });