Class: ChupaText::Command::ChupaText

Inherits:
Object
  • Object
show all
Defined in:
lib/chupa-text/command/chupa-text.rb

Constant Summary collapse

AVAILABLE_FORMATS =
[:json, :text, :mime]
SIZE =
/\A\d+x\d+\z/o

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChupaText

Returns a new instance of ChupaText.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chupa-text/command/chupa-text.rb', line 42

def initialize
  @input = nil
  @configuration = Configuration.load_default
  @enable_gems = true
  @uri = nil
  @mime_type = nil
  @format = :json
  @mime_formatter_options = {}
  @need_screenshot = true
  @expected_screenshot_size = [200, 200]
  @max_body_size = nil
end

Class Method Details

.run(*arguments) ⇒ Object



23
24
25
26
# File 'lib/chupa-text/command/chupa-text.rb', line 23

def run(*arguments)
  chupa_text = new
  chupa_text.run(*arguments)
end

Instance Method Details

#run(*arguments) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/chupa-text/command/chupa-text.rb', line 55

def run(*arguments)
  return false unless parse_arguments(arguments)

  load_decomposers
  extractor = create_extractor
  data = create_data
  formatter = create_formatter
  formatter.format_start(data)
  extractor.extract(data) do |extracted|
    formatter.format_extracted(extracted)
  end
  formatter.format_finish(data)
  true
end