prompt-lists 0.1.0 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/prompt_lists.rb +16 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 012544c471f1798737ad316b6754c759ef71a8517773b6327d2b6df27eb55b02
4
- data.tar.gz: 75c763367e9e2a2d559fd7770c8d482113ac8e45fc5256e63b0d78919ac90f96
3
+ metadata.gz: 1081fe5953e84622f8d0a63263278649d9fbb86da553c0651993c31a155a597d
4
+ data.tar.gz: c1a7c7e0655eff637358ea805d52dab76d149d8bee0513d6549987eaeaf0dd4e
5
5
  SHA512:
6
- metadata.gz: 2fe3625e9fdcf56a5898b3fad615c2afa94aeb5e88ce54cbe3d32592c80a7a300385f9de05d383f3d61d3c1890ec93db24f5f49486f997a2cf8a12b4e91b9528
7
- data.tar.gz: aac8fa273db97b0bc760c0cf811520e12a629a54119a2feb2188daa26c4bc652202d4c3b26a7d44e2f038c6d0c9afb1ebf9a56e3579028cf414f164b4c8992ef
6
+ metadata.gz: 81b1bb8bf974b77490ee745f99bf10c69829c0a406ee198bbada2f70ed6966531ea0c77d24c3fedff2c0d1429dccf9c0e2ca5bcbc436b13f1750b76b7241b618
7
+ data.tar.gz: 921bf43b191ce9b0739a21e23edf6759dc1974380c39db1ba73e1ff47281703a45dcd168cf4ebfaf7ba4084d8778b139ef10ee4d39eef936d5b3807abef4d9f2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prompt-lists (0.1.0)
4
+ prompt-lists (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/prompt_lists.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'yaml'
4
3
 
5
4
  module PromptLists
6
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
7
6
 
8
7
  class List
9
8
  attr_reader :id, :sublist_names
@@ -33,6 +32,7 @@ module PromptLists
33
32
  class Sublist
34
33
  attr_reader :id
35
34
  attr_accessor :metadata, :items
35
+
36
36
  def initialize(file_path)
37
37
  @file_path = file_path
38
38
  @id = File.basename(file_path, ".yml").gsub(/-/, "_").to_sym
@@ -49,14 +49,25 @@ module PromptLists
49
49
  def all
50
50
  Dir[File.expand_path("../lists/*", __dir__)].map do |list|
51
51
  list_name = File.basename(list)
52
- List.new(list_name, load_sublists(list_name))
52
+ find(list_name)
53
53
  end
54
54
  end
55
55
 
56
56
  def find(list_name)
57
- if list_exists?(list_name)
58
- List.new(list_name, load_sublists(list_name))
57
+ @lists ||= {}
58
+
59
+ if list_name.to_s.include?('.')
60
+ main_list, sublist = list_name.to_s.split('.')
61
+ if list_exists?(main_list)
62
+ list = find(main_list)
63
+ sublist_sym = sublist&.gsub(/-/, '_')&.to_sym
64
+ return list.send(sublist_sym) if list.sublist_names.include?(sublist_sym)
65
+ end
66
+ elsif list_exists?(list_name)
67
+ @lists[list_name.to_sym] ||= List.new(list_name, load_sublists(list_name))
68
+ return @lists[list_name.to_sym]
59
69
  end
70
+ nil
60
71
  end
61
72
 
62
73
  def method_missing(method_name, *args)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt-lists
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dreaming Tulpa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry