Class: FlyingSphinx::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier = nil, api_key = nil) ⇒ Configuration

Returns a new instance of Configuration.



4
5
6
7
8
9
10
# File 'lib/flying_sphinx/configuration.rb', line 4

def initialize(identifier = nil, api_key = nil)
  @identifier = identifier || identifier_from_env
  @api_key    = api_key    || api_key_from_env

  set_from_server
  setup_environment_settings
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def api_key
  @api_key
end

#database_portObject (readonly)

Returns the value of attribute database_port.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def database_port
  @database_port
end

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def host
  @host
end

#identifierObject (readonly)

Returns the value of attribute identifier.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def identifier
  @identifier
end

#mem_limitObject (readonly)

Returns the value of attribute mem_limit.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def mem_limit
  @mem_limit
end

#portObject (readonly)

Returns the value of attribute port.



2
3
4
# File 'lib/flying_sphinx/configuration.rb', line 2

def port
  @port
end

Instance Method Details

#apiObject



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

def api
  @api ||= FlyingSphinx::API.new(identifier, api_key)
end

#client_keyObject



31
32
33
# File 'lib/flying_sphinx/configuration.rb', line 31

def client_key
  "#{identifier}:#{api_key}"
end

#output_recent_actionsObject



35
36
37
38
39
# File 'lib/flying_sphinx/configuration.rb', line 35

def output_recent_actions
  api.get('actions').body.each do |action|
    puts "#{action.created_at}  #{action.name}"
  end
end

#sphinx_configurationObject



16
17
18
19
20
21
# File 'lib/flying_sphinx/configuration.rb', line 16

def sphinx_configuration
  thinking_sphinx.generate
  set_database_settings

  riddle.render
end

#start_sphinxObject



23
24
25
# File 'lib/flying_sphinx/configuration.rb', line 23

def start_sphinx
  api.post('start')
end

#stop_sphinxObject



27
28
29
# File 'lib/flying_sphinx/configuration.rb', line 27

def stop_sphinx
  api.post('stop')
end