command_kit-completion 0.2.0 → 0.2.1

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: 5f85e448a2df37a8bc6231b839b8e56992432498384e6ea4c2e1060a9485c874
4
- data.tar.gz: 898168ab4ed70e3e595de27c933432a085976ea81980c7bcc3572e6e2cc4c38c
3
+ metadata.gz: 0c0c0378bac84ce2d4471fa0f3765f67b0c5fbf2324e4014fbbc6dc7b2d65eba
4
+ data.tar.gz: 5bc39444369f6b447b8a7ac7e184180de85867be5c11a69d9a0d5fcbb11124f8
5
5
  SHA512:
6
- metadata.gz: 45ceb26079e0d5caf31e94ea0851fc30e5175661491bed0d6da4f57feb3bc37352ef48e9f7d817f5dced1825db2aa94e0500387a8175dde6b805921c62453ab6
7
- data.tar.gz: 8858593122d06c2e4fff8d5f78fae75cd8f23665732131d36eb2fd9c52a51e94a8aa5fe3920b5b622a4f03a16360f442b79e6fd5a9b1c96cf78389c1871a6872
6
+ metadata.gz: cb50d3dfa8d1ea82cbc4e81587e2d96f197417d0e05c1e553ea246dba428387c93baf78c4ec8985a92d6c38177eddc3468e2285460680578e703941c2c8dc007
7
+ data.tar.gz: 0ed3ebd76e5463e2d05b74b424a3e83c87c69ca99babd98486d47ca0c813546a737ff258fa17c5badc744d21c9ec55b916b3bdf86f0f30c3d2f2aef232b6de81
data/ChangeLog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.2.1 / 2024-04-29
2
+
3
+ * Support loading YAML input files that contain YAML aliases.
4
+
1
5
  ### 0.2.0 / 2024-04-26
2
6
 
3
7
  * Also generate completion rules for option's short flags.
@@ -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 = YAML.load_file(@input_file)
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|
@@ -3,6 +3,6 @@
3
3
  module CommandKit
4
4
  module Completion
5
5
  # command_kit-completion version
6
- VERSION = '0.2.0'
6
+ VERSION = '0.2.1'
7
7
  end
8
8
  end
@@ -0,0 +1,4 @@
1
+ ---
2
+ foo update: &update
3
+ - $(foo list)
4
+ foo up: *update
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.0
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-27 00:00:00.000000000 Z
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