precedences 1.6.1 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +9 -0
- data/Manual/Manuel-fr.md +15 -0
- data/Manual/Manuel-fr.pdf +0 -0
- data/Rakefile +2 -1
- data/lib/precedences/precedence.rb +37 -0
- data/lib/precedences/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: 1ed9f5b6998fb031df105d341a359c9d94a80076d4da8f8c0045cc9df7a969bc
|
4
|
+
data.tar.gz: 51a2dba7c25fda5e793bd2c652252b23d9b6ce27bd8b7e6a6bffc0b230e35d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c369c5eadbad2aab5e2de1718fd32f0ad4011857ed276b34e021adfd216a4e929491ac99e32a7892afd01146e4391b542ab2d2c5dbf7e0d0459575b27fb9ca52
|
7
|
+
data.tar.gz: aafb057ec9ecf018cda24822aa51a0f99d7f5226a40d7cda6da6dad836f15a65c5893108efd032c758b9c43720382bc79074467217a5f3557f6a7278ab044e61
|
data/CHANGELOG
CHANGED
data/Manual/Manuel-fr.md
CHANGED
@@ -106,6 +106,7 @@ choix = precedencize(choices, file) do |q|
|
|
106
106
|
end
|
107
107
|
~~~
|
108
108
|
|
109
|
+
<a name="options"></a>
|
109
110
|
|
110
111
|
## Options possibles
|
111
112
|
|
@@ -161,6 +162,14 @@ choix = precedencize(choices, precfile) do |q|
|
|
161
162
|
q.default = "premier"
|
162
163
|
# ou q.default "premier"
|
163
164
|
# => Sélectionnera le choix "Choix premier"
|
165
|
+
|
166
|
+
# Ajout de menus à la fin, jamais classés
|
167
|
+
q.add "Dernier menu", :last
|
168
|
+
q.add_choice "Tout dernier", :very_last
|
169
|
+
|
170
|
+
# Ajout de menus au début, jamais classés
|
171
|
+
q.add_choice "Tout premier".bleu, :very_first, **{at_top:true}
|
172
|
+
q.add("Premier", :first, {at_top: true})
|
164
173
|
|
165
174
|
end
|
166
175
|
|
@@ -187,3 +196,9 @@ end
|
|
187
196
|
~~~
|
188
197
|
|
189
198
|
> 😃 Noter qu’on peut en fait se servir de ce menu pour ajouter n’importe quel autre menu que “Renoncer”.
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
#### Ajouter un menu quelconque
|
203
|
+
|
204
|
+
Utiliser les méthodes `#add` ou `#add_choice` (alias). Cf. ci-dessus [Options possibles](#options).
|
data/Manual/Manuel-fr.pdf
CHANGED
Binary file
|
data/Rakefile
CHANGED
@@ -4,7 +4,8 @@ require "rake/testtask"
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
5
|
t.libs << "test"
|
6
6
|
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
7
|
+
# t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
t.test_files = FileList["test/**/precedences_test.rb"]
|
8
9
|
end
|
9
10
|
|
10
11
|
task :default => :test
|
@@ -169,16 +169,42 @@ class Precedence
|
|
169
169
|
@add_choice_cancel = params
|
170
170
|
end
|
171
171
|
|
172
|
+
##
|
173
|
+
# To add any choice not precedencized
|
174
|
+
#
|
175
|
+
# @param name [String] The menu name
|
176
|
+
# @param value [Any] Then value of the menu
|
177
|
+
# @param params [Hash]
|
178
|
+
# :at_top If true, add the item at the top
|
179
|
+
# Else (default) add at the bottom
|
180
|
+
#
|
181
|
+
attr_reader :added_choices_before
|
182
|
+
attr_reader :added_choices_after
|
183
|
+
def add(name, value, **params)
|
184
|
+
@added_choices_before ||= []
|
185
|
+
@added_choices_after ||= []
|
186
|
+
name.is_a?(String) || raise(ArgumentError.new("First argument should be a String."))
|
187
|
+
lechoix = {name: name, value: value}
|
188
|
+
if params[:at_top]
|
189
|
+
@added_choices_before << lechoix
|
190
|
+
else
|
191
|
+
@added_choices_after << lechoix
|
192
|
+
end
|
193
|
+
end
|
194
|
+
alias :add_choice :add
|
195
|
+
|
172
196
|
private
|
173
197
|
|
174
198
|
##
|
175
199
|
# = main =
|
200
|
+
# @private
|
176
201
|
#
|
177
202
|
def prepare_choices(choices)
|
178
203
|
#
|
179
204
|
# Classement des choix par précédence
|
180
205
|
#
|
181
206
|
choices = sort_items(choices)
|
207
|
+
|
182
208
|
#
|
183
209
|
# Faut-il ajouter un choix cancel ?
|
184
210
|
#
|
@@ -186,6 +212,17 @@ class Precedence
|
|
186
212
|
add_method = (@add_choice_cancel[:position] == :down) ? :push : :unshift
|
187
213
|
choices.send(add_method, @add_choice_cancel)
|
188
214
|
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# Y a-t-il des menus à ajouter ?
|
218
|
+
#
|
219
|
+
if added_choices_before && not(added_choices_before.empty?)
|
220
|
+
choices = added_choices_before + choices
|
221
|
+
end
|
222
|
+
if added_choices_after && not(added_choices_after.empty?)
|
223
|
+
choices = choices + added_choices_after
|
224
|
+
end
|
225
|
+
|
189
226
|
#
|
190
227
|
# On retourne les choix préparés
|
191
228
|
#
|
data/lib/precedences/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: precedences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PhilippePerret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clir
|