Class: ProductiveGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



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

def create_initializer_file
  if /^[a-f0-9\-]{36}$/ !~ api_key
    raise Thor::Error, "Invalid Productive API key #{api_key.inspect}\nYou can find the API key on the Settings -> Security page of https://productive.io"
  end

  if /^[0-9]*$/ !~ 
    raise Thor::Error, "Invalid Productive Account ID #{.inspect}\n"
  end

  initializer 'productive.rb' do
    <<-CONFIG.strip_heredoc
      Productive.configure do |config|
        config.api_key = #{api_key.inspect}
        config.account_id = #{.inspect}
      end
    CONFIG
  end
end