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 #{account_id.inspect}\n"
  end

  initializer 'productive.rb' do
    "      Productive.configure do |config|\n        config.api_key = \#{api_key.inspect}\n        config.account_id = \#{account_id.inspect}\n      end\n    CONFIG\n  end\nend\n".strip_heredoc