better filenames
This commit is contained in:
parent
e9e7cb036c
commit
3c8342fca4
16
README.md
16
README.md
|
@ -6,30 +6,30 @@ Currently only works with Rails-ish projects and with Jasmine & Jammit. I'm self
|
||||||
|
|
||||||
`backbone-generate model Admin::User` creates an AdminUserModel object in:
|
`backbone-generate model Admin::User` creates an AdminUserModel object in:
|
||||||
|
|
||||||
* `public/javascripts/models/admin/user.js`
|
* `public/javascripts/models/admin/user_model.js`
|
||||||
* `spec/javascripts/models/admin/user_spec.js`
|
* `spec/javascripts/models/admin/user_model_spec.js`
|
||||||
|
|
||||||
### View
|
### View
|
||||||
|
|
||||||
`backbone-generate view Admin::User` creates an AdminUserView object in:
|
`backbone-generate view Admin::User` creates an AdminUserView object in:
|
||||||
|
|
||||||
* `public/javascripts/views/admin/user.js`
|
* `public/javascripts/views/admin/user_view.js`
|
||||||
* `spec/javascripts/views/admin/user_spec.js`
|
* `spec/javascripts/views/admin/user_view_spec.js`
|
||||||
* `app/views/admin/user.jst`
|
* `app/views/admin/user.jst`
|
||||||
|
|
||||||
### Collection
|
### Collection
|
||||||
|
|
||||||
`backbone-generate collection Admin::User` creates an AdminUsersCollection object in:
|
`backbone-generate collection Admin::User` creates an AdminUsersCollection object in:
|
||||||
|
|
||||||
* `public/javascripts/collections/admin/users.js`
|
* `public/javascripts/collections/admin/users_collection.js`
|
||||||
* `spec/javascripts/collections/admin/users_spec.js`
|
* `spec/javascripts/collections/admin/users_collection_spec.js`
|
||||||
|
|
||||||
### Collection View
|
### Collection View
|
||||||
|
|
||||||
`backbone-generate collection-view Admin::User` creates an AdminUsersView object in:
|
`backbone-generate collection-view Admin::User` creates an AdminUsersView object in:
|
||||||
|
|
||||||
* `public/javascripts/views/admin/users.js`
|
* `public/javascripts/views/admin/users_view.js`
|
||||||
* `spec/javascripts/views/admin/users_spec.js`
|
* `spec/javascripts/views/admin/users_view_spec.js`
|
||||||
* `app/views/admin/users.jst`
|
* `app/views/admin/users.jst`
|
||||||
|
|
||||||
Please add more and make it more friendly with things that are not Rails, Jasmine, and Jammit!
|
Please add more and make it more friendly with things that are not Rails, Jasmine, and Jammit!
|
||||||
|
|
|
@ -24,31 +24,31 @@ class BackboneGenerator < Thor
|
||||||
desc 'model Namespaced::Name', "Create a model"
|
desc 'model Namespaced::Name', "Create a model"
|
||||||
def model(name)
|
def model(name)
|
||||||
@name = name
|
@name = name
|
||||||
template('model.js.erb', "public/javascripts/models/#{underscore_name}.js")
|
template('model.js.erb', "public/javascripts/models/#{underscore_name}_model.js")
|
||||||
template('model_spec.js.erb', "spec/javascripts/models/#{underscore_name}_spec.js")
|
template('model_spec.js.erb', "spec/javascripts/models/#{underscore_name}_model_spec.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'view Namespaced::Name', "Create a view"
|
desc 'view Namespaced::Name', "Create a view"
|
||||||
def view(name)
|
def view(name)
|
||||||
@name = name
|
@name = name
|
||||||
template('view.js.erb', "public/javascripts/views/#{underscore_name}.js")
|
template('view.js.erb', "public/javascripts/views/#{underscore_name}_view.js")
|
||||||
template('view.jst.erb', "app/views/#{underscore_name}.jst")
|
template('view.jst.erb', "app/views/#{underscore_name}.jst")
|
||||||
template('view_spec.js.erb', "spec/javascripts/views/#{underscore_name}_spec.js")
|
template('view_spec.js.erb', "spec/javascripts/views/#{underscore_name}_view_spec.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'collection Namespaced::Name', "Create a collection"
|
desc 'collection Namespaced::Name', "Create a collection"
|
||||||
def collection(name)
|
def collection(name)
|
||||||
@name = name
|
@name = name
|
||||||
template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s.js")
|
template('collection.js.erb', "public/javascripts/collections/#{underscore_name}s_collection.js")
|
||||||
template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_spec.js")
|
template('collection_spec.js.erb', "spec/javascripts/collections/#{underscore_name}s_collection_spec.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'collection-view Namespaced::Name', "Create a collection view"
|
desc 'collection-view Namespaced::Name', "Create a collection view"
|
||||||
def collection_view(name)
|
def collection_view(name)
|
||||||
@name = name
|
@name = name
|
||||||
template('collection_view.js.erb', "public/javascripts/views/#{underscore_name}s.js")
|
template('collection_view.js.erb', "public/javascripts/views/#{underscore_name}s_view.js")
|
||||||
template('collection_view.jst.erb', "app/views/#{underscore_name}s.jst")
|
template('collection_view.jst.erb', "app/views/#{underscore_name}s.jst")
|
||||||
template('collection_view_spec.js.erb', "spec/javascripts/views/#{underscore_name}s_spec.js")
|
template('collection_view_spec.js.erb', "spec/javascripts/views/#{underscore_name}s_view_spec.js")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ describe 'backbone-generator' do
|
||||||
it "should generate the model files" do
|
it "should generate the model files" do
|
||||||
system %{bin/backbone-generator model Section::Model}
|
system %{bin/backbone-generator model Section::Model}
|
||||||
|
|
||||||
File.file?(model = 'public/javascripts/models/section/model.js').should be_true
|
File.file?(model = 'public/javascripts/models/section/model_model.js').should be_true
|
||||||
File.file?(spec = 'spec/javascripts/models/section/model_spec.js').should be_true
|
File.file?(spec = 'spec/javascripts/models/section/model_model_spec.js').should be_true
|
||||||
|
|
||||||
File.read(model).should match(/SectionModel/)
|
File.read(model).should match(/SectionModel/)
|
||||||
File.read(spec).should match(/SectionModel/)
|
File.read(spec).should match(/SectionModel/)
|
||||||
|
@ -27,8 +27,8 @@ describe 'backbone-generator' do
|
||||||
it "should generate the view files" do
|
it "should generate the view files" do
|
||||||
system %{bin/backbone-generator view Section::Model}
|
system %{bin/backbone-generator view Section::Model}
|
||||||
|
|
||||||
File.file?(view = 'public/javascripts/views/section/model.js').should be_true
|
File.file?(view = 'public/javascripts/views/section/model_view.js').should be_true
|
||||||
File.file?(spec = 'spec/javascripts/views/section/model_spec.js').should be_true
|
File.file?(spec = 'spec/javascripts/views/section/model_view_spec.js').should be_true
|
||||||
File.file?(template = 'app/views/section/model.jst').should be_true
|
File.file?(template = 'app/views/section/model.jst').should be_true
|
||||||
|
|
||||||
File.read(view).should match(/SectionModel/)
|
File.read(view).should match(/SectionModel/)
|
||||||
|
@ -41,8 +41,8 @@ describe 'backbone-generator' do
|
||||||
it "should generate the collection view files" do
|
it "should generate the collection view files" do
|
||||||
system %{bin/backbone-generator collection-view Section::Model}
|
system %{bin/backbone-generator collection-view Section::Model}
|
||||||
|
|
||||||
File.file?(view = 'public/javascripts/views/section/models.js').should be_true
|
File.file?(view = 'public/javascripts/views/section/models_view.js').should be_true
|
||||||
File.file?(spec = 'spec/javascripts/views/section/models_spec.js').should be_true
|
File.file?(spec = 'spec/javascripts/views/section/models_view_spec.js').should be_true
|
||||||
File.file?(template = 'app/views/section/models.jst').should be_true
|
File.file?(template = 'app/views/section/models.jst').should be_true
|
||||||
|
|
||||||
File.read(view).should match(/SectionModelsView/)
|
File.read(view).should match(/SectionModelsView/)
|
||||||
|
@ -55,8 +55,8 @@ describe 'backbone-generator' do
|
||||||
it "should generate the collection files" do
|
it "should generate the collection files" do
|
||||||
system %{bin/backbone-generator collection Section::Model}
|
system %{bin/backbone-generator collection Section::Model}
|
||||||
|
|
||||||
File.file?(collection = 'public/javascripts/collections/section/models.js').should be_true
|
File.file?(collection = 'public/javascripts/collections/section/models_collection.js').should be_true
|
||||||
File.file?(spec = 'spec/javascripts/collections/section/models_spec.js').should be_true
|
File.file?(spec = 'spec/javascripts/collections/section/models_collection_spec.js').should be_true
|
||||||
|
|
||||||
File.read(collection).should match(/SectionModelsCollection/)
|
File.read(collection).should match(/SectionModelsCollection/)
|
||||||
File.read(collection).should match(%r{section/model})
|
File.read(collection).should match(%r{section/model})
|
||||||
|
|
Loading…
Reference in New Issue