prompts 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40fa96bdb16258c1e9612971eeea11a1757e82cdbc68e6084000c26c96f2d86c
4
- data.tar.gz: b7a7daee831ca3473aa043bfe0b1f94aff8f12a9aa8e2fa4acdb6a4a75fb0634
3
+ metadata.gz: 85f88312acdfb5be0eb5b24924d140c96d01453f742edbc1a1576a8759c37997
4
+ data.tar.gz: d82a75efffa864d9854a78c29a1f1ae110bbce7b61cd24770067ad1103c29c45
5
5
  SHA512:
6
- metadata.gz: fb8c9184e577f2e7b9f6c003407e028ee1613db35ee288c0ac914d5a8464f3c2135e22d4e280aab7233aa52418f60fed3ca6cf05c37d4c6907ef5937099f1445
7
- data.tar.gz: cd5e4cb5512224d68c825b28f67398f5366d0d8a5a1026523c3cc431b44efea1ddef5fdb969832af49b2158dc1bb3e94b6a98cb8781c9422c324f02ebbce16c3
6
+ metadata.gz: ce5e838beb75e5d1e70fcfebcdc5eaf42e5dc77046465af025c2a8c9d78db70092f78a59737da631c12f89b9c292183cc80642c45f6b8b16036d54d5ad2bb83a
7
+ data.tar.gz: 4223935ce6374fa970f1e5634666a413fad19980105bce0258952a8caab283046a3a3473203ce0439ff168a408d355cea025cca10abe1adaeb80cc4816b7115b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2024-10-08
4
+
5
+ - Update `fmt` gem and use new syntax ([@KonnorRogers](https://github.com/fractaledmind/prompts/pull/9))
6
+
3
7
  ## [0.2.1] - 2024-08-22
4
8
 
5
9
  - Add `Form.submit` method
data/lib/prompts/box.rb CHANGED
@@ -55,16 +55,16 @@ module Prompts
55
55
 
56
56
  def top_border
57
57
  border = @border_parts[:top_left] + @border_parts[:horizontal] * (@width - 2) + @border_parts[:top_right]
58
- Fmt("#{@line_padding}%{border}#{@border_color}", border: border)
58
+ Fmt("#{@line_padding}%{border}|>#{@border_color}", border: border)
59
59
  end
60
60
 
61
61
  def bottom_border
62
62
  border = @border_parts[:bottom_left] + @border_parts[:horizontal] * (@width - 2) + @border_parts[:bottom_right]
63
- Fmt("#{@line_padding}%{border}#{@border_color}", border: border)
63
+ Fmt("#{@line_padding}%{border}|>#{@border_color}", border: border)
64
64
  end
65
65
 
66
66
  def align(text, alignment, between: @border_parts[:vertical])
67
- formatted_boundary = Fmt("%{boundary}#{@border_color}", boundary: between)
67
+ formatted_boundary = Fmt("%{boundary}|>#{@border_color}", boundary: between)
68
68
  wrap_text(text, width: @width, line_prefix: formatted_boundary + SPACE, line_suffix: SPACE + formatted_boundary, alignment: alignment)
69
69
  end
70
70
  end
data/lib/prompts/form.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Prompts
4
4
  class Form
5
5
  def self.submit(&block)
6
- instance = new()
7
- yield instance if block_given?
6
+ instance = new
7
+ yield instance if block
8
8
  instance.submit
9
9
  end
10
10
 
@@ -21,28 +21,28 @@ module Prompts
21
21
 
22
22
  def text(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
23
23
  prompt = TextPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
24
- yield(prompt) if block_given?
24
+ yield(prompt) if block
25
25
  prepend_form_content_to_prompt(prompt)
26
26
  @prompts << prompt
27
27
  end
28
28
 
29
29
  def select(label: nil, options: nil, prompt: "> ", hint: nil, default: nil, validate: nil, &block)
30
30
  prompt = SelectPrompt.new(label: label, options: options, prompt: prompt, hint: hint, default: default, validate: validate)
31
- yield(prompt) if block_given?
31
+ yield(prompt) if block
32
32
  prepend_form_content_to_prompt(prompt)
33
33
  @prompts << prompt
34
34
  end
35
35
 
36
36
  def pause(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
37
37
  prompt = PausePrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
38
- yield(prompt) if block_given?
38
+ yield(prompt) if block
39
39
  prepend_form_content_to_prompt(prompt)
40
40
  @prompts << prompt
41
41
  end
42
42
 
43
43
  def confirm(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
44
44
  prompt = ConfirmPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
45
- yield(prompt) if block_given?
45
+ yield(prompt) if block
46
46
  prepend_form_content_to_prompt(prompt)
47
47
  @prompts << prompt
48
48
  end
@@ -61,7 +61,7 @@ module Prompts
61
61
 
62
62
  if (@error = ensure_validity(response))
63
63
  @content.reset!
64
- @content.paragraph Fmt("%{error}red|bold", error: @error + " Try again (×#{@attempts})...")
64
+ @content.paragraph Fmt("%{error}|>red|>bold", error: @error + " Try again (×#{@attempts})...")
65
65
  @attempts += 1
66
66
  next
67
67
  else
@@ -114,20 +114,20 @@ module Prompts
114
114
 
115
115
  def formatted_prompt
116
116
  prompt_with_space = @prompt.end_with?(SPACE) ? @prompt : @prompt + SPACE
117
- ansi_prompt = Fmt("%{prompt}faint|bold", prompt: prompt_with_space)
117
+ ansi_prompt = Fmt("%{prompt}|>faint|>bold", prompt: prompt_with_space)
118
118
  @formatted_prompt ||= Paragraph.new(ansi_prompt, width: MAX_WIDTH).lines
119
119
  end
120
120
 
121
121
  def formatted_label
122
- Fmt("%{label}cyan|bold %{instructions}faint|italic", label: @label, instructions: @instructions ? "(#{@instructions})" : "")
122
+ Fmt("%{label}|>cyan|>bold %{instructions}|>faint|>italic", label: @label, instructions: @instructions ? "(#{@instructions})" : "")
123
123
  end
124
124
 
125
125
  def formatted_hint
126
- Fmt("%{hint}faint|bold", hint: @hint)
126
+ Fmt("%{hint}|>faint|>bold", hint: @hint)
127
127
  end
128
128
 
129
129
  def formatted_error
130
- Fmt("%{error}red|bold", error: @error + " Try again (×#{@attempts})...")
130
+ Fmt("%{error}|>red|>bold", error: @error + " Try again (×#{@attempts})...")
131
131
  end
132
132
 
133
133
  def ensure_validity(response)
@@ -29,7 +29,7 @@ module Prompts
29
29
  def prepare_content
30
30
  super
31
31
  @options.each_with_index do |(key, value), index|
32
- @content.paragraph Fmt("%{prefix}faint|bold %{option}", prefix: "#{index + 1}.", option: value)
32
+ @content.paragraph Fmt("%{prefix}|>faint|>bold %{option}", prefix: "#{index + 1}.", option: value)
33
33
  end
34
34
  @content
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prompts
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/prompts.rb CHANGED
@@ -2,10 +2,8 @@
2
2
 
3
3
  require "io/console"
4
4
  require "reline"
5
+ require "rainbow" # this needs to come before require "fmt"
5
6
  require "fmt"
6
- require "rainbow"
7
-
8
- Fmt.add_rainbow_filters
9
7
 
10
8
  require_relative "prompts/version"
11
9
  require_relative "prompts/prompt"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode-display_width
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rainbow
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.5.17
131
+ rubygems_version: 3.5.11
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Beautiful and user-friendly forms for your command-line Ruby applications.