Class: DeviseHackerTrackerGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/devise_hacker_tracker_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_hacker_tracker_migrationObject



42
43
44
45
# File 'lib/generators/devise_hacker_tracker_generator.rb', line 42

def create_hacker_tracker_migration
  @uuid_enabled = options.uuid
  migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb"
end

#setup_hacker_tracker_configurationObject



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
# File 'lib/generators/devise_hacker_tracker_generator.rb', line 10

def setup_hacker_tracker_configuration
  devise_initializer_path = "config/initializers/devise.rb"
  if File.exist?(devise_initializer_path)
    old_content = File.read(devise_initializer_path)

    if old_content.match(Regexp.new(/^\s# ==> Configuration for :hacker_tracker\n/))
      false
    else
      inject_into_file(devise_initializer_path, :before => "  # ==> Configuration for :confirmable\n") do
" # ==> Configuration for :hacker_tracker
# Amount of time an IP address stays blocked for
# config.ip_block_time = 5.minutes
#
# Total number of failed sign in attempts allowed per IP address before being blocked
# config.maximum_attempts_per_ip = #{Devise.maximum_attempts_per_ip}
#
# Total number accounts a single IP address is allowed to attempt before being blocked
# config.maximum_accounts_attempted = #{Devise.maximum_accounts_attempted}
#
# The name of the table storing the failed sign in attempts
config.sign_in_failures_table_name = '#{table_name}'

"
      end
    end
  end
end

#setup_hacker_tracker_localesObject



38
39
40
# File 'lib/generators/devise_hacker_tracker_generator.rb', line 38

def setup_hacker_tracker_locales
  copy_file "../../../config/locales/en.yml", "config/locales/devise_hacker_tracker.en.yml"
end