Class: Flex::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/flex/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides = {}) ⇒ Tasks

Returns a new instance of Tasks.



6
7
8
9
10
# File 'lib/flex/tasks.rb', line 6

def initialize(overrides={})
  options = Flex::Utils.env2options *default_options.keys
  options[:index] = options[:index].split(',') if options[:index]
  @options = default_options.merge(options).merge(overrides)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/flex/tasks.rb', line 4

def options
  @options
end

Instance Method Details

#config_hashObject



31
32
33
34
# File 'lib/flex/tasks.rb', line 31

def config_hash
  @config_hash ||= ( hash = YAML.load(Utils.erb_process(config_path))
                     Utils.delete_allcaps_keys(hash) )
end

#create_indicesObject



18
19
20
21
22
23
24
25
# File 'lib/flex/tasks.rb', line 18

def create_indices
  indices.each do |index|
    delete_index(index) if options[:force]
    raise ExistingIndexError, "#{index.inspect} already exists. Please use FORCE=1 if you want to delete it first." \
          if exist?(index)
    create(index)
  end
end

#default_optionsObject



12
13
14
15
16
# File 'lib/flex/tasks.rb', line 12

def default_options
  @default_options ||= { :force          => false,
                         :index          => Conf.variables[:index],
                         :config_file    => Conf.config_file }
end

#delete_indicesObject



27
28
29
# File 'lib/flex/tasks.rb', line 27

def delete_indices
  indices.each { |index| delete_index(index) }
end