Sha256: cbaba8295504be7c26066d8c75afe79793d1ac8b53fe682f13c9b60a856c8a40

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

INITIALIZER = <<END
require 'yaml'
require 'gds_zendesk/client'
require 'gds_zendesk/dummy_client'

GDS_ZENDESK_CLIENT = if Rails.env.development? || Rails.env.test?
  GDSZendesk::DummyClient.new(logger: Rails.logger)
else
  config_yaml_file = File.join(Rails.root, 'config', 'zendesk.yml')
  config = YAML.load_file(config_yaml_file)[Rails.env]
  GDSZendesk::Client.new(username: config['username'], password: config['password'], token: config['token'], logger: Rails.logger)
end
END

# This module name is slightly differently capitalised to the main library module
# The reason for this is that the module name is used by Rails within the 
# generator CLI tools, and the tools get confused if the module is called GDSZendesk
module GdsZendesk
  class InstallGenerator < Rails::Generators::Base
    def create_initializer_file
      initializer "gds_zendesk.rb", INITIALIZER
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gds_zendesk-3.2.0 lib/generators/gds_zendesk/install/install_generator.rb