joosy 1.2.0.alpha.59 → 1.2.0.alpha.62

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.travis.yml +2 -1
  4. data/Gruntfile.coffee +50 -217
  5. data/bin/joosy +1 -1
  6. data/bower.json +1 -1
  7. data/build/joosy.js +5 -5
  8. data/{generators → lib/generators}/base.coffee +1 -1
  9. data/{generators → lib/generators}/command/command.coffee +1 -1
  10. data/{generators → lib/generators}/command/help.coffee +0 -0
  11. data/{generators → lib/generators}/layout.coffee +0 -0
  12. data/{generators → lib/generators}/page.coffee +0 -0
  13. data/{generators → lib/generators}/project.coffee +1 -1
  14. data/{generators → lib/generators}/project/base.coffee +0 -0
  15. data/{generators → lib/generators}/project/standalone.coffee +9 -4
  16. data/{generators → lib/generators}/templates/application/base/application.coffee +0 -0
  17. data/{generators → lib/generators}/templates/application/base/helpers/application.coffee +0 -0
  18. data/{generators → lib/generators}/templates/application/base/layouts/application.coffee +0 -0
  19. data/{generators → lib/generators}/templates/application/base/pages/application.coffee +0 -0
  20. data/{generators → lib/generators}/templates/application/base/pages/welcome/index.coffee +0 -0
  21. data/{generators → lib/generators}/templates/application/base/routes.coffee +0 -0
  22. data/{generators → lib/generators}/templates/application/base/templates/layouts/application.jst.hamlc +0 -0
  23. data/{generators → lib/generators}/templates/application/base/templates/pages/welcome/index.jst.hamlc +0 -0
  24. data/{generators → lib/generators}/templates/application/standalone/Gruntfile.coffee +11 -25
  25. data/{generators → lib/generators}/templates/application/standalone/Procfile +0 -0
  26. data/{generators → lib/generators}/templates/application/standalone/_gitignore +2 -2
  27. data/{generators/templates/application/standalone/source → lib/generators/templates/application/standalone/app}/haml/index.haml +0 -0
  28. data/{generators/templates/application/standalone/source → lib/generators/templates/application/standalone/app}/stylesheets/application.styl +0 -0
  29. data/{generators → lib/generators}/templates/application/standalone/bower.json +0 -0
  30. data/{generators → lib/generators}/templates/application/standalone/package.json +3 -0
  31. data/{generators → lib/generators}/templates/application/standalone/spec/application_spec.coffee +0 -0
  32. data/{generators → lib/generators}/templates/application/standalone/spec/helpers/environment.coffee +0 -0
  33. data/{generators → lib/generators}/templates/application/standalone/tasks/spec.coffee +0 -0
  34. data/{generators → lib/generators}/templates/layout/basic.coffee +0 -0
  35. data/{generators → lib/generators}/templates/layout/namespaced.coffee +0 -0
  36. data/{generators → lib/generators}/templates/page/basic.coffee +0 -0
  37. data/{generators → lib/generators}/templates/page/namespaced.coffee +0 -0
  38. data/{generators → lib/generators}/templates/widget/basic.coffee +0 -0
  39. data/{generators → lib/generators}/templates/widget/namespaced.coffee +0 -0
  40. data/{generators → lib/generators}/widget.coffee +0 -0
  41. data/lib/joosy.rb +2 -2
  42. data/lib/tasks/build.coffee +16 -0
  43. data/lib/tasks/doc.coffee +80 -0
  44. data/lib/tasks/publish.coffee +29 -0
  45. data/lib/tasks/testem.coffee +58 -0
  46. data/package.json +10 -15
  47. data/source/joosy/helpers/widgets.coffee +1 -1
  48. data/source/joosy/modules/events.coffee +1 -1
  49. data/source/joosy/router.coffee +2 -2
  50. data/source/joosy/templaters/jst.coffee +1 -1
  51. data/source/joosy/widget.coffee +2 -2
  52. data/spec/joosy/core/helpers/routes_spec.coffee +8 -2
  53. data/spec/joosy/core/router_spec.coffee +4 -4
  54. data/tasks/joosy.coffee +2 -0
  55. metadata +39 -42
  56. data/Gemfile +0 -6
  57. data/build/joosy/extensions/preloaders.js +0 -189
  58. data/source/joosy/extensions/preloaders/caching.coffee +0 -169
  59. data/source/joosy/extensions/preloaders/index.coffee +0 -1
  60. data/source/joosy/extensions/preloaders/inline.coffee +0 -56
  61. data/spec/joosy/extensions/preloaders/caching_spec.coffee +0 -36
  62. data/spec/joosy/extensions/preloaders/inline_spec.coffee +0 -16
@@ -11,43 +11,29 @@ module.exports = (grunt) ->
11
11
  #
12
12
  grunt.initConfig
13
13
  joosy:
14
- # Pass data to Stylus and HAML templates
14
+ assets:
15
+ root: 'application.*'
16
+ greedy: '/'
17
+
18
+ # Pass static data to Stylus and HAML templates
15
19
  # config: require('./config.json')
16
20
 
17
21
  # Setup built-in development proxy to workaround Cross-Origin
18
- # server:
19
- # proxy: [
20
- # {src: '/joosy', dest: 'http://joosy.ws'}
21
- # ]
22
-
23
- assets:
24
- application:
25
- src: 'application.coffee'
26
- dest: 'public/assets/application.js'
27
- styles:
28
- src: 'application.styl'
29
- dest: 'public/assets/application.css'
30
- haml:
31
- application:
32
- path: '/'
33
- src: 'index.haml'
34
- dest: 'public/index.html'
35
- url: '/'
36
- greedy: true
22
+ # proxy: '/joosy': 'http://joosy.ws'
37
23
 
38
24
  uglify:
39
25
  application:
40
26
  files:
41
- 'public/assets/application.js': 'public/assets/application.js'
27
+ 'public/application.js': 'public/application.js'
42
28
 
43
29
  cssmin:
44
- styles:
30
+ application:
45
31
  files:
46
- 'public/assets/application.css': 'public/assets/application.css'
32
+ 'public/application.css': 'public/application.css'
47
33
 
48
34
  jasmine:
49
35
  application:
50
- src: 'public/assets/application.js'
36
+ src: 'public/application.js'
51
37
  options:
52
38
  keepRunner: true
53
39
  outfile: 'spec/application.html'
@@ -64,4 +50,4 @@ module.exports = (grunt) ->
64
50
 
65
51
  grunt.registerTask 'spec', ['coffee', 'joosy:compile', 'jasmine']
66
52
 
67
- grunt.registerTask 'joosy:postinstall', ['joosy:bower', 'joosy:compile:production']
53
+ grunt.registerTask 'joosy:postinstall', ['joosy:bower', 'joosy:compile']
@@ -1,5 +1,5 @@
1
1
  bower_components
2
2
  node_modules
3
+ public
3
4
  .DS_Store
4
- public/assets
5
- public/index.html
5
+ Thumbs.db
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "joosy": "~<%= joosy_version %>",
4
+ "haml-coffee": "~1.11.1",
5
+ "stylus": "~0.32.1",
6
+ "nib": "~0.9.1",
4
7
  "grunt": "~0.4.1",
5
8
  "grunt-cli": "~0.1.9",
6
9
  "grunt-contrib-uglify": "~0.2.2",
@@ -13,10 +13,10 @@ module Joosy
13
13
  end
14
14
 
15
15
  def self.generators_path
16
- File.expand_path '../../generators', __FILE__
16
+ File.expand_path '../../lib/generators', __FILE__
17
17
  end
18
18
 
19
19
  def self.templates_path
20
- File.expand_path '../../generators/templates', __FILE__
20
+ File.expand_path '../../lib/generators/templates', __FILE__
21
21
  end
22
22
  end
@@ -0,0 +1,16 @@
1
+ Mincer = require 'mincer'
2
+
3
+ module.exports = (grunt) ->
4
+
5
+ grunt.registerMultiTask 'mince', ->
6
+ Mincer.CoffeeEngine.configure bare: false
7
+ environment = new Mincer.Environment
8
+ environment.appendPath x for x in @data.include
9
+ grunt.file.write @data.dest, environment.findAsset(@data.src).toString()
10
+
11
+ grunt.registerTask 'bowerize', ->
12
+ bower = require '../../bower.json'
13
+ meta = require '../../package.json'
14
+
15
+ bower.version = meta.version
16
+ grunt.file.write 'bower.json', JSON.stringify(bower, null, 2)
@@ -0,0 +1,80 @@
1
+ semver = require 'semver'
2
+
3
+ module.exports = (grunt) ->
4
+
5
+ grunt.registerTask 'doc', ['doc:prepare', 'doc:generate']
6
+
7
+ grunt.registerTask 'doc:generate', ->
8
+ complete = @async()
9
+ version = JSON.parse(grunt.file.read 'package.json').version.split('-')
10
+ version = version[0]+'-'+version[1]?.split('.')[0]
11
+ destination = "doc/#{version}"
12
+ args = ['source', '--output-dir', destination]
13
+
14
+ git = (args, callback) ->
15
+ grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2], cwd: 'doc'}}, callback
16
+
17
+ date = (version) ->
18
+ return undefined unless version
19
+ Date.create(grunt.file.read "doc/#{version}/DATE").format "{d} {Month} {yyyy}"
20
+
21
+ git ['pull'], (error, result) ->
22
+ grunt.fatal "Error pulling from git" if error
23
+
24
+ grunt.file.delete destination if grunt.file.exists destination
25
+ grunt.util.spawn {cmd: "codo", args: args, opts: {stdio: [0,1,2]}}, (error, result) ->
26
+ grunt.fatal "Error generating docs" if error
27
+ grunt.file.write "#{destination}/DATE", (new Date).toISOString()
28
+
29
+ versions = []
30
+ for version in grunt.file.expand({cwd: 'doc'}, '*')
31
+ versions.push version if semver.valid(version)
32
+
33
+ versions = versions.sort(semver.rcompare)
34
+ edge = versions.find (x) -> x.has('-')
35
+ stable = versions.find (x) -> !x.has('-')
36
+ versions = versions.remove edge, stable
37
+
38
+ versions = {
39
+ edge:
40
+ version: edge
41
+ date: date(edge)
42
+ stable:
43
+ version: stable
44
+ date: date(stable)
45
+ versions: versions.map (x) -> { version: x, date: date(x) }
46
+ }
47
+ grunt.file.write 'doc/versions.js', "window.versions = #{JSON.stringify(versions)}"
48
+
49
+ git ['add', '-A'], (error, result) ->
50
+ grunt.fatal "Error adding files" if error
51
+
52
+ git ['commit', '-m', "Updated at #{(new Date).toISOString()}"], (error, result) ->
53
+ grunt.fatal "Error commiting" if error
54
+
55
+ git ['push', 'origin', 'gh-pages'], (error, result) ->
56
+ grunt.fatal "Error pushing" if error
57
+ complete()
58
+
59
+ grunt.registerTask 'doc:prepare', ->
60
+ if grunt.file.exists 'doc'
61
+ unless grunt.file.exists 'doc/.git'
62
+ grunt.fatal "Documentation directory exists. Please remove it"
63
+ else
64
+ return
65
+
66
+ complete = @async()
67
+
68
+ base = process.cwd()
69
+ git = (args, callback) ->
70
+ grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2]}}, callback
71
+
72
+ git ["clone", "git@github.com:joosy/joosy.git", "doc"], (error, result) ->
73
+ grunt.fatal "Erorr cloning repo" if error
74
+ process.chdir 'doc'
75
+
76
+ git ["checkout", "gh-pages"], (error, result) ->
77
+ grunt.fatal "Erorr checking branch out" if error
78
+
79
+ process.chdir base
80
+ complete()
@@ -0,0 +1,29 @@
1
+ module.exports = (grunt) ->
2
+
3
+ grunt.registerTask 'publish:ensureCommits', ->
4
+ complete = @async()
5
+
6
+ grunt.util.spawn {cmd: "git", args: ["status", "--porcelain" ]}, (error, result) ->
7
+ if !!error || result.stdout.length > 0
8
+ console.log ""
9
+ console.log "Uncommited changes found. Please commit prior to release or use `--force`.".bold
10
+ console.log ""
11
+ complete false
12
+ else
13
+ complete true
14
+
15
+ grunt.registerTask 'publish:gem', ->
16
+ meta = require '../../package.json'
17
+ complete = @async()
18
+
19
+ grunt.util.spawn {cmd: "gem", args: ["build", "joosy.gemspec"]}, (error, result) ->
20
+ return complete false if error
21
+
22
+ gem = "joosy-#{meta.version.replace('-', '.')}.gem"
23
+ grunt.log.ok "Built #{gem}"
24
+
25
+ grunt.util.spawn {cmd: "gem", args: ["push", gem]}, (error, result) ->
26
+ return complete false if error
27
+ grunt.log.ok "Published #{gem}"
28
+ grunt.file.delete gem
29
+ complete(true)
@@ -0,0 +1,58 @@
1
+ Path = require 'path'
2
+
3
+ module.exports = (grunt) ->
4
+
5
+ grunt.registerTask 'testem:generate', ->
6
+ unless @args[0]
7
+ grunt.config.requires 'testem'
8
+ return Object.each grunt.config.get('testem'), (key, value) ->
9
+ grunt.task.run "testem:generate:#{key}"
10
+
11
+ grunt.config.requires "testem.#{@args[0]}"
12
+
13
+ coffee = []
14
+ source = grunt.file.expand grunt.config.get("testem.#{@args[0]}.src")
15
+
16
+ serve = source.map (name) ->
17
+ if Path.extname(name) == '.coffee'
18
+ destination = ".grunt/#{Path.dirname(name)}/#{Path.basename(name, '.coffee')}.js"
19
+ coffee.push "coffee -o #{Path.dirname(destination)} -c #{name}"
20
+ destination
21
+ else
22
+ name
23
+
24
+ result =
25
+ framework: 'jasmine',
26
+ src_files: source
27
+ serve_files: serve
28
+ before_tests: 'grunt mince;'+coffee.join(';')
29
+ launch_in_dev: ['PhantomJS'],
30
+ launch_in_ci: ['PhantomJS', 'Chrome', 'Firefox', 'Safari', 'IE7', 'IE8', 'IE9']
31
+
32
+ grunt.file.write "spec/#{@args[0]}.json", JSON.stringify(result, null, 2)
33
+
34
+ grunt.registerTask 'testem:ci', ->
35
+ unless @args[0]
36
+ grunt.config.requires 'testem'
37
+ return Object.each grunt.config.get('testem'), (key, value) ->
38
+ grunt.task.run "testem:ci:#{key}"
39
+
40
+ complete = @async()
41
+
42
+ grunt.config.requires "testem.#{@args[0]}"
43
+
44
+ command = "node_modules/.bin/testem"
45
+ options = ['ci', '-f', "spec/#{@args[0]}.json", '-R', 'dot', '-P', '8']
46
+
47
+ grunt.util.spawn {cmd: command, args: options, opts: {stdio: [0,1,2]}}, (error, result) ->
48
+ grunt.fatal "Tests did not succed" if error
49
+ complete()
50
+
51
+ grunt.registerTask 'testem:run', ->
52
+ complete = @async()
53
+
54
+ command = "node_modules/.bin/testem"
55
+ options = ['-f', "spec/#{@args[0]}.json"]
56
+
57
+ grunt.util.spawn {cmd: command, args: options, opts: {stdio: [0,1,2]}}, (error, result) ->
58
+ complete()
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.59",
7
+ "version": "1.2.0-alpha.62",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -18,27 +18,22 @@
18
18
  "node": ">=0.4.0"
19
19
  },
20
20
  "dependencies": {
21
- "grill": "~1.0.0-alpha.3",
22
- "sugar": "~1.3.8",
21
+ "grunt": "~0.4.1",
23
22
  "coffee-script": "~1.6.3",
23
+ "sugar": "~1.3.8",
24
+ "grill": "~1.0.0-alpha.5",
24
25
  "command-router": "0.0.5",
25
26
  "resolve": "~0.4.0",
26
27
  "ejs": "~0.8.4",
27
28
  "commander": "~1.2.0",
28
- "colors": "~0.6.0-1",
29
- "grunt": "~0.4.1",
30
- "mincer": ">= 0.5.5",
31
- "stylus": "~0.32.1",
32
- "nib": "~0.9.1"
29
+ "colors": "~0.6.0-1"
33
30
  },
34
31
  "devDependencies": {
35
- "grunt-contrib-jasmine": "~0.5.1",
36
- "grunt-contrib-watch": "~0.4.4",
37
- "grunt-contrib-coffee": "~0.7.0",
38
- "grunt-contrib-connect": "~0.3.0",
39
- "grunt-coffeelint": "0.0.6",
40
- "grunt-release": "~0.3.5",
32
+ "bower": "~1.1.2",
33
+ "mincer": ">= 0.5.5",
41
34
  "semver": "~2.1.0",
42
- "bower": "~1.1.2"
35
+ "testem": "~0.3.24",
36
+ "grunt-coffeelint": "0.0.6",
37
+ "grunt-release": "~0.3.5"
43
38
  }
