Class: Auth::Generators::ViewsGenerator

Inherits:
Rails::Generator::NamedBase
  • Object
show all
Defined in:
lib/auth/generators/views_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, options = {}) ⇒ ViewsGenerator

Returns a new instance of ViewsGenerator.



4
5
6
7
8
# File 'lib/auth/generators/views_generator.rb', line 4

def initialize(model, options = {})
  @model = model
  args = [ model.name ]
  super(args, options)
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



2
3
4
# File 'lib/auth/generators/views_generator.rb', line 2

def model
  @model
end

Instance Method Details

#manifestObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/auth/generators/views_generator.rb', line 10

def manifest
  record do |m|
    m.directory resource_directory = File.join("app/views", model.accounts_controller.underscore)
    m.directory sessions_directory = File.join("app/views", model.sessions_controller.underscore)
    
    resource_directory = File.join("app/views", model.accounts_controller.underscore)
    sessions_directory = File.join("app/views", model.sessions_controller.underscore)
    
    base = File.join(source_root, "views/sparkly_accounts")
    Dir[File.join(base, "**/*")].each do |fi|
      fi.gsub!(/^#{Regexp::escape base}/, '')
      m.file(File.join("views/sparkly_accounts", fi), File.join(resource_directory, fi))
    end

    base = File.join(source_root, "views/sparkly_sessions")
    Dir[File.join(base, "**/*")].each do |fi|
      fi.gsub!(/^#{Regexp::escape base}/, '')
      m.file(File.join("views/sparkly_sessions", fi), File.join(sessions_directory, fi))
    end
  end
end

#specObject



32
33
34
# File 'lib/auth/generators/views_generator.rb', line 32

def spec
  @spec ||= Rails::Generator::Spec.new("views", File.join(Auth.path, "auth/generators"), nil)
end