Class: DeviseSmsVerifiable::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/devise_sms_verifiable/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_config_options_to_initializerObject



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
45
46
# File 'lib/generators/devise_sms_verifiable/install_generator.rb', line 7

def add_config_options_to_initializer
  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 :sms_verifiable\n/))
      false
    else
      inject_into_file(devise_initializer_path, before: "# ==> Configuration for :database_authenticatable\n") do
<<-CONTENT
# ==> Configuration for :sms_verifiable
  # Field in model for confirm phone(must be boolean)
  #config.phone_confirmation_field = :phone_confirm
  # Attribut on model return rigth answer
  #config.sms_answer_field = :sms_answer
  # Field in model which phone number
  #config.phone_field = :phone
  # Field in model for confirm phone(must be boolean)
  #config.phone_confirmation_field = :phone_confirm
  # Path after successful confirmation
  #config.successful_path = '/'
  # Token generator method(default 4 digit)
  # must return valid token
  #config.token_generator = -> { rand(1000..2000) }
  # SMS provider module(have default for STREAM-TELECOM)
  #config.sms_provider = DeviseSmsVerifiable::Provider
  # Send sms silent for test
  #config.provider_silent = true
  # SMS provider login
  #config.provider_login = ""
  # SMS provider password
  #config.provider_password = ""
  # SMS provider from
  #config.provider_from = ""
  \n
CONTENT
      end
    end
  end
end

#show_readmeObject



48
49
50
# File 'lib/generators/devise_sms_verifiable/install_generator.rb', line 48

def show_readme
  readme "README"
end