Module: Summarize
- Defined in:
- lib/summarize.rb,
lib/summarize/client.rb,
lib/summarize/errors.rb,
lib/summarize/result.rb,
lib/summarize/options.rb,
lib/summarize/version.rb,
lib/summarize/configuration.rb
Defined Under Namespace
Classes: BinaryNotFoundError, Client, CommandError, Configuration, Error, ExtractionError, Options, Result, SummarizationError, TimeoutError, VersionMismatchError
Constant Summary collapse
- VERSION =
"0.3.0"- MINIMUM_CLI_VERSION =
"0.11.1"
Class Attribute Summary collapse
Class Method Summary collapse
-
.call(input, **opts, &block) ⇒ Object
Convenience method: summarize a URL or file path.
-
.check_version! ⇒ Object
Eagerly check CLI version.
- .configure {|configuration| ... } ⇒ Object
-
.extract(input, **opts) ⇒ Object
Convenience method: extract content without summarization.
-
.from_text(text, **opts, &block) ⇒ Object
Convenience method: summarize text content.
- .reset_configuration! ⇒ Object
Class Attribute Details
.configuration ⇒ Object
14 15 16 |
# File 'lib/summarize.rb', line 14 def configuration @configuration ||= Configuration.new end |
Class Method Details
.call(input, **opts, &block) ⇒ Object
Convenience method: summarize a URL or file path.
Summarize.call("https://example.com", length: :short)
30 31 32 |
# File 'lib/summarize.rb', line 30 def call(input, **opts, &block) Client.new.call(input, **opts, &block) end |
.check_version! ⇒ Object
Eagerly check CLI version. Returns the version string or raises VersionMismatchError / BinaryNotFoundError.
Summarize.check_version! # => "0.10.0"
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/summarize.rb', line 55 def check_version! config = configuration path = config.binary_path unless path == "summarize" || File.executable?(path) raise BinaryNotFoundError, path end installed = config.cli_version required = MINIMUM_CLI_VERSION if installed && Gem::Version.new(installed) < Gem::Version.new(required) raise VersionMismatchError.new(installed, required) end installed end |
.configure {|configuration| ... } ⇒ Object
18 19 20 |
# File 'lib/summarize.rb', line 18 def configure yield(configuration) end |
.extract(input, **opts) ⇒ Object
Convenience method: extract content without summarization.
Summarize.extract("https://example.com", format: :md)
46 47 48 |
# File 'lib/summarize.rb', line 46 def extract(input, **opts) Client.new.extract(input, **opts) end |
.from_text(text, **opts, &block) ⇒ Object
Convenience method: summarize text content.
Summarize.from_text("Long text...", length: :medium)
38 39 40 |
# File 'lib/summarize.rb', line 38 def from_text(text, **opts, &block) Client.new.from_text(text, **opts, &block) end |
.reset_configuration! ⇒ Object
22 23 24 |
# File 'lib/summarize.rb', line 22 def reset_configuration! @configuration = Configuration.new end |