command_kit-completion 0.2.0 → 0.2.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/ChangeLog.md +4 -0
- data/lib/command_kit/completion/task.rb +11 -1
- data/lib/command_kit/completion/version.rb +1 -1
- data/spec/fixtures/additional_rules_with_aliases.yml +4 -0
- data/spec/task_spec.rb +36 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0c0378bac84ce2d4471fa0f3765f67b0c5fbf2324e4014fbbc6dc7b2d65eba
|
4
|
+
data.tar.gz: 5bc39444369f6b447b8a7ac7e184180de85867be5c11a69d9a0d5fcbb11124f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb50d3dfa8d1ea82cbc4e81587e2d96f197417d0e05c1e553ea246dba428387c93baf78c4ec8985a92d6c38177eddc3468e2285460680578e703941c2c8dc007
|
7
|
+
data.tar.gz: 0ed3ebd76e5463e2d05b74b424a3e83c87c69ca99babd98486d47ca0c813546a737ff258fa17c5badc744d21c9ec55b916b3bdf86f0f30c3d2f2aef232b6de81
|
data/ChangeLog.md
CHANGED
@@ -110,6 +110,16 @@ module CommandKit
|
|
110
110
|
Object.const_get(@class_name)
|
111
111
|
end
|
112
112
|
|
113
|
+
#
|
114
|
+
# Loads the completion rules from the {#input_file}.
|
115
|
+
#
|
116
|
+
# @return [Hash]
|
117
|
+
# The completion rules from the {#input_file}.
|
118
|
+
#
|
119
|
+
def load_input_file
|
120
|
+
YAML.load_file(@input_file, aliases: true)
|
121
|
+
end
|
122
|
+
|
113
123
|
#
|
114
124
|
# Maps the argument name strings to completely suggestion `<keyword>`s.
|
115
125
|
#
|
@@ -211,7 +221,7 @@ module CommandKit
|
|
211
221
|
|
212
222
|
if @input_file
|
213
223
|
# load the additional rules from the input file
|
214
|
-
additional_completion_rules =
|
224
|
+
additional_completion_rules = load_input_file
|
215
225
|
|
216
226
|
# merge the additional completion rules
|
217
227
|
additional_completion_rules.each do |command_string,completions|
|
data/spec/task_spec.rb
CHANGED
@@ -69,6 +69,42 @@ describe CommandKit::Completion::Task do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
describe "#load_input_file" do
|
73
|
+
let(:input_file) { File.join(fixtures_dir,'additional_rules.yml') }
|
74
|
+
|
75
|
+
subject do
|
76
|
+
described_class.new(
|
77
|
+
class_file: class_file,
|
78
|
+
class_name: class_name,
|
79
|
+
input_file: input_file,
|
80
|
+
output_file: output_file
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "must load the YAML from the input file" do
|
85
|
+
expect(subject.load_input_file).to eq(
|
86
|
+
{
|
87
|
+
'foo update' => ['$(foo list)']
|
88
|
+
}
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when the input file contains YAML aliases" do
|
93
|
+
let(:input_file) do
|
94
|
+
File.join(fixtures_dir,'additional_rules_with_aliases.yml')
|
95
|
+
end
|
96
|
+
|
97
|
+
it "must support parsing YAML aliases" do
|
98
|
+
expect(subject.load_input_file).to eq(
|
99
|
+
{
|
100
|
+
'foo update' => ['$(foo list)'],
|
101
|
+
'foo up'=> ['$(foo list)']
|
102
|
+
}
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
72
108
|
describe "#completion_rules_for" do
|
73
109
|
context "when given a simple CommandKit::Command class" do
|
74
110
|
class TestBasicCommand < CommandKit::Command
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_kit-completion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: command_kit
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/command_kit/completion/task.rb
|
85
85
|
- lib/command_kit/completion/version.rb
|
86
86
|
- spec/fixtures/additional_rules.yml
|
87
|
+
- spec/fixtures/additional_rules_with_aliases.yml
|
87
88
|
- spec/spec_helper.rb
|
88
89
|
- spec/task_spec.rb
|
89
90
|
homepage: https://github.com/postmodern/command_kit-completion#readme
|