toys-core 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0202fa141dcee7d96aacdec2092ace8041f5498e367596d8e2a5aa893fa64d36
4
- data.tar.gz: 20ea445f7ad7a5ab964ad23434e57f4acb6ee567e6dc38837751246d32940ca5
3
+ metadata.gz: ac33c1214b7ae27c8ecea97837cd1ba186dfc3715db69ef52ef9dc24e56f8064
4
+ data.tar.gz: 9e8cc340e38cd320893cf9ee47c31c138ea42f9850c8efebb315a9e60182d791
5
5
  SHA512:
6
- metadata.gz: 704d70fc544435c23cf3d0e88550fa3a3951bbb9b3611eabdc89c3c9871d3ad67098cce21fa54ffb130aa4da6d0901729471b9e698ae78a394f8ff750392205f
7
- data.tar.gz: 57d9cacc5646fd39e0399bb2729d0a936d70f5d67a1f7a7e3d4b19a5d38ab699dc6b0e5044ae455fea3cdb0d46e44406bfc898074e71e2d9b3cc7882981886d7
6
+ metadata.gz: e77ed0de1cc6ee14300c4787c334f3ecd97e338d16df4e9004b303a618163b6cd07709cf1d956e9278b9e52624105cdfd87010c55d111580a164a9a6cddf9b4f
7
+ data.tar.gz: 02521cfe60b37bb36c7a5550a2c33a42e4de6f74350fa3b852c333642fc7aa0e7e7b4523a94219236f1523ad7a9c3f5297a2467b2a03b5337234fb059eac730c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History
2
2
 
3
+ ### 0.6.1 / 2019-01-07
4
+
5
+ * FIXED: The presence of aliases caused subtool listing to crash.
6
+
3
7
  ### 0.6.0 / 2018-10-22
4
8
 
5
9
  * CHANGED: Replaced Toys::Definition::DataFinder with Toys::Definition::SourceInfo.
@@ -34,5 +34,5 @@ module Toys
34
34
  # Current version of Toys core
35
35
  # @return [String]
36
36
  #
37
- CORE_VERSION = "0.6.0"
37
+ CORE_VERSION = "0.6.1"
38
38
  end
data/lib/toys/loader.rb CHANGED
@@ -341,7 +341,7 @@ module Toys
341
341
 
342
342
  private
343
343
 
344
- ALLOWED_DELIMITERS = %r{^[\./:]*$}
344
+ ALLOWED_DELIMITERS = %r{^[\./:]*$}.freeze
345
345
 
346
346
  def process_extra_delimiters(input)
347
347
  unless ALLOWED_DELIMITERS =~ input
@@ -374,19 +374,12 @@ module Toys
374
374
  # priority tool that has been defined. If no tool has been defined with
375
375
  # the given name, returns `nil`.
376
376
  #
377
- # @private
378
- #
379
377
  def get_active_tool(words, looked_up = [])
380
378
  tool_data = get_tool_data(words)
381
379
  result = tool_data.active_definition
382
380
  case result
383
381
  when Definition::Alias
384
- words = result.target_name
385
- if looked_up.include?(words)
386
- raise ToolDefinitionError, "Circular alias references: #{looked_up.inspect}"
387
- end
388
- looked_up << words
389
- get_active_tool(words, looked_up)
382
+ resolve_alias(result, looked_up)
390
383
  when Definition::Tool
391
384
  result
392
385
  else
@@ -394,6 +387,18 @@ module Toys
394
387
  end
395
388
  end
396
389
 
390
+ ##
391
+ # Resolves the given alias
392
+ #
393
+ def resolve_alias(alias_tool, looked_up = [])
394
+ words = alias_tool.target_name
395
+ if looked_up.include?(words)
396
+ raise ToolDefinitionError, "Circular alias references: #{looked_up.inspect}"
397
+ end
398
+ looked_up << words
399
+ get_active_tool(words, looked_up)
400
+ end
401
+
397
402
  def resolve_middleware(input)
398
403
  input = Array(input)
399
404
  cls = input.first
@@ -526,16 +531,17 @@ module Toys
526
531
  def filter_hidden_subtools(tools)
527
532
  result = []
528
533
  tools.each_with_index do |tool, index|
529
- next if tool.full_name.any? { |n| n.start_with?("_") }
530
- unless tool.runnable?
531
- next_tool = tools[index + 1]
532
- next if next_tool && next_tool.full_name.slice(0..-2) == tool.full_name
533
- end
534
- result << tool
534
+ result << tool unless tool_hidden?(tool, tools[index + 1])
535
535
  end
536
536
  result
537
537
  end
538
538
 
539
+ def tool_hidden?(tool, next_tool)
540
+ return true if tool.full_name.any? { |n| n.start_with?("_") }
541
+ return tool_hidden?(resolve_alias(tool), nil) if tool.is_a? Definition::Alias
542
+ !tool.runnable? && next_tool && next_tool.full_name.slice(0..-2) == tool.full_name
543
+ end
544
+
539
545
  def calc_remaining_words(words1, words2)
540
546
  index = 0
541
547
  lengths = [words1.length, words2.length]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toys-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-22 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.59.2
89
+ version: 0.62.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.59.2
96
+ version: 0.62.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yard
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -180,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 2.7.6
183
+ rubygems_version: 3.0.2
185
184
  signing_key:
186
185
  specification_version: 4
187
186
  summary: Framework for creating command line binaries