joosy 1.2.0.alpha.58 → 1.2.0.alpha.59
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bower.json +1 -1
- data/build/joosy/extensions/resources-form.js +3 -0
- data/build/joosy/extensions/resources.js +167 -123
- data/build/joosy.js +4 -3
- data/generators/templates/application/base/application.coffee +0 -1
- data/package.json +4 -7
- data/source/joosy/extensions/resources/base.coffee +25 -15
- data/source/joosy/extensions/resources/rest.coffee +124 -101
- data/source/joosy/extensions/resources/rest_collection.coffee +7 -1
- data/source/joosy/extensions/resources-form/form.coffee +2 -0
- data/source/joosy/helpers/routes.coffee +3 -3
- data/source/joosy/joosy.coffee +1 -1
- data/source/joosy/module.coffee +1 -1
- data/source/joosy/router.coffee +1 -1
- data/spec/joosy/core/helpers/routes_spec.coffee +9 -0
- data/spec/joosy/extensions/form/form_spec.coffee +5 -1
- data/spec/joosy/extensions/resources/rest_spec.coffee +62 -35
- data/tasks/joosy.coffee +7 -265
- metadata +3 -2
data/tasks/joosy.coffee
CHANGED
@@ -1,268 +1,10 @@
|
|
1
1
|
module.exports = (grunt) ->
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
haml: Path.join('source', 'haml')
|
10
|
-
javascript: Path.join('source', 'javascript')
|
11
|
-
stylesheets: Path.join('source', 'stylesheets')
|
12
|
-
public: 'public'
|
13
|
-
|
14
|
-
grunt.joosy =
|
15
|
-
helpers:
|
16
|
-
normalizeFiles: (config, target) ->
|
17
|
-
entries = grunt.config.get(config) || {}
|
18
|
-
entries = if target
|
19
|
-
grunt.config.requires "#{config}.#{target}"
|
20
|
-
[ entries[entry] ]
|
21
|
-
else
|
22
|
-
Object.values entries
|
23
|
-
|
24
|
-
entries
|
25
|
-
|
26
|
-
expandFiles: (root, entry) ->
|
27
|
-
root = Path.join(root, entry.cwd) if entry.cwd?
|
28
|
-
files = grunt.file.expand({cwd: Path.join(process.cwd(), root)}, entry.src)
|
29
|
-
|
30
|
-
return {
|
31
|
-
cwd: root,
|
32
|
-
list: files.map (file) ->
|
33
|
-
src: file
|
34
|
-
extname: Path.extname file
|
35
|
-
filename: Path.basename file, Path.extname(file)
|
36
|
-
dirname: Path.dirname file
|
37
|
-
}
|
38
|
-
|
3
|
+
#
|
4
|
+
# Joosy utilizes Grill to setup standalone environment
|
5
|
+
# Check out https://github.com/inossidabile/grill
|
6
|
+
#
|
7
|
+
require('grill').setup grunt,
|
8
|
+
prefix: 'joosy'
|
39
9
|
assets:
|
40
|
-
|
41
|
-
Mincer.logger.use console
|
42
|
-
Mincer.CoffeeEngine.configure bare: false
|
43
|
-
Mincer.StylusEngine.configure (stylus) ->
|
44
|
-
stylus.options.paths.push Path.join(process.cwd(), paths.public)
|
45
|
-
stylus.define '$environment', environment
|
46
|
-
stylus.define '$config', grunt.config.get('joosy.config') || {}
|
47
|
-
stylus.use require('nib')()
|
48
|
-
|
49
|
-
assets = new Mincer.Environment(process.cwd())
|
50
|
-
assets.appendPath paths.javascript
|
51
|
-
assets.appendPath paths.stylesheets
|
52
|
-
assets.appendPath 'vendor'
|
53
|
-
assets.appendPath 'bower_components'
|
54
|
-
assets.appendPath 'node_modules/joosy/source'
|
55
|
-
|
56
|
-
assets
|
57
|
-
|
58
|
-
compile: (environment, map, callbacks) ->
|
59
|
-
assets = grunt.joosy.assets.instance(environment)
|
60
|
-
deepness = 0
|
61
|
-
|
62
|
-
for entry in map
|
63
|
-
do (entry) ->
|
64
|
-
asset = assets.findAsset entry.src
|
65
|
-
callbacks.error? "Cannot find #{entry.src}" unless asset
|
66
|
-
grunt.file.write entry.dest, asset.toString()
|
67
|
-
callbacks.compiled? asset, entry.dest
|
68
|
-
|
69
|
-
callbacks.success?()
|
70
|
-
|
71
|
-
haml:
|
72
|
-
compile: (file, partials=paths.haml, environment='development', locals={}) ->
|
73
|
-
HAMLC = require 'haml-coffee'
|
74
|
-
|
75
|
-
HAMLC.compile(grunt.file.read file)(
|
76
|
-
Object.merge locals,
|
77
|
-
environment: environment
|
78
|
-
config: grunt.config.get('joosy.config') || {}
|
79
|
-
partial: (location, locals) ->
|
80
|
-
grunt.joosy.haml.compile(Path.join(partials, location), partials, environment, locals)
|
81
|
-
)
|
82
|
-
|
83
|
-
server:
|
84
|
-
start: (port, setup) ->
|
85
|
-
server = connect()
|
86
|
-
setup?(server)
|
87
|
-
server.listen port
|
88
|
-
|
89
|
-
console.log "=> Started on 4000\n"
|
90
|
-
|
91
|
-
serveProxied: (server, map) ->
|
92
|
-
URL = require 'url'
|
93
|
-
proxy = require 'proxy-middleware'
|
94
|
-
|
95
|
-
return unless map?
|
96
|
-
|
97
|
-
for entry in map
|
98
|
-
[from, to] = if entry.src
|
99
|
-
[entry.src, entry.dest]
|
100
|
-
else
|
101
|
-
key = Object.keys(entry).first()
|
102
|
-
[key, entry[key]]
|
103
|
-
|
104
|
-
server.use from, proxy(URL.parse to)
|
105
|
-
console.log "=> Proxying #{from} to #{to}"
|
106
|
-
|
107
|
-
serveAssets: (server, path='/assets') ->
|
108
|
-
assets = grunt.joosy.assets.instance()
|
109
|
-
server.use path, Mincer.createServer(assets)
|
110
|
-
|
111
|
-
console.log "=> Serving assets from #{path}"
|
112
|
-
|
113
|
-
serveHAML: (server, map) ->
|
114
|
-
serve = (urls, greedy, template, partials) ->
|
115
|
-
urls = [urls] unless Object.isArray(urls)
|
116
|
-
|
117
|
-
for url in urls
|
118
|
-
do (url) ->
|
119
|
-
server.use url, (req, res, next) ->
|
120
|
-
if greedy && req.originalUrl.startsWith(url) || req.originalUrl == url
|
121
|
-
res.end grunt.joosy.haml.compile(template, partials)
|
122
|
-
console.log "Served #{url} (#{template})"
|
123
|
-
else
|
124
|
-
next()
|
125
|
-
console.log "=> Serving #{template} from #{urls.join(', ')}"
|
126
|
-
|
127
|
-
for entry in map
|
128
|
-
do (entry) ->
|
129
|
-
unless entry.expand
|
130
|
-
serve(entry.url, entry.greedy, Path.join(paths.haml, entry.src), entry.partials)
|
131
|
-
else
|
132
|
-
files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
|
133
|
-
|
134
|
-
for file in files.list
|
135
|
-
serve(
|
136
|
-
entry.url(file),
|
137
|
-
entry.greedy,
|
138
|
-
Path.join(files.cwd, file.src),
|
139
|
-
entry.partials
|
140
|
-
)
|
141
|
-
|
142
|
-
serveStatic: (server, compress=false) ->
|
143
|
-
unless compress
|
144
|
-
server.use connect.static(paths.public)
|
145
|
-
else
|
146
|
-
Gzippo = require 'gzippo'
|
147
|
-
server.use Gzippo.staticGzip(paths.public)
|
148
|
-
|
149
|
-
console.log "=> Serving static from /#{paths.public}"
|
150
|
-
|
151
|
-
bower:
|
152
|
-
install: (complete) ->
|
153
|
-
if grunt.file.exists('bower.json')
|
154
|
-
require('bower').commands.install()
|
155
|
-
.on('data', (msg) -> grunt.log.ok msg)
|
156
|
-
.on('error', (error) ->
|
157
|
-
if error.code == 'ECONFLICT'
|
158
|
-
grunt.joosy.bower.resolve complete, error
|
159
|
-
else
|
160
|
-
grunt.log.subhead "Bower has errored"
|
161
|
-
grunt.log.warn error
|
162
|
-
grunt.log.warn error.details if error.details?
|
163
|
-
)
|
164
|
-
.on('end', complete)
|
165
|
-
else
|
166
|
-
complete()
|
167
|
-
|
168
|
-
resolve: (complete, error) ->
|
169
|
-
grunt.log.subhead "Bower conflict for '#{error.name}'"
|
170
|
-
|
171
|
-
error.picks.each (p) ->
|
172
|
-
dependencies = p.dependants.map((x) -> x.endpoint.name).join(',')
|
173
|
-
grunt.log.warn "#{p.endpoint.target} (#{dependencies.yellow}: resolves to #{p.pkgMeta._release.yellow})"
|
174
|
-
|
175
|
-
resolutions = error.picks.map((x) -> x.pkgMeta._release).unique()
|
176
|
-
|
177
|
-
unless process.env['NODE_ENV'] == 'production'
|
178
|
-
grunt.log.subhead "Pick a resolution from the list:"
|
179
|
-
require('commander').choose resolutions, (i) ->
|
180
|
-
bowerConfig = JSON.parse grunt.file.read('./bower.json')
|
181
|
-
bowerConfig.resolutions ||= {}
|
182
|
-
bowerConfig.resolutions[error.name] = resolutions[i]
|
183
|
-
|
184
|
-
grunt.file.write './bower.json', JSON.stringify(bowerConfig, null, 2)
|
185
|
-
|
186
|
-
grunt.joosy.bower.install complete
|
187
|
-
else
|
188
|
-
grunt.log.subhead "Possible resolutions:"
|
189
|
-
resolutions.unique().each (r) -> grunt.log.warn r
|
190
|
-
grunt.fatal "Bower has errored"
|
191
|
-
|
192
|
-
|
193
|
-
# Tasks
|
194
|
-
grunt.registerTask 'joosy:bower', ->
|
195
|
-
grunt.joosy.bower.install @async()
|
196
|
-
|
197
|
-
grunt.registerTask 'joosy:server', ->
|
198
|
-
@async()
|
199
|
-
|
200
|
-
grunt.joosy.server.start 4000, (server) ->
|
201
|
-
grunt.joosy.server.serveAssets server
|
202
|
-
grunt.joosy.server.serveProxied server, grunt.config.get('joosy.server.proxy')
|
203
|
-
grunt.joosy.server.serveStatic server
|
204
|
-
grunt.joosy.server.serveHAML server, grunt.joosy.helpers.normalizeFiles('joosy.haml')
|
205
|
-
|
206
|
-
grunt.registerTask 'joosy:server:production', ->
|
207
|
-
@async()
|
208
|
-
|
209
|
-
grunt.joosy.server.start process.env['PORT'] ? 4000, (server) ->
|
210
|
-
grunt.joosy.server.serveStatic server, true
|
211
|
-
|
212
|
-
grunt.registerTask 'joosy:compile', ['joosy:assets', 'joosy:haml']
|
213
|
-
|
214
|
-
grunt.registerTask 'joosy:compile:production', ->
|
215
|
-
grunt.task.run 'compile' if process.env['NODE_ENV'] == 'production'
|
216
|
-
|
217
|
-
grunt.registerTask 'joosy:assets', (target) ->
|
218
|
-
complete = @async()
|
219
|
-
assets = grunt.joosy.helpers.normalizeFiles('joosy.assets', target)
|
220
|
-
|
221
|
-
grunt.joosy.assets.compile 'production', assets,
|
222
|
-
error: (asset, msg) -> grunt.fail.fatal msg
|
223
|
-
compiled: (asset, dest) -> grunt.log.ok "Compiled #{dest}"
|
224
|
-
success: complete
|
225
|
-
|
226
|
-
grunt.registerTask 'joosy:haml', (target) ->
|
227
|
-
for _, entry of grunt.joosy.helpers.normalizeFiles('joosy.haml', target)
|
228
|
-
unless entry.expand
|
229
|
-
grunt.file.write entry.dest, grunt.joosy.haml.compile(
|
230
|
-
Path.join(paths.haml, entry.src),
|
231
|
-
entry.partials,
|
232
|
-
'production'
|
233
|
-
)
|
234
|
-
|
235
|
-
grunt.log.ok "Compiled #{entry.dest}"
|
236
|
-
else
|
237
|
-
files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
|
238
|
-
|
239
|
-
for file in files.list
|
240
|
-
destination = Path.join entry.dest, file.dirname, file.filename+(entry.ext || '.html')
|
241
|
-
|
242
|
-
grunt.file.write destination, grunt.joosy.haml.compile(
|
243
|
-
Path.join(files.cwd, file.src),
|
244
|
-
entry.partials,
|
245
|
-
'production'
|
246
|
-
)
|
247
|
-
|
248
|
-
grunt.log.ok "Compiled #{destination}"
|
249
|
-
|
250
|
-
grunt.registerTask 'joosy:clean', ->
|
251
|
-
trash = []
|
252
|
-
|
253
|
-
for entry in grunt.joosy.helpers.normalizeFiles('joosy.assets')
|
254
|
-
trash.push entry.dest
|
255
|
-
|
256
|
-
for entry in grunt.joosy.helpers.normalizeFiles('joosy.haml')
|
257
|
-
unless entry.expand
|
258
|
-
trash.push entry.dest
|
259
|
-
else
|
260
|
-
files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
|
261
|
-
|
262
|
-
for file in files.list
|
263
|
-
trash.push Path.join(entry.dest, file.dirname, file.filename+(entry.ext || '.html'))
|
264
|
-
|
265
|
-
for file in trash
|
266
|
-
if grunt.file.exists(file)
|
267
|
-
grunt.file.delete(file)
|
268
|
-
grunt.log.warn "Removed #{file}"
|
10
|
+
vendor: ['vendor/*', 'node_modules/joosy/source']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joosy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.alpha.
|
4
|
+
version: 1.2.0.alpha.59
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-08-
|
13
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sprockets
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- spec/helpers/ground.coffee
|
133
133
|
- spec/helpers/matchers.coffee
|
134
134
|
- spec/joosy/core/application_spec.coffee
|
135
|
+
- spec/joosy/core/helpers/routes_spec.coffee
|
135
136
|
- spec/joosy/core/helpers/view_spec.coffee
|
136
137
|
- spec/joosy/core/helpers/widgets_spec.coffee
|
137
138
|
- spec/joosy/core/joosy_spec.coffee
|