Class: Pennyworth::Processor
- Inherits:
-
Object
- Object
- Pennyworth::Processor
- Defined in:
- lib/pennyworth/processor.rb
Overview
Processes all steps required to render an Alfred Script Filter response.
Class Method Summary collapse
- .for_encodings ⇒ Object
- .for_gems ⇒ Object
- .for_htmx ⇒ Object
- .for_http_statuses ⇒ Object
- .for_projects ⇒ Object
- .for_standard_errors ⇒ Object
- .for_standard_gems ⇒ Object
- .for_system_errors ⇒ Object
- .for_system_signals ⇒ Object
- .for_text ⇒ Object
Instance Method Summary collapse
- #call(content = nil) ⇒ Object
-
#initialize(steps) ⇒ Processor
constructor
A new instance of Processor.
Constructor Details
#initialize(steps) ⇒ Processor
Returns a new instance of Processor.
60 61 62 |
# File 'lib/pennyworth/processor.rb', line 60 def initialize steps @steps = steps end |
Class Method Details
.for_encodings ⇒ Object
6 7 8 9 10 |
# File 'lib/pennyworth/processor.rb', line 6 def self.for_encodings new loader: Loaders::Encoding.new, presenter: Presenters::Encoding, serializer: Serializers::Encoding end |
.for_gems ⇒ Object
12 13 14 |
# File 'lib/pennyworth/processor.rb', line 12 def self.for_gems new loader: Loaders::Gem.new, presenter: Presenters::Gem, serializer: Serializers::Project end |
.for_htmx ⇒ Object
22 23 24 |
# File 'lib/pennyworth/processor.rb', line 22 def self.for_htmx new loader: Loaders::HTMX.new, presenter: Presenters::HTMX, serializer: Serializers::HTMX end |
.for_http_statuses ⇒ Object
16 17 18 19 20 |
# File 'lib/pennyworth/processor.rb', line 16 def self.for_http_statuses new loader: Loaders::HTTPStatus.new, presenter: Presenters::HTTPStatus, serializer: Serializers::HTTPStatus end |
.for_projects ⇒ Object
26 27 28 29 30 |
# File 'lib/pennyworth/processor.rb', line 26 def self.for_projects new loader: Loaders::GitHub.new, presenter: Presenters::Repository, serializer: Serializers::Project end |
.for_standard_errors ⇒ Object
38 39 40 41 42 |
# File 'lib/pennyworth/processor.rb', line 38 def self.for_standard_errors new loader: Loaders::StandardError.new, presenter: Presenters::StandardError, serializer: Serializers::StandardError end |
.for_standard_gems ⇒ Object
32 33 34 35 36 |
# File 'lib/pennyworth/processor.rb', line 32 def self.for_standard_gems new loader: Loaders::StandardGem.new, presenter: Presenters::StandardGem, serializer: Serializers::Project end |
.for_system_errors ⇒ Object
44 45 46 47 48 |
# File 'lib/pennyworth/processor.rb', line 44 def self.for_system_errors new loader: Loaders::System::Error.new, presenter: Presenters::System::Error, serializer: Serializers::System::Error end |
.for_system_signals ⇒ Object
50 51 52 53 54 |
# File 'lib/pennyworth/processor.rb', line 50 def self.for_system_signals new loader: Loaders::System::Signal.new, presenter: Presenters::System::Signal, serializer: Serializers::System::Signal end |
.for_text ⇒ Object
56 57 58 |
# File 'lib/pennyworth/processor.rb', line 56 def self.for_text new loader: Loaders::Text.new, presenter: Presenters::Text, serializer: Serializers::Text end |
Instance Method Details
#call(content = nil) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/pennyworth/processor.rb', line 64 def call content = nil loader.call(content) .map { |record| presenter.new record } .sort_by(&:label) .map { |record| serializer.new record } .then { |records| {items: records.map(&:to_h)} } end |