class Flex::Tasks
Attributes
options[R]
Public Class Methods
new(overrides={})
click to toggle source
# 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
Public Instance Methods
config_hash()
click to toggle source
# 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_indices()
click to toggle source
# 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_options()
click to toggle source
# 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_indices()
click to toggle source
# File lib/flex/tasks.rb, line 27 def delete_indices indices.each { |index| delete_index(index) } end
Private Instance Methods
config_path()
click to toggle source
# File lib/flex/tasks.rb, line 47 def config_path @config_path ||= options[:config_file] || Conf.config_file end
create(index)
click to toggle source
# File lib/flex/tasks.rb, line 55 def create(index) config_hash[index] = {} unless config_hash.has_key?(index) Flex.POST "/#{index}", config_hash[index] end
delete_index(index)
click to toggle source
# File lib/flex/tasks.rb, line 51 def delete_index(index) Flex.delete_index(:index => index) if exist?(index) end
exist?(index)
click to toggle source
# File lib/flex/tasks.rb, line 43 def exist?(index) Flex.exist?(:index => index) end
indices()
click to toggle source
# File lib/flex/tasks.rb, line 38 def indices i = options[:index] || config_hash.keys i.is_a?(Array) ? i : [i] end