Module: Chaplin::Generators::Helpers

Included in:
InstallGenerator
Defined in:
lib/generators/chaplin/helpers.rb

Instance Method Summary collapse

Instance Method Details

#app_filenameObject



77
78
79
# File 'lib/generators/chaplin/helpers.rb', line 77

def app_filename
  rails_app_name.underscore
end

#app_nameObject



73
74
75
# File 'lib/generators/chaplin/helpers.rb', line 73

def app_name
  rails_app_name.camelize
end

#asset_pathObject



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

def asset_path
  File.join('app', 'assets')
end

#base_path(path) ⇒ Object



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

def base_path(path)
  File.join(path, 'base')
end

#collection_namespaceObject



57
58
59
# File 'lib/generators/chaplin/helpers.rb', line 57

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

#controller_pathObject



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

def controller_path
  File.join(javascript_path, "controllers")
end

#display(output, color = :green) ⇒ Object



89
90
91
# File 'lib/generators/chaplin/helpers.rb', line 89

def display(output, color = :green)
  say(" - #{output}", color)
end

#javascript_pathObject



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

def javascript_path
  File.join(asset_path, 'javascripts')
end

#layout_pathObject



85
86
87
# File 'lib/generators/chaplin/helpers.rb', line 85

def layout_path
  Dir['app/views/layouts/application*'].first
end

#lib_pathObject



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

def lib_path
  File.join(javascript_path, "lib")
end

#model_namespaceObject



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

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

#model_pathObject



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

def model_path
  File.join(javascript_path, "models")
end

#plural_file_nameObject



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

def plural_file_name
  "#{file_name.pluralize}#{@ext}"
end

#rails_app_nameObject



81
82
83
# File 'lib/generators/chaplin/helpers.rb', line 81

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

#router_file_nameObject



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

def router_file_name
  "#{file_name.pluralize}_router#{@ext}"
end

#router_namespaceObject



61
62
63
# File 'lib/generators/chaplin/helpers.rb', line 61

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

#singular_file_nameObject



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

def singular_file_name
  "#{file_name.singularize}#{@ext}"
end

#template_namespaceObject



69
70
71
# File 'lib/generators/chaplin/helpers.rb', line 69

def template_namespace
  File.join(file_path.pluralize, "index")
end

#template_pathObject



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

def template_path
  File.join(asset_path, "templates")
end

#view_file_nameObject



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

def view_file_name
  "#{file_name.pluralize}_index#{@ext}"
end

#view_namespaceObject



65
66
67
# File 'lib/generators/chaplin/helpers.rb', line 65

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

#view_pathObject



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

def view_path
  File.join(javascript_path, "views")
end