whtt-eric-beet 0.6.10
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.
- data/Gemfile +12 -0
- data/Gemfile.lock +25 -0
- data/LICENSE +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +59 -0
- data/TODO +25 -0
- data/VERSION +1 -0
- data/bin/beet +114 -0
- data/features/generating.feature +24 -0
- data/features/step_definitions/beet_steps.rb +7 -0
- data/features/step_definitions/common_steps.rb +172 -0
- data/features/support/common.rb +33 -0
- data/features/support/env.rb +25 -0
- data/lib/beet.rb +13 -0
- data/lib/beet/capistrano.rb +14 -0
- data/lib/beet/command_execution.rb +56 -0
- data/lib/beet/executor.rb +236 -0
- data/lib/beet/file_system.rb +163 -0
- data/lib/beet/files/swfupload/images/cancelbutton.gif +0 -0
- data/lib/beet/files/swfupload/images/header-bg.jpg +0 -0
- data/lib/beet/files/swfupload/images/logo.gif +0 -0
- data/lib/beet/files/swfupload/js/handlers.js +290 -0
- data/lib/beet/gem_location_map.rb +65 -0
- data/lib/beet/interaction.rb +47 -0
- data/lib/beet/logger.rb +44 -0
- data/lib/beet/rails.rb +175 -0
- data/lib/beet/recipes/passenger/vhost.rb +17 -0
- data/lib/beet/recipes/rack/middleware.rb +17 -0
- data/lib/beet/recipes/rails/auth/authlogic.rb +302 -0
- data/lib/beet/recipes/rails/auth/clearance.rb +22 -0
- data/lib/beet/recipes/rails/auth/devise.rb +22 -0
- data/lib/beet/recipes/rails/clean_files.rb +4 -0
- data/lib/beet/recipes/rails/cms/bcms_blog.rb +21 -0
- data/lib/beet/recipes/rails/cms/bcms_event.rb +24 -0
- data/lib/beet/recipes/rails/css/blueprint.rb +5 -0
- data/lib/beet/recipes/rails/css/compass.rb +35 -0
- data/lib/beet/recipes/rails/css/nifty_layout.rb +5 -0
- data/lib/beet/recipes/rails/css/reset.rb +10 -0
- data/lib/beet/recipes/rails/db/mongo.rb +57 -0
- data/lib/beet/recipes/rails/db/mysql.rb +47 -0
- data/lib/beet/recipes/rails/db/postgres.rb +52 -0
- data/lib/beet/recipes/rails/git.rb +23 -0
- data/lib/beet/recipes/rails/jquery.rb +11 -0
- data/lib/beet/recipes/rails/swfupload.rb +305 -0
- data/lib/beet/recipes/rails/testing/rspec.rb +3 -0
- data/lib/beet/recipes/rails/testing/shoulda.rb +1 -0
- data/lib/beet/recipes/rails3/admin_interface/active_scaffold.rb +10 -0
- data/lib/beet/recipes/rails3/admin_interface/rails_admin.rb +9 -0
- data/lib/beet/recipes/rails3/auth/devise.rb +17 -0
- data/lib/beet/recipes/rails3/clean_files.rb +3 -0
- data/lib/beet/recipes/rails3/css/boilerplate.rb +41 -0
- data/lib/beet/recipes/rails3/css/reset.rb +10 -0
- data/lib/beet/recipes/rails3/css/sass.rb +3 -0
- data/lib/beet/recipes/rails3/db/mysql.rb +35 -0
- data/lib/beet/recipes/rails3/file_uploads/paperclip.rb +29 -0
- data/lib/beet/recipes/rails3/git.rb +16 -0
- data/lib/beet/recipes/rails3/jammit.rb +26 -0
- data/lib/beet/recipes/rails3/js/jquery.rb +12 -0
- data/lib/beet/recipes/rails3/markup/haml.rb +3 -0
- data/lib/beet/recipes/rails3/testing/cucumber.rb +19 -0
- data/lib/beet/recipes/rails3/testing/rspec.rb +40 -0
- data/lib/beet/recipes/standalone/hades.rb +61 -0
- data/lib/beet/recipes/system/rvmrc.rb +15 -0
- data/lib/beet/scm.rb +36 -0
- data/lib/beet/scm/git.rb +15 -0
- data/lib/beet/scm/svn.rb +5 -0
- data/lib/beet/template_location_map.rb +15 -0
- data/test/executor_test.rb +24 -0
- data/test/file_system_test.rb +59 -0
- data/test/test_helper.rb +12 -0
- data/whtt-eric-beet.gemspec +120 -0
- metadata +203 -0
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,290 @@
|
|
1
|
+
function fileQueueError(file, errorCode, message) {
|
2
|
+
try {
|
3
|
+
var imageName = "error.gif";
|
4
|
+
var errorName = "";
|
5
|
+
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
|
6
|
+
errorName = "You have attempted to queue too many files.";
|
7
|
+
}
|
8
|
+
|
9
|
+
if (errorName !== "") {
|
10
|
+
alert(errorName);
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
switch (errorCode) {
|
15
|
+
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
16
|
+
imageName = "zerobyte.gif";
|
17
|
+
break;
|
18
|
+
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
19
|
+
imageName = "toobig.gif";
|
20
|
+
break;
|
21
|
+
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
22
|
+
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
23
|
+
default:
|
24
|
+
alert(message);
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
|
28
|
+
addImage("images/swfupload/" + imageName);
|
29
|
+
|
30
|
+
} catch (ex) {
|
31
|
+
this.debug(ex);
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
function fileDialogComplete(numFilesSelected, numFilesQueued) {
|
37
|
+
try {
|
38
|
+
if (numFilesQueued > 0) {
|
39
|
+
this.startUpload();
|
40
|
+
}
|
41
|
+
} catch (ex) {
|
42
|
+
this.debug(ex);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
function uploadProgress(file, bytesLoaded) {
|
47
|
+
|
48
|
+
try {
|
49
|
+
var percent = Math.ceil((bytesLoaded / file.size) * 100);
|
50
|
+
|
51
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
52
|
+
progress.setProgress(percent);
|
53
|
+
if (percent === 100) {
|
54
|
+
progress.setStatus("Processing file...");
|
55
|
+
progress.toggleCancel(false, this);
|
56
|
+
} else {
|
57
|
+
progress.setStatus("Uploading...");
|
58
|
+
progress.toggleCancel(true, this);
|
59
|
+
}
|
60
|
+
} catch (ex) {
|
61
|
+
this.debug(ex);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function uploadSuccess(file, serverData) {
|
66
|
+
try {
|
67
|
+
$('#mp3info').append("<p>"+serverData+"</p>");
|
68
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
69
|
+
|
70
|
+
if (serverData.substring(0, 2) === "OK") {
|
71
|
+
//addImage("thumbnail.php?id=" + serverData.substring(7));
|
72
|
+
|
73
|
+
progress.setStatus("Upload Successfull.");
|
74
|
+
progress.toggleCancel(false);
|
75
|
+
} else {
|
76
|
+
addImage("/images/swfupload/error.gif");
|
77
|
+
progress.setStatus("Error.");
|
78
|
+
progress.toggleCancel(false);
|
79
|
+
alert(serverData);
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
} catch (ex) {
|
85
|
+
this.debug(ex);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
function uploadComplete(file) {
|
90
|
+
try {
|
91
|
+
/* I want the next upload to continue automatically so I'll call startUpload here */
|
92
|
+
if (this.getStats().files_queued > 0) {
|
93
|
+
this.startUpload();
|
94
|
+
} else {
|
95
|
+
var progress = new FileProgress(file, this.customSettings.upload_target);
|
96
|
+
progress.setComplete();
|
97
|
+
progress.setStatus("All files received.");
|
98
|
+
progress.toggleCancel(false);
|
99
|
+
}
|
100
|
+
} catch (ex) {
|
101
|
+
this.debug(ex);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
function uploadError(file, errorCode, message) {
|
106
|
+
var imageName = "error.gif";
|
107
|
+
var progress;
|
108
|
+
try {
|
109
|
+
switch (errorCode) {
|
110
|
+
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
|
111
|
+
try {
|
112
|
+
progress = new FileProgress(file, this.customSettings.upload_target);
|
113
|
+
progress.setCancelled();
|
114
|
+
progress.setStatus("Cancelled");
|
115
|
+
progress.toggleCancel(false);
|
116
|
+
}
|
117
|
+
catch (ex1) {
|
118
|
+
this.debug(ex1);
|
119
|
+
}
|
120
|
+
break;
|
121
|
+
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
122
|
+
try {
|
123
|
+
progress = new FileProgress(file, this.customSettings.upload_target);
|
124
|
+
progress.setCancelled();
|
125
|
+
progress.setStatus("Stopped");
|
126
|
+
progress.toggleCancel(true);
|
127
|
+
}
|
128
|
+
catch (ex2) {
|
129
|
+
this.debug(ex2);
|
130
|
+
}
|
131
|
+
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
132
|
+
imageName = "uploadlimit.gif";
|
133
|
+
break;
|
134
|
+
default:
|
135
|
+
alert(message);
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
|
139
|
+
addImage("/images/swfupload/" + imageName);
|
140
|
+
|
141
|
+
} catch (ex3) {
|
142
|
+
this.debug(ex3);
|
143
|
+
}
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
function addImage(src) {
|
149
|
+
var newImg = document.createElement("img");
|
150
|
+
newImg.style.margin = "5px";
|
151
|
+
|
152
|
+
document.getElementById("thumbnails").appendChild(newImg);
|
153
|
+
if (newImg.filters) {
|
154
|
+
try {
|
155
|
+
newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
|
156
|
+
} catch (e) {
|
157
|
+
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
158
|
+
newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
|
159
|
+
}
|
160
|
+
} else {
|
161
|
+
newImg.style.opacity = 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
newImg.onload = function () {
|
165
|
+
fadeIn(newImg, 0);
|
166
|
+
};
|
167
|
+
newImg.src = src;
|
168
|
+
}
|
169
|
+
|
170
|
+
function fadeIn(element, opacity) {
|
171
|
+
var reduceOpacityBy = 5;
|
172
|
+
var rate = 30; // 15 fps
|
173
|
+
|
174
|
+
|
175
|
+
if (opacity < 100) {
|
176
|
+
opacity += reduceOpacityBy;
|
177
|
+
if (opacity > 100) {
|
178
|
+
opacity = 100;
|
179
|
+
}
|
180
|
+
|
181
|
+
if (element.filters) {
|
182
|
+
try {
|
183
|
+
element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
184
|
+
} catch (e) {
|
185
|
+
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
186
|
+
element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
|
187
|
+
}
|
188
|
+
} else {
|
189
|
+
element.style.opacity = opacity / 100;
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
if (opacity < 100) {
|
194
|
+
setTimeout(function () {
|
195
|
+
fadeIn(element, opacity);
|
196
|
+
}, rate);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
/* ******************************************
|
203
|
+
* FileProgress Object
|
204
|
+
* Control object for displaying file info
|
205
|
+
* ****************************************** */
|
206
|
+
|
207
|
+
function FileProgress(file, targetID) {
|
208
|
+
this.fileProgressID = "divFileProgress";
|
209
|
+
|
210
|
+
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
|
211
|
+
if (!this.fileProgressWrapper) {
|
212
|
+
this.fileProgressWrapper = document.createElement("div");
|
213
|
+
this.fileProgressWrapper.className = "progressWrapper";
|
214
|
+
this.fileProgressWrapper.id = this.fileProgressID;
|
215
|
+
|
216
|
+
this.fileProgressElement = document.createElement("div");
|
217
|
+
this.fileProgressElement.className = "progressContainer";
|
218
|
+
|
219
|
+
var progressCancel = document.createElement("a");
|
220
|
+
progressCancel.className = "progressCancel";
|
221
|
+
progressCancel.href = "#";
|
222
|
+
progressCancel.style.visibility = "hidden";
|
223
|
+
progressCancel.appendChild(document.createTextNode(" "));
|
224
|
+
|
225
|
+
var progressText = document.createElement("div");
|
226
|
+
progressText.className = "progressName";
|
227
|
+
progressText.appendChild(document.createTextNode(file.name));
|
228
|
+
|
229
|
+
var progressBar = document.createElement("div");
|
230
|
+
progressBar.className = "progressBarInProgress";
|
231
|
+
|
232
|
+
var progressStatus = document.createElement("div");
|
233
|
+
progressStatus.className = "progressBarStatus";
|
234
|
+
progressStatus.innerHTML = " ";
|
235
|
+
|
236
|
+
this.fileProgressElement.appendChild(progressCancel);
|
237
|
+
this.fileProgressElement.appendChild(progressText);
|
238
|
+
this.fileProgressElement.appendChild(progressStatus);
|
239
|
+
this.fileProgressElement.appendChild(progressBar);
|
240
|
+
|
241
|
+
this.fileProgressWrapper.appendChild(this.fileProgressElement);
|
242
|
+
|
243
|
+
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
|
244
|
+
fadeIn(this.fileProgressWrapper, 0);
|
245
|
+
|
246
|
+
} else {
|
247
|
+
this.fileProgressElement = this.fileProgressWrapper.firstChild;
|
248
|
+
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
|
249
|
+
}
|
250
|
+
|
251
|
+
this.height = this.fileProgressWrapper.offsetHeight;
|
252
|
+
|
253
|
+
}
|
254
|
+
FileProgress.prototype.setProgress = function (percentage) {
|
255
|
+
this.fileProgressElement.className = "progressContainer green";
|
256
|
+
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
257
|
+
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
|
258
|
+
};
|
259
|
+
FileProgress.prototype.setComplete = function () {
|
260
|
+
this.fileProgressElement.className = "progressContainer blue";
|
261
|
+
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
|
262
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
263
|
+
|
264
|
+
};
|
265
|
+
FileProgress.prototype.setError = function () {
|
266
|
+
this.fileProgressElement.className = "progressContainer red";
|
267
|
+
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
268
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
269
|
+
|
270
|
+
};
|
271
|
+
FileProgress.prototype.setCancelled = function () {
|
272
|
+
this.fileProgressElement.className = "progressContainer";
|
273
|
+
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
274
|
+
this.fileProgressElement.childNodes[3].style.width = "";
|
275
|
+
|
276
|
+
};
|
277
|
+
FileProgress.prototype.setStatus = function (status) {
|
278
|
+
this.fileProgressElement.childNodes[2].innerHTML = status;
|
279
|
+
};
|
280
|
+
|
281
|
+
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
|
282
|
+
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
|
283
|
+
if (swfuploadInstance) {
|
284
|
+
var fileID = this.fileProgressID;
|
285
|
+
this.fileProgressElement.childNodes[0].onclick = function () {
|
286
|
+
swfuploadInstance.cancelUpload(fileID);
|
287
|
+
return false;
|
288
|
+
};
|
289
|
+
}
|
290
|
+
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
GEM_LOCATIONS = {
|
2
|
+
'restful-authentcation' => 'git://github.com/technoweenie/restful-authentication.git',
|
3
|
+
'authlogic' => 'git://github.com/binarylogic/authlogic.git',
|
4
|
+
'clearance' => 'git://github.com/thoughtbot/clearance.git',
|
5
|
+
'will_paginate' => 'git://github.com/mislav/will_paginate.git',
|
6
|
+
'paperclip' => 'git://github.com/thoughtbot/paperclip.git',
|
7
|
+
'attachment_fu' => 'git://github.com/technoweenie/attachment_fu.git',
|
8
|
+
'rspec' => 'git://github.com/dchelimsky/rspec.git',
|
9
|
+
'rspec-rails' => 'git://github.com/dchelimsky/rspec-rails.git',
|
10
|
+
'cucumber' => 'git://github.com/aslakhellesoy/cucumber.git',
|
11
|
+
'shoulda' => 'git://github.com/thoughtbot/shoulda.git',
|
12
|
+
'matchy' => 'git://github.com/jeremymcanally/matchy.git',
|
13
|
+
'context' => 'git://github.com/jeremymcanally/context.git',
|
14
|
+
'exception-notifier' => 'git://github.com/Lipsiasoft/exception-notifier.git',
|
15
|
+
'asset_packager' => 'git://github.com/sbecker/asset_packager.git',
|
16
|
+
'acts_as_list' => 'git://github.com/rails/acts_as_list.git',
|
17
|
+
'acts_as_tree' => 'git://github.com/rails/acts_as_tree.git',
|
18
|
+
'webrat' => 'git://github.com/brynary/webrat.git',
|
19
|
+
'rcov' => 'git://github.com/relevance/rcov.git',
|
20
|
+
'rcov_plugin' => 'git://github.com/commondream/rcov_plugin.git',
|
21
|
+
'flog' => 'git://github.com/seattlerb/flog.git',
|
22
|
+
'flay' => 'git://github.com/seattlerb/flay.git',
|
23
|
+
'hoe' => 'git://github.com/seattlerb/hoe.git',
|
24
|
+
'integrity' => 'git://github.com/integrity/integrity.git',
|
25
|
+
'active_merchant' => 'git://github.com/Shopify/active_merchant.git',
|
26
|
+
'spree' => 'git://github.com/railsdog/spree.git',
|
27
|
+
'exception_notification' => 'git://github.com/rails/exception_notification.git',
|
28
|
+
'hoptoad_notifier' => 'git://github.com/thoughtbot/hoptoad_notifier.git',
|
29
|
+
'exception_logger' => 'git://github.com/defunkt/exception_logger.git',
|
30
|
+
'jeweler' => 'git://github.com/technicalpickles/jeweler.git',
|
31
|
+
'newgem' => 'git://github.com/drnic/newgem.git',
|
32
|
+
'bones' => 'git://github.com/TwP/bones.git',
|
33
|
+
'echoe' => 'git://github.com/fauna/echoe.git',
|
34
|
+
'nokogiri' => 'git://github.com/tenderlove/nokogiri.git',
|
35
|
+
'hpricot' => 'git://github.com/why/hpricot.git',
|
36
|
+
'httparty' => 'git://github.com/jnunemaker/httparty.git',
|
37
|
+
'rest-client' => 'git://github.com/adamwiggins/rest-client.git',
|
38
|
+
'typoeus' => 'git://github.com/pauldix/typhoeus.git',
|
39
|
+
'redcloth' => 'git://github.com/jgarber/redcloth.git',
|
40
|
+
'rdiscount' => 'git://github.com/rtomayko/rdiscount.git',
|
41
|
+
'bluecloth' => 'git://github.com/mislav/bluecloth.git',
|
42
|
+
'rr' => 'git://github.com/btakita/rr.git',
|
43
|
+
'mocha' => 'git://github.com/floehopper/mocha.git',
|
44
|
+
'stump' => 'git://github.com/jeremymcanally/stump.git',
|
45
|
+
'active_scaffold' => 'git://github.com/activescaffold/active_scaffold.git',
|
46
|
+
'delayed_job' => 'git://github.com/tobi/delayed_job.git',
|
47
|
+
'starling' => 'git://github.com/starling/starling.git',
|
48
|
+
'amqp' => 'git://github.com/tmm1/amqp.git',
|
49
|
+
'negative-captcha' => 'git://github.com/subwindow/negative-captcha.git',
|
50
|
+
'factory_girl' => 'git://github.com/thoughtbot/factory_girl.git',
|
51
|
+
'machinist' => 'git://github.com/notahat/machinist.git',
|
52
|
+
'thinking-sphinx' => 'git://github.com/freelancing-god/thinking-sphinx.git',
|
53
|
+
'acts-as-taggable-on' => 'git://github.com/mbleigh/acts-as-taggable-on.git',
|
54
|
+
'is_taggable' => 'git://github.com/giraffesoft/is_taggable.git',
|
55
|
+
'forgery' => 'git://github.com/sevenwire/forgery.git',
|
56
|
+
'faker' => 'git://github.com/yyyc514/faker.git',
|
57
|
+
'whenever' => 'git://github.com/javan/whenever.git',
|
58
|
+
'aasm' => 'git://github.com/rubyist/aasm.git',
|
59
|
+
'workflow' => 'git://github.com/ryan-allen/workflow.git',
|
60
|
+
'chef' => 'git://github.com/opscode/chef.git',
|
61
|
+
'passenger' => 'git://github.com/FooBarWidget/passenger.git',
|
62
|
+
'thin' => 'git://github.com/macournoyer/thin.git',
|
63
|
+
'happymapper' => 'git://github.com/jnunemaker/happymapper.git',
|
64
|
+
'simple-navigation' => {:source => 'git://github.com/andi/simple-navigation.git', :lib => 'simple_navigation'}
|
65
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Beet
|
2
|
+
module Interaction
|
3
|
+
# Print text to the console
|
4
|
+
#
|
5
|
+
# ==== Example
|
6
|
+
#
|
7
|
+
# say("This is the default. You probably shouldn't change it.")
|
8
|
+
#
|
9
|
+
def say(string)
|
10
|
+
puts "\n#{string}"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get a user's input
|
14
|
+
#
|
15
|
+
# ==== Example
|
16
|
+
#
|
17
|
+
# answer = ask("Should I freeze the latest Rails?")
|
18
|
+
# freeze! if ask("Should I freeze the latest Rails?") == "yes"
|
19
|
+
#
|
20
|
+
def ask(string)
|
21
|
+
say(string)
|
22
|
+
print '> '
|
23
|
+
STDIN.gets.strip
|
24
|
+
end
|
25
|
+
|
26
|
+
# Helper to test if the user says yes(y)?
|
27
|
+
#
|
28
|
+
# ==== Example
|
29
|
+
#
|
30
|
+
# freeze! if yes?("Should I freeze the latest Rails?")
|
31
|
+
#
|
32
|
+
def yes?(question)
|
33
|
+
answer = ask(question).downcase
|
34
|
+
answer == "y" || answer == "yes"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Helper to test if the user does NOT say yes(y)?
|
38
|
+
#
|
39
|
+
# ==== Example
|
40
|
+
#
|
41
|
+
# capify! if no?("Will you be using vlad to deploy your application?")
|
42
|
+
#
|
43
|
+
def no?(question)
|
44
|
+
!yes?(question)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/beet/logger.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Beet
|
2
|
+
class Logger # :nodoc:
|
3
|
+
attr_reader :out
|
4
|
+
attr_accessor :quiet
|
5
|
+
|
6
|
+
def initialize(out = $stdout)
|
7
|
+
@out = out
|
8
|
+
@quiet = false
|
9
|
+
@level = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def log(status, message, &block)
|
13
|
+
@out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet
|
14
|
+
indent(&block) if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
def indent(&block)
|
18
|
+
@level += 1
|
19
|
+
if block_given?
|
20
|
+
begin
|
21
|
+
block.call
|
22
|
+
ensure
|
23
|
+
outdent
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def outdent
|
29
|
+
@level -= 1
|
30
|
+
if block_given?
|
31
|
+
begin
|
32
|
+
block.call
|
33
|
+
ensure
|
34
|
+
indent
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def method_missing(method, *args, &block)
|
41
|
+
log(method.to_s, args.first, &block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|