bundle_update_interactive 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e71278ee6c0ffbfb39537712a8d97e956c57062dad9723d358d97474cf63b69c
|
4
|
+
data.tar.gz: 13491cad6f990d97fb3a2c918913fb4bc5eb5048829a18dd8c5400f6e5f9fadf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bf5c295484ae3aa19d12d5891afd7883873204d0a9314babcf111b832cab60b89be13afcb6f33e8a8d2cbc7b702df9b0c800ca0639a2c8148e56adb6964cde4
|
7
|
+
data.tar.gz: 0caebaf4d1bbc2a2d3cd6a5820ed031491a41a43286d7ba6f3e7bf419c28c5627ac58b8bed0407658d46efdc01d105f75857c66784b61b98eb581c00fe0ec575
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "launchy"
|
3
4
|
require "pastel"
|
4
5
|
require "tty/prompt"
|
5
6
|
require "tty/screen"
|
@@ -8,6 +9,7 @@ class BundleUpdateInteractive::CLI
|
|
8
9
|
class MultiSelect
|
9
10
|
class List < TTY::Prompt::MultiList
|
10
11
|
def initialize(prompt, **options)
|
12
|
+
@opener = options.delete(:opener)
|
11
13
|
defaults = {
|
12
14
|
cycle: true,
|
13
15
|
help_color: :itself.to_proc,
|
@@ -21,48 +23,64 @@ class BundleUpdateInteractive::CLI
|
|
21
23
|
def selected_names
|
22
24
|
""
|
23
25
|
end
|
26
|
+
|
27
|
+
# Unregister tty-prompt's default ctrl-a and ctrl-r bindings
|
28
|
+
alias select_all keyctrl_a
|
29
|
+
alias reverse_selection keyctrl_r
|
30
|
+
def keyctrl_a(*); end
|
31
|
+
def keyctrl_r(*); end
|
32
|
+
|
33
|
+
def keypress(event)
|
34
|
+
case event.value
|
35
|
+
when "k", "p" then keyup
|
36
|
+
when "j", "n" then keydown
|
37
|
+
when "a" then select_all
|
38
|
+
when "r" then reverse_selection
|
39
|
+
when "o" then opener&.call(choices[@active - 1].value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
attr_reader :opener
|
24
46
|
end
|
25
47
|
|
26
|
-
def self.prompt_for_gems_to_update(outdated_gems)
|
48
|
+
def self.prompt_for_gems_to_update(outdated_gems, prompt: nil)
|
27
49
|
table = Table.new(outdated_gems)
|
28
50
|
title = "#{outdated_gems.length} gems can be updated."
|
29
|
-
|
51
|
+
opener = lambda do |gem|
|
52
|
+
url = outdated_gems[gem].changelog_uri
|
53
|
+
Launchy.open(url) unless url.nil?
|
54
|
+
end
|
55
|
+
chosen = new(title: title, table: table, prompt: prompt, opener: opener).prompt
|
30
56
|
outdated_gems.slice(*chosen)
|
31
57
|
end
|
32
58
|
|
33
|
-
def initialize(title:, table:)
|
59
|
+
def initialize(title:, table:, opener: nil, prompt: nil)
|
34
60
|
@title = title
|
35
61
|
@table = table
|
36
|
-
@
|
62
|
+
@opener = opener
|
63
|
+
@tty_prompt = prompt || TTY::Prompt.new(
|
37
64
|
interrupt: lambda {
|
38
65
|
puts
|
39
66
|
exit(130)
|
40
67
|
}
|
41
68
|
)
|
42
|
-
add_keybindings
|
43
|
-
|
44
69
|
@pastel = BundleUpdateInteractive.pastel
|
45
70
|
end
|
46
71
|
|
47
72
|
def prompt
|
48
73
|
choices = table.gem_names.to_h { |name| [table.render_gem(name), name] }
|
49
|
-
tty_prompt.invoke_select(List, title, choices, help: help)
|
74
|
+
tty_prompt.invoke_select(List, title, choices, help: help, opener: opener)
|
50
75
|
end
|
51
76
|
|
52
77
|
private
|
53
78
|
|
54
|
-
attr_reader :pastel, :table, :tty_prompt, :title
|
55
|
-
|
56
|
-
def add_keybindings
|
57
|
-
tty_prompt.on(:keypress) do |event|
|
58
|
-
tty_prompt.trigger(:keyup) if %w[k p].include?(event.value)
|
59
|
-
tty_prompt.trigger(:keydown) if %w[j n].include?(event.value)
|
60
|
-
end
|
61
|
-
end
|
79
|
+
attr_reader :pastel, :table, :opener, :tty_prompt, :title
|
62
80
|
|
63
81
|
def help
|
64
82
|
[
|
65
|
-
pastel.dim("\nPress <space> to select, ↑/↓ move, <
|
83
|
+
pastel.dim("\nPress <space> to select, ↑/↓ move, <a> all, <r> reverse, <o> open url, <enter> to finish."),
|
66
84
|
"\n ",
|
67
85
|
table.render_header
|
68
86
|
].join
|
@@ -10,10 +10,12 @@ module BundleUpdateInteractive
|
|
10
10
|
|
11
11
|
@same_segments = new_segments.take_while.with_index { |seg, i| seg == old_segments[i] }
|
12
12
|
@diff_segments = new_segments[same_segments.length..]
|
13
|
+
|
14
|
+
@changed = diff_segments.any? || old_segments.length != new_segments.length
|
13
15
|
end
|
14
16
|
|
15
17
|
def severity
|
16
|
-
return nil
|
18
|
+
return nil unless @changed
|
17
19
|
|
18
20
|
SEVERITIES[same_segments.length] || :patch
|
19
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundle_update_interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: launchy
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.5.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.5.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pastel
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|