Class: FlyingSphinx::Configurer
- Inherits:
-
Object
- Object
- FlyingSphinx::Configurer
- Defined in:
- lib/flying_sphinx/configurer.rb
Constant Summary collapse
- InvalidVersionError =
Class.new FlyingSphinx::Error
- PresignatureError =
Class.new FlyingSphinx::Error
- UploadError =
Class.new FlyingSphinx::Error
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(api, input = nil) ⇒ Configurer
constructor
A new instance of Configurer.
Constructor Details
#initialize(api, input = nil) ⇒ Configurer
Returns a new instance of Configurer.
12 13 14 15 |
# File 'lib/flying_sphinx/configurer.rb', line 12 def initialize(api, input = nil) @api = api @input = input end |
Class Method Details
.call(api, input = nil) ⇒ Object
8 9 10 |
# File 'lib/flying_sphinx/configurer.rb', line 8 def self.call(api, input = nil) new(api, input).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flying_sphinx/configurer.rb', line 17 def call if invalid_version? raise InvalidVersionError, "Unknown Sphinx engine/version: #{config.engine}-#{config.version}" end if presignature["status"] != "OK" raise PresignatureError, "Requesting presignature failed" end response = connection.post "", fields.merge( "file" => Faraday::UploadIO.new(file, 'application/gzip', 'sphinx.tar.gz') ) if response.status == 200 presignature["path"] else raise UploadError, "Uploading configuration failed" end end |