assistant 0.0.1 → 0.1.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
- data/.editorconfig +13 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ci.yml +41 -0
- data/.github/workflows/release.yml +46 -0
- data/.gitignore +2 -0
- data/.markdownlint.json +6 -0
- data/.rubocop.yml +36 -99
- data/.rubocop_todo.yml +7 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +56 -0
- data/Gemfile.lock +99 -64
- data/Rakefile +11 -4
- data/assistant.gemspec +24 -27
- data/bin/console +3 -3
- data/bin/version +14 -9
- data/lib/assistant/input_builder.rb +84 -0
- data/lib/assistant/log_item.rb +49 -0
- data/lib/assistant/log_list.rb +26 -0
- data/lib/assistant/refinements/string_blankness.rb +18 -0
- data/lib/assistant/service.rb +50 -3
- data/lib/assistant/service.rbs +5 -0
- data/lib/assistant/version.rb +1 -1
- data/lib/assistant.rb +3 -1
- data/mise.toml +4 -0
- metadata +60 -60
- data/.rspec +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5c9349088dd10a8a058d3d95c0fb80217f5ac5abd2a7bded0e2d19018baf1fb
|
|
4
|
+
data.tar.gz: e8494d003e8a5cfe35da752c9234f6635db669f0529a941bef551ae143096c79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d336fd45017b3d6446bb1dd5d4f697ad3ee962295761201521dc15a8b423da336d1d9ab0eecd0d04c0486db9c2886c3e5c49cd845581bad67f1bee8131758a20
|
|
7
|
+
data.tar.gz: 68153612bb94532f476072fc7b326eeb392248cd6161fccdcf654315c36b437e4f1c4e90f78d3d13fb15da3e87ecae2182161e94f263f820d30a0c7cb4599a20
|
data/.editorconfig
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*]
|
|
7
|
+
indent_style = space
|
|
8
|
+
indent_size = 2
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
charset = utf-8
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
insert_final_newline = true
|
|
13
|
+
quote_type = single
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
- package-ecosystem: "github-actions"
|
|
13
|
+
directory: "/"
|
|
14
|
+
schedule:
|
|
15
|
+
interval: "weekly"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
# Default to least privilege; jobs may opt into more.
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
name: Minitest (Ruby ${{ matrix.ruby }})
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
ruby: ['3.4', '4.0']
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: bundle exec rake test
|
|
30
|
+
|
|
31
|
+
rubocop:
|
|
32
|
+
name: RuboCop
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: ruby/setup-ruby@v1
|
|
37
|
+
with:
|
|
38
|
+
ruby-version: '4.0'
|
|
39
|
+
bundler-cache: true
|
|
40
|
+
- name: Run RuboCop
|
|
41
|
+
run: bundle exec rubocop --parallel
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Release
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- 'v*.*.*'
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
# Default to least privilege; the release job opts into the perms it needs.
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
release:
|
|
16
|
+
name: Build and publish gem
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
environment: rubygems
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
id-token: write
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: '4.0'
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Run tests before publishing
|
|
30
|
+
run: bundle exec rake test
|
|
31
|
+
|
|
32
|
+
- name: Configure trusted publishing
|
|
33
|
+
uses: rubygems/configure-rubygems-credentials@v1.0.0
|
|
34
|
+
|
|
35
|
+
- name: Build gem
|
|
36
|
+
run: gem build assistant.gemspec
|
|
37
|
+
|
|
38
|
+
- name: Push gem to RubyGems
|
|
39
|
+
run: gem push assistant-*.gem
|
|
40
|
+
|
|
41
|
+
- name: Create GitHub Release
|
|
42
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
43
|
+
uses: softprops/action-gh-release@v2
|
|
44
|
+
with:
|
|
45
|
+
generate_release_notes: true
|
|
46
|
+
files: assistant-*.gem
|
data/.gitignore
CHANGED
data/.markdownlint.json
ADDED
data/.rubocop.yml
CHANGED
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
plugins:
|
|
4
4
|
- rubocop-performance
|
|
5
|
-
- rubocop-
|
|
6
|
-
|
|
5
|
+
- rubocop-minitest
|
|
6
|
+
|
|
7
|
+
require:
|
|
8
|
+
- rubocop-rake
|
|
7
9
|
|
|
8
10
|
AllCops:
|
|
9
11
|
NewCops: enable
|
|
12
|
+
TargetRubyVersion: 3.4
|
|
13
|
+
SuggestExtensions: false
|
|
10
14
|
Exclude:
|
|
11
15
|
- 'vendor/**/*'
|
|
12
|
-
- 'spec/fixtures/**/*'
|
|
13
16
|
- 'tmp/**/*'
|
|
14
17
|
- '.git/**/*'
|
|
15
18
|
- 'bin/*'
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
- 'Gemfile.lock'
|
|
20
|
+
|
|
21
|
+
Gemspec/DevelopmentDependencies:
|
|
22
|
+
EnforcedStyle: gemspec
|
|
23
|
+
|
|
24
|
+
Gemspec/DependencyVersion:
|
|
25
|
+
Enabled: true
|
|
18
26
|
|
|
19
|
-
Naming/
|
|
20
|
-
# Method define macros for dynamically generated method.
|
|
27
|
+
Naming/PredicatePrefix:
|
|
21
28
|
MethodDefinitionMacros:
|
|
22
29
|
- define_method
|
|
23
30
|
- define_singleton_method
|
|
24
|
-
- def_node_matcher
|
|
25
|
-
- def_node_search
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
# Tests use simple `def execute = true` to fabricate services; the boolean
|
|
33
|
+
# return doesn't make these predicate methods.
|
|
34
|
+
Naming/PredicateMethod:
|
|
28
35
|
Exclude:
|
|
29
|
-
-
|
|
30
|
-
- lib/rubocop/cop/offense.rb
|
|
31
|
-
|
|
32
|
-
Style/FormatStringToken:
|
|
33
|
-
# Because we parse a lot of source codes from strings. Percent arrays
|
|
34
|
-
# look like unannotated format string tokens to this cop.
|
|
35
|
-
Exclude:
|
|
36
|
-
- spec/**/*
|
|
37
|
-
|
|
38
|
-
Style/IpAddresses:
|
|
39
|
-
# The test for this cop includes strings that would cause offenses
|
|
40
|
-
Exclude:
|
|
41
|
-
- spec/rubocop/cop/style/ip_addresses_spec.rb
|
|
36
|
+
- 'test/**/*.rb'
|
|
42
37
|
|
|
43
38
|
Layout/EndOfLine:
|
|
44
39
|
EnforcedStyle: lf
|
|
@@ -49,13 +44,6 @@ Layout/ClassStructure:
|
|
|
49
44
|
Layout/RedundantLineBreak:
|
|
50
45
|
Enabled: true
|
|
51
46
|
|
|
52
|
-
Layout/TrailingWhitespace:
|
|
53
|
-
AllowInHeredoc: false
|
|
54
|
-
|
|
55
|
-
Lint/AmbiguousBlockAssociation:
|
|
56
|
-
Exclude:
|
|
57
|
-
- 'spec/**/*.rb'
|
|
58
|
-
|
|
59
47
|
Layout/HashAlignment:
|
|
60
48
|
EnforcedHashRocketStyle:
|
|
61
49
|
- key
|
|
@@ -66,83 +54,32 @@ Layout/HashAlignment:
|
|
|
66
54
|
|
|
67
55
|
Layout/LineLength:
|
|
68
56
|
Max: 120
|
|
69
|
-
IgnoredPatterns:
|
|
70
|
-
- !ruby/regexp /\A +(it|describe|context|shared_examples|include_examples|it_behaves_like) ["']/
|
|
71
|
-
|
|
72
|
-
Lint/InterpolationCheck:
|
|
73
|
-
Exclude:
|
|
74
|
-
- 'spec/**/*.rb'
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- 'def_matcher'
|
|
79
|
-
- 'def_node_matcher'
|
|
58
|
+
Style/RequireOrder:
|
|
59
|
+
Enabled: true
|
|
80
60
|
|
|
61
|
+
# Test files use anonymous Class.new(...) blocks and dynamic define_method,
|
|
62
|
+
# which inflates length/metrics counts that don't reflect real complexity.
|
|
81
63
|
Metrics/BlockLength:
|
|
82
64
|
Exclude:
|
|
83
65
|
- 'Rakefile'
|
|
84
66
|
- '**/*.rake'
|
|
85
|
-
- '
|
|
67
|
+
- 'test/**/*.rb'
|
|
86
68
|
- '**/*.gemspec'
|
|
87
69
|
|
|
88
70
|
Metrics/ClassLength:
|
|
89
71
|
Exclude:
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
Metrics/ModuleLength:
|
|
93
|
-
Exclude:
|
|
94
|
-
- 'spec/**/*.rb'
|
|
95
|
-
|
|
96
|
-
Naming/InclusiveLanguage:
|
|
97
|
-
FlaggedTerms:
|
|
98
|
-
offence:
|
|
99
|
-
Suggestions:
|
|
100
|
-
- offense
|
|
101
|
-
Exclude:
|
|
102
|
-
- lib/rubocop/cop/naming/inclusive_language.rb
|
|
103
|
-
|
|
104
|
-
RSpec/FilePath:
|
|
105
|
-
Exclude:
|
|
106
|
-
- spec/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new_spec.rb
|
|
107
|
-
- spec/rubocop/formatter/junit_formatter_spec.rb
|
|
108
|
-
|
|
109
|
-
RSpec/PredicateMatcher:
|
|
110
|
-
EnforcedStyle: explicit
|
|
111
|
-
|
|
112
|
-
RSpec/MessageSpies:
|
|
113
|
-
EnforcedStyle: receive
|
|
72
|
+
- 'test/**/*.rb'
|
|
114
73
|
|
|
115
|
-
|
|
116
|
-
Max: 7
|
|
117
|
-
|
|
118
|
-
RSpec/MultipleMemoizedHelpers:
|
|
119
|
-
Enabled: false
|
|
120
|
-
|
|
121
|
-
Performance/CollectionLiteralInLoop:
|
|
74
|
+
Metrics/MethodLength:
|
|
122
75
|
Exclude:
|
|
123
|
-
- '
|
|
124
|
-
- 'spec/**/*.rb'
|
|
125
|
-
|
|
126
|
-
Performance/EndWith:
|
|
127
|
-
SafeMultiline: false
|
|
128
|
-
|
|
129
|
-
Performance/StartWith:
|
|
130
|
-
SafeMultiline: false
|
|
76
|
+
- 'test/**/*.rb'
|
|
131
77
|
|
|
132
|
-
|
|
133
|
-
|
|
78
|
+
Naming/MethodParameterName:
|
|
79
|
+
AllowedNames:
|
|
80
|
+
- a
|
|
81
|
+
- b
|
|
82
|
+
- c
|
|
134
83
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
- 'spec/rubocop/cop/**/*.rb'
|
|
138
|
-
|
|
139
|
-
InternalAffairs/UndefinedConfig:
|
|
140
|
-
Include:
|
|
141
|
-
- 'lib/rubocop/cop/**/*.rb'
|
|
142
|
-
Exclude:
|
|
143
|
-
- 'lib/rubocop/cop/correctors/**/*.rb'
|
|
144
|
-
- 'lib/rubocop/cop/mixin/**/*.rb'
|
|
145
|
-
|
|
146
|
-
InternalAffairs/StyleDetectedApiUse:
|
|
147
|
-
Exclude:
|
|
148
|
-
- 'lib/rubocop/cop/mixin/percent_array.rb'
|
|
84
|
+
Minitest/MultipleAssertions:
|
|
85
|
+
Max: 8
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 20000`
|
|
3
|
+
# on 2023-11-27 19:58:04 UTC using RuboCop version 1.57.2.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.4.1
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD043 -->
|
|
2
|
+
# Changelog
|
|
3
|
+
|
|
4
|
+
All notable changes to this project will be documented in this file.
|
|
5
|
+
|
|
6
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
## [0.1.0] - 2026-05-07
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `LogList#log_item_error_initialize` helper, used by `InputBuilder`-generated
|
|
16
|
+
validators (previously redefined on every `input` declaration).
|
|
17
|
+
- GitHub Actions CI workflow (`.github/workflows/ci.yml`) running Minitest and
|
|
18
|
+
RuboCop.
|
|
19
|
+
- GitHub Actions release workflow (`.github/workflows/release.yml`) using
|
|
20
|
+
RubyGems trusted publishing (OIDC) on `v*.*.*` tags.
|
|
21
|
+
- Direct test coverage for `LogList#warnings`, `#errors`, `#merge_logs`,
|
|
22
|
+
`Service#success?`, `#failure?`, `#status`, `#result` memoization,
|
|
23
|
+
conditional requirement behavior, the `inputs(...)` plural DSL form, and
|
|
24
|
+
`LogItem#trace`/`#item`.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Standardized on Ruby 3.4 (`.ruby-version`, gemspec `required_ruby_version`,
|
|
29
|
+
RuboCop `TargetRubyVersion`).
|
|
30
|
+
- `InputBuilder` no longer requires `active_support`; the previous use of
|
|
31
|
+
`Object#present?` is replaced with plain Ruby checks. Whitespace-only
|
|
32
|
+
strings continue to be treated as missing via a scoped
|
|
33
|
+
`Assistant::Refinements::StringBlankness` refinement that adds
|
|
34
|
+
`String#whitespace?` and is activated inside `InputBuilder`. The method is
|
|
35
|
+
intentionally named to avoid colliding with ActiveSupport's `String#blank?`.
|
|
36
|
+
- `assistant.gemspec` `changelog_uri` now points at `CHANGELOG.md` instead of
|
|
37
|
+
`CODE_OF_CONDUCT.md`.
|
|
38
|
+
- Migrated the test suite from RSpec to Minitest (`test/**/*_test.rb`),
|
|
39
|
+
exposed via `rake test` (the new default rake task).
|
|
40
|
+
- Replaced the largely-dead RuboCop config (a fork of RuboCop's own internal
|
|
41
|
+
config) with a focused configuration for this gem; `rubocop-rspec` is
|
|
42
|
+
replaced with `rubocop-minitest`.
|
|
43
|
+
|
|
44
|
+
### Removed
|
|
45
|
+
|
|
46
|
+
- CircleCI configuration (`.circleci/`); replaced by GitHub Actions.
|
|
47
|
+
- Dead `@keys = []` instance variable in `Assistant::Service#initialize`.
|
|
48
|
+
- `active_support` and `active_support/core_ext/object` requires from
|
|
49
|
+
`lib/assistant/input_builder.rb`.
|
|
50
|
+
- RSpec, FactoryBot, Faker, `rspec-collection_matchers`,
|
|
51
|
+
`rspec_junit_formatter`, `rubocop-faker`, and `rubocop-rspec` development
|
|
52
|
+
dependencies; replaced by `minitest` and `rubocop-minitest`.
|
|
53
|
+
|
|
54
|
+
## [0.0.2] - 2023-11-27
|
|
55
|
+
|
|
56
|
+
- Initial public release.
|
data/Gemfile.lock
CHANGED
|
@@ -1,83 +1,118 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
assistant (0.
|
|
4
|
+
assistant (0.1.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
ast (2.4.
|
|
10
|
-
brakeman (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
ast (2.4.3)
|
|
10
|
+
brakeman (8.0.4)
|
|
11
|
+
racc
|
|
12
|
+
byebug (13.0.0)
|
|
13
|
+
reline (>= 0.6.0)
|
|
14
|
+
colorize (1.1.0)
|
|
15
|
+
fasterer (0.11.0)
|
|
16
|
+
ruby_parser (>= 3.19.1)
|
|
17
|
+
io-console (0.8.2)
|
|
18
|
+
json (2.19.5)
|
|
19
|
+
language_server-protocol (3.17.0.5)
|
|
20
|
+
lint_roller (1.1.0)
|
|
21
|
+
minitest (5.27.0)
|
|
22
|
+
parallel (2.1.0)
|
|
23
|
+
parser (3.3.11.1)
|
|
23
24
|
ast (~> 2.4.1)
|
|
25
|
+
racc
|
|
26
|
+
prism (1.9.0)
|
|
27
|
+
racc (1.8.1)
|
|
24
28
|
rainbow (3.1.1)
|
|
25
|
-
rake (13.
|
|
26
|
-
regexp_parser (2.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
|
-
rspec-support (~> 3.10.0)
|
|
37
|
-
rspec-mocks (3.10.2)
|
|
38
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
|
-
rspec-support (~> 3.10.0)
|
|
40
|
-
rspec-support (3.10.3)
|
|
41
|
-
rubocop (1.25.0)
|
|
42
|
-
parallel (~> 1.10)
|
|
43
|
-
parser (>= 3.1.0.0)
|
|
29
|
+
rake (13.4.2)
|
|
30
|
+
regexp_parser (2.12.0)
|
|
31
|
+
reline (0.6.3)
|
|
32
|
+
io-console (~> 0.5)
|
|
33
|
+
rubocop (1.86.1)
|
|
34
|
+
json (~> 2.3)
|
|
35
|
+
language_server-protocol (~> 3.17.0.2)
|
|
36
|
+
lint_roller (~> 1.1.0)
|
|
37
|
+
parallel (>= 1.10)
|
|
38
|
+
parser (>= 3.3.0.2)
|
|
44
39
|
rainbow (>= 2.2.2, < 4.0)
|
|
45
|
-
regexp_parser (>=
|
|
46
|
-
|
|
47
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
|
40
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
41
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
48
42
|
ruby-progressbar (~> 1.7)
|
|
49
|
-
unicode-display_width (>=
|
|
50
|
-
rubocop-ast (1.
|
|
51
|
-
parser (>= 3.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
rubocop (>= 1.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rubocop (
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
44
|
+
rubocop-ast (1.49.1)
|
|
45
|
+
parser (>= 3.3.7.2)
|
|
46
|
+
prism (~> 1.7)
|
|
47
|
+
rubocop-minitest (0.39.1)
|
|
48
|
+
lint_roller (~> 1.1)
|
|
49
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
50
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
51
|
+
rubocop-performance (1.26.1)
|
|
52
|
+
lint_roller (~> 1.1)
|
|
53
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
54
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
55
|
+
rubocop-rake (0.7.1)
|
|
56
|
+
lint_roller (~> 1.1)
|
|
57
|
+
rubocop (>= 1.72.1)
|
|
58
|
+
ruby-progressbar (1.13.0)
|
|
59
|
+
ruby_parser (3.22.0)
|
|
60
|
+
racc (~> 1.5)
|
|
62
61
|
sexp_processor (~> 4.16)
|
|
63
|
-
sexp_processor (4.
|
|
64
|
-
unicode-display_width (2.
|
|
62
|
+
sexp_processor (4.17.5)
|
|
63
|
+
unicode-display_width (3.2.0)
|
|
64
|
+
unicode-emoji (~> 4.1)
|
|
65
|
+
unicode-emoji (4.2.0)
|
|
65
66
|
|
|
66
67
|
PLATFORMS
|
|
67
|
-
|
|
68
|
+
arm64-darwin-25
|
|
69
|
+
ruby
|
|
68
70
|
|
|
69
71
|
DEPENDENCIES
|
|
70
72
|
assistant!
|
|
71
|
-
brakeman (~>
|
|
72
|
-
bundler (~>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
rubocop
|
|
79
|
-
rubocop-
|
|
80
|
-
rubocop-
|
|
73
|
+
brakeman (~> 8.0)
|
|
74
|
+
bundler (~> 4.0)
|
|
75
|
+
byebug (~> 13.0)
|
|
76
|
+
colorize (~> 1.1)
|
|
77
|
+
fasterer (~> 0.11.0)
|
|
78
|
+
minitest (~> 5.25)
|
|
79
|
+
rake (~> 13.4)
|
|
80
|
+
rubocop (~> 1.86)
|
|
81
|
+
rubocop-minitest (~> 0.39)
|
|
82
|
+
rubocop-performance (~> 1.26)
|
|
83
|
+
rubocop-rake (~> 0.7)
|
|
84
|
+
|
|
85
|
+
CHECKSUMS
|
|
86
|
+
assistant (0.1.0)
|
|
87
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
88
|
+
brakeman (8.0.4) sha256=7bf921fa9638544835df9aa7b3e720a9a72c0267f34f92135955edd80d4dcf6f
|
|
89
|
+
bundler (4.0.11) sha256=5bcec0fb78302e48d02ee46f10ee6e6942be647ba5b44a6d1ddfda9a240ce785
|
|
90
|
+
byebug (13.0.0) sha256=d2263efe751941ca520fa29744b71972d39cbc41839496706f5d9b22e92ae05d
|
|
91
|
+
colorize (1.1.0) sha256=30b5237f0603f6662ab8d1fc2bd4a96142b806c6415d79e45ef5fdc6a0cfc837
|
|
92
|
+
fasterer (0.11.0) sha256=9c38b77583584f3339a729eb077fd8f2856a317abe747528f6563d7c23e9dda8
|
|
93
|
+
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
|
|
94
|
+
json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59
|
|
95
|
+
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
96
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
97
|
+
minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
|
|
98
|
+
parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
|
|
99
|
+
parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
|
|
100
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
101
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
102
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
103
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
104
|
+
regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
|
|
105
|
+
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
106
|
+
rubocop (1.86.1) sha256=44415f3f01d01a21e01132248d2fd0867572475b566ca188a0a42133a08d4531
|
|
107
|
+
rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
|
|
108
|
+
rubocop-minitest (0.39.1) sha256=998398d6da4026d297f0f9bf709a1eac5f2b6947c24431f94af08138510cf7ed
|
|
109
|
+
rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
|
|
110
|
+
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
|
|
111
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
112
|
+
ruby_parser (3.22.0) sha256=1eb4937cd9eb220aa2d194e352a24dba90aef00751e24c8dfffdb14000f15d23
|
|
113
|
+
sexp_processor (4.17.5) sha256=ae2b48ba98353d5d465ce8759836b7a05f2e12c5879fcd14d7815b026de32f0e
|
|
114
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
115
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
81
116
|
|
|
82
117
|
BUNDLED WITH
|
|
83
|
-
|
|
118
|
+
4.0.11
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
require "rspec/core/rake_task"
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.libs << 'lib'
|
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
10
|
+
t.warning = false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: :test
|
data/assistant.gemspec
CHANGED
|
@@ -6,45 +6,42 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
6
6
|
require 'assistant/version'
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
|
10
|
+
|
|
9
11
|
spec.name = 'assistant'
|
|
10
12
|
spec.version = Assistant::VERSION
|
|
11
13
|
spec.authors = ['Ramon Rodrigues']
|
|
12
14
|
spec.email = ['cerberus.ramon@gmail.com']
|
|
13
15
|
|
|
14
|
-
spec.summary = 'Simple, composable services'
|
|
16
|
+
spec.summary = 'Simple, soft fail enabled, composable services'
|
|
15
17
|
spec.description = 'Simple, composable services'
|
|
16
18
|
spec.homepage = 'https://github.com/ramongr/assistant'
|
|
17
19
|
spec.license = 'MIT'
|
|
18
|
-
spec.required_ruby_version = '>=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
spec.metadata['homepage_uri'] = spec.homepage
|
|
26
|
-
spec.metadata['source_code_uri'] = 'https://github.com/ramongr/assistant'
|
|
27
|
-
else
|
|
28
|
-
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
29
|
-
'public gem pushes.'
|
|
30
|
-
end
|
|
20
|
+
spec.required_ruby_version = '>= 3.4'
|
|
21
|
+
|
|
22
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/ramongr/assistant/blob/main/CHANGELOG.md'
|
|
24
|
+
spec.metadata['homepage_uri'] = 'https://github.com/ramongr/assistant'
|
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
26
|
+
spec.metadata['source_code_uri'] = 'https://github.com/ramongr/assistant'
|
|
31
27
|
|
|
32
28
|
# Specify which files should be added to the gem when it is released.
|
|
33
29
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
34
30
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
35
31
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
36
32
|
end
|
|
37
|
-
|
|
38
|
-
spec.
|
|
39
|
-
|
|
40
|
-
spec.add_development_dependency 'brakeman', '~>
|
|
41
|
-
spec.add_development_dependency '
|
|
42
|
-
spec.add_development_dependency '
|
|
43
|
-
spec.add_development_dependency '
|
|
44
|
-
spec.add_development_dependency '
|
|
45
|
-
spec.add_development_dependency '
|
|
46
|
-
spec.add_development_dependency '
|
|
47
|
-
spec.add_development_dependency 'rubocop
|
|
48
|
-
spec.add_development_dependency 'rubocop-
|
|
49
|
-
spec.add_development_dependency 'rubocop-
|
|
33
|
+
|
|
34
|
+
spec.require_paths = 'lib'
|
|
35
|
+
|
|
36
|
+
spec.add_development_dependency 'brakeman', '~> 8.0'
|
|
37
|
+
spec.add_development_dependency 'bundler', '~> 4.0'
|
|
38
|
+
spec.add_development_dependency 'byebug', '~> 13.0'
|
|
39
|
+
spec.add_development_dependency 'colorize', '~> 1.1'
|
|
40
|
+
spec.add_development_dependency 'fasterer', '~> 0.11.0'
|
|
41
|
+
spec.add_development_dependency 'minitest', '~> 5.25'
|
|
42
|
+
spec.add_development_dependency 'rake', '~> 13.4'
|
|
43
|
+
spec.add_development_dependency 'rubocop', '~> 1.86'
|
|
44
|
+
spec.add_development_dependency 'rubocop-minitest', '~> 0.39'
|
|
45
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.26'
|
|
46
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.7'
|
|
50
47
|
end
|
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'assistant'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "assistant"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start(__FILE__)
|
data/bin/version
CHANGED
|
@@ -8,16 +8,12 @@ def process_command(argument)
|
|
|
8
8
|
original_version = version_arr.join('.')
|
|
9
9
|
case argument
|
|
10
10
|
when '-h', '--help'
|
|
11
|
-
puts
|
|
12
|
-
|
|
13
|
-
puts '--bump-minor-version --minor Bumps the minor version and sets the patch version to 0'
|
|
14
|
-
puts '--bump-major-version --version Bumps the major version sets all other values to 0'
|
|
15
|
-
return
|
|
16
|
-
when '--bump-patch-version', '--patch'
|
|
11
|
+
return puts help_message
|
|
12
|
+
when '--patch-version', '--patch'
|
|
17
13
|
bumped_version = [version_arr[0], version_arr[1], version_arr[2] + 1].join('.')
|
|
18
|
-
when '--
|
|
14
|
+
when '--minor-version', '--minor'
|
|
19
15
|
bumped_version = [version_arr[0], version_arr[1] + 1, 0].join('.')
|
|
20
|
-
when '--
|
|
16
|
+
when '--major-version', '--version'
|
|
21
17
|
bumped_version = [version_arr[0] + 1, 0, 0].join('.')
|
|
22
18
|
else
|
|
23
19
|
return puts "Invalid command #{argument}, use --help to see all available commands".colorize(:red)
|
|
@@ -27,6 +23,15 @@ def process_command(argument)
|
|
|
27
23
|
write_file(bumped_version_file)
|
|
28
24
|
end
|
|
29
25
|
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def help_message
|
|
29
|
+
puts "\t\t\t\t\tVERSION BUMP OPTIONS\t\t\t\t\t"
|
|
30
|
+
puts "--patch-version --patch\t\tBumps the patch version\t\t\t\t\t"
|
|
31
|
+
puts "--minor-version --minor\t\tBumps the minor version and sets the patch version to 0 "
|
|
32
|
+
puts "--major-version --version\t\tBumps the major version sets all other values to 0\t"
|
|
33
|
+
end
|
|
34
|
+
|
|
30
35
|
def write_file(text)
|
|
31
36
|
File.write(VERSION_FILE, text)
|
|
32
37
|
end
|
|
@@ -45,4 +50,4 @@ end
|
|
|
45
50
|
|
|
46
51
|
ARGV.each do |argument|
|
|
47
52
|
process_command(argument)
|
|
48
|
-
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'assistant/refinements/string_blankness'
|
|
4
|
+
|
|
5
|
+
module Assistant
|
|
6
|
+
# This module has the building blocks for the input validation.
|
|
7
|
+
# The building blocks of listing inputs with the #input and #inputs methods
|
|
8
|
+
# and the building blocks of validating inputs with the methods that are called within those methods.
|
|
9
|
+
module InputBuilder
|
|
10
|
+
using Assistant::Refinements::StringBlankness
|
|
11
|
+
|
|
12
|
+
# Lists all inputs that have the same type and options.
|
|
13
|
+
def inputs(attr_names, type:, **)
|
|
14
|
+
attr_names.each do |attr_name|
|
|
15
|
+
input(attr_name, type:, **)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Individual input with a specific type or options
|
|
20
|
+
def input(attr_name, type:, **options)
|
|
21
|
+
# Base Methods
|
|
22
|
+
input_getter_meth(attr_name)
|
|
23
|
+
input_checker_meth(attr_name)
|
|
24
|
+
|
|
25
|
+
# Input type validation method, simple and conditional requirement validation methods
|
|
26
|
+
input_type_validator_meth(attr_name, type)
|
|
27
|
+
input_require_validator_meth(attr_name, **options) if options[:required] == true
|
|
28
|
+
input_require_conditional_meth(attr_name, **options) if options[:required] == true && options[:if]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def input_getter_meth(attr_name)
|
|
32
|
+
define_method(attr_name) do
|
|
33
|
+
@inputs[attr_name]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def input_checker_meth(attr_name)
|
|
38
|
+
define_method("#{attr_name}?") do
|
|
39
|
+
val = @inputs[attr_name]
|
|
40
|
+
return false if val.nil? || val == false
|
|
41
|
+
return !val.whitespace? if val.is_a?(String)
|
|
42
|
+
|
|
43
|
+
val.respond_to?(:empty?) ? !val.empty? : true
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def input_require_validator_meth(attr_name, **options)
|
|
48
|
+
define_method("valid_require_#{attr_name}?") do |log = true|
|
|
49
|
+
return true if options[:required] == true && send("#{attr_name}?") == true
|
|
50
|
+
|
|
51
|
+
log && send(
|
|
52
|
+
:log_item_error_initialize, attr_name:, message: "Service is missing argument with name #{attr_name}"
|
|
53
|
+
)
|
|
54
|
+
false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def input_require_conditional_meth(attr_name, **options)
|
|
59
|
+
define_method("valid_require_conditional_#{attr_name}?") do
|
|
60
|
+
return false if send("valid_require_#{attr_name}?", false) == false
|
|
61
|
+
return true if options[:if].call(send(attr_name))
|
|
62
|
+
|
|
63
|
+
send(
|
|
64
|
+
:log_item_error_initialize,
|
|
65
|
+
attr_name:, message: "Service argument conditional requirement not met properly for #{attr_name}"
|
|
66
|
+
)
|
|
67
|
+
false
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def input_type_validator_meth(attr_name, type)
|
|
72
|
+
define_method("valid_type_#{attr_name}?") do
|
|
73
|
+
return true if @inputs[attr_name].is_a?(type)
|
|
74
|
+
|
|
75
|
+
send("#{attr_name}?") &&
|
|
76
|
+
send(
|
|
77
|
+
:log_item_error_initialize,
|
|
78
|
+
attr_name:, message: "Service argument with name #{attr_name} is not a #{type} but #{send(attr_name).class}"
|
|
79
|
+
)
|
|
80
|
+
false
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assistant
|
|
4
|
+
# Log base class
|
|
5
|
+
class LogItem
|
|
6
|
+
VALID_LEVELS = %i[info warning error].freeze
|
|
7
|
+
|
|
8
|
+
attr_reader :level, :source, :detail, :message, :trace
|
|
9
|
+
|
|
10
|
+
def initialize(level:, source:, detail:, message:, trace: nil)
|
|
11
|
+
@level = level.to_sym
|
|
12
|
+
@source = source.to_sym
|
|
13
|
+
@detail = detail.to_sym
|
|
14
|
+
@message = message.to_s
|
|
15
|
+
@trace = trace
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def valid?
|
|
19
|
+
[valid_level?, valid_source?, valid_detail?, valid_message?].all?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def item
|
|
23
|
+
{ level:, source:, detail:, message:, trace: }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
VALID_LEVELS.each do |valid_level|
|
|
27
|
+
# info? warning? error?
|
|
28
|
+
define_method("#{valid_level}?") do
|
|
29
|
+
level == valid_level
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def valid_level?
|
|
34
|
+
VALID_LEVELS.include?(level)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def valid_source?
|
|
38
|
+
source.size.positive? && detail != source
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def valid_detail?
|
|
42
|
+
detail.size.positive? && source != detail
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def valid_message?
|
|
46
|
+
message.size.positive?
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assistant
|
|
4
|
+
# Service level list of logs
|
|
5
|
+
module LogList
|
|
6
|
+
def add_log(level:, source:, detail:, message:, trace: nil)
|
|
7
|
+
@logs << Assistant::LogItem.new(level:, source:, detail:, message:, trace:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def merge_logs(other_logs)
|
|
11
|
+
@logs.concat(other_logs)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Convenience used by InputBuilder-generated validators to record an
|
|
15
|
+
# initialization-time error for a specific input attribute.
|
|
16
|
+
def log_item_error_initialize(attr_name:, message:)
|
|
17
|
+
@logs << Assistant::LogItem.new(detail: attr_name, level: :error, message:, source: :initialize)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
::Assistant::LogItem::VALID_LEVELS.each do |level|
|
|
21
|
+
define_method("#{level}s") do
|
|
22
|
+
@logs.select { |log| log.send("#{level}?") }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assistant
|
|
4
|
+
module Refinements
|
|
5
|
+
# Refines String with `#whitespace?`, true when a string is empty or
|
|
6
|
+
# contains only whitespace characters. Used by `InputBuilder` validators
|
|
7
|
+
# to treat whitespace-only strings as missing input without depending on
|
|
8
|
+
# ActiveSupport's `String#blank?`.
|
|
9
|
+
module StringBlankness
|
|
10
|
+
refine String do
|
|
11
|
+
# True when the string is empty or contains only whitespace.
|
|
12
|
+
def whitespace?
|
|
13
|
+
strip.empty?
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/assistant/service.rb
CHANGED
|
@@ -1,18 +1,65 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'input_builder'
|
|
4
|
+
require_relative 'log_list'
|
|
5
|
+
|
|
3
6
|
module Assistant
|
|
4
7
|
# Base class for the Assistant gem
|
|
5
8
|
class Service
|
|
6
|
-
|
|
9
|
+
include LogList
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
include InputBuilder
|
|
13
|
+
|
|
14
|
+
def run(**)
|
|
15
|
+
new(**).run
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def initialize(**args)
|
|
7
20
|
@inputs = args
|
|
21
|
+
@logs = []
|
|
8
22
|
end
|
|
9
23
|
|
|
10
24
|
def run
|
|
11
|
-
|
|
25
|
+
validate_inputs
|
|
26
|
+
validate
|
|
27
|
+
|
|
28
|
+
if errors.empty?
|
|
29
|
+
{ result:, status:, warnings: }
|
|
30
|
+
else
|
|
31
|
+
{ errors:, result: nil, status: :with_errors }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def result
|
|
36
|
+
@result ||= execute
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def success?
|
|
40
|
+
errors.empty?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def failure?
|
|
44
|
+
errors.any?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def status
|
|
48
|
+
warnings.empty? ? :ok : :with_warnings
|
|
12
49
|
end
|
|
13
50
|
|
|
14
|
-
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def validate_inputs
|
|
54
|
+
methods.grep(/valid_(require|type|require_conditional)_\w+\?$/).each do |validation_method|
|
|
55
|
+
send(validation_method)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
attr_reader :inputs
|
|
15
60
|
|
|
16
61
|
def execute; end
|
|
62
|
+
|
|
63
|
+
def validate; end
|
|
17
64
|
end
|
|
18
65
|
end
|
data/lib/assistant/version.rb
CHANGED
data/lib/assistant.rb
CHANGED
data/mise.toml
ADDED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: assistant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ramon Rodrigues
|
|
8
|
-
|
|
9
|
-
bindir: exe
|
|
8
|
+
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: brakeman
|
|
@@ -16,164 +15,154 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '8.0'
|
|
20
19
|
type: :development
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '8.0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: bundler
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0
|
|
32
|
+
version: '4.0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0
|
|
39
|
+
version: '4.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: byebug
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
48
|
-
- - ">="
|
|
49
|
-
- !ruby/object:Gem::Version
|
|
50
|
-
version: 2.3.5
|
|
46
|
+
version: '13.0'
|
|
51
47
|
type: :development
|
|
52
48
|
prerelease: false
|
|
53
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
50
|
requirements:
|
|
55
51
|
- - "~>"
|
|
56
52
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: '
|
|
58
|
-
|
|
53
|
+
version: '13.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: colorize
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
60
|
+
version: '1.1'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '1.1'
|
|
61
68
|
- !ruby/object:Gem::Dependency
|
|
62
69
|
name: fasterer
|
|
63
70
|
requirement: !ruby/object:Gem::Requirement
|
|
64
71
|
requirements:
|
|
65
72
|
- - "~>"
|
|
66
73
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.
|
|
74
|
+
version: 0.11.0
|
|
68
75
|
type: :development
|
|
69
76
|
prerelease: false
|
|
70
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
78
|
requirements:
|
|
72
79
|
- - "~>"
|
|
73
80
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.
|
|
81
|
+
version: 0.11.0
|
|
75
82
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
83
|
+
name: minitest
|
|
77
84
|
requirement: !ruby/object:Gem::Requirement
|
|
78
85
|
requirements:
|
|
79
86
|
- - "~>"
|
|
80
87
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
82
|
-
- - ">="
|
|
83
|
-
- !ruby/object:Gem::Version
|
|
84
|
-
version: 13.0.6
|
|
88
|
+
version: '5.25'
|
|
85
89
|
type: :development
|
|
86
90
|
prerelease: false
|
|
87
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
88
92
|
requirements:
|
|
89
93
|
- - "~>"
|
|
90
94
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: '
|
|
92
|
-
- - ">="
|
|
93
|
-
- !ruby/object:Gem::Version
|
|
94
|
-
version: 13.0.6
|
|
95
|
+
version: '5.25'
|
|
95
96
|
- !ruby/object:Gem::Dependency
|
|
96
|
-
name:
|
|
97
|
+
name: rake
|
|
97
98
|
requirement: !ruby/object:Gem::Requirement
|
|
98
99
|
requirements:
|
|
99
100
|
- - "~>"
|
|
100
101
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '
|
|
102
|
+
version: '13.4'
|
|
102
103
|
type: :development
|
|
103
104
|
prerelease: false
|
|
104
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
106
|
requirements:
|
|
106
107
|
- - "~>"
|
|
107
108
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: '
|
|
109
|
+
version: '13.4'
|
|
109
110
|
- !ruby/object:Gem::Dependency
|
|
110
111
|
name: rubocop
|
|
111
112
|
requirement: !ruby/object:Gem::Requirement
|
|
112
113
|
requirements:
|
|
113
114
|
- - "~>"
|
|
114
115
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: '1.
|
|
116
|
-
- - ">="
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: 1.24.1
|
|
116
|
+
version: '1.86'
|
|
119
117
|
type: :development
|
|
120
118
|
prerelease: false
|
|
121
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
122
120
|
requirements:
|
|
123
121
|
- - "~>"
|
|
124
122
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: '1.
|
|
126
|
-
- - ">="
|
|
127
|
-
- !ruby/object:Gem::Version
|
|
128
|
-
version: 1.24.1
|
|
123
|
+
version: '1.86'
|
|
129
124
|
- !ruby/object:Gem::Dependency
|
|
130
|
-
name: rubocop-
|
|
125
|
+
name: rubocop-minitest
|
|
131
126
|
requirement: !ruby/object:Gem::Requirement
|
|
132
127
|
requirements:
|
|
133
128
|
- - "~>"
|
|
134
129
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '
|
|
130
|
+
version: '0.39'
|
|
136
131
|
type: :development
|
|
137
132
|
prerelease: false
|
|
138
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
139
134
|
requirements:
|
|
140
135
|
- - "~>"
|
|
141
136
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: '
|
|
137
|
+
version: '0.39'
|
|
143
138
|
- !ruby/object:Gem::Dependency
|
|
144
139
|
name: rubocop-performance
|
|
145
140
|
requirement: !ruby/object:Gem::Requirement
|
|
146
141
|
requirements:
|
|
147
142
|
- - "~>"
|
|
148
143
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '1.
|
|
150
|
-
- - ">="
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: 1.13.2
|
|
144
|
+
version: '1.26'
|
|
153
145
|
type: :development
|
|
154
146
|
prerelease: false
|
|
155
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
156
148
|
requirements:
|
|
157
149
|
- - "~>"
|
|
158
150
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: '1.
|
|
160
|
-
- - ">="
|
|
161
|
-
- !ruby/object:Gem::Version
|
|
162
|
-
version: 1.13.2
|
|
151
|
+
version: '1.26'
|
|
163
152
|
- !ruby/object:Gem::Dependency
|
|
164
|
-
name: rubocop-
|
|
153
|
+
name: rubocop-rake
|
|
165
154
|
requirement: !ruby/object:Gem::Requirement
|
|
166
155
|
requirements:
|
|
167
156
|
- - "~>"
|
|
168
157
|
- !ruby/object:Gem::Version
|
|
169
|
-
version: '
|
|
158
|
+
version: '0.7'
|
|
170
159
|
type: :development
|
|
171
160
|
prerelease: false
|
|
172
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
173
162
|
requirements:
|
|
174
163
|
- - "~>"
|
|
175
164
|
- !ruby/object:Gem::Version
|
|
176
|
-
version: '
|
|
165
|
+
version: '0.7'
|
|
177
166
|
description: Simple, composable services
|
|
178
167
|
email:
|
|
179
168
|
- cerberus.ramon@gmail.com
|
|
@@ -181,11 +170,17 @@ executables: []
|
|
|
181
170
|
extensions: []
|
|
182
171
|
extra_rdoc_files: []
|
|
183
172
|
files:
|
|
173
|
+
- ".editorconfig"
|
|
184
174
|
- ".fasterer.yml"
|
|
175
|
+
- ".github/dependabot.yml"
|
|
176
|
+
- ".github/workflows/ci.yml"
|
|
177
|
+
- ".github/workflows/release.yml"
|
|
185
178
|
- ".gitignore"
|
|
186
|
-
- ".
|
|
179
|
+
- ".markdownlint.json"
|
|
187
180
|
- ".rubocop.yml"
|
|
181
|
+
- ".rubocop_todo.yml"
|
|
188
182
|
- ".ruby-version"
|
|
183
|
+
- CHANGELOG.md
|
|
189
184
|
- CODE_OF_CONDUCT.md
|
|
190
185
|
- Gemfile
|
|
191
186
|
- Gemfile.lock
|
|
@@ -197,17 +192,23 @@ files:
|
|
|
197
192
|
- bin/setup
|
|
198
193
|
- bin/version
|
|
199
194
|
- lib/assistant.rb
|
|
195
|
+
- lib/assistant/input_builder.rb
|
|
196
|
+
- lib/assistant/log_item.rb
|
|
197
|
+
- lib/assistant/log_list.rb
|
|
198
|
+
- lib/assistant/refinements/string_blankness.rb
|
|
200
199
|
- lib/assistant/service.rb
|
|
200
|
+
- lib/assistant/service.rbs
|
|
201
201
|
- lib/assistant/version.rb
|
|
202
|
+
- mise.toml
|
|
202
203
|
homepage: https://github.com/ramongr/assistant
|
|
203
204
|
licenses:
|
|
204
205
|
- MIT
|
|
205
206
|
metadata:
|
|
206
207
|
allowed_push_host: https://rubygems.org
|
|
207
|
-
changelog_uri: https://github.com/ramongr/assistant/blob/main/
|
|
208
|
+
changelog_uri: https://github.com/ramongr/assistant/blob/main/CHANGELOG.md
|
|
208
209
|
homepage_uri: https://github.com/ramongr/assistant
|
|
210
|
+
rubygems_mfa_required: 'true'
|
|
209
211
|
source_code_uri: https://github.com/ramongr/assistant
|
|
210
|
-
post_install_message:
|
|
211
212
|
rdoc_options: []
|
|
212
213
|
require_paths:
|
|
213
214
|
- lib
|
|
@@ -215,15 +216,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
215
216
|
requirements:
|
|
216
217
|
- - ">="
|
|
217
218
|
- !ruby/object:Gem::Version
|
|
218
|
-
version:
|
|
219
|
+
version: '3.4'
|
|
219
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
requirements:
|
|
221
222
|
- - ">="
|
|
222
223
|
- !ruby/object:Gem::Version
|
|
223
224
|
version: '0'
|
|
224
225
|
requirements: []
|
|
225
|
-
rubygems_version:
|
|
226
|
-
signing_key:
|
|
226
|
+
rubygems_version: 4.0.6
|
|
227
227
|
specification_version: 4
|
|
228
|
-
summary: Simple, composable services
|
|
228
|
+
summary: Simple, soft fail enabled, composable services
|
|
229
229
|
test_files: []
|
data/.rspec
DELETED