Module: Khoj

Defined in:
lib/khoj.rb,
lib/khoj/index.rb,
lib/khoj/client.rb,
lib/khoj/version.rb,
lib/khoj/function.rb,
lib/khoj/configuration.rb

Defined Under Namespace

Modules: Index Classes: Client, Configuration, Function, KhojException

Constant Summary collapse

VERSION =
"0.0.1"
@@clients =
{}
@@functions =
{}

Class Method Summary collapse

Class Method Details

.client(index) ⇒ Object



37
38
39
# File 'lib/khoj.rb', line 37

def self.client(index)
  @@clients[index] ||= Client.new(index)
end

.config {|Configuration| ... } ⇒ Object

Yields:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/khoj.rb', line 19

def self.config(&block)
  yield Configuration

  unless Configuration.api_host
    Configuration.api_host = Configuration::DEFAULTS[:api_host]
  end

  if Configuration.api_key.nil? or Configuration.api_key.strip.empty?
    Configuration.valid = false
    raise KhojException.new('api key is nil.')
  end

  Configuration.valid = true
  #Configuration.freeze
end

.function(index) ⇒ Object



43
44
45
# File 'lib/khoj.rb', line 43

def self.function(index)
  @@functions[index] ||= Function.new(index)
end