Class: Annotations2triannon::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/annotations2triannon/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/annotations2triannon/configuration.rb', line 18

def initialize
  @debug = env_boolean('DEBUG')
  logger_init

  # In development, enable options for sampling the data
  @limit_random = env_boolean('ANNO_LIMIT_RANDOM') # 0..limit or random sampling
  @limit_manifests = ENV['ANNO_LIMIT_MANIFESTS'].to_i # 0 disables sampling
  @limit_annolists = ENV['ANNO_LIMIT_ANNOLISTS'].to_i # 0 disables sampling
  @limit_openannos = ENV['ANNO_LIMIT_OPENANNOS'].to_i # 0 disables sampling

  # Persistence options (TODO: provide options for triple stores)
  redis_init
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



10
11
12
# File 'lib/annotations2triannon/configuration.rb', line 10

def debug
  @debug
end

#limit_annolistsObject

Returns the value of attribute limit_annolists.



13
14
15
# File 'lib/annotations2triannon/configuration.rb', line 13

def limit_annolists
  @limit_annolists
end

#limit_manifestsObject

Returns the value of attribute limit_manifests.



12
13
14
# File 'lib/annotations2triannon/configuration.rb', line 12

def limit_manifests
  @limit_manifests
end

#limit_openannosObject

Returns the value of attribute limit_openannos.



14
15
16
# File 'lib/annotations2triannon/configuration.rb', line 14

def limit_openannos
  @limit_openannos
end

#limit_randomObject

Returns the value of attribute limit_random.



11
12
13
# File 'lib/annotations2triannon/configuration.rb', line 11

def limit_random
  @limit_random
end

#log_fileObject (readonly)

Returns the value of attribute log_file.



6
7
8
# File 'lib/annotations2triannon/configuration.rb', line 6

def log_file
  @log_file
end

#log_pathObject (readonly)

Returns the value of attribute log_path.



7
8
9
# File 'lib/annotations2triannon/configuration.rb', line 7

def log_path
  @log_path
end

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/annotations2triannon/configuration.rb', line 8

def logger
  @logger
end

#redisObject

Returns the value of attribute redis.



16
17
18
# File 'lib/annotations2triannon/configuration.rb', line 16

def redis
  @redis
end

Instance Method Details

#array_sampler(array, limit = 0) ⇒ Object

Utility method for sampling annotation arrays, using either linear or random sampling of a subset of elements. The instance variable .limit_random is a configuration parameter that defines whether linear or random sampling is used.

Parameters:

  • array (Array)

    An array to be sampled

  • limit (Integer) (defaults to: 0)

    The number of elements to sample



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/annotations2triannon/configuration.rb', line 39

def array_sampler(array, limit=0)
  if limit > 0
    if @limit_random
      array.sample(limit)
    else
      limit = limit - 1
      array[0..limit]
    end
  else
    array
  end
end