backbone_generator 0.0.3 → 0.0.4
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/.gitignore +1 -0
- data/.rspec +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +10 -7
- data/backbone_generator.gemspec +9 -15
- data/bin/backbone_generator +6 -0
- data/lib/backbone_generator.rb +13 -1
- data/lib/backbone_generator/auxilliary.rb +44 -0
- data/lib/backbone_generator/cli.rb +79 -0
- data/lib/backbone_generator/generators/collections/collections_generator.rb +35 -0
- data/lib/backbone_generator/generators/collections/template/Collection.tt +29 -0
- data/lib/backbone_generator/generators/library/library_generator.rb +17 -0
- data/lib/backbone_generator/generators/models/models_generator.rb +35 -0
- data/lib/backbone_generator/generators/models/template/Model.tt +44 -0
- data/lib/backbone_generator/generators/new/new_generator.rb +89 -0
- data/lib/backbone_generator/generators/new/template/.gitignore +1 -0
- data/lib/backbone_generator/generators/new/template/README.tt +9 -0
- data/lib/backbone_generator/generators/new/template/css/main.css +43 -0
- data/lib/backbone_generator/generators/new/template/img/backbone.png +0 -0
- data/lib/backbone_generator/generators/new/template/index.html +15 -0
- data/lib/backbone_generator/generators/new/template/js/libs/backbone/backbone-1.1.0.js +1498 -0
- data/lib/backbone_generator/generators/new/template/js/libs/jquery/jquery-2.0.3.min.js +6 -0
- data/lib/backbone_generator/generators/new/template/js/libs/requirejs-text/text-2.0.10.js +332 -0
- data/lib/backbone_generator/generators/new/template/js/libs/requirejs/require-2.1.9.js +2019 -0
- data/lib/backbone_generator/generators/new/template/js/libs/underscore/underscore-1.5.2.js +1226 -0
- data/lib/backbone_generator/generators/new/template/js/views/Main.View.tt +39 -0
- data/lib/backbone_generator/generators/new/template/main.tt +45 -0
- data/lib/backbone_generator/generators/route/route_generator.rb +36 -0
- data/lib/backbone_generator/generators/route/template/Routes.tt +27 -0
- data/lib/backbone_generator/generators/templates/template/Template.tt +10 -0
- data/lib/backbone_generator/generators/templates/templates_generator.rb +35 -0
- data/lib/backbone_generator/generators/tests/template/mainview.js +48 -0
- data/lib/backbone_generator/generators/tests/tests_generator.rb +17 -0
- data/lib/backbone_generator/generators/utilities/template/Utility.tt +28 -0
- data/lib/backbone_generator/generators/utilities/utilities_generator.rb +35 -0
- data/lib/backbone_generator/generators/views/template/View.tt +50 -0
- data/lib/backbone_generator/generators/views/views_generator.rb +36 -0
- data/lib/backbone_generator/post_install_message.rb +21 -0
- data/lib/backbone_generator/version.rb +1 -1
- data/spec/backbone_generator/post_install_message.rb +20 -0
- data/spec/backbone_generator/version.rb +3 -0
- data/spec/backbone_generator_spec.rb +5 -0
- data/spec/cli_spec.rb +34 -0
- data/spec/post_install_message_spec.rb +6 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/version_spec.rb +5 -0
- metadata +105 -21
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* TODO: add description of class
|
3
|
+
* @author: <%= config[:author] %>
|
4
|
+
* @class: MainView
|
5
|
+
* */
|
6
|
+
|
7
|
+
/* global define */
|
8
|
+
var <%= config[:app_name] %> = <%= config[:app_name] %> || {};
|
9
|
+
|
10
|
+
(function() {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
define([
|
14
|
+
'jquery',
|
15
|
+
'underscore',
|
16
|
+
'backbone',
|
17
|
+
'views/Hello.View',
|
18
|
+
], function($, _, Backbone) {
|
19
|
+
|
20
|
+
<%= config[:app_name] %>.MainView = Backbone.View.extend({
|
21
|
+
|
22
|
+
//TODO: Put all event listener code here
|
23
|
+
events: {
|
24
|
+
},
|
25
|
+
|
26
|
+
//TODO: Put all initialization code here
|
27
|
+
initialize: function() {
|
28
|
+
this.helloView = new <%= config[:app_name] %>.HelloView();
|
29
|
+
},
|
30
|
+
|
31
|
+
//TODO: Put all render logic here
|
32
|
+
render: function() {
|
33
|
+
},
|
34
|
+
|
35
|
+
});
|
36
|
+
|
37
|
+
return <%= config[:app_name] %>.MainView;
|
38
|
+
});
|
39
|
+
}());
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* TODO: add description of class
|
3
|
+
* @author: <%= config[:author] %>
|
4
|
+
* @class: main.js
|
5
|
+
* */
|
6
|
+
|
7
|
+
/* global require */
|
8
|
+
(function() {
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
require.config({
|
12
|
+
shim: {
|
13
|
+
underscore: {
|
14
|
+
exports: '_'
|
15
|
+
},
|
16
|
+
backbone: {
|
17
|
+
deps: ['underscore', 'jquery'],
|
18
|
+
exports: 'Backbone'
|
19
|
+
}
|
20
|
+
},
|
21
|
+
paths: {
|
22
|
+
jquery: 'libs/jquery/jquery-2.0.3.min',
|
23
|
+
underscore: 'libs/underscore/underscore-1.5.2',
|
24
|
+
backbone: 'libs/backbone/backbone-1.1.0',
|
25
|
+
text: 'libs/requirejs-text/text-2.0.10'
|
26
|
+
},
|
27
|
+
urlArgs : "v=2"
|
28
|
+
|
29
|
+
});
|
30
|
+
|
31
|
+
require([
|
32
|
+
'backbone',
|
33
|
+
'views/Main.View',
|
34
|
+
'routes/<%= config[:app_name] %>.Route',
|
35
|
+
], function (Backbone, <%= config[:app_name] %>MainView, <%= config[:app_name] %>Routes) {
|
36
|
+
/*jshint nonew:false*/
|
37
|
+
|
38
|
+
// Initialize routing and start Backbone.history()
|
39
|
+
new <%= config[:app_name] %>Routes();
|
40
|
+
Backbone.history.start();
|
41
|
+
|
42
|
+
// Initialize the main application view
|
43
|
+
new <%= config[:app_name] %>MainView();
|
44
|
+
});
|
45
|
+
}());
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Namespace for all the classess
|
2
|
+
# @since 0.0.3
|
3
|
+
module BackboneGenerator
|
4
|
+
|
5
|
+
# Abstract base class for generating
|
6
|
+
# routes A.K.A copying template
|
7
|
+
# @author Tawheed Abdul-Raheem
|
8
|
+
class RouteGenerator
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create_route route_name
|
12
|
+
app_name = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/")
|
13
|
+
if BackboneGenerator.option_details[:app_name]
|
14
|
+
dir_path = File.join(Dir.getwd, app_name)
|
15
|
+
else
|
16
|
+
dir_path = File.join(Dir.getwd)
|
17
|
+
end
|
18
|
+
template_path = File.expand_path(File.dirname(__FILE__)) + "/template/Routes.tt"
|
19
|
+
target_path = "/js/routes/" + route_name + ".Route.js"
|
20
|
+
route_hash = {
|
21
|
+
:app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
|
22
|
+
:route_name => route_name.slice(0,1).capitalize + route_name.slice(1..-1),
|
23
|
+
}
|
24
|
+
|
25
|
+
if File.exists? dir_path + target_path
|
26
|
+
print "error ".red
|
27
|
+
puts "Route with the name specified already exists"
|
28
|
+
else
|
29
|
+
BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, route_hash)
|
30
|
+
print "created ".green
|
31
|
+
puts route_hash[:app_name] + target_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* TODO: add description of class
|
3
|
+
* @author:
|
4
|
+
* @class: <%= config[:route_name] %>Route
|
5
|
+
* */
|
6
|
+
|
7
|
+
/* global define */
|
8
|
+
var <%= config[:app_name] %> = <%= config[:app_name] %> || {};
|
9
|
+
|
10
|
+
/* global define */
|
11
|
+
(function() {
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
define([
|
15
|
+
'jquery',
|
16
|
+
'underscore',
|
17
|
+
'backbone',
|
18
|
+
], function($, _, Backbone) {
|
19
|
+
|
20
|
+
<%= config[:app_name] %>.<%= config[:route_name]%>Route = Backbone.Router.extend({
|
21
|
+
|
22
|
+
//TODO: Define all your routes here
|
23
|
+
});
|
24
|
+
|
25
|
+
return <%= config[:app_name] %>.<%= config[:route_name] %>Route;
|
26
|
+
});
|
27
|
+
}());
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1>Aloha! fellow javascripters</h1>
|
2
|
+
|
3
|
+
<p>This app was generated with the <code>backbone_generator</code> gem</p>
|
4
|
+
<p>This view was dynamically inserted into the DOM using the awesomeness of
|
5
|
+
<code>backbone.js</code></p> I think its really cool that you are writting
|
6
|
+
javascript code that is maintainable. This view is located in <code>js/templates/Hello.Template.html</code>
|
7
|
+
|
8
|
+
<h2>Getting started</h2>
|
9
|
+
<p>Please view this <a href="http://tawrahim.github.io/backbone_generator_web">tutorial</a> on how to get started. If you like the project, please star it on <a href="https://github.com/tawrahim/backbone_generator">Github</a> so that other awesomene people like you can also find it.</p>
|
10
|
+
<p>Thanks <a href="http://github.com/tawrahim">Tawheed</a>!</p>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Namespace for all the classess
|
2
|
+
# @since 0.0.3
|
3
|
+
module BackboneGenerator
|
4
|
+
|
5
|
+
# Abstract base class for generating
|
6
|
+
# utility A.K.A copying template
|
7
|
+
# @author Tawheed Abdul-Raheem
|
8
|
+
class TemplateGenerator
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create_template template_name
|
12
|
+
app_name = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/")
|
13
|
+
if BackboneGenerator.option_details[:app_name]
|
14
|
+
dir_path = File.join(Dir.getwd, app_name)
|
15
|
+
else
|
16
|
+
dir_path = File.join(Dir.getwd)
|
17
|
+
end
|
18
|
+
template_path = File.expand_path(File.dirname(__FILE__)) + "/template/Template.tt"
|
19
|
+
target_path = "/js/templates/" + template_name.capitalize + ".Template.html"
|
20
|
+
template_hash = {
|
21
|
+
:app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
|
22
|
+
:template_name => template_name.slice(0,1).capitalize + template_name.slice(1..-1),
|
23
|
+
}
|
24
|
+
if File.exist? dir_path + target_path
|
25
|
+
print "error ".red
|
26
|
+
puts "View with the name specified already exists"
|
27
|
+
else
|
28
|
+
BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, template_hash)
|
29
|
+
print "created ".green
|
30
|
+
puts template_hash[:app_name] + target_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* This file is responsible for rendering
|
3
|
+
* all the ports on the system
|
4
|
+
* @author: Tawheed Abdul-Raheem
|
5
|
+
* @class: SANBLaze.PortView
|
6
|
+
*
|
7
|
+
**/
|
8
|
+
|
9
|
+
/* global define */
|
10
|
+
var SANBLaze = SANBLaze || {};
|
11
|
+
|
12
|
+
(function() {
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
define([
|
16
|
+
'jquery',
|
17
|
+
'underscore',
|
18
|
+
'backbone',
|
19
|
+
'views/Port.View',
|
20
|
+
], function($, _, Backbone) {
|
21
|
+
|
22
|
+
SANBLaze.AllPortsView = Backbone.View.extend({
|
23
|
+
|
24
|
+
// Instead of generating a new element, bind to the
|
25
|
+
// the existing element present in the HTML
|
26
|
+
el: '.nav',
|
27
|
+
|
28
|
+
// Initialization
|
29
|
+
initialize: function() {
|
30
|
+
this.collection = SANBLaze.PortView();
|
31
|
+
},
|
32
|
+
|
33
|
+
// Rendering the app
|
34
|
+
render: function() {
|
35
|
+
this.renderPort();
|
36
|
+
},
|
37
|
+
|
38
|
+
// Render a port by creating a PortView and appending
|
39
|
+
// the element it renders
|
40
|
+
renderPort: function() {
|
41
|
+
var portView = new SANBLaze.PortView();
|
42
|
+
this.$el.append(portView.render().el);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
return SANBLaze.AllPortsView;
|
47
|
+
});
|
48
|
+
}());
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Namespace for all the classess
|
2
|
+
# @since 0.0.3
|
3
|
+
module BackboneGenerator
|
4
|
+
|
5
|
+
# Abstract base class for generating
|
6
|
+
# tests A.K.A copying template
|
7
|
+
# @author Tawheed Abdul-Raheem
|
8
|
+
class TestGenerator
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create_test test_name
|
12
|
+
print "NOTICE ".yellow
|
13
|
+
puts "Will be implemented in the next Release"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* TODO: add description of class
|
3
|
+
* @author:
|
4
|
+
* @class: <%= config[:utility_name] %>Utility
|
5
|
+
* */
|
6
|
+
|
7
|
+
/* global define */
|
8
|
+
var <%= config[:app_name] %> = <%= config[:app_name] %> || {};
|
9
|
+
|
10
|
+
(function() {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
define([
|
14
|
+
'jquery',
|
15
|
+
'underscore',
|
16
|
+
], function($, _) {
|
17
|
+
|
18
|
+
<%= config[:app_name] %>.<%= config[:utility_name] %>Utility = {
|
19
|
+
|
20
|
+
//TODO: Define all your utility methods here
|
21
|
+
sayHello: function() {
|
22
|
+
console.log('Hello from the main utility');
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
return <%= config[:app_name] %>.<%= config[:utility_name] %>Utility;
|
27
|
+
});
|
28
|
+
}());
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Namespace for all the classess
|
2
|
+
# @since 0.0.3
|
3
|
+
module BackboneGenerator
|
4
|
+
|
5
|
+
# Abstract base class for generating
|
6
|
+
# utility A.K.A copying template
|
7
|
+
# @author Tawheed Abdul-Raheem
|
8
|
+
class UtilityGenerator
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create_utility utility_name
|
12
|
+
app_name = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/")
|
13
|
+
if BackboneGenerator.option_details[:app_name]
|
14
|
+
dir_path = File.join(Dir.getwd, app_name)
|
15
|
+
else
|
16
|
+
dir_path = File.join(Dir.getwd)
|
17
|
+
end
|
18
|
+
utility_hash = {
|
19
|
+
:app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
|
20
|
+
:utility_name => utility_name.slice(0,1).capitalize + utility_name.slice(1..-1),
|
21
|
+
}
|
22
|
+
template_path = File.expand_path(File.dirname(__FILE__)) + "/template/Utility.tt"
|
23
|
+
target_path = "/js/utilities/" + utility_hash[:app_name] + "." + utility_name + "Utility.js"
|
24
|
+
if File.exist? dir_path + target_path
|
25
|
+
print "error ".red
|
26
|
+
puts "Utility with the name specified already exists"
|
27
|
+
else
|
28
|
+
BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, utility_hash)
|
29
|
+
print "created ".green
|
30
|
+
puts utility_hash[:app_name] + target_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/**
|
2
|
+
* TODO: add description of class
|
3
|
+
* @author:
|
4
|
+
* @class: <%= config[:view_name] %>.js
|
5
|
+
* */
|
6
|
+
|
7
|
+
/* global define */
|
8
|
+
var <%= config[:app_name] %> = <%= config[:app_name] %> || {};
|
9
|
+
|
10
|
+
(function() {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
define([
|
14
|
+
'jquery',
|
15
|
+
'underscore',
|
16
|
+
'backbone',
|
17
|
+
'text!templates/<%= config[:view_name] %>.Template.html',
|
18
|
+
], function($, _, Backbone, <%= config[:view_name].downcase %>Template) {
|
19
|
+
|
20
|
+
<%= config[:app_name] %>.<%= config[:view_name] %>View = Backbone.View.extend({
|
21
|
+
|
22
|
+
//Declare a hash to hold your model data
|
23
|
+
model: {},
|
24
|
+
|
25
|
+
//TODO: Change the el tag to match your needs
|
26
|
+
el: "#hello_div",
|
27
|
+
|
28
|
+
template: _.template(<%= config[:view_name].downcase %>Template),
|
29
|
+
|
30
|
+
//TODO: Put all event listener code here
|
31
|
+
events: {
|
32
|
+
},
|
33
|
+
|
34
|
+
//TODO: Put all initialization code here
|
35
|
+
initialize: function() {
|
36
|
+
this.render();
|
37
|
+
},
|
38
|
+
|
39
|
+
//TODO: Put all render logic here
|
40
|
+
render: function() {
|
41
|
+
this.$el.html(this.template);
|
42
|
+
return this;
|
43
|
+
},
|
44
|
+
|
45
|
+
|
46
|
+
});
|
47
|
+
|
48
|
+
return <%= config[:app_name] %>.<%= config[:view_name] %>View;
|
49
|
+
});
|
50
|
+
}());
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Namespace for all the classess
|
2
|
+
# @since 0.0.3
|
3
|
+
module BackboneGenerator
|
4
|
+
|
5
|
+
# Abstract base class for generating
|
6
|
+
# views A.K.A copying template
|
7
|
+
# @author Tawheed Abdul-Raheem
|
8
|
+
class ViewGenerator
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create_view view_name
|
12
|
+
app_name = BackboneGenerator.option_details[:app_name] || File.basename(Dir.getwd).chomp("/")
|
13
|
+
if BackboneGenerator.option_details[:app_name]
|
14
|
+
dir_path = File.join(Dir.getwd, app_name)
|
15
|
+
else
|
16
|
+
dir_path = File.join(Dir.getwd)
|
17
|
+
end
|
18
|
+
template_path = File.expand_path(File.dirname(__FILE__)) + "/template/View.tt"
|
19
|
+
target_path = "/js/views/" + view_name.capitalize + ".View.js"
|
20
|
+
view_hash = {
|
21
|
+
:app_name => app_name.slice(0,1).capitalize + app_name.slice(1..-1),
|
22
|
+
:view_name => view_name.slice(0,1).capitalize + view_name.slice(1..-1),
|
23
|
+
}
|
24
|
+
if File.exist? dir_path + target_path
|
25
|
+
print "error ".red
|
26
|
+
puts "View with the name specified already exists"
|
27
|
+
else
|
28
|
+
BackboneGenerator.compile_and_copy(template_path, dir_path + target_path, view_hash)
|
29
|
+
print "created ".green
|
30
|
+
puts view_hash[:app_name] + target_path
|
31
|
+
BackboneGenerator::TemplateGenerator.create_template(view_name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BackboneGenerator
|
2
|
+
class << self
|
3
|
+
def post_install_message
|
4
|
+
footer = <<'EOS'
|
5
|
+
|
6
|
+
======== Release notes for BackboneGenerator ===========
|
7
|
+
|
8
|
+
Thank you very much for downloading the backbone_generator
|
9
|
+
gem. I would like to hear your feedback on possible bugs
|
10
|
+
and also potential features that you would like to see in
|
11
|
+
the next release!
|
12
|
+
|
13
|
+
Happy Coding :-)
|
14
|
+
- Tawheed
|
15
|
+
|
16
|
+
==========================================================
|
17
|
+
|
18
|
+
EOS
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|