joosy 1.2.0.alpha.4 → 1.2.0.alpha.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02b11c8b16a833bce2041755884857abb5ebc8d7
4
- data.tar.gz: 325c12aabae0052cdd11a098e1d2551e59962e77
3
+ metadata.gz: 8395d61d74334b79dff75dfac8d41a983da6cd7d
4
+ data.tar.gz: f8bc1d0db984fa3c4bd689a5ad00defe632c3f19
5
5
  SHA512:
6
- metadata.gz: c70a1a3d66b29e5b3c35bbd9e989128441ab28d680805b17dcc624ae5edabb1be2a13154ca6becf56f048ba059d442ec9ed8ff5dae8d47c3299690cf43f3a5c6
7
- data.tar.gz: a92fe9856fab357b6953bed3e31744470b5a67028741af7419575bc11295a40f4122224601425c00731dc2f0bf7b5ce7605294da1db17443d265a4b6d7fe77e3
6
+ metadata.gz: bf279fa42a0b35c7fb01950e28af1f33701aa762ae82747b4854da0dd46bfd04e16dd4d56f81fed3c48ce7845b17973236f0846f155fc59d2c9028e1cb03d278
7
+ data.tar.gz: 4a33c7dd7ff43dc198842f133d5ed2a31307f3f5173fc87b0aa431291334eca0e37d548f0194fa1a9b95ffc5a6db08998e7d25fc360c12b29a6ff63a4a2a2f7a
data/README.md CHANGED
@@ -65,7 +65,7 @@ Now run basic application generator with the following command:
65
65
 
66
66
  joosy new dummy
67
67
 
68
- Now you can `grunt server` to get Joosy placeholder at [localhost:4000/](http://localhost:4000/). Generated application will consist of one `Layout` and one `Page` both including very basic practices of Joosy.
68
+ The main application code will appear at `source` directory. `stylesheets` is for Stylus-based styles and the main canvas of page is defined at `source/index.haml`. Now you can `grunt joosy:server` to start development server at [localhost:4000/](http://localhost:4000/).
69
69
 
70
70
  To generate assets statically prior to the deployment run
71
71
 
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.4",
3
+ "version": "1.2.0-alpha.5",
4
4
  "main": "lib/joosy.js",
5
5
  "ignore": [
6
6
  "bin",
data/lib/joosy.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'haml_coffee_assets'
2
1
  require 'json'
2
+ require 'haml_coffee_assets'
3
3
 
4
4
  module Joosy
5
5
  PACKAGE = File.expand_path("../../package.json", __FILE__)
@@ -13,4 +13,12 @@ module Joosy
13
13
  File.dirname(HamlCoffeeAssets.helpers_path)
14
14
  ]
15
15
  end
16
+
17
+ def self.generators_path
18
+ File.expand_path '../../src/joosy/generators', __FILE__
19
+ end
20
+
21
+ def self.templates_path
22
+ File.expand_path '../../templates', __FILE__
23
+ end
16
24
  end
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.4",
7
+ "version": "1.2.0-alpha.5",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "bin": {
10
10
  "joosy": "bin/joosy"
@@ -1,14 +1,15 @@
1
- File = require('grunt').file
2
- Log = require('grunt').log
3
- Path = require('path')
4
- EJS = require('ejs')
5
- Commander = require('commander')
6
-
7
- module.exports = class
8
- constructor: (destination, templates) ->
9
- @destination = destination || process.cwd()
10
- @templates = templates || @join(__dirname, '..', '..', '..', 'templates')
11
- @actions = []
1
+ if module?
2
+ File = require('grunt').file
3
+ Log = require('grunt').log
4
+ Path = require('path')
5
+ EJS = require('ejs')
6
+ Commander = require('commander')
7
+
8
+ class Base
9
+ constructor: (@destination, @templates) ->
10
+ @destination ||= process?.cwd()
11
+ @templates ||= @join(__dirname, '..', '..', '..', 'templates') if __dirname?
12
+ @actions = []
12
13
 
13
14
  getNamespace: (name) ->
14
15
  name = name.split('/')
@@ -23,9 +24,7 @@ module.exports = class
23
24
  source = @join(@templates, source...) if source instanceof Array
24
25
  destination = @join(destination...) if destination instanceof Array
25
26
 
26
- result = @compileTemplate source, data
27
-
28
- @actions.push ['template', destination, result]
27
+ @actions.push ['template', destination, source, data]
29
28
 
30
29
  file: (destination, content='') ->
31
30
  destination = @join(destination...) if destination instanceof Array
@@ -38,18 +37,28 @@ module.exports = class
38
37
 
39
38
  @actions.push ['copy', destination, source]
40
39
 
41
- #
42
- # Required but Node-only methods
43
- #
40
+ camelize: (string) ->
41
+ parts = (part.charAt(0).toUpperCase() + part.substr(1) for part in string.split(/_|-/))
42
+ parts.join ''
43
+
44
44
  join: ->
45
- Path.join arguments...
45
+ if Path?
46
+ Path.join arguments...
47
+ else
48
+ Array.prototype.slice.call(arguments, 0).join('/')
46
49
 
47
- compileTemplate: (source, data) ->
48
- EJS.render File.read(source), data
50
+ #
51
+ # Methods that have to be overrided outside of Node.js
52
+ #
53
+ version: ->
54
+ require('../../../package.json').version
49
55
 
50
56
  #
51
57
  # Node-base performer
52
58
  #
59
+ compileTemplate: (source, data) ->
60
+ EJS.render File.read(source), data
61
+
53
62
  perform: (callback) ->
54
63
  actions = @actions.clone()
55
64
  @performAction actions.pop(), actions, callback
@@ -90,4 +99,10 @@ module.exports = class
90
99
  write()
91
100
  callback()
92
101
 
93
- performTemplateAction: -> @performFileAction arguments...
102
+ performTemplateAction: (callback, destination, source, data) ->
103
+ @performFileAction callback, destination, @compileTemplate(source, data)
104
+
105
+ if module?
106
+ module.exports = Base
107
+ else
108
+ @Base = Base
@@ -1,6 +1,6 @@
1
- Generator = require './generator'
1
+ @Base = require './base' if module?
2
2
 
3
- module.exports = class extends Generator
3
+ class Layout extends @Base
4
4
  constructor: (@name, destination, templates) ->
5
5
  super(destination, templates)
6
6
  @destination = @join @destination, 'source'
@@ -11,10 +11,15 @@ module.exports = class extends Generator
11
11
  template = if namespace.length > 0 then 'namespaced' else 'basic'
12
12
 
13
13
  @template ['layout', "#{template}.coffee"], ['layouts', @join(namespace...), "#{basename}.coffee"],
14
- namespace_name: namespace.map (x) -> x.camelize()
15
- class_name: basename.camelize()
14
+ namespace_name: (@camelize(x) for x in namespace).join('.')
15
+ class_name: @camelize(basename)
16
16
  view_name: basename
17
17
 
18
18
  @file ['templates', 'layouts', @join(namespace...), "#{basename}.jst.hamlc"]
19
19
 
20
- @actions
20
+ @actions
21
+
22
+ if module?
23
+ module.exports = Layout
24
+ else
25
+ @Generator = Layout
@@ -1,6 +1,6 @@
1
- Generator = require './generator'
1
+ @Base = require './base' if module?
2
2
 
3
- module.exports = class extends Generator
3
+ class Page extends @Base
4
4
  constructor: (@name, destination, templates) ->
5
5
  super(destination, templates)
6
6
  @destination = @join @destination, 'source'
@@ -11,10 +11,15 @@ module.exports = class extends Generator
11
11
  template = if namespace.length > 0 then 'namespaced' else 'basic'
12
12
 
13
13
  @template ['page', "#{template}.coffee"], ['pages', @join(namespace...), "#{basename}.coffee"],
14
- namespace_name: namespace.map (x) -> x.camelize()
15
- class_name: basename.camelize()
14
+ namespace_name: (@camelize(x) for x in namespace).join('.')
15
+ class_name: @camelize(basename)
16
16
  view_name: basename
17
17
 
18
18
  @file ['templates', 'pages', @join(namespace...), "#{basename}.jst.hamlc"]
19
19
 
20
- @actions
20
+ @actions
21
+
22
+ if module?
23
+ module.exports = Page
24
+ else
25
+ @Generator = Page
@@ -1,8 +1,9 @@
1
- Generator = require '../generator'
1
+ @Base = require '../base' if module?
2
2
 
3
- module.exports = class extends Generator
4
- constructor: (@name, destination, templates) ->
3
+ class ProjectBase extends @Base
4
+ constructor: (name, destination, templates) ->
5
5
  super(destination, templates)
6
+ @name = name.split('/').pop()
6
7
  @destination = @join @destination, 'source'
7
8
 
8
9
  generate: ->
@@ -25,4 +26,9 @@ module.exports = class extends Generator
25
26
  @template ['application', 'base', 'application.coffee'], ['application.coffee'],
26
27
  application: @name
27
28
 
28
- @actions
29
+ @actions
30
+
31
+ if module?
32
+ module.exports = ProjectBase
33
+ else
34
+ @Generator = ProjectBase
@@ -1,9 +1,8 @@
1
- meta = require '../../../../package.json'
2
- Generator = require '../generator'
1
+ @Base = require '../base' if module?
3
2
 
4
- module.exports = class extends Generator
3
+ class ProjectStandalone extends @Base
5
4
  constructor: (@name, destination, templates) ->
6
- destination = @join (destination || process.cwd()), @name unless destination?
5
+ destination = @join process.cwd(), @name if !destination? && process?
7
6
  super(destination, templates)
8
7
 
9
8
  generate: ->
@@ -20,6 +19,11 @@ module.exports = class extends Generator
20
19
  ['stylesheets', 'application.styl']
21
20
 
22
21
  @template ['application', 'standalone', 'package.json'], ['package.json'],
23
- joosy_version: meta.version
22
+ joosy_version: @version()
24
23
 
25
- @actions
24
+ @actions
25
+
26
+ if module?
27
+ module.exports = ProjectStandalone
28
+ else
29
+ @Generator = ProjectStandalone
@@ -1,6 +1,6 @@
1
- Generator = require './generator'
1
+ @Base = require './base' if module?
2
2
 
3
- module.exports = class extends Generator
3
+ class Widget extends @Base
4
4
  constructor: (@name, destination, templates) ->
5
5
  super(destination, templates)
6
6
  @destination = @join @destination, 'source'
@@ -11,10 +11,15 @@ module.exports = class extends Generator
11
11
  template = if namespace.length > 0 then 'namespaced' else 'basic'
12
12
 
13
13
  @template ['widget', "#{template}.coffee"], ['widgets', @join(namespace...), "#{basename}.coffee"],
14
- namespace_name: namespace.map (x) -> x.camelize()
15
- class_name: basename.camelize()
14
+ namespace_name: (@camelize(x) for x in namespace).join('.')
15
+ class_name: @camelize(basename)
16
16
  view_name: basename
17
17
 
18
18
  @file ['templates', 'widgets', @join(namespace...), "#{basename}.jst.hamlc"]
19
19
 
20
- @actions
20
+ @actions
21
+
22
+ if module?
23
+ module.exports = Widget
24
+ else
25
+ @Generator = Widget
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
4
+ version: 1.2.0.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal
@@ -110,8 +110,8 @@ files:
110
110
  - src/joosy/core/router.coffee
111
111
  - src/joosy/core/templaters/rails_jst.coffee
112
112
  - src/joosy/core/widget.coffee
113
+ - src/joosy/generators/base.coffee
113
114
  - src/joosy/generators/command.coffee
114
- - src/joosy/generators/generator.coffee
115
115
  - src/joosy/generators/layout.coffee
116
116
  - src/joosy/generators/page.coffee
117
117
  - src/joosy/generators/project.coffee