marionette_dust 0.0.2 → 0.0.3
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/README.md +24 -5
- data/Rakefile +9 -2
- data/lib/dust_engine/dust.rb +4 -4
- data/lib/generators/{marionette_dust → md}/common/templates/app.js +5 -2
- data/lib/generators/md/common/templates/app.js.coffee +8 -0
- data/lib/generators/{marionette_dust → md}/common/templates/controller.js +0 -0
- data/lib/generators/md/common/templates/controller.js.coffee +2 -0
- data/lib/generators/{marionette_dust → md}/common/templates/entity.js +0 -0
- data/lib/generators/md/common/templates/entity.js.coffee +7 -0
- data/lib/generators/{marionette_dust → md}/common/templates/template.jst.dust +0 -0
- data/lib/generators/{marionette_dust → md}/common/templates/view.js +0 -0
- data/lib/generators/md/common/templates/view.js.coffee +3 -0
- data/lib/generators/{marionette_dust → md}/helpers.rb +0 -0
- data/lib/generators/{marionette_dust → md}/install/install_generator.rb +2 -2
- data/lib/generators/{marionette_dust → md}/install/templates/app.js +5 -0
- data/lib/generators/{marionette_dust → md}/install/templates/app.js.coffee +0 -0
- data/lib/generators/{marionette_dust → md}/scaffold/scaffold_generator.rb +5 -5
- data/lib/generators/{marionette_dust → md}/submodule/submodule_generator.rb +4 -5
- data/lib/marionette_dust/version.rb +1 -1
- data/marionette_dust.gemspec +1 -0
- data/test/lib/generators/marionette_dust/install/install_generator_test.rb +47 -0
- data/test/lib/generators/marionette_dust/install/templates/app/assets/javascripts/app.js +25 -0
- data/test/lib/generators/marionette_dust/install/templates/app/assets/javascripts/app.js.coffee +16 -0
- data/test/lib/generators/marionette_dust/install/templates/app/assets/javascripts/application.js +5 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/scaffold_generator_test.rb +36 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/submodule_generator_test.rb +28 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/app.js +25 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/app.js.coffee +16 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/application.js +5 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/foo/bar/bar_controller.js +3 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/foo/bar/bar_controller.js.coffee +2 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/foo/bar/bar_view.js +5 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/foo/bar/bar_view.js.coffee +3 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/test/test_app.js +13 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/apps/test/test_app.js.coffee +8 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/entities/test.js +9 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/javascripts/entities/test.js.coffee +7 -0
- data/test/lib/generators/marionette_dust/scaffold_and_submodule/templates/app/assets/templates/foo/bar/bar.jst.dust +1 -0
- data/test/test_helper.rb +23 -0
- data/vendor/assets/javascripts/marionette_dust/{dust-full-2.1.0.js → dust-full-2.2.2.js} +742 -673
- data/vendor/assets/javascripts/marionette_dust/index.js +1 -1
- metadata +57 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7b327b6b68458d0476694b8417306ac159c29fd
|
4
|
+
data.tar.gz: b635707c5699b47414ff67bf85569a3ee9f06763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc88109dcbc9b9baef2eab4ecad52d1b346bc45b25a638ed232ef5f2feefbaa4713f3219282f40a1dfd53bd9af03490394a086e9f8689c1569c964d54e6000b6
|
7
|
+
data.tar.gz: 2cbc754b5333c6e7db22330bbc6da98d6905890d74551bb911666a55e1ba904da9f59cb4fb2f3cb5b925ee46b6f824a6395a7ad3e5854f18b48719d76911c962
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Installation
|
|
12
12
|
-------
|
13
13
|
|
14
14
|
|
15
|
-
Add marionette_dust
|
15
|
+
Add marionette_dust to your gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
gem 'marionette_dust'
|
@@ -26,7 +26,7 @@ $ bundle install
|
|
26
26
|
Initialize your app with:
|
27
27
|
|
28
28
|
```
|
29
|
-
$ rails generate
|
29
|
+
$ rails generate md:install
|
30
30
|
```
|
31
31
|
|
32
32
|
This adds `//= require marionette_dust` in your application.js manifest and generates the basic scaffold for your marionette application:
|
@@ -40,16 +40,18 @@ app/
|
|
40
40
|
└── app.js
|
41
41
|
```
|
42
42
|
|
43
|
+
You can past an optional argument ( -c ) if you want coffeescript files.
|
44
|
+
|
43
45
|
Generators
|
44
46
|
-------
|
45
|
-
All generators are based on [marionette modules][3], the original idea is described in the
|
47
|
+
All generators are based on [marionette modules][3], the original idea is described in the excellent book [Backbone.Marionette.js: A Gentle Introduction][4], and the all credits go to [BackboneRails.com][5]
|
46
48
|
|
47
49
|
- **Scaffold**
|
48
50
|
|
49
51
|
Generates a scaffold for a sub-app, under apps folder, running:
|
50
52
|
|
51
53
|
```
|
52
|
-
$ rails generate
|
54
|
+
$ rails generate md:scaffold Foo [-c]
|
53
55
|
```
|
54
56
|
|
55
57
|
will generate:
|
@@ -69,7 +71,7 @@ app/
|
|
69
71
|
Generates a submodule under an existent app (previously generated with the Scaffold generator), running:
|
70
72
|
|
71
73
|
```
|
72
|
-
$ rails generate
|
74
|
+
$ rails generate md:submodule bar --parent foo [-c]
|
73
75
|
```
|
74
76
|
|
75
77
|
will generate:
|
@@ -91,6 +93,19 @@ app/
|
|
91
93
|
└── bar.jst.dust
|
92
94
|
```
|
93
95
|
|
96
|
+
About
|
97
|
+
-------
|
98
|
+
This version includes:
|
99
|
+
|
100
|
+
* Marionette.js v1.2.2
|
101
|
+
* Dust.js v2.2.2
|
102
|
+
|
103
|
+
Also this project is inspired by:
|
104
|
+
|
105
|
+
[Backbone on rails][7] and [Dust assets][6]
|
106
|
+
|
107
|
+
|
108
|
+
|
94
109
|
Contributing
|
95
110
|
-------
|
96
111
|
|
@@ -100,11 +115,15 @@ Contributing
|
|
100
115
|
4. Push to the branch (`git push origin my-new-feature`)
|
101
116
|
5. Create new Pull Request
|
102
117
|
|
118
|
+
[](http://githalytics.com/RobertoDip/marionette_dust-rails)
|
119
|
+
|
103
120
|
[1]: http://marionettejs.com/
|
104
121
|
[2]: http://linkedin.github.io/dustjs/
|
105
122
|
[3]: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.application.module.md
|
106
123
|
[4]: https://leanpub.com/marionette-gentle-introduction
|
107
124
|
[5]: http://www.backbonerails.com/
|
125
|
+
[6]: https://github.com/hasmanydevelopers/dust_assets
|
126
|
+
[7]: https://github.com/meleyal/backbone-on-rails
|
108
127
|
|
109
128
|
[Build Status]: https://travis-ci.org/RobertoDip/marionette_dust-rails
|
110
129
|
[Code Climate]: https://codeclimate.com/github/RobertoDip/marionette_dust-rails
|
data/Rakefile
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.libs << 'test'
|
7
|
+
t.pattern = 'test/**/*_test.rb'
|
8
|
+
t.verbose = true
|
5
9
|
end
|
10
|
+
|
11
|
+
desc "Run tests"
|
12
|
+
task :default => :test
|
data/lib/dust_engine/dust.rb
CHANGED
@@ -4,8 +4,8 @@ require 'pathname'
|
|
4
4
|
module MarionetteDust
|
5
5
|
class Dust
|
6
6
|
class << self
|
7
|
-
def precompile(
|
8
|
-
context.call('dust.compile',
|
7
|
+
def precompile(src, name)
|
8
|
+
context.call('dust.compile', src, name)
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -15,11 +15,11 @@ module MarionetteDust
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def source
|
18
|
-
@source ||= path.read
|
18
|
+
@source ||= open(path).read
|
19
19
|
end
|
20
20
|
|
21
21
|
def path
|
22
|
-
@path ||= assets_path.join('dust-full-2.
|
22
|
+
@path ||= assets_path.join('dust-full-2.2.2.js')
|
23
23
|
end
|
24
24
|
|
25
25
|
def assets_path
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= app_name %>.module "<%= sub_app_name %>", (<%= sub_app_name %>, <%= app_name %>, Backbone, Marionette, $, _) ->
|
2
|
+
|
3
|
+
<%= sub_app_name %>.Router = Marionette.AppRouter.extend(appRoutes: {})
|
4
|
+
|
5
|
+
API = {}
|
6
|
+
|
7
|
+
<%= sub_app_name %>.addInitializer ->
|
8
|
+
router = new <%= sub_app_name %>.Router(controller: API)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'generators/
|
1
|
+
require 'generators/md/helpers'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Md
|
4
4
|
module Generators
|
5
5
|
class ScaffoldGenerator < Rails::Generators::NamedBase
|
6
6
|
include MarionetteDust::Generators::Helpers
|
@@ -22,8 +22,8 @@ module MarionetteDust
|
|
22
22
|
desc: ""
|
23
23
|
|
24
24
|
def parse_options
|
25
|
-
|
26
|
-
@ext =
|
25
|
+
coffee = options.coffeescript
|
26
|
+
@ext = coffee ? ".js.coffee" : ".js"
|
27
27
|
end
|
28
28
|
|
29
29
|
def create_marionette_entity
|
@@ -34,7 +34,7 @@ module MarionetteDust
|
|
34
34
|
def create_marionette_app
|
35
35
|
empty_directory File.join(apps_path, file_name.downcase)
|
36
36
|
file = File.join(apps_path, file_name.downcase, sub_app_file_name)
|
37
|
-
template "app
|
37
|
+
template "app#{@ext}", file
|
38
38
|
end
|
39
39
|
|
40
40
|
def create_subapp
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'generators/
|
1
|
+
require 'generators/md/helpers'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Md
|
4
4
|
module Generators
|
5
5
|
class SubmoduleGenerator < Rails::Generators::NamedBase
|
6
6
|
include MarionetteDust::Generators::Helpers
|
@@ -23,11 +23,10 @@ module MarionetteDust
|
|
23
23
|
desc: "Parent app (required)"
|
24
24
|
|
25
25
|
def parse_options
|
26
|
-
|
27
|
-
@ext =
|
26
|
+
coffee = options.coffeescript
|
27
|
+
@ext = coffee ? ".js.coffee" : ".js"
|
28
28
|
@parent_name = options.parent
|
29
29
|
@submodule_name = file_name
|
30
|
-
puts "#{@parent_name}"
|
31
30
|
end
|
32
31
|
|
33
32
|
def create_subapp
|
data/marionette_dust.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
22
|
spec.add_dependency 'rails', '>= 3.1'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class InstallGeneratorTest < Rails::Generators::TestCase
|
4
|
+
tests Md::Generators::InstallGenerator
|
5
|
+
destination File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
test "creates the folder structure" do
|
8
|
+
run_generator
|
9
|
+
|
10
|
+
assert_directory "app/assets/javascripts/entities"
|
11
|
+
assert_directory "app/assets/templates"
|
12
|
+
assert_directory "app/assets/javascripts/apps"
|
13
|
+
end
|
14
|
+
|
15
|
+
test "creates the default application file(javascript)" do
|
16
|
+
run_generator
|
17
|
+
|
18
|
+
assert_file "app/assets/javascripts/app.js"
|
19
|
+
end
|
20
|
+
|
21
|
+
test "creates the coffeescript application file if required" do
|
22
|
+
run_generator %w(-c)
|
23
|
+
|
24
|
+
assert_file "app/assets/javascripts/app.js.coffee"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "genereates the manifest(default)" do
|
28
|
+
run_generator
|
29
|
+
|
30
|
+
assert_file "app/assets/javascripts/application.js"
|
31
|
+
end
|
32
|
+
|
33
|
+
test "injects the required libraries(default)" do
|
34
|
+
run_generator
|
35
|
+
|
36
|
+
assert_file "app/assets/javascripts/application.js", /require marionette_dust/
|
37
|
+
assert_file "app/assets/javascripts/application.js", /require app/
|
38
|
+
end
|
39
|
+
|
40
|
+
test "injects the required paths(default)" do
|
41
|
+
run_generator
|
42
|
+
|
43
|
+
assert_file "app/assets/javascripts/application.js", /require_tree \.\/apps/
|
44
|
+
assert_file "app/assets/javascripts/application.js", /require_tree \.\/entities/
|
45
|
+
assert_file "app/assets/javascripts/application.js", /require_tree \.\.\/templates/
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
var Class = new Marionette.Application();
|
2
|
+
|
3
|
+
Class.addRegions({
|
4
|
+
//Add application regions here
|
5
|
+
});
|
6
|
+
|
7
|
+
//Navigate to specific route
|
8
|
+
Class.navigate = function (route, options) {
|
9
|
+
options || (options = {});
|
10
|
+
Backbone.history.navigate(route, options);
|
11
|
+
};
|
12
|
+
|
13
|
+
//Returns current route
|
14
|
+
Class.getCurrentRoute = function () {
|
15
|
+
return Backbone.history.fragment;
|
16
|
+
};
|
17
|
+
|
18
|
+
Class.on('initialize:after', function () {
|
19
|
+
//Things to do after app initialize
|
20
|
+
if (Backbone.history) {
|
21
|
+
Backbone.history.start({
|
22
|
+
pushState: true
|
23
|
+
});
|
24
|
+
}
|
25
|
+
});
|
data/test/lib/generators/marionette_dust/install/templates/app/assets/javascripts/app.js.coffee
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Class = new Marionette.Application()
|
2
|
+
|
3
|
+
#Add application regions here
|
4
|
+
Class.addRegions {}
|
5
|
+
|
6
|
+
#Navigate to specific route
|
7
|
+
Class.navigate = (route, options) ->
|
8
|
+
options or (options = {})
|
9
|
+
Backbone.history.navigate route, options
|
10
|
+
|
11
|
+
#Returns current route
|
12
|
+
Class.getCurrentRoute = ->
|
13
|
+
Backbone.history.fragment
|
14
|
+
|
15
|
+
Class.on "initialize:after", ->
|
16
|
+
#Things to do after app initialize
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
4
|
+
tests Md::Generators::ScaffoldGenerator
|
5
|
+
destination File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
test "creates the folder structure" do
|
8
|
+
run_generator %w(test)
|
9
|
+
|
10
|
+
assert_directory "app/assets/javascripts/apps/test"
|
11
|
+
end
|
12
|
+
|
13
|
+
test "creates the sub application file" do
|
14
|
+
run_generator %w(test)
|
15
|
+
|
16
|
+
assert_file "app/assets/javascripts/apps/test/test_app.js"
|
17
|
+
end
|
18
|
+
|
19
|
+
test "creates the entities file" do
|
20
|
+
run_generator %w(test)
|
21
|
+
|
22
|
+
assert_file "app/assets/javascripts/entities/test.js"
|
23
|
+
end
|
24
|
+
|
25
|
+
test "creates coffeescript sub application file if requried" do
|
26
|
+
run_generator %w(test -c)
|
27
|
+
|
28
|
+
assert_file "app/assets/javascripts/apps/test/test_app.js.coffee"
|
29
|
+
end
|
30
|
+
|
31
|
+
test "creates coffeescript entities file if required" do
|
32
|
+
run_generator %w(test -c)
|
33
|
+
|
34
|
+
assert_file "app/assets/javascripts/entities/test.js.coffee"
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SubmoduleGeneratorTest < Rails::Generators::TestCase
|
4
|
+
tests Md::Generators::SubmoduleGenerator
|
5
|
+
destination File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
test "creates the folder structure" do
|
8
|
+
run_generator %w(bar --parent foo)
|
9
|
+
|
10
|
+
assert_directory "app/assets/javascripts/apps/foo"
|
11
|
+
assert_directory "app/assets/javascripts/apps/foo/bar"
|
12
|
+
assert_directory "app/assets/javascripts/entities"
|
13
|
+
end
|
14
|
+
|
15
|
+
test "creates the submodule application" do
|
16
|
+
run_generator %w(bar --parent foo)
|
17
|
+
|
18
|
+
assert_file "app/assets/javascripts/apps/foo/bar/bar_view.js"
|
19
|
+
assert_file "app/assets/javascripts/apps/foo/bar/bar_controller.js"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "creates the submodule application with coffeescript files if required" do
|
23
|
+
run_generator %w(bar --parent foo -c)
|
24
|
+
|
25
|
+
assert_file "app/assets/javascripts/apps/foo/bar/bar_view.js.coffee"
|
26
|
+
assert_file "app/assets/javascripts/apps/foo/bar/bar_controller.js.coffee"
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
var Class = new Marionette.Application();
|
2
|
+
|
3
|
+
Class.addRegions({
|
4
|
+
//Add application regions here
|
5
|
+
});
|
6
|
+
|
7
|
+
//Navigate to specific route
|
8
|
+
Class.navigate = function (route, options) {
|
9
|
+
options || (options = {});
|
10
|
+
Backbone.history.navigate(route, options);
|
11
|
+
};
|
12
|
+
|
13
|
+
//Returns current route
|
14
|
+
Class.getCurrentRoute = function () {
|
15
|
+
return Backbone.history.fragment;
|
16
|
+
};
|
17
|
+
|
18
|
+
Class.on('initialize:after', function () {
|
19
|
+
//Things to do after app initialize
|
20
|
+
if (Backbone.history) {
|
21
|
+
Backbone.history.start({
|
22
|
+
pushState: true
|
23
|
+
});
|
24
|
+
}
|
25
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Class = new Marionette.Application()
|
2
|
+
|
3
|
+
#Add application regions here
|
4
|
+
Class.addRegions {}
|
5
|
+
|
6
|
+
#Navigate to specific route
|
7
|
+
Class.navigate = (route, options) ->
|
8
|
+
options or (options = {})
|
9
|
+
Backbone.history.navigate route, options
|
10
|
+
|
11
|
+
#Returns current route
|
12
|
+
Class.getCurrentRoute = ->
|
13
|
+
Backbone.history.fragment
|
14
|
+
|
15
|
+
Class.on "initialize:after", ->
|
16
|
+
#Things to do after app initialize
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Class.module("TestsApp", function (TestsApp, Class, Backbone, Marionette, $, _) {
|
2
|
+
TestsApp.Router = Marionette.AppRouter.extend({
|
3
|
+
appRoutes: {}
|
4
|
+
});
|
5
|
+
|
6
|
+
var API = {};
|
7
|
+
|
8
|
+
TestsApp.addInitializer(function() {
|
9
|
+
router = new TestsApp.Router({
|
10
|
+
controller: API
|
11
|
+
});
|
12
|
+
});
|
13
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
<h2>To be filled</h2>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rails/all'
|
6
|
+
require 'rails/generators'
|
7
|
+
require 'rails/generators/test_case'
|
8
|
+
|
9
|
+
class TestApp < Rails::Application
|
10
|
+
config.root = File.dirname(__FILE__)
|
11
|
+
end
|
12
|
+
Rails.application = TestApp
|
13
|
+
|
14
|
+
module Rails
|
15
|
+
def self.root
|
16
|
+
@root ||= File.expand_path("../../vendor/assets/javascripts/marionette_dust/", __FILE__)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
Rails.application.config.root = Rails.root
|
20
|
+
|
21
|
+
require 'generators/md/install/install_generator'
|
22
|
+
require 'generators/md/scaffold/scaffold_generator'
|
23
|
+
require 'generators/md/submodule/submodule_generator'
|