Class: Clearance::Generators::ViewsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/clearance/views/views_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_localesObject


14
15
16
17
18
# File 'lib/generators/clearance/views/views_generator.rb', line 14

def create_locales
  locales.each do |locale|
    copy_file locale
  end
end

#create_viewsObject


8
9
10
11
12
# File 'lib/generators/clearance/views/views_generator.rb', line 8

def create_views
  views.each do |view|
    copy_file view
  end
end

#files_within_root(prefix, glob) ⇒ Object (private)


30
31
32
33
34
35
36
# File 'lib/generators/clearance/views/views_generator.rb', line 30

def files_within_root(prefix, glob)
  root = "#{self.class.source_root}/#{prefix}"

  Dir["#{root}/#{glob}"].sort.map do |full_path|
    full_path.sub(root, '.').gsub('/./', '/')
  end
end

#localesObject (private)


26
27
28
# File 'lib/generators/clearance/views/views_generator.rb', line 26

def locales
  files_within_root('.', 'config/locales/**/*.*')
end

#viewsObject (private)


22
23
24
# File 'lib/generators/clearance/views/views_generator.rb', line 22

def views
  files_within_root('.', 'app/views/**/*.*')
end