foobara-sh-cli-connector 0.0.12 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df5c4fd103cab9693642c588edfbabbb886b72415744891b49d527777191d502
4
- data.tar.gz: 570b3e18e965e139ef7a490c82b45a84e31f59ec5090d8b2762b57e69c94ca5e
3
+ metadata.gz: 665dbe7ec95119ae45a08a732dd7435b4a95a77a65f9db4fbe886fc682f34a68
4
+ data.tar.gz: a296ff798f597f90d638ae67b1352a41b4f043e29aef811a00e3f4c084ee4ab2
5
5
  SHA512:
6
- metadata.gz: b55e725797013e2f711776d0281724ff80fc0cb9d8aa33dfbafcf629e3541e8c9530f5ecf15a115a76aea01c67ed6b6b03157a34e7a15b9b98997c9043bccf40
7
- data.tar.gz: 7f0ca76f1e4c4c5711aa0ee20352fd13fbbab793472444b4193df0fe3506a128f0283dc6985ce50e4276372cd82a9b6bdcee558c06b6a8521f1b4ef350eedfd9
6
+ metadata.gz: af0c874392c53914b85bda8d5513464b725b50cf833207e9ac4b232c921961ce8e62b97d1990319efe3ac6e2dcad6327abe28a618c4b3f63d00928cf82efb9e5
7
+ data.tar.gz: 4c9d55a9d040971adbd62cddc94560291667385de959460ad63d0d7d0cb7e2c5d19c5068e3ee6f4f6ebc47b1063373d9b335f6718f14749d50e9aa29c576c566
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.14] - 2025-04-11
2
+
3
+ - Handle newer versions of foobara
4
+
5
+ ## [0.0.13] - 2025-03-28
6
+
7
+ - Handle recent #request_to_response refactor
8
+
1
9
  ## [0.0.12] - 2025-03-06
2
10
 
3
11
  - Allow passing a command or connect args to single_command_mode:
@@ -11,6 +11,8 @@ module Foobara
11
11
 
12
12
  def validate!
13
13
  unless remainder.empty?
14
+ # TODO: let's invert the order for single command mode: parse inputs first, then global from remainder,
15
+ # and then raise if there's anything left
14
16
  raise ParseError, "Unexpected argument: #{remainder.first}"
15
17
  end
16
18
  end
@@ -120,6 +120,7 @@ module Foobara
120
120
  # TODO: needs to be the only registered command
121
121
  self.argument = command
122
122
  self.inputs_argv = argv
123
+ self.command_class = command.command_class
123
124
  end
124
125
  end
125
126
 
@@ -3,9 +3,9 @@ module Foobara
3
3
  class ShCliConnector < CommandConnector
4
4
  module Serializers
5
5
  # Should allow either atomic or aggregate
6
- class CliResultSerializer < CommandConnectors::Serializers::AtomicSerializer
6
+ class CliResultSerializer < CommandConnectors::Serializers::SuccessSerializer
7
7
  def serialize(object)
8
- serializable = super
8
+ serializable = atomic_serializer.serialize(object)
9
9
 
10
10
  if serializable.is_a?(::String)
11
11
  serializable
@@ -19,6 +19,10 @@ module Foobara
19
19
  end
20
20
  end
21
21
 
22
+ def atomic_serializer
23
+ @atomic_serializer ||= Foobara::CommandConnectors::Serializers::AtomicSerializer.new
24
+ end
25
+
22
26
  private
23
27
 
24
28
  def print(io, object, padding = nil, after_colon: false)
@@ -172,8 +172,8 @@ module Foobara
172
172
 
173
173
  parts_size = parts.size
174
174
 
175
- parts.each.with_index do |rows_worth, index|
176
- rows_worth << "-" unless index == parts_size - 1
175
+ parts.each.with_index do |rows_worth, inner_index|
176
+ rows_worth << "-" unless inner_index == parts_size - 1
177
177
  cell << rows_worth
178
178
  end
179
179
  else
@@ -40,7 +40,7 @@ module Foobara
40
40
  command_registry.foobara_all_command.first
41
41
  end
42
42
 
43
- self.class::Request.new(*, **, command:, &)
43
+ super(*, **, command:, &)
44
44
  end
45
45
 
46
46
  # TODO: this needs a better name... it's doing more than building.
@@ -65,48 +65,54 @@ module Foobara
65
65
  nil
66
66
  end
67
67
 
68
- def request_to_response(request)
69
- if request.error
70
- case request.error
71
- when ParseError, CommandConnector::NotFoundError
72
- return Response.new(status: 6, body: request.error.message, request:)
73
- else
74
- # :nocov:
75
- raise "Not sure how to handle error: #{request.error}"
76
- # :nocov:
77
- end
78
- end
68
+ def set_response_status(response)
69
+ request = response.request
70
+
71
+ response.status = if request.error
72
+ 6
73
+ elsif request.success?
74
+ 0
75
+ else
76
+ errors = request.error_collection.error_array
77
+ error = errors.first
78
+
79
+ case error
80
+ when CommandConnector::NotFoundError, Foobara::Entity::NotFoundError
81
+ # TODO: we should not be coupled to Entities here...
82
+ # :nocov:
83
+ 2
84
+ # :nocov:
85
+ when CommandConnector::UnauthenticatedError
86
+ # :nocov:
87
+ 3
88
+ # :nocov:
89
+ when CommandConnector::NotAllowedError
90
+ # :nocov:
91
+ 4
92
+ # :nocov:
93
+ when CommandConnector::UnknownError
94
+ # :nocov:
95
+ 5
96
+ # :nocov:
97
+ end || 1
98
+ end
99
+ end
79
100
 
80
- body = request.response_body
81
-
82
- status = if request.success?
83
- 0
84
- else
85
- errors = request.error_collection.error_array
86
- error = errors.first
87
-
88
- case error
89
- when CommandConnector::NotFoundError, Foobara::Entity::NotFoundError
90
- # TODO: we should not be coupled to Entities here...
91
- # :nocov:
92
- 2
93
- # :nocov:
94
- when CommandConnector::UnauthenticatedError
95
- # :nocov:
96
- 3
97
- # :nocov:
98
- when CommandConnector::NotAllowedError
99
- # :nocov:
100
- 4
101
- # :nocov:
102
- when CommandConnector::UnknownError
103
- # :nocov:
104
- 5
105
- # :nocov:
106
- end || 1
107
- end
108
-
109
- Response.new(status:, body:, request:)
101
+ def set_response_body(response)
102
+ request = response.request
103
+
104
+ response.body = if request.error
105
+ case request.error
106
+ when ParseError, CommandConnector::NotFoundError
107
+ request.error.message
108
+ else
109
+ # :nocov:
110
+ raise "Not sure how to handle error: #{request.error}"
111
+ # :nocov:
112
+ end
113
+ else
114
+ request.response_body
115
+ end
110
116
  end
111
117
  end
112
118
  end
metadata CHANGED
@@ -1,28 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-sh-cli-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - ">="
16
+ - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '0'
18
+ version: 0.0.88
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - ">="
23
+ - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '0'
25
+ version: 0.0.88
26
26
  email:
27
27
  - azimux@gmail.com
28
28
  executables: []
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.6.5
79
+ rubygems_version: 3.6.7
80
80
  specification_version: 4
81
81
  summary: Command-line connector for Foobara
82
82
  test_files: []