Module: JobIteration

Extended by:
JobIteration
Included in:
JobIteration
Defined in:
lib/job-iteration.rb,
lib/job-iteration/version.rb,
lib/job-iteration/iteration.rb,
lib/job-iteration/test_helper.rb,
lib/job-iteration/csv_enumerator.rb,
lib/job-iteration/enumerator_builder.rb,
lib/job-iteration/integrations/resque.rb,
lib/job-iteration/active_record_cursor.rb,
lib/job-iteration/integrations/sidekiq.rb,
lib/job-iteration/active_record_enumerator.rb

Defined Under Namespace

Modules: Iteration, TestHelper Classes: ActiveRecordEnumerator, CsvEnumerator, EnumeratorBuilder

Constant Summary collapse

IntegrationLoadError =
Class.new(StandardError)
INTEGRATIONS =
[:resque, :sidekiq]
VERSION =
"0.9.0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interruption_adapterObject

Returns the value of attribute interruption_adapter


14
15
16
# File 'lib/job-iteration.rb', line 14

def interruption_adapter
  @interruption_adapter
end

#max_job_runtimeObject

Returns the value of attribute max_job_runtime


14
15
16
# File 'lib/job-iteration.rb', line 14

def max_job_runtime
  @max_job_runtime
end

Class Method Details

.load_integration(integration) ⇒ Object


34
35
36
37
38
39
40
41
# File 'lib/job-iteration.rb', line 34

def load_integration(integration)
  unless INTEGRATIONS.include?(integration)
    raise IntegrationLoadError,
      "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(', ')}"
  end

  require_relative "./job-iteration/integrations/#{integration}"
end

.load_integrationsObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/job-iteration.rb', line 17

def load_integrations
  loaded = nil
  INTEGRATIONS.each do |integration|
    if loaded
      raise IntegrationLoadError,
        "#{loaded} integration has already been loaded, but #{integration} is also available. " \
        "Iteration will only work with one integration."
    end

    begin
      load_integration(integration)
      loaded = integration
    rescue LoadError
    end
  end
end

Instance Method Details

#load_integration(integration) ⇒ Object


34
35
36
37
38
39
40
41
# File 'lib/job-iteration.rb', line 34

def load_integration(integration)
  unless INTEGRATIONS.include?(integration)
    raise IntegrationLoadError,
      "#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(', ')}"
  end

  require_relative "./job-iteration/integrations/#{integration}"
end

#load_integrationsObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/job-iteration.rb', line 17

def load_integrations
  loaded = nil
  INTEGRATIONS.each do |integration|
    if loaded
      raise IntegrationLoadError,
        "#{loaded} integration has already been loaded, but #{integration} is also available. " \
        "Iteration will only work with one integration."
    end

    begin
      load_integration(integration)
      loaded = integration
    rescue LoadError
    end
  end
end