44
39
  }
@@ -7,7 +7,7 @@ Joosy.helpers 'Application', ->
7
7
 
8
8
  #
9
9
  # Injects widget
10
- #
10
+ #
11
11
  # @param [String] tag Tag name to use a widget container
12
12
  # @param [Object] options Tag attributes
13
13
  # @param [Joosy.Widget] widget Class or instance of {Joosy.Widget} to register
@@ -138,7 +138,7 @@ Joosy.Modules.Events =
138
138
  context.actions.each (action) =>
139
139
  action.call @, ->
140
140
  if ++counter >= context.actions.length
141
- context.after.call(@)
141
+ context.after.call(@)
142
142
 
143
143
  __splitEvents: (events) ->
144
144
  if Object.isString events
@@ -129,8 +129,6 @@ class Joosy.Router extends Joosy.Module
129
129
  @config.prefix ||= ''
130
130
  @config.prefix = ('/'+@config.prefix+'/').replace(/\/{2,}/g, '/') if @config.html5
131
131
 
132
- @respond @canonizeLocation() if respond
133
-
134
132
  if @config.html5
135
133
  @listener = @bind 'popstate pushstate', =>
136
134
  @respond @canonizeLocation()
@@ -139,6 +137,8 @@ class Joosy.Router extends Joosy.Module
139
137
  $(window).bind 'hashchange.JoosyRouter', =>
140
138
  @respond @canonizeLocation()
141
139
 
140
+ @respond @canonizeLocation() if respond
141
+
142
142
  #
143
143
  # Clears current map of routes and deactivates bindings
144
144
  #
@@ -26,7 +26,7 @@ class Joosy.Templaters.JST
26
26
  "templates/#{name}"
27
27
  ]
28
28
 
29
- for path in haystack
29
+ for path in haystack
30
30
  return window.JST[path] if window.JST[path]
31
31
 
32
32
  throw new Error "Template '#{name}' not found. Checked at: '#{haystack.join(', ')}'"
@@ -22,7 +22,7 @@
22
22
  # "dependent chains" that will be rendered together (HTML will be injected into DOM atomically). Such chains
23
23
  # use paint filters of the top elements. Independent widgets on the other hand load on their own behalf and
24
24
  # use their own paint filters. To understand this better, here is the sample:
25
- #
25
+ #
26
26
  # Let's say we have 4 widgets A, B, C and D nested into each other:
27
27
  #
28
28
  # A is the root widget
@@ -31,7 +31,7 @@
31
31
  # D is nested into C. It does not define itself as an independent and therefore defaults to dependent rendering
32
32
  #
33
33
  # Then total chain of asynchronous callbacks goes with the following scenario.
34
- #
34
+ #
35
35
  # 1. A collects all the fetches from the whole tree recursively and starts them in parallel.
36
36
  #
37
37
  # 2. A runs erase on the previous same-level widget (attribute `@previous`) if one is given.
@@ -2,8 +2,14 @@ describe "Joosy.Helpers.Routes", ->
2
2
 
3
3
  it "renders data-joosy links", ->
4
4
  link = Joosy.Helpers.Routes.linkTo 'test', '/app/link', nice: true
5
- expect(link).toEqual '<a nice="true" data-joosy="true" href="/app/link">test</a>'
5
+ expect(link).toBeTag 'a', 'test',
6
+ 'data-joosy': 'true'
7
+ nice: 'true'
8
+ href: '/app/link'
6
9
 
7
10
  it "renders data-joosy links yielding block", ->
8
11
  link = Joosy.Helpers.Routes.linkTo '/app/link', nice: true, -> 'test'
9
- expect(link).toEqual '<a nice="true" data-joosy="true" href="/app/link">test</a>'
12
+ expect(link).toBeTag 'a', 'test',
13
+ 'data-joosy': 'true'
14
+ nice: 'true'
15
+ href: '/app/link'