poke-your-api 0.4.0 → 0.4.1
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/lib/poke/commands/curl.rb +28 -3
- data/lib/poke/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9349d971fd268f0c75b1d9409088e4b33491ce5fa95f4fa29a780af02400904
|
|
4
|
+
data.tar.gz: 36e07caa239aef944dbad213412e48f6e7a8acc68b035d3e61ad6d1fd0dea5df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b097dcf106434d01689f31191fd73036c4a7c4c488c5db41acc43db7dac3cb6e8e33fa1dbbd101ad864ee9da020adb978aab9be9d76421c4d0da41f175a4e9dc
|
|
7
|
+
data.tar.gz: 022a899d6bdc476e15148725c65ff5e8eec0698db1b236de74c664fd2b118fba9e9831520af2696dc65bc6e061901c919aaa5f77f79b6e4367190c81b316b1dd
|
data/lib/poke/commands/curl.rb
CHANGED
|
@@ -12,6 +12,7 @@ require 'pastel'
|
|
|
12
12
|
|
|
13
13
|
require 'tty-command'
|
|
14
14
|
require 'tty-editor'
|
|
15
|
+
require 'tty-prompt'
|
|
15
16
|
require 'tty-table'
|
|
16
17
|
|
|
17
18
|
module Poke
|
|
@@ -36,7 +37,7 @@ module Poke
|
|
|
36
37
|
request = Request.find_by_name(Config.find_request_name_by_alias(name))
|
|
37
38
|
else
|
|
38
39
|
choices = Request.all.sort_by(&:position).map(&:name_with_alias)
|
|
39
|
-
name =
|
|
40
|
+
name = select_request_name(choices, errors)
|
|
40
41
|
request = Request.find_by_name_with_alias(name)
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -76,8 +77,8 @@ module Poke
|
|
|
76
77
|
curl_command
|
|
77
78
|
)
|
|
78
79
|
if command.failure?
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
errors << Pastel.new.decorate(command.err, :red)
|
|
81
|
+
errors << Poke::Paint.farewell
|
|
81
82
|
return
|
|
82
83
|
else
|
|
83
84
|
errors << Pastel.new.decorate(command.err, :green)
|
|
@@ -115,6 +116,30 @@ module Poke
|
|
|
115
116
|
]
|
|
116
117
|
end
|
|
117
118
|
# rubocop:enable Style/FormatStringToken
|
|
119
|
+
|
|
120
|
+
def select_request_name(choices, errors)
|
|
121
|
+
with_prompt_output_stream(errors) do |prompt_output|
|
|
122
|
+
TTY::Prompt.new(interrupt: :exit, output: prompt_output).select(
|
|
123
|
+
'Select the endpoint', choices, filter: true, quiet: true
|
|
124
|
+
)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def with_prompt_output_stream(errors)
|
|
129
|
+
stream = default_prompt_output_stream(errors)
|
|
130
|
+
return yield(stream) if stream
|
|
131
|
+
|
|
132
|
+
File.open('/dev/tty', 'w') { |tty| yield(tty) }
|
|
133
|
+
rescue Errno::ENOENT, Errno::ENXIO, Errno::EACCES
|
|
134
|
+
yield(errors)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def default_prompt_output_stream(errors)
|
|
138
|
+
return errors if errors.respond_to?(:tty?) && errors.tty?
|
|
139
|
+
return $stderr if $stderr.respond_to?(:tty?) && $stderr.tty?
|
|
140
|
+
|
|
141
|
+
nil
|
|
142
|
+
end
|
|
118
143
|
end
|
|
119
144
|
end
|
|
120
145
|
end
|
data/lib/poke/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: poke-your-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Bator
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pastel
|