pennyworth 10.0.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.adoc +209 -30
- data/bin/pennyworth +1 -3
- data/lib/pennyworth.rb +11 -2
- data/lib/pennyworth/cli/actions/config.rb +35 -0
- data/lib/pennyworth/cli/actions/encodings.rb +23 -0
- data/lib/pennyworth/cli/actions/git_hub.rb +27 -0
- data/lib/pennyworth/cli/actions/http_statuses.rb +23 -0
- data/lib/pennyworth/cli/actions/ruby_gems.rb +27 -0
- data/lib/pennyworth/cli/actions/system/errors.rb +25 -0
- data/lib/pennyworth/cli/actions/system/signals.rb +25 -0
- data/lib/pennyworth/cli/actions/text.rb +23 -0
- data/lib/pennyworth/cli/configuration/content.rb +28 -0
- data/lib/pennyworth/cli/configuration/defaults.yml +25 -0
- data/lib/pennyworth/cli/configuration/loader.rb +37 -0
- data/lib/pennyworth/cli/parsers.rb +11 -0
- data/lib/pennyworth/cli/parsers/assembler.rb +32 -0
- data/lib/pennyworth/cli/parsers/core.rb +100 -0
- data/lib/pennyworth/cli/parsers/git_hub.rb +51 -0
- data/lib/pennyworth/cli/parsers/ruby_gems.rb +35 -0
- data/lib/pennyworth/cli/shell.rb +82 -0
- data/lib/pennyworth/container.rb +40 -0
- data/lib/pennyworth/identity.rb +2 -1
- data/lib/pennyworth/inflector.rb +18 -0
- data/lib/pennyworth/integrations/git_hub/client.rb +59 -0
- data/lib/pennyworth/integrations/git_hub/response.rb +33 -0
- data/lib/pennyworth/integrations/ruby_gems/client.rb +29 -0
- data/lib/pennyworth/loaders/encodings.rb +31 -0
- data/lib/pennyworth/loaders/http_statuses.rb +28 -0
- data/lib/pennyworth/loaders/projects.rb +22 -0
- data/lib/pennyworth/loaders/system/errors.rb +33 -0
- data/lib/pennyworth/loaders/system/signals.rb +21 -0
- data/lib/pennyworth/loaders/text.rb +27 -0
- data/lib/pennyworth/models/encoding.rb +8 -0
- data/lib/pennyworth/models/http_status.rb +8 -0
- data/lib/pennyworth/models/system/error.rb +10 -0
- data/lib/pennyworth/models/system/signal.rb +10 -0
- data/lib/pennyworth/models/text.rb +8 -0
- data/lib/pennyworth/presenters/encoding.rb +22 -0
- data/lib/pennyworth/presenters/gem.rb +48 -0
- data/lib/pennyworth/presenters/http_status.rb +41 -0
- data/lib/pennyworth/presenters/repository.rb +35 -0
- data/lib/pennyworth/presenters/system/error.rb +28 -0
- data/lib/pennyworth/presenters/system/signal.rb +22 -0
- data/lib/pennyworth/presenters/text.rb +25 -0
- data/lib/pennyworth/processor.rb +68 -0
- data/lib/pennyworth/serializers/encoding.rb +33 -0
- data/lib/pennyworth/serializers/http_status.rb +41 -0
- data/lib/pennyworth/serializers/project.rb +52 -0
- data/lib/pennyworth/serializers/system/error.rb +46 -0
- data/lib/pennyworth/serializers/system/signal.rb +40 -0
- data/lib/pennyworth/serializers/text.rb +31 -0
- metadata +110 -19
- metadata.gz.sig +2 -2
- data/lib/pennyworth/cli.rb +0 -140
- data/lib/pennyworth/templates/workflows/user.workflow.B59B22A2-1880-4765-9358-412791BE9202/icon.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.B59B22A2-1880-4765-9358-412791BE9202/info.plist +0 -159
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/icon.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/info.plist +0 -272
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-camelcase.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-capitalize.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-lowercase.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-size.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-snakecase.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-titleize.png +0 -0
- data/lib/pennyworth/templates/workflows/user.workflow.C431E56A-0EC2-47EE-94D5-D67D9FE323BE/string-uppercase.png +0 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "refinements/strings"
|
4
|
+
|
5
|
+
module Pennyworth
|
6
|
+
module Presenters
|
7
|
+
# Renders RubyGems records into a compatible format for use in Alfred script filters.
|
8
|
+
class Gem
|
9
|
+
using Refinements::Strings
|
10
|
+
|
11
|
+
def initialize record, inflector: Inflector.new
|
12
|
+
@record = record
|
13
|
+
@inflector = inflector
|
14
|
+
end
|
15
|
+
|
16
|
+
def id = record.fetch(:name)
|
17
|
+
|
18
|
+
def label = inflector.call(id.titleize)
|
19
|
+
|
20
|
+
def subtitle
|
21
|
+
"Version: #{version}. " \
|
22
|
+
"Updated: #{updated_at[..9]}. " \
|
23
|
+
"Licenses: #{licenses}. " \
|
24
|
+
"Downloads: #{downloads}."
|
25
|
+
end
|
26
|
+
|
27
|
+
def version = record.fetch(__method__)
|
28
|
+
|
29
|
+
def licenses = record.fetch(__method__).join(", ")
|
30
|
+
|
31
|
+
def downloads = record.fetch(__method__)
|
32
|
+
|
33
|
+
def site_url = record.fetch(:homepage_uri)
|
34
|
+
|
35
|
+
def source_url = record.fetch(:source_code_uri)
|
36
|
+
|
37
|
+
def changes_url = record.fetch(:changelog_uri)
|
38
|
+
|
39
|
+
def issues_url = record.fetch(:bug_tracker_uri)
|
40
|
+
|
41
|
+
def updated_at = record.fetch(:version_created_at)
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
attr_reader :record, :inflector
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
require "refinements/strings"
|
5
|
+
|
6
|
+
module Pennyworth
|
7
|
+
module Presenters
|
8
|
+
# Renders system error into a compatible format for use in Alfred script filters.
|
9
|
+
class HTTPStatus
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
using Refinements::Strings
|
13
|
+
|
14
|
+
delegate %i[code label url] => :record
|
15
|
+
|
16
|
+
def initialize record, inflector: Inflector.new
|
17
|
+
@record = record
|
18
|
+
@inflector = inflector
|
19
|
+
end
|
20
|
+
|
21
|
+
def id = record.code
|
22
|
+
|
23
|
+
def subtitle = "#{id} #{label}"
|
24
|
+
|
25
|
+
def symbol = ":#{inflector.call name}"
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :record, :inflector
|
30
|
+
|
31
|
+
def name
|
32
|
+
label.snakecase
|
33
|
+
.tr("/", "_")
|
34
|
+
.gsub(/(\(|\))/, "")
|
35
|
+
.sub("h_t_t_p_version_not_supported", "http_version_not_supported")
|
36
|
+
.sub("i_m_used", "im_used")
|
37
|
+
.sub("u_r_i_too_long", "uri_too_long")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "refinements/strings"
|
4
|
+
|
5
|
+
module Pennyworth
|
6
|
+
module Presenters
|
7
|
+
# Renders a GitHub repository record into a compatible format for use in Alfred script filters.
|
8
|
+
class Repository
|
9
|
+
using Refinements::Strings
|
10
|
+
|
11
|
+
def initialize record, inflector: Inflector.new
|
12
|
+
@record = record
|
13
|
+
@inflector = inflector
|
14
|
+
end
|
15
|
+
|
16
|
+
def id = record.fetch(:name)
|
17
|
+
|
18
|
+
def label = inflector.call(id.titleize)
|
19
|
+
|
20
|
+
def subtitle = record.fetch(:description)
|
21
|
+
|
22
|
+
def site_url = record.fetch(:homepage)
|
23
|
+
|
24
|
+
def source_url = record.fetch(:html_url)
|
25
|
+
|
26
|
+
def changes_url = "#{site_url}/changes.html"
|
27
|
+
|
28
|
+
def issues_url = "#{source_url}/issues"
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :record, :inflector
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module Pennyworth
|
6
|
+
module Presenters
|
7
|
+
module System
|
8
|
+
# Renders system error into a compatible format for use in Alfred script filters.
|
9
|
+
class Error
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
delegate %i[id description] => :record
|
13
|
+
|
14
|
+
def initialize record
|
15
|
+
@record = record
|
16
|
+
end
|
17
|
+
|
18
|
+
def label = record.name
|
19
|
+
|
20
|
+
def subtitle = "#{label}: #{description}."
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :record
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Presenters
|
5
|
+
module System
|
6
|
+
# Renders strings into a compatible format for use in Alfred script filters.
|
7
|
+
class Signal
|
8
|
+
def initialize record
|
9
|
+
@record = record
|
10
|
+
end
|
11
|
+
|
12
|
+
def id = record.number
|
13
|
+
|
14
|
+
def label = record.name
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :record
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module Pennyworth
|
6
|
+
module Presenters
|
7
|
+
# Renders text into a compatible format for use in Alfred script filters.
|
8
|
+
class Text
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
delegate %i[id content] => :record
|
12
|
+
|
13
|
+
def initialize record, inflector: Inflector.new
|
14
|
+
@record = record
|
15
|
+
@inflector = inflector
|
16
|
+
end
|
17
|
+
|
18
|
+
def label = inflector.call(record.content.to_s)
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :record, :inflector
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
# Processes all steps required to render an Alfred Script Filter response.
|
5
|
+
class Processor
|
6
|
+
def self.for_encodings
|
7
|
+
new loader: Loaders::Encodings.new,
|
8
|
+
presenter: Presenters::Encoding,
|
9
|
+
serializer: Serializers::Encoding
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.for_gems
|
13
|
+
new loader: Loaders::Projects.for_ruby_gems,
|
14
|
+
presenter: Presenters::Gem,
|
15
|
+
serializer: Serializers::Project
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.for_http_statuses
|
19
|
+
new loader: Loaders::HTTPStatuses.new,
|
20
|
+
presenter: Presenters::HTTPStatus,
|
21
|
+
serializer: Serializers::HTTPStatus
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.for_projects
|
25
|
+
new loader: Loaders::Projects.for_git_hub,
|
26
|
+
presenter: Presenters::Repository,
|
27
|
+
serializer: Serializers::Project
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.for_system_signals
|
31
|
+
new loader: Loaders::System::Signals.new,
|
32
|
+
presenter: Presenters::System::Signal,
|
33
|
+
serializer: Serializers::System::Signal
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.for_system_errors
|
37
|
+
new loader: Loaders::System::Errors.new,
|
38
|
+
presenter: Presenters::System::Error,
|
39
|
+
serializer: Serializers::System::Error
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.for_text
|
43
|
+
new loader: Loaders::Text.new, presenter: Presenters::Text, serializer: Serializers::Text
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize steps
|
47
|
+
@steps = steps
|
48
|
+
end
|
49
|
+
|
50
|
+
def call content = nil
|
51
|
+
loader.call(content)
|
52
|
+
.map { |record| presenter.new record }
|
53
|
+
.sort_by(&:label)
|
54
|
+
.map { |record| serializer.new record }
|
55
|
+
.then { |records| {items: records.map(&:to_h)} }
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
attr_reader :steps
|
61
|
+
|
62
|
+
def loader = steps.fetch(__method__)
|
63
|
+
|
64
|
+
def presenter = steps.fetch(__method__)
|
65
|
+
|
66
|
+
def serializer = steps.fetch(__method__)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Serializers
|
5
|
+
# Serializes a encoding into a compatible format for parsing within Alfred script filters.
|
6
|
+
class Encoding
|
7
|
+
def initialize presenter
|
8
|
+
@presenter = presenter
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_h
|
12
|
+
{
|
13
|
+
uid: presenter.id,
|
14
|
+
title: label,
|
15
|
+
subtitle: %(Aliases: #{aliases}.),
|
16
|
+
arg: label,
|
17
|
+
mods: {
|
18
|
+
alt: {subtitle: "Copy aliases.", arg: aliases}
|
19
|
+
},
|
20
|
+
text: {copy: label, largetype: label}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :presenter
|
27
|
+
|
28
|
+
def label = presenter.label
|
29
|
+
|
30
|
+
def aliases = presenter.aliases.join(", ")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Serializers
|
5
|
+
# Serializes a HTTP status into a compatible format for parsing within Alfred script filters.
|
6
|
+
class HTTPStatus
|
7
|
+
def initialize presenter
|
8
|
+
@presenter = presenter
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_h
|
12
|
+
{
|
13
|
+
uid: id,
|
14
|
+
title: code,
|
15
|
+
subtitle: label,
|
16
|
+
arg: presenter.symbol,
|
17
|
+
mods: modifications,
|
18
|
+
text: {copy: "#{code} #{label}", largetype: "#{code} #{label}"}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :presenter
|
25
|
+
|
26
|
+
def id = presenter.id
|
27
|
+
|
28
|
+
def code = presenter.code
|
29
|
+
|
30
|
+
def label = presenter.label
|
31
|
+
|
32
|
+
def modifications
|
33
|
+
{
|
34
|
+
control: {subtitle: "Copy code.", arg: id},
|
35
|
+
alt: {subtitle: "Copy label.", arg: label},
|
36
|
+
cmd: {subtitle: "View documentation.", arg: presenter.url}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Serializers
|
5
|
+
# Serializes a project into a compatible format for parsing within Alfred script filters.
|
6
|
+
class Project
|
7
|
+
def initialize presenter
|
8
|
+
@presenter = presenter
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_h
|
12
|
+
{
|
13
|
+
uid: presenter.id,
|
14
|
+
title: presenter.label,
|
15
|
+
subtitle: presenter.subtitle,
|
16
|
+
arg: site_url,
|
17
|
+
quicklookurl: site_url,
|
18
|
+
mods: modifications,
|
19
|
+
text: text
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :presenter
|
26
|
+
|
27
|
+
def modifications
|
28
|
+
{
|
29
|
+
control: modification(presenter.changes_url, "View changes."),
|
30
|
+
alt: modification(presenter.source_url, "View source."),
|
31
|
+
cmd: modification(presenter.issues_url, "View issues.")
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def modification argument, subtitle
|
36
|
+
{
|
37
|
+
subtitle: subtitle,
|
38
|
+
arg: argument
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def text
|
43
|
+
{
|
44
|
+
copy: site_url,
|
45
|
+
largetype: site_url
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def site_url = presenter.site_url
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Serializers
|
5
|
+
module System
|
6
|
+
# Serializes a system error into a compatible format for parsing within Alfred script filters.
|
7
|
+
class Error
|
8
|
+
def initialize presenter
|
9
|
+
@presenter = presenter
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
{
|
14
|
+
uid: id,
|
15
|
+
title: id,
|
16
|
+
subtitle: presenter.subtitle,
|
17
|
+
arg: label,
|
18
|
+
mods: modifications,
|
19
|
+
text: {copy: label, largetype: label}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :presenter
|
26
|
+
|
27
|
+
def id = presenter.id
|
28
|
+
|
29
|
+
def label = presenter.label
|
30
|
+
|
31
|
+
def description = presenter.description
|
32
|
+
|
33
|
+
def modifications
|
34
|
+
{
|
35
|
+
control: {subtitle: "Copy ID.", arg: id},
|
36
|
+
alt: {subtitle: "Copy description.", arg: description},
|
37
|
+
cmd: {
|
38
|
+
subtitle: "Copy ID, name, and description.",
|
39
|
+
arg: "#{id}, #{label}, #{description}"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|