foobara-sh-cli-connector 0.0.12 → 0.0.13

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: baee3b1690dc7108efe1763f106088b5c60ec44bee67f9e5e973af806dc23dcb
4
+ data.tar.gz: ff4692056eed0949ef1c4f1b0ece541e3c5805ed9afd1fb282feb35727c48780
5
5
  SHA512:
6
- metadata.gz: b55e725797013e2f711776d0281724ff80fc0cb9d8aa33dfbafcf629e3541e8c9530f5ecf15a115a76aea01c67ed6b6b03157a34e7a15b9b98997c9043bccf40
7
- data.tar.gz: 7f0ca76f1e4c4c5711aa0ee20352fd13fbbab793472444b4193df0fe3506a128f0283dc6985ce50e4276372cd82a9b6bdcee558c06b6a8521f1b4ef350eedfd9
6
+ metadata.gz: c45bc3cb9f0d47d3ec1dce2cc6fb7ce34712905f9f2c8895d03c56ba5e3bc1a285bc5f325740d17c5d7f6403e17892836b71829f0d065e1c4e0d124823e5c97d
7
+ data.tar.gz: 7de22a9ff9f3f780b08eb8cb4587204232d7d5e8bd00ccedfead314d737401acd31a51c26a13bc68ad518ec336003e1332aabf2ff40040b336ed70b897fb555a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.13] - 2025-03-28
2
+
3
+ - Handle recent #request_to_response refactor
4
+
1
5
  ## [0.0.12] - 2025-03-06
2
6
 
3
7
  - 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
 
@@ -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
@@ -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.13
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: 2025-03-28 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.6
80
80
  specification_version: 4
81
81
  summary: Command-line connector for Foobara
82
82
  test_files: []