sudojs-rails 0.4.6 → 0.4.7
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.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +14 -14
- data/lib/generators/sudojs/class/class_generator.rb +13 -4
- data/lib/generators/sudojs/helpers.rb +0 -8
- data/lib/generators/sudojs/install/USAGE +9 -10
- data/lib/generators/sudojs/install/install_generator.rb +14 -13
- data/lib/generators/sudojs/install/templates/{app_manifest.css.erb → app_manifest.css} +0 -0
- data/lib/generators/sudojs/install/templates/{app_manifest.js.erb → app_manifest.js} +3 -3
- data/lib/generators/sudojs/install/templates/namespace.coffee +8 -0
- data/lib/generators/sudojs/install/templates/namespace.js +8 -0
- data/lib/generators/sudojs/install/templates/sudo_js.erb.yml +5 -11
- data/lib/sudojs/version.rb +1 -1
- data/sudojs-rails.gemspec +0 -2
- data/vendor/assets/javascripts/sudojs/sudo.js +33 -2
- metadata +7 -23
- data/lib/generators/sudojs/install/templates/model.coffee.erb +0 -5
- data/lib/generators/sudojs/install/templates/model.js.erb +0 -7
- data/lib/generators/sudojs/install/templates/namespace.coffee.erb +0 -8
- data/lib/generators/sudojs/install/templates/namespace.js.erb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb644c09ab21d3500df93cbede3023bacfacfba
|
4
|
+
data.tar.gz: 6e0fe9702b729f16025cd3b23be6e580271a86d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ac70d1f915348c625b572da7eab797407dbc1bddbf6c497c534c9c8c626411e6baf40008ea14a625ec9180c390b1ea64a755b3ae015744585864650e871858
|
7
|
+
data.tar.gz: 500391e74e1dead14ba65d771c311c8e1bbfcdbc399f01b0235614327564e2e40dead59ace1547619f26794fb0a6fbe2f563f8025394eb35b628fde53341c8dd
|
data/.DS_Store
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -79,17 +79,16 @@ Description:
|
|
79
79
|
Install sudo.js along with it's particular directory hierarchy.
|
80
80
|
|
81
81
|
Example:
|
82
|
-
rails g sudojs:install
|
82
|
+
rails g sudojs:install [html_extension] [js_extension] [css_extension] [--skip-css=true/false]
|
83
83
|
|
84
|
-
|
84
|
+
Two namespaces, 'page' and 'lib', will be automagically created. The 'models' and 'templates'
|
85
|
+
Containers will be appended to the page namespace, and 'lib' is used to house Class definitions
|
86
|
+
by convention.
|
85
87
|
|
86
|
-
The install generator uses these
|
87
|
-
1. `
|
88
|
-
|
89
|
-
|
90
|
-
2. `html_extension` => Use the full extension, i.e. `.haml`. defaults to `.erb`.
|
91
|
-
3. `js_extension` => defaults to `.js` pass `.js.coffee` if you are of the coffee persuasion.
|
92
|
-
4. `css_extension` => defaults to `.css`. Sass for example would need `.css.scss`
|
88
|
+
The install generator uses these options to expand the values in the sudo_js.yml file:
|
89
|
+
1. `--html_extension` => Use the full extension, i.e. `.haml`. defaults to `.erb`.
|
90
|
+
2. `--js_extension` => defaults to `.js` pass `.coffee` if you are of the coffee persuasion.
|
91
|
+
3. `--css_extension` => defaults to `.css`. Sass for example would need `.scss`
|
93
92
|
|
94
93
|
NOTE: to skip any and all generating of css files pass the option `--skip-css=true` when invoking the install generator.
|
95
94
|
Obviously, you could then leave the `css_extension` argument out. The option defaults to false.
|
@@ -99,14 +98,15 @@ Example:
|
|
99
98
|
assets/
|
100
99
|
stylesheets/
|
101
100
|
manifests/
|
102
|
-
application
|
101
|
+
application.*
|
103
102
|
javascripts/
|
104
|
-
application/
|
105
|
-
yourNamespace.js
|
106
|
-
model.js
|
107
103
|
manifests/
|
108
|
-
application
|
104
|
+
application.*
|
105
|
+
models/
|
106
|
+
base.*
|
109
107
|
views/
|
108
|
+
application/
|
109
|
+
page.*
|
110
110
|
config/
|
111
111
|
sudo_js.yml
|
112
112
|
|
@@ -52,41 +52,50 @@ module Sudojs
|
|
52
52
|
# the arguments vary in the templates for class types
|
53
53
|
# also we can make some assumptions about paths
|
54
54
|
case @parent
|
55
|
-
when '_.Base'
|
55
|
+
when '_.Base'
|
56
56
|
@args = 'data'
|
57
57
|
@js_path = @js_views_path
|
58
58
|
@js_req = 'views'
|
59
59
|
skip_css = true
|
60
|
+
namespace = 'lib'
|
61
|
+
when '_.Container'
|
62
|
+
@args = 'data'
|
63
|
+
@js_path = @js_views_path
|
64
|
+
@js_req = 'containers'
|
65
|
+
skip_css = true
|
66
|
+
namespace = 'lib.containers'
|
60
67
|
when '_.Model'
|
61
68
|
@args = 'data'
|
62
69
|
@js_path = @js_model_path
|
63
70
|
@js_req = 'models'
|
64
71
|
skip_css = true
|
72
|
+
namespace = 'lib.models'
|
65
73
|
when '_.View', '_.ViewController', 'DataView'
|
66
74
|
@args = 'el, data'
|
67
75
|
@js_path = @js_views_path
|
68
76
|
@js_req = 'views'
|
77
|
+
namespace = 'lib.views'
|
69
78
|
else
|
70
79
|
#default to unknown args and views path with css
|
71
80
|
@args = '/* args */'
|
72
81
|
@js_path = @js_views_path
|
73
82
|
@js_req = 'views'
|
83
|
+
namespace = 'lib'
|
74
84
|
end
|
75
85
|
|
76
86
|
end
|
77
87
|
|
78
88
|
# expand the template to <destination>
|
79
89
|
def copy_class_template
|
90
|
+
@path_to_object = namespace
|
80
91
|
if @is_application
|
81
92
|
# a more definitive indicator
|
82
93
|
js_path = @js_app_path
|
83
94
|
css_path = @css_app_path
|
84
|
-
@path_to_object = namespace
|
85
95
|
else
|
86
96
|
# the user passed option takes precedence
|
87
97
|
js_path = "#{@js_dir || @js_path}/#{@c_name}"
|
88
98
|
css_path = "#{@css_views_path}/#{@c_name}"
|
89
|
-
@path_to_object = [namespace, '.', @c_camel].join('')
|
90
99
|
# make sure the directory is present (create if not)
|
91
100
|
unless skip_css?
|
92
101
|
ensure_cname_dir(js_path, css_path)
|
@@ -147,7 +156,7 @@ module Sudojs
|
|
147
156
|
end
|
148
157
|
|
149
158
|
def modify_view_if_exists
|
150
|
-
filename = "app/views/#{@c_name}/#{@a_name}
|
159
|
+
filename = "app/views/#{@c_name}/#{@a_name}#{html_extension}"
|
151
160
|
if File.exist? filename
|
152
161
|
# TODO other pre-processors may need entries here
|
153
162
|
if js_extension == '.js.coffee'
|
@@ -2,17 +2,16 @@ Description:
|
|
2
2
|
Install sudo.js along with it's particular directory hierarchy.
|
3
3
|
|
4
4
|
Example:
|
5
|
-
rails g sudojs:install
|
5
|
+
rails g sudojs:install [html_extension] [js_extension] [css_extension] [--skip-css=true/false]
|
6
6
|
|
7
|
-
|
7
|
+
Two namespaces, 'page' and 'lib', will be automagically created. The 'models' and 'templates'
|
8
|
+
Containers will be appended to the page namespace, and 'lib' is used to house Class definitions
|
9
|
+
by convention.
|
8
10
|
|
9
|
-
The install generator uses these
|
10
|
-
1. `
|
11
|
-
|
12
|
-
|
13
|
-
2. `html_extension` => Use the full extension, i.e. `.haml`. defaults to `.erb`.
|
14
|
-
3. `js_extension` => defaults to `.js` pass `.js.coffee` if you are of the coffee persuasion.
|
15
|
-
4. `css_extension` => defaults to `.css`. Sass for example would need `.css.scss`
|
11
|
+
The install generator uses these options to expand the values in the sudo_js.yml file:
|
12
|
+
1. `--html_extension` => Use the full extension, i.e. `--html_extension=.haml`. Defaults to `.erb`.
|
13
|
+
2. `--js_extension` => Defaults to `.js` pass `--js_extension=.coffee` if you are of the coffee persuasion.
|
14
|
+
3. `--css_extension` => Defaults to `.css`. For Sass you would pass `-css_extension=.scss`
|
16
15
|
|
17
16
|
NOTE: to skip any and all generating of css files pass the option `--skip-css=true` when invoking the install generator.
|
18
17
|
Obviously, you could then leave the `css_extension` argument out. The option defaults to false.
|
@@ -30,6 +29,6 @@ Example:
|
|
30
29
|
base.*
|
31
30
|
views/
|
32
31
|
application/
|
33
|
-
|
32
|
+
page.*
|
34
33
|
config/
|
35
34
|
sudo_js.yml
|
@@ -1,14 +1,17 @@
|
|
1
1
|
module Sudojs
|
2
2
|
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
argument :js_extension_arg, :type => :string, :default => '.js'
|
9
|
-
argument :css_extension_arg, :type => :string, :default => '.css'
|
6
|
+
class_option :html_extension, :type => :string, :aliases => '--html_extension', :default => '.erb',
|
7
|
+
:desc => 'Which html extension to use'
|
10
8
|
|
11
|
-
class_option :
|
9
|
+
class_option :js_extension, :type => :string, :default => '.js', :aliases => '--js_extension',
|
10
|
+
:desc => 'Which js extension to use'
|
11
|
+
|
12
|
+
class_option :css_extension, :type => :string, :default => '.css', :aliases => '--css_extension',
|
13
|
+
:desc => 'Which css extension to use'
|
14
|
+
class_option :skip_css, :type => :boolean, :aliases => '--skip-css', :default => false,
|
12
15
|
:desc => 'Skip the generation of any css files along with js'
|
13
16
|
|
14
17
|
def create_yaml
|
@@ -40,19 +43,17 @@ module Sudojs
|
|
40
43
|
end
|
41
44
|
|
42
45
|
def place_install_files
|
43
|
-
|
46
|
+
copy_file 'app_manifest.js', 'app/assets/javascripts/manifests/application.js'
|
44
47
|
unless options[:skip_css]
|
45
|
-
|
48
|
+
copy_file 'app_manifest.css', 'app/assets/stylesheets/manifests/application.css'
|
46
49
|
end
|
47
50
|
|
48
51
|
# TODO templates for other javascript pre-processors
|
49
|
-
if
|
50
|
-
|
51
|
-
template 'model.coffee.erb', 'app/assets/javascripts/models/base.js.coffee'
|
52
|
+
if options[:js_extension] == '.coffee'
|
53
|
+
copy_file 'namespace.coffee', "app/assets/javascripts/views/application/page.js.coffee"
|
52
54
|
else
|
53
55
|
# for now any other js flavor gets the baseline .js
|
54
|
-
|
55
|
-
template 'model.js.erb', "app/assets/javascripts/models/base#{js_extension_arg}"
|
56
|
+
copy_file 'namespace.js', "app/assets/javascripts/views/application/page.js#{options[:js_extension] if options[:js_extension] != '.js'}"
|
56
57
|
end
|
57
58
|
|
58
59
|
end
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
2
|
// listed below.
|
3
3
|
//
|
4
|
-
//= require sudojs
|
5
|
-
//= require
|
6
|
-
//= require
|
4
|
+
//= require sudojs/zepto
|
5
|
+
//= require sudojs/sudo
|
6
|
+
//= require views/application/page
|
@@ -1,17 +1,11 @@
|
|
1
|
-
# What is the applications top level namespace?
|
2
|
-
js_namespace: <%= name %>
|
3
|
-
|
4
|
-
# sudo.js with templating or without?
|
5
|
-
which_sudo: <%= which_sudo_arg %>
|
6
|
-
|
7
1
|
# erb or haml or ...?
|
8
|
-
html_extension: <%=
|
2
|
+
html_extension: .html<%= options[:html_extension] if options[:html_extension] != '.html' %>
|
9
3
|
|
10
|
-
# coffee
|
11
|
-
js_extension: <%=
|
4
|
+
# coffee/...?
|
5
|
+
js_extension: .js<%= options[:js_extension] if options[:js_extension] != '.js'%>
|
12
6
|
|
13
7
|
# create (S)css files too?
|
14
8
|
skip_css: <%= @skip_css %>
|
15
9
|
|
16
|
-
# sass
|
17
|
-
css_extension: <%=
|
10
|
+
# sass/less/...?
|
11
|
+
css_extension: .css<%= options[:css_extension] if options[:css_extension] != '.css'%>
|
data/lib/sudojs/version.rb
CHANGED
data/sudojs-rails.gemspec
CHANGED
@@ -339,13 +339,18 @@ sudo.Model.prototype.unsets = function unsets(ary) {
|
|
339
339
|
// ##Container Class Object
|
340
340
|
//
|
341
341
|
// A container is any object that can both contain other objects and
|
342
|
-
// itself be contained
|
342
|
+
// itself be contained.
|
343
|
+
//
|
344
|
+
// `param` {Array|Object} 'arg'. Optional array or hash
|
345
|
+
// of child objects which the Container will add as child objects
|
346
|
+
// via `addChildren`
|
343
347
|
//
|
344
348
|
// `constructor`
|
345
|
-
sudo.Container = function() {
|
349
|
+
sudo.Container = function(arg) {
|
346
350
|
sudo.Base.call(this);
|
347
351
|
this.children = [];
|
348
352
|
this.childNames = {};
|
353
|
+
if(arg) this.addChildren(arg);
|
349
354
|
};
|
350
355
|
// Container is a subclass of sudo.Base
|
351
356
|
sudo.inherit(sudo.Base, sudo.Container);
|
@@ -369,6 +374,30 @@ sudo.Container.prototype.addChild = function addChild(child, name) {
|
|
369
374
|
if('addedToParent' in child) child.addedToParent(this);
|
370
375
|
return this;
|
371
376
|
};
|
377
|
+
// ###addChildren
|
378
|
+
// Allows for multiple children to be added to this Container by passing
|
379
|
+
// either an Array or an Object literal.
|
380
|
+
//
|
381
|
+
// see `addChild`
|
382
|
+
//
|
383
|
+
// `param` {Array|Object} `arg`. An array of children to add or an
|
384
|
+
// Object literal in the form {name: child}
|
385
|
+
// `returns` {Object} `this`
|
386
|
+
sudo.Container.prototype.addChildren = function addChildren(arg) {
|
387
|
+
var i, keys;
|
388
|
+
// Array?
|
389
|
+
if(Array.isArray(arg)) {
|
390
|
+
for (i = 0; i < arg.length; i++) {
|
391
|
+
this.addChild(arg[i]);
|
392
|
+
}
|
393
|
+
} else {
|
394
|
+
keys = Object.keys(arg);
|
395
|
+
for (i = 0; i < keys.length; i++) {
|
396
|
+
this.addChild(arg[keys[i]] , keys[i]);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
return this;
|
400
|
+
};
|
372
401
|
// ###bubble
|
373
402
|
// By default, `bubble` returns the current view's parent (if it has one)
|
374
403
|
//
|
@@ -428,6 +457,8 @@ sudo.Container.prototype.removeChild = function removeChild(arg) {
|
|
428
457
|
// Remove all children, name references and adjust indexes accordingly.
|
429
458
|
// This method calls removeFromParent as each child may have overridden logic there.
|
430
459
|
//
|
460
|
+
// see `removeChild`
|
461
|
+
//
|
431
462
|
// `returns` {object} `this`
|
432
463
|
sudo.Container.prototype.removeChildren = function removeChildren() {
|
433
464
|
while(this.children.length) {
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sudojs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robrobbins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.6'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.6'
|
11
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Install the latest versions of sudo.js and provide generators for fast
|
28
14
|
and easy use.
|
29
15
|
email:
|
@@ -47,12 +33,10 @@ files:
|
|
47
33
|
- lib/generators/sudojs/helpers.rb
|
48
34
|
- lib/generators/sudojs/install/USAGE
|
49
35
|
- lib/generators/sudojs/install/install_generator.rb
|
50
|
-
- lib/generators/sudojs/install/templates/app_manifest.css
|
51
|
-
- lib/generators/sudojs/install/templates/app_manifest.js
|
52
|
-
- lib/generators/sudojs/install/templates/
|
53
|
-
- lib/generators/sudojs/install/templates/
|
54
|
-
- lib/generators/sudojs/install/templates/namespace.coffee.erb
|
55
|
-
- lib/generators/sudojs/install/templates/namespace.js.erb
|
36
|
+
- lib/generators/sudojs/install/templates/app_manifest.css
|
37
|
+
- lib/generators/sudojs/install/templates/app_manifest.js
|
38
|
+
- lib/generators/sudojs/install/templates/namespace.coffee
|
39
|
+
- lib/generators/sudojs/install/templates/namespace.js
|
56
40
|
- lib/generators/sudojs/install/templates/sudo_js.erb.yml
|
57
41
|
- lib/sudojs-rails.rb
|
58
42
|
- lib/sudojs/engine.rb
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# Define the top-level app namespace as defined in the sudo_js yaml file.
|
2
|
-
|
3
|
-
# The `descriptors` array is a global necessity that solves the issue of
|
4
|
-
# child objects being parsed on a _partial before their parent ViewControllers
|
5
|
-
# (who are declared on a containing view file)
|
6
|
-
window.<%= name %> =
|
7
|
-
descriptors: []
|
8
|
-
|
@@ -1,8 +0,0 @@
|
|
1
|
-
// Define the top-level app namespace as defined in the sudo_js yaml file.
|
2
|
-
|
3
|
-
// The `descriptors` array is a global necessity that solves the issue of
|
4
|
-
// child objects being parsed on a _partial before their parent ViewControllers
|
5
|
-
// (who are declared on a containing view file)
|
6
|
-
window.<%= name %> = {
|
7
|
-
descriptors: []
|
8
|
-
};
|