coffeegrinder 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/LICENSE +21 -0
  2. data/bin/grind +62 -0
  3. data/lib/coffee_grinder/coffee_grinder_generator/coffee_grinder_generator.rb +48 -0
  4. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Cakefile.template +48 -0
  5. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Gemfile.template +13 -0
  6. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/LICENSE.template +21 -0
  7. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/README.textitle.template +1 -0
  8. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Rakefile.template +8 -0
  9. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/config.ru.template +14 -0
  10. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/lib/%=app%.coffee.template +1 -0
  11. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/css/960.css.scss.template +378 -0
  12. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/css/styles.scss.template +6 -0
  13. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/index.html.template +23 -0
  14. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/backbone.js.template +1 -0
  15. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/jquery.js.template +1 -0
  16. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/jqueryui.js.template +1 -0
  17. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/underscore.js.template +1 -0
  18. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/%=app%_spec.js.coffee.template +4 -0
  19. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/helpers/SpecHelper.js.template +9 -0
  20. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/helpers/jasmine-jquery.js.template +254 -0
  21. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine.yml.template +82 -0
  22. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine_config.rb.template +23 -0
  23. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine_runner.rb.template +32 -0
  24. data/lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/watchr.rb.template +15 -0
  25. metadata +114 -0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 markbates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/bin/grind ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/local/bin/ruby
2
+ require 'rubygems'
3
+ require 'fileutils'
4
+ require 'optparse'
5
+ require 'optparse/time'
6
+ require 'ostruct'
7
+ require 'pp'
8
+ require 'active_support'
9
+ require 'mark_facets'
10
+ require 'genosaurus'
11
+ require 'erb'
12
+
13
+ app = ARGV[0]
14
+ raise "You must specify a name for this project!" if app.nil?
15
+
16
+ options = OpenStruct.new
17
+ options.force = false
18
+ options.backbone = true
19
+ options.version = "0.0.1"
20
+ options.author = (ENV["USERNAME"] || ENV["USER"])
21
+
22
+ opts = OptionParser.new do |opts|
23
+ opts.banner = "Usage: grinder [options]"
24
+
25
+ opts.on("-f [force]") do |v|
26
+ options.force = true
27
+ end
28
+
29
+ opts.on("-b [skip-backbone.js]") do |v|
30
+ options.backbone = false
31
+ end
32
+
33
+ opts.on("-v [initial version]") do |v|
34
+ options.version = v
35
+ end
36
+
37
+ opts.on("-a [author name]") do |v|
38
+ options.author = v
39
+ end
40
+
41
+ end
42
+
43
+ opts.parse!(ARGV)
44
+
45
+ # puts "options = #{options.inspect}"
46
+
47
+ app = app.downcase.gsub(" ", "_")
48
+
49
+ if options.force
50
+ begin
51
+ FileUtils.rm_rf app
52
+ rescue Exception => e
53
+ puts e
54
+ end
55
+ end
56
+
57
+ path = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", 'coffee_grinder', 'coffee_grinder_generator', 'coffee_grinder_generator.rb'))
58
+ puts path
59
+ require path
60
+ CoffeeGrinderGenerator.run("app" => app,
61
+ "backbone" => options.backbone,
62
+ "version" => options.version)
@@ -0,0 +1,48 @@
1
+ require 'net/http'
2
+ class CoffeeGrinderGenerator < Genosaurus
3
+
4
+ require_param :app
5
+
6
+ def app
7
+ param(:app)
8
+ end
9
+
10
+ def version
11
+ param(:version) || '0.0.1'
12
+ end
13
+
14
+ def backbone?
15
+ param(:backbone)
16
+ end
17
+
18
+ def author
19
+ param(:author) || (ENV["USERNAME"] || ENV["USER"])
20
+ end
21
+
22
+ def jquery_code
23
+ slurp_url("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")
24
+ end
25
+
26
+ def jquery_ui_code
27
+ slurp_url("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js")
28
+ end
29
+
30
+ def underscore_code
31
+ slurp_url("http://documentcloud.github.com/underscore/underscore-min.js")
32
+ end
33
+
34
+ def backbone_code
35
+ slurp_url("http://documentcloud.github.com/backbone/backbone-min.js")
36
+ end
37
+
38
+ protected
39
+ def slurp_url(url)
40
+ url = URI.parse(url)
41
+ req = Net::HTTP::Get.new(url.path)
42
+ res = Net::HTTP.start(url.host, url.port) {|http|
43
+ http.request(req)
44
+ }
45
+ res.body
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ coffee = require 'coffee-script'
2
+ sys = require 'sys'
3
+ exec = require('child_process').exec
4
+ fs = require 'fs'
5
+ # npm install wrench
6
+ # for rmdirSyncRecursive:
7
+ wrench = require "wrench"
8
+ # npm install jsmin
9
+ # for minifying code:
10
+ jsmin = require('jsmin').jsmin
11
+
12
+ version = '<%= version %>'
13
+
14
+ task "test", (options) =>
15
+ invoke 'build'
16
+ exec "bundle exec jasmine-headless-webkit", (error, stdout, stderr)->
17
+ console.log stdout
18
+
19
+ task 'clean', (options) ->
20
+ try
21
+ wrench.rmdirSyncRecursive 'builds'
22
+ catch error
23
+
24
+ task 'build', (options) ->
25
+ invoke 'clean'
26
+ fs.mkdirSync 'builds', '0777'
27
+
28
+ bigFile = """
29
+ ###
30
+ <%= app %> - v#{version}
31
+ https://github.com/<%= author %>/<%= app %>.js
32
+ ###
33
+ """
34
+
35
+ for file in fs.readdirSync 'lib'
36
+ bigFile += fs.readFileSync "lib/#{file}", 'utf-8'
37
+ bigFile += "\n\n"
38
+
39
+ compiled = coffee.compile(bigFile)
40
+ fs.writeFileSync 'builds/<%= app %>.edge.js', compiled
41
+ fs.writeFileSync 'public/js/<%= app %>.js', compiled
42
+
43
+ console.log 'Finished building'
44
+
45
+ task 'release', (options) ->
46
+ invoke 'build'
47
+ fs.writeFileSync "builds/<%= app %>-#{version}.js", fs.readFileSync('builds/<%= app %>.edge.js', 'utf-8')
48
+ fs.writeFileSync "builds/<%= app %>-#{version}.min.js", jsmin(fs.readFileSync('builds/<%= app %>.edge.js', 'utf-8'))
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group(:development) do
4
+ gem 'rake', '0.8.7', :require => false
5
+
6
+ # gem 'rails'
7
+ gem 'watchr'
8
+ gem 'uglifier'
9
+ gem 'RedCloth'
10
+ gem 'sass'
11
+ gem 'jasmine'
12
+ gem 'jasmine-headless-webkit'
13
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 <%= author %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'jasmine'
3
+ load 'jasmine/tasks/jasmine.rake'
4
+ rescue LoadError
5
+ task :jasmine do
6
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ use Rack::Static,
2
+ :urls => ["/stylesheets", "/images", "/js","/css"],
3
+ :root => "public"
4
+
5
+ run lambda { |env|
6
+ [
7
+ 200,
8
+ {
9
+ 'Content-Type' => 'text/html',
10
+ 'Cache-Control' => 'public, max-age=86400'
11
+ },
12
+ File.open('public/index.html', File::RDONLY)
13
+ ]
14
+ }
@@ -0,0 +1,378 @@
1
+ /*
2
+ Variable Grid System.
3
+ Learn more ~ http://www.spry-soft.com/grids/
4
+ Based on 960 Grid System - http://960.gs/
5
+
6
+ Licensed under GPL and MIT.
7
+ */
8
+
9
+ /*
10
+ Forces backgrounds to span full width,
11
+ even if there is horizontal scrolling.
12
+ Increase this if your layout is wider.
13
+
14
+ Note: IE6 works fine without this fix.
15
+ */
16
+
17
+ .debug_960 {
18
+ background-color: red;
19
+ }
20
+
21
+ body {
22
+ min-width: 960px;
23
+ }
24
+
25
+ /* Containers
26
+ ----------------------------------------------------------------------------------------------------*/
27
+ .container_12 {
28
+ margin-left: auto;
29
+ margin-right: auto;
30
+ width: 960px;
31
+ }
32
+
33
+ /* Grid >> Global
34
+ ----------------------------------------------------------------------------------------------------*/
35
+
36
+
37
+ .grid_1,
38
+ .grid_2,
39
+ .grid_3,
40
+ .grid_4,
41
+ .grid_5,
42
+ .grid_6,
43
+ .grid_7,
44
+ .grid_8,
45
+ .grid_9,
46
+ .grid_10,
47
+ .grid_11,
48
+ .grid_12 {
49
+ display:inline;
50
+ float: left;
51
+ position: relative;
52
+ margin-left: 0px;
53
+ margin-right: 0px;
54
+ }
55
+
56
+
57
+
58
+ .push_1, .pull_1,
59
+ .push_2, .pull_2,
60
+ .push_3, .pull_3,
61
+ .push_4, .pull_4,
62
+ .push_5, .pull_5,
63
+ .push_6, .pull_6,
64
+ .push_7, .pull_7,
65
+ .push_8, .pull_8,
66
+ .push_9, .pull_9,
67
+ .push_10, .pull_10,
68
+ .push_11, .pull_11,
69
+ .push_12, .pull_12 {
70
+ position:relative;
71
+ }
72
+
73
+
74
+ /* Grid >> Children (Alpha ~ First, Omega ~ Last)
75
+ ----------------------------------------------------------------------------------------------------*/
76
+
77
+ .alpha {
78
+ margin-left: 0;
79
+ }
80
+
81
+ .omega {
82
+ margin-right: 0;
83
+ }
84
+
85
+ /* Grid >> 12 Columns
86
+ ----------------------------------------------------------------------------------------------------*/
87
+
88
+
89
+ .container_12 .grid_1 {
90
+ width:80px;
91
+ }
92
+
93
+ .container_12 .grid_2 {
94
+ width:160px;
95
+ }
96
+
97
+ .container_12 .grid_3 {
98
+ width:240px;
99
+ }
100
+
101
+ .container_12 .grid_4 {
102
+ width:320px;
103
+ }
104
+
105
+ .container_12 .grid_5 {
106
+ width:400px;
107
+ }
108
+
109
+ .container_12 .grid_6 {
110
+ width:480px;
111
+ }
112
+
113
+ .container_12 .grid_7 {
114
+ width:560px;
115
+ }
116
+
117
+ .container_12 .grid_8 {
118
+ width:640px;
119
+ }
120
+
121
+ .container_12 .grid_9 {
122
+ width:720px;
123
+ }
124
+
125
+ .container_12 .grid_10 {
126
+ width:800px;
127
+ }
128
+
129
+ .container_12 .grid_11 {
130
+ width:880px;
131
+ }
132
+
133
+ .container_12 .grid_12 {
134
+ width:960px;
135
+ }
136
+
137
+
138
+
139
+
140
+ /* Prefix Extra Space >> 12 Columns
141
+ ----------------------------------------------------------------------------------------------------*/
142
+
143
+
144
+ .container_12 .prefix_1 {
145
+ padding-left:80px;
146
+ }
147
+
148
+ .container_12 .prefix_2 {
149
+ padding-left:160px;
150
+ }
151
+
152
+ .container_12 .prefix_3 {
153
+ padding-left:240px;
154
+ }
155
+
156
+ .container_12 .prefix_4 {
157
+ padding-left:320px;
158
+ }
159
+
160
+ .container_12 .prefix_5 {
161
+ padding-left:400px;
162
+ }
163
+
164
+ .container_12 .prefix_6 {
165
+ padding-left:480px;
166
+ }
167
+
168
+ .container_12 .prefix_7 {
169
+ padding-left:560px;
170
+ }
171
+
172
+ .container_12 .prefix_8 {
173
+ padding-left:640px;
174
+ }
175
+
176
+ .container_12 .prefix_9 {
177
+ padding-left:720px;
178
+ }
179
+
180
+ .container_12 .prefix_10 {
181
+ padding-left:800px;
182
+ }
183
+
184
+ .container_12 .prefix_11 {
185
+ padding-left:880px;
186
+ }
187
+
188
+
189
+
190
+ /* Suffix Extra Space >> 12 Columns
191
+ ----------------------------------------------------------------------------------------------------*/
192
+
193
+
194
+ .container_12 .suffix_1 {
195
+ padding-right:80px;
196
+ }
197
+
198
+ .container_12 .suffix_2 {
199
+ padding-right:160px;
200
+ }
201
+
202
+ .container_12 .suffix_3 {
203
+ padding-right:240px;
204
+ }
205
+
206
+ .container_12 .suffix_4 {
207
+ padding-right:320px;
208
+ }
209
+
210
+ .container_12 .suffix_5 {
211
+ padding-right:400px;
212
+ }
213
+
214
+ .container_12 .suffix_6 {
215
+ padding-right:480px;
216
+ }
217
+
218
+ .container_12 .suffix_7 {
219
+ padding-right:560px;
220
+ }
221
+
222
+ .container_12 .suffix_8 {
223
+ padding-right:640px;
224
+ }
225
+
226
+ .container_12 .suffix_9 {
227
+ padding-right:720px;
228
+ }
229
+
230
+ .container_12 .suffix_10 {
231
+ padding-right:800px;
232
+ }
233
+
234
+ .container_12 .suffix_11 {
235
+ padding-right:880px;
236
+ }
237
+
238
+
239
+
240
+ /* Push Space >> 12 Columns
241
+ ----------------------------------------------------------------------------------------------------*/
242
+
243
+
244
+ .container_12 .push_1 {
245
+ left:80px;
246
+ }
247
+
248
+ .container_12 .push_2 {
249
+ left:160px;
250
+ }
251
+
252
+ .container_12 .push_3 {
253
+ left:240px;
254
+ }
255
+
256
+ .container_12 .push_4 {
257
+ left:320px;
258
+ }
259
+
260
+ .container_12 .push_5 {
261
+ left:400px;
262
+ }
263
+
264
+ .container_12 .push_6 {
265
+ left:480px;
266
+ }
267
+
268
+ .container_12 .push_7 {
269
+ left:560px;
270
+ }
271
+
272
+ .container_12 .push_8 {
273
+ left:640px;
274
+ }
275
+
276
+ .container_12 .push_9 {
277
+ left:720px;
278
+ }
279
+
280
+ .container_12 .push_10 {
281
+ left:800px;
282
+ }
283
+
284
+ .container_12 .push_11 {
285
+ left:880px;
286
+ }
287
+
288
+
289
+
290
+ /* Pull Space >> 12 Columns
291
+ ----------------------------------------------------------------------------------------------------*/
292
+
293
+
294
+ .container_12 .pull_1 {
295
+ left:-80px;
296
+ }
297
+
298
+ .container_12 .pull_2 {
299
+ left:-160px;
300
+ }
301
+
302
+ .container_12 .pull_3 {
303
+ left:-240px;
304
+ }
305
+
306
+ .container_12 .pull_4 {
307
+ left:-320px;
308
+ }
309
+
310
+ .container_12 .pull_5 {
311
+ left:-400px;
312
+ }
313
+
314
+ .container_12 .pull_6 {
315
+ left:-480px;
316
+ }
317
+
318
+ .container_12 .pull_7 {
319
+ left:-560px;
320
+ }
321
+
322
+ .container_12 .pull_8 {
323
+ left:-640px;
324
+ }
325
+
326
+ .container_12 .pull_9 {
327
+ left:-720px;
328
+ }
329
+
330
+ .container_12 .pull_10 {
331
+ left:-800px;
332
+ }
333
+
334
+ .container_12 .pull_11 {
335
+ left:-880px;
336
+ }
337
+
338
+
339
+
340
+
341
+ /* `Clear Floated Elements
342
+ ----------------------------------------------------------------------------------------------------*/
343
+
344
+ /* http://sonspring.com/journal/clearing-floats */
345
+
346
+ .clear {
347
+ clear: both;
348
+ display: block;
349
+ overflow: hidden;
350
+ visibility: hidden;
351
+ width: 0;
352
+ height: 0;
353
+ }
354
+
355
+ /* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */
356
+
357
+ .clearfix:before,
358
+ .clearfix:after {
359
+ content: '\0020';
360
+ display: block;
361
+ overflow: hidden;
362
+ visibility: hidden;
363
+ width: 0;
364
+ height: 0;
365
+ }
366
+
367
+ .clearfix:after {
368
+ clear: both;
369
+ }
370
+
371
+ /*
372
+ The following zoom:1 rule is specifically for IE6 + IE7.
373
+ Move to separate stylesheet if invalid CSS is a problem.
374
+ */
375
+
376
+ .clearfix {
377
+ zoom: 1;
378
+ }
@@ -0,0 +1,6 @@
1
+ @import '960.css.scss';
2
+
3
+ @mixin reset-mp() {
4
+ margin: 0px;
5
+ padding: 0px;
6
+ }
@@ -0,0 +1,23 @@
1
+ <html>
2
+ <head>
3
+ <title><%= app %></title>
4
+ <link rel="stylesheet" href="css/styles.css" type="text/css" media="screen" title="no title" charset="utf-8">
5
+
6
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
7
+ <script src="js/jqueryui.js" type="text/javascript" charset="utf-8"></script>
8
+ <% if backbone? %>
9
+ <script src='js/underscore.js' type="text/javascript" charset="utf-8"></script>
10
+ <script src='js/backbone.js' type="text/javascript" charset="utf-8"></script>
11
+ <% end %>
12
+ <script src="js/<%= app %>.js" type="text/javascript" charset="utf-8"></script>
13
+ </head>
14
+ <body>
15
+
16
+ <script>
17
+ $(function() {
18
+
19
+ })
20
+ </script>
21
+
22
+ </body>
23
+ </html>
@@ -0,0 +1,4 @@
1
+ describe "<%= app %>", ->
2
+
3
+ it "should do something", ->
4
+ expect(true).toBeTruthy()
@@ -0,0 +1,9 @@
1
+ beforeEach(function() {
2
+ this.addMatchers({
3
+ // toBePlaying: function(expectedSong) {
4
+ // var player = this.actual;
5
+ // return player.currentlyPlayingSong === expectedSong
6
+ // && player.isPlaying;
7
+ // }
8
+ })
9
+ });
@@ -0,0 +1,254 @@
1
+ var readFixtures = function() {
2
+ return jasmine.getFixtures().proxyCallTo_('read', arguments);
3
+ };
4
+
5
+ var loadFixtures = function() {
6
+ jasmine.getFixtures().proxyCallTo_('load', arguments);
7
+ };
8
+
9
+ var setFixtures = function(html) {
10
+ jasmine.getFixtures().set(html);
11
+ };
12
+
13
+ var sandbox = function(attributes) {
14
+ return jasmine.getFixtures().sandbox(attributes);
15
+ };
16
+
17
+ var spyOnEvent = function(selector, eventName) {
18
+ jasmine.JQuery.events.spyOn(selector, eventName);
19
+ }
20
+
21
+ jasmine.getFixtures = function() {
22
+ return jasmine.currentFixtures_ = jasmine.currentFixtures_ || new jasmine.Fixtures();
23
+ };
24
+
25
+ jasmine.Fixtures = function() {
26
+ this.containerId = 'jasmine-fixtures';
27
+ this.fixturesCache_ = {};
28
+ this.fixturesPath = 'spec/javascripts/fixtures';
29
+ };
30
+
31
+ jasmine.Fixtures.prototype.set = function(html) {
32
+ this.cleanUp();
33
+ this.createContainer_(html);
34
+ };
35
+
36
+ jasmine.Fixtures.prototype.load = function() {
37
+ this.cleanUp();
38
+ this.createContainer_(this.read.apply(this, arguments));
39
+ };
40
+
41
+ jasmine.Fixtures.prototype.read = function() {
42
+ var htmlChunks = [];
43
+
44
+ var fixtureUrls = arguments;
45
+ for(var urlCount = fixtureUrls.length, urlIndex = 0; urlIndex < urlCount; urlIndex++) {
46
+ htmlChunks.push(this.getFixtureHtml_(fixtureUrls[urlIndex]));
47
+ }
48
+
49
+ return htmlChunks.join('');
50
+ };
51
+
52
+ jasmine.Fixtures.prototype.clearCache = function() {
53
+ this.fixturesCache_ = {};
54
+ };
55
+
56
+ jasmine.Fixtures.prototype.cleanUp = function() {
57
+ $('#' + this.containerId).remove();
58
+ };
59
+
60
+ jasmine.Fixtures.prototype.sandbox = function(attributes) {
61
+ var attributesToSet = attributes || {};
62
+ return $('<div id="sandbox" />').attr(attributesToSet);
63
+ };
64
+
65
+ jasmine.Fixtures.prototype.createContainer_ = function(html) {
66
+ var container = $('<div id="' + this.containerId + '" />');
67
+ container.html(html);
68
+ $('body').append(container);
69
+ };
70
+
71
+ jasmine.Fixtures.prototype.getFixtureHtml_ = function(url) {
72
+ if (typeof this.fixturesCache_[url] == 'undefined') {
73
+ this.loadFixtureIntoCache_(url);
74
+ }
75
+ return this.fixturesCache_[url];
76
+ };
77
+
78
+ jasmine.Fixtures.prototype.loadFixtureIntoCache_ = function(relativeUrl) {
79
+ var self = this;
80
+ var url = this.fixturesPath.match('/$') ? this.fixturesPath + relativeUrl : this.fixturesPath + '/' + relativeUrl;
81
+ $.ajax({
82
+ async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
83
+ cache: false,
84
+ dataType: 'html',
85
+ url: url,
86
+ success: function(data) {
87
+ self.fixturesCache_[relativeUrl] = data;
88
+ }
89
+ });
90
+ };
91
+
92
+ jasmine.Fixtures.prototype.proxyCallTo_ = function(methodName, passedArguments) {
93
+ return this[methodName].apply(this, passedArguments);
94
+ };
95
+
96
+
97
+ jasmine.JQuery = function() {};
98
+
99
+ jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
100
+ return $('<div/>').append(html).html();
101
+ };
102
+
103
+ jasmine.JQuery.elementToString = function(element) {
104
+ return $('<div />').append(element.clone()).html();
105
+ };
106
+
107
+ jasmine.JQuery.matchersClass = {};
108
+
109
+ (function(namespace) {
110
+ var data = {
111
+ spiedEvents: {},
112
+ handlers: []
113
+ };
114
+
115
+ namespace.events = {
116
+ spyOn: function(selector, eventName) {
117
+ var handler = function(e) {
118
+ data.spiedEvents[[selector, eventName]] = e;
119
+ };
120
+ $(selector).bind(eventName, handler);
121
+ data.handlers.push(handler);
122
+ },
123
+
124
+ wasTriggered: function(selector, eventName) {
125
+ return !!(data.spiedEvents[[selector, eventName]]);
126
+ },
127
+
128
+ cleanUp: function() {
129
+ data.spiedEvents = {};
130
+ data.handlers = [];
131
+ }
132
+ }
133
+ })(jasmine.JQuery);
134
+
135
+ (function(){
136
+ var jQueryMatchers = {
137
+ toHaveClass: function(className) {
138
+ return this.actual.hasClass(className);
139
+ },
140
+
141
+ toBeVisible: function() {
142
+ return this.actual.is(':visible');
143
+ },
144
+
145
+ toBeHidden: function() {
146
+ return this.actual.is(':hidden');
147
+ },
148
+
149
+ toBeSelected: function() {
150
+ return this.actual.is(':selected');
151
+ },
152
+
153
+ toBeChecked: function() {
154
+ return this.actual.is(':checked');
155
+ },
156
+
157
+ toBeEmpty: function() {
158
+ return this.actual.is(':empty');
159
+ },
160
+
161
+ toExist: function() {
162
+ return this.actual.size() > 0;
163
+ },
164
+
165
+ toHaveAttr: function(attributeName, expectedAttributeValue) {
166
+ return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
167
+ },
168
+
169
+ toHaveId: function(id) {
170
+ return this.actual.attr('id') == id;
171
+ },
172
+
173
+ toHaveHtml: function(html) {
174
+ return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html);
175
+ },
176
+
177
+ toHaveText: function(text) {
178
+ if (text && jQuery.isFunction(text.test)) {
179
+ return text.test(this.actual.text());
180
+ } else {
181
+ return this.actual.text() == text;
182
+ }
183
+ },
184
+
185
+ toHaveValue: function(value) {
186
+ return this.actual.val() == value;
187
+ },
188
+
189
+ toHaveData: function(key, expectedValue) {
190
+ return hasProperty(this.actual.data(key), expectedValue);
191
+ },
192
+
193
+ toBe: function(selector) {
194
+ return this.actual.is(selector);
195
+ },
196
+
197
+ toContain: function(selector) {
198
+ return this.actual.find(selector).size() > 0;
199
+ },
200
+
201
+ toBeDisabled: function(selector){
202
+ return this.actual.attr("disabled") == true;
203
+ }
204
+ };
205
+
206
+ var hasProperty = function(actualValue, expectedValue) {
207
+ if (expectedValue === undefined) {
208
+ return actualValue !== undefined;
209
+ }
210
+ return actualValue == expectedValue;
211
+ };
212
+
213
+ var bindMatcher = function(methodName) {
214
+ var builtInMatcher = jasmine.Matchers.prototype[methodName];
215
+
216
+ jasmine.JQuery.matchersClass[methodName] = function() {
217
+ if (this.actual instanceof jQuery) {
218
+ var result = jQueryMatchers[methodName].apply(this, arguments);
219
+ this.actual = jasmine.JQuery.elementToString(this.actual);
220
+ return result;
221
+ }
222
+
223
+ if (builtInMatcher) {
224
+ return builtInMatcher.apply(this, arguments);
225
+ }
226
+
227
+ return false;
228
+ };
229
+ };
230
+
231
+ for(var methodName in jQueryMatchers) {
232
+ bindMatcher(methodName);
233
+ }
234
+ })();
235
+
236
+ beforeEach(function() {
237
+ this.addMatchers(jasmine.JQuery.matchersClass);
238
+ this.addMatchers({
239
+ toHaveBeenTriggeredOn: function(selector) {
240
+ this.message = function() {
241
+ return [
242
+ "Expected event " + this.actual + " to have been triggered on" + selector,
243
+ "Expected event " + this.actual + " not to have been triggered on" + selector
244
+ ];
245
+ };
246
+ return jasmine.JQuery.events.wasTriggered(selector, this.actual);
247
+ }
248
+ })
249
+ });
250
+
251
+ afterEach(function() {
252
+ jasmine.getFixtures().cleanUp();
253
+ jasmine.JQuery.events.cleanUp();
254
+ });
@@ -0,0 +1,82 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ - public/js/jquery.js
15
+ - public/js/jqueryui.js
16
+ - public/js/underscore.js
17
+ - public/js/backbone.js
18
+ - public/js/<%= app %>.js
19
+
20
+ # stylesheets
21
+ #
22
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
23
+ # Default: []
24
+ #
25
+ # EXAMPLE:
26
+ #
27
+ # stylesheets:
28
+ # - css/style.css
29
+ # - stylesheets/*.css
30
+ #
31
+ stylesheets:
32
+ - public/css/styles.css
33
+
34
+ # helpers
35
+ #
36
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
37
+ # Default: ["helpers/**/*.js"]
38
+ #
39
+ # EXAMPLE:
40
+ #
41
+ # helpers:
42
+ # - helpers/**/*.js
43
+ #
44
+ helpers:
45
+ - spec/javascripts/helpers/jasmine-jquery.js
46
+ - spec/javascripts/helpers/*.js.coffee
47
+ - spec/javascripts/helpers/*.js
48
+
49
+ # spec_files
50
+ #
51
+ # Return an array of filepaths relative to spec_dir to include.
52
+ # Default: ["**/*[sS]pec.js"]
53
+ #
54
+ # EXAMPLE:
55
+ #
56
+ # spec_files:
57
+ # - **/*[sS]pec.js
58
+ #
59
+ spec_files:
60
+ - spec/javascripts/*_spec.js.coffee
61
+
62
+ # src_dir
63
+ #
64
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
65
+ # Default: project root
66
+ #
67
+ # EXAMPLE:
68
+ #
69
+ # src_dir: public
70
+ #
71
+ src_dir:
72
+
73
+ # spec_dir
74
+ #
75
+ # Spec directory path. Your spec_files must be returned relative to this path.
76
+ # Default: spec/javascripts
77
+ #
78
+ # EXAMPLE:
79
+ #
80
+ # spec_dir: spec/javascripts
81
+ #
82
+ spec_dir:
@@ -0,0 +1,23 @@
1
+ module Jasmine
2
+ class Config
3
+
4
+ # Add your overrides or custom config code here
5
+
6
+ end
7
+ end
8
+
9
+
10
+ # Note - this is necessary for rspec2, which has removed the backtrace
11
+ module Jasmine
12
+ class SpecBuilder
13
+ def declare_spec(parent, spec)
14
+ me = self
15
+ example_name = spec["name"]
16
+ @spec_ids << spec["id"]
17
+ backtrace = @example_locations[parent.description + " " + example_name]
18
+ parent.it example_name, {} do
19
+ me.report_spec(spec["id"])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2
+
3
+ require 'rubygems'
4
+ require 'jasmine'
5
+ jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
6
+ require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
7
+ if Jasmine::rspec2?
8
+ require 'rspec'
9
+ else
10
+ require 'spec'
11
+ end
12
+
13
+ jasmine_config = Jasmine::Config.new
14
+ spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
15
+
16
+ should_stop = false
17
+
18
+ if Jasmine::rspec2?
19
+ RSpec.configuration.after(:suite) do
20
+ spec_builder.stop if should_stop
21
+ end
22
+ else
23
+ Spec::Runner.configure do |config|
24
+ config.after(:suite) do
25
+ spec_builder.stop if should_stop
26
+ end
27
+ end
28
+ end
29
+
30
+ spec_builder.start
31
+ should_stop = true
32
+ spec_builder.declare_suites
@@ -0,0 +1,15 @@
1
+ watch('Gemfile') do |md|
2
+ system("bundle")
3
+ end
4
+
5
+ watch('lib/.*\.coffee') do |md|
6
+ system("rake build")
7
+ end
8
+
9
+ watch('public/js/.*\.coffee') do |md|
10
+ system("coffee -c public/js")
11
+ end
12
+
13
+ watch('public/css/.*\.scss') do |md|
14
+ system("sass #{md[0]} #{md[0].gsub('.scss', '.css')}")
15
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coffeegrinder
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - markbates
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-15 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: mark_facets
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: genosaurus
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ description: "coffeegrinder was developed by: markbates"
50
+ email: mark@markbates.com
51
+ executables:
52
+ - grind
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE
57
+ files:
58
+ - lib/coffee_grinder/coffee_grinder_generator/coffee_grinder_generator.rb
59
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Cakefile.template
60
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/config.ru.template
61
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Gemfile.template
62
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/lib/%=app%.coffee.template
63
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/LICENSE.template
64
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/css/960.css.scss.template
65
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/css/styles.scss.template
66
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/index.html.template
67
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/backbone.js.template
68
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/jquery.js.template
69
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/jqueryui.js.template
70
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/public/js/underscore.js.template
71
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/Rakefile.template
72
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/README.textitle.template
73
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/%=app%_spec.js.coffee.template
74
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/helpers/jasmine-jquery.js.template
75
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/helpers/SpecHelper.js.template
76
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine.yml.template
77
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine_config.rb.template
78
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/spec/javascripts/support/jasmine_runner.rb.template
79
+ - lib/coffee_grinder/coffee_grinder_generator/templates/%=app%/watchr.rb.template
80
+ - LICENSE
81
+ - bin/grind
82
+ has_rdoc: true
83
+ homepage: http://www.metabates.com
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options: []
88
+
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: -781076467330329579
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.6.2
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: coffeegrinder
113
+ test_files: []
114
+