Class: Revocare::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/revocare/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



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

def initialize
  environment_path = "#{Dir.pwd}/config/environment.rb"
  Kernel.require environment_path

  if Module.const_defined?("Rails")
    Rails.application.eager_load!

    if Rails.application.config.respond_to?(:eager_load_namespaces)
      Rails.application.config.eager_load_namespaces.each(&:eager_load!)
    end

    if !Module.const_defined?("ActiveRecord")
      raise "Must use `ActiveRecord`"
    end
  end
rescue LoadError
  puts "Tried to load Rails environment but could not find it"
end

Class Method Details

.callObject



7
8
9
# File 'lib/revocare/cli.rb', line 7

def self.call
  new.call
end

Instance Method Details

#callObject



30
31
32
33
34
# File 'lib/revocare/cli.rb', line 30

def call
  data = Revocare::CallbackData.to_a
  writer = Revocare::DataWriter.new(data: data)
  writer.write_to_directory
end