Class: Eastrails::Components::Devise

Inherits:
Base
  • Object
show all
Defined in:
lib/eastrails/components/devise.rb

Instance Method Summary collapse

Methods inherited from Base

#component_installed?, #dir_html_to_haml, #do_if_installed, #file_html_to_haml, #gems, #html_to_haml, #parse_gemfile

Methods inherited from Generator

#initialize

Constructor Details

This class inherits a constructor from Eastrails::Generator

Instance Method Details

#addObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/eastrails/components/devise.rb', line 6

def add
  unless gems.include?("devise")
    gem 'devise'
    system 'bundle install'
    system 'rails g devise:install'
    system 'rails g devise User'
  end

  if File.directory?("spec")
    FileUtils.mkdir_p("spec/support")
    create_file 'spec/support/devise.rb' do
      <<-RUBY
RSpec.configure do |config|
  config.include Devise::TestHelpers, :type => :controller
end
      RUBY
    end
  end

  unless File.directory?("app/views/devise")
    directory "devise", "app/views/devise"

    if gems.include?("haml") || gems.include?("haml-rails")
      dir_html_to_haml("app/views/devise")
    end
  end

  erb_navigation_content = File.read(
    File.expand_path(find_in_source_paths("navigation/devise.html.erb")))
  if File.exists?("app/views/layouts/_navigation.html.erb")
    append_file("app/views/layouts/_navigation.html.erb") do
      erb_navigation_content
    end
  elsif File.exists?("app/views/layouts/_navigation.html.haml")
    append_file("app/views/layouts/_navigation.html.haml") do
      html_to_haml(erb_navigation_content)
    end
  end
end