Module: Backbone::Generators::Helpers

Included in:
InstallGenerator, ScaffoldGenerator
Defined in:
lib/generators/backbone/helpers.rb

Instance Method Summary collapse

Instance Method Details

#app_filenameObject



41
42
43
# File 'lib/generators/backbone/helpers.rb', line 41

def app_filename
  "#{namespaced_path}/#{rails_app_name.underscore}"
end

#app_nameObject



37
38
39
# File 'lib/generators/backbone/helpers.rb', line 37

def app_name
  rails_app_name.camelize + namespaces.map!{ |n| n.camelize }.join('')
end

#asset_pathObject



5
6
7
# File 'lib/generators/backbone/helpers.rb', line 5

def asset_path
  "app/assets"
end

#collection_namespaceObject



21
22
23
# File 'lib/generators/backbone/helpers.rb', line 21

def collection_namespace
  [app_name, "Collections", file_name.pluralize.camelize].join(".")
end

#js_pathObject



9
10
11
# File 'lib/generators/backbone/helpers.rb', line 9

def js_path
  "#{asset_path}/javascripts"
end

#model_namespaceObject



17
18
19
# File 'lib/generators/backbone/helpers.rb', line 17

def model_namespace
  [app_name, "Models", file_name.singularize.camelize].join(".")
end

#namespaced_pathObject



53
54
55
# File 'lib/generators/backbone/helpers.rb', line 53

def namespaced_path
  '/' + namespaces.join('/')
end

#namespacesObject



49
50
51
# File 'lib/generators/backbone/helpers.rb', line 49

def namespaces
  options[:namespace] ? options[:namespace].split('/') : file_path.split('/')[0...-1]
end

#rails_app_nameObject



45
46
47
# File 'lib/generators/backbone/helpers.rb', line 45

def rails_app_name
  Rails.application.class.name.split('::').first
end

#router_namespaceObject



25
26
27
# File 'lib/generators/backbone/helpers.rb', line 25

def router_namespace
  [app_name, "Routers", file_name.pluralize.camelize].join(".")
end

#template_namespaceObject



33
34
35
# File 'lib/generators/backbone/helpers.rb', line 33

def template_namespace
  [file_path.pluralize, "index"].join("/")
end

#template_pathObject



13
14
15
# File 'lib/generators/backbone/helpers.rb', line 13

def template_path
  "#{asset_path}/templates"
end

#view_namespaceObject



29
30
31
# File 'lib/generators/backbone/helpers.rb', line 29

def view_namespace
  [app_name, "Views", "#{file_name.pluralize.camelize}Index"].join(".")
end