Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update file naming to match latest version of book, fixes #33

  • Loading branch information...
commit a7673b07d5d4b8e082732412c1c55b312b0d155c 1 parent 40f3438
@meleyal authored
View
2  CHANGELOG
@@ -4,7 +4,7 @@ CHANGELOG
0.9.2.3 (unreleased)
--------------------
- * Update file naming to match latest version of book
+ * Update file naming to match latest version of book (#33)
* Install generator works on empty manifests (#16)
View
8 lib/generators/backbone/helpers.rb
@@ -38,6 +38,14 @@ def plural_file_name
"#{file_name.pluralize}#{@ext}"
end
+ def router_file_name
+ "#{file_name.pluralize}_router#{@ext}"
+ end
+
+ def view_file_name
+ "#{file_name.pluralize}_index#{@ext}"
+ end
+
def model_namespace
[app_name, "Models", file_name.singularize.camelize].join(".")
end
View
4 lib/generators/backbone/scaffold/scaffold_generator.rb
@@ -32,13 +32,13 @@ def create_backbone_collection
end
def create_backbone_router
- file = File.join(router_path, plural_file_name)
+ file = File.join(router_path, router_file_name)
template "router#{@ext}", file
end
def create_backbone_view
empty_directory File.join(view_path, file_name.pluralize)
- file = File.join(view_path, file_name.pluralize, "index#{@ext}")
+ file = File.join(view_path, file_name.pluralize, view_file_name)
template "view#{@ext}", file
end
View
8 test/generators/scaffold_generator_test.rb
@@ -47,21 +47,21 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
test "router coffee file is created" do
run_generator ['planet']
- assert_file "#{router_path}/planets.js.coffee" do |content|
+ assert_file "#{router_path}/planets_router.js.coffee" do |content|
assert_match('class Dummy.Routers.Planets', content)
end
end
test "router javascript file is created" do
run_generator ['planet', '--javascript']
- assert_file "#{router_path}/planets.js" do |content|
+ assert_file "#{router_path}/planets_router.js" do |content|
assert_match('Dummy.Routers.Planets = Backbone.Router.extend', content)
end
end
test "view coffee file is created" do
run_generator ['planet']
- assert_file "#{view_path}/planets/index.js.coffee" do |content|
+ assert_file "#{view_path}/planets/planets_index.js.coffee" do |content|
assert_match('class Dummy.Views.PlanetsIndex', content)
assert_match("template: JST['planets/index']", content)
end
@@ -69,7 +69,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
test "view javascript file is created" do
run_generator ['planet', '--javascript']
- assert_file "#{view_path}/planets/index.js" do |content|
+ assert_file "#{view_path}/planets/planets_index.js" do |content|
assert_match('Dummy.Views.PlanetsIndex = Backbone.View.extend', content)
assert_match("template: JST['planets/index']", content)
end
Please sign in to comment.
Something went wrong with that request. Please try again.