prompt-lists 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -0
  3. data/lib/prompt_lists.rb +23 -19
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0719a4ca57aa5a503c6b75a3738ab02fa9b5e7b1e39f04342df11e331d60f8b
4
- data.tar.gz: 2d06005433ed1af9caf552d4a70ece60bffff996ce67e04105ac2113c0a8c478
3
+ metadata.gz: 12cf020db05a18abd78762cda6066f4b99220d20bfb0fe43c82f684523191436
4
+ data.tar.gz: 1bc63760c24188c261532c6a8f75a30a5d8d17a3918795a9b2b5d8bb82945f7e
5
5
  SHA512:
6
- metadata.gz: a11c80a4b2df1b536f0f21a2c982f7671c3d5fb27e553b7be30f17028138c9ae53a843704b221e33f639ad537fcfbf9f3730502b4c74ff3fd4a28817e8949322
7
- data.tar.gz: 32eebde5492e826b64d77113cdac16d752c38668e415d19965d75524ca800b2eac32d6b3d2e516159d59084d1866d451334621eb05d09bc11e03e9dea284403d
6
+ metadata.gz: 6bf0c5c275c75c4b05cc452fa7609084ec030d312fd839a7713d6c623370ca78f4016e72c13c8734f4b6241328f546960baaedcb593ba11c1686e8287c420060
7
+ data.tar.gz: 45aaa46345e2c5214cce932450856eafb08f408b73f26e8313847bce6a0cd9c5998029166f695dd868833bc7c295a38321e93d32ac2f4415d01dee30dcc81331
data/README.md CHANGED
@@ -7,3 +7,12 @@ generation on [PROMPTCACHE](https://promptcache.com).
7
7
 
8
8
  ```ruby
9
9
  gem "prompt-lists"
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ You can retrieve items like so:
15
+
16
+ ```ruby
17
+ PromptLists.photography.camera.items
18
+ ```
data/lib/prompt_lists.rb CHANGED
@@ -3,27 +3,26 @@
3
3
  require 'yaml'
4
4
 
5
5
  module PromptLists
6
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
7
7
 
8
8
  class List
9
- def initialize(file_paths)
10
- @sublists = file_paths.map do |file_path|
11
- id = File.basename(file_path, ".yml").gsub("-", "_").to_sym
12
- Hash[id, file_path]
13
- end
9
+ def initialize(list_name, sublist_names)
10
+ @id = list_name.to_sym
11
+ @sublists = sublist_names
14
12
  end
15
13
 
16
14
  def method_missing(method_name, *args)
17
- sublist = @sublists.find { |sublist| sublist.key?(method_name) }
15
+ sublist = @sublists.find { |sublist| sublist == method_name }
18
16
  if sublist
19
- Sublist.new(sublist.values[0])
17
+ path = "lists/#{@id}/#{sublist}.yml"
18
+ Sublist.new(path)
20
19
  else
21
20
  super
22
21
  end
23
22
  end
24
23
 
25
24
  def respond_to_missing?(method_name, include_private = false)
26
- sublist = @sublists.find { |sublist| sublist.key?(method_name) }
25
+ sublist = @sublists.find { |sublist| sublist == method_name }
27
26
  sublist || super
28
27
  end
29
28
  end
@@ -42,24 +41,29 @@ module PromptLists
42
41
  end
43
42
 
44
43
  class << self
45
- def method_missing(method_name, *args)
46
- list_name = method_name.to_s
44
+ def all
45
+ Dir["lists/*"].map do |list|
46
+ list_name = File.basename(list)
47
+ List.new(list_name, load_sublists(list_name))
48
+ end
49
+ end
50
+
51
+ def find(list_name)
47
52
  if list_exists?(list_name)
48
- result = load_list(list_name)
49
- List.new(result)
50
- else
51
- super
53
+ List.new(list_name, load_sublists(list_name))
52
54
  end
53
55
  end
54
56
 
55
- def respond_to_missing?(method_name, include_private = false)
56
- list_exists?(method_name.to_s) || super
57
+ def method_missing(method_name, *args)
58
+ find(method_name) || super
57
59
  end
58
60
 
59
61
  private
60
62
 
61
- def load_list(list_name)
62
- Dir["lists/#{list_name}/*.yml"]
63
+ def load_sublists(list_name)
64
+ Dir["lists/#{list_name}/*.yml"].map do |file_path|
65
+ File.basename(file_path, ".yml").gsub(/-/, "_").to_sym
66
+ end
63
67
  end
64
68
 
65
69
  def list_exists?(list_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt-lists
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dreaming Tulpa
@@ -270,11 +270,11 @@ files:
270
270
  - lists/word/adverb.yml
271
271
  - lists/word/noun.yml
272
272
  - lists/word/verb.yml
273
- homepage: https://github.com/dreamingtulpa/prompt-lists
273
+ homepage: https://promptcache.com
274
274
  licenses:
275
275
  - MIT
276
276
  metadata:
277
- homepage_uri: https://github.com/dreamingtulpa/prompt-lists
277
+ homepage_uri: https://promptcache.com
278
278
  source_code_uri: https://github.com/dreamingtulpa/prompt-lists
279
279
  changelog_uri: https://github.com/dreamingtulpa/prompt-lists/blob/master/CHANGELOG.md
280
280
  post_install_message:
@@ -295,5 +295,5 @@ requirements: []
295
295
  rubygems_version: 3.4.10
296
296
  signing_key:
297
297
  specification_version: 4
298
- summary: Categorised lists of things for AI image and media generation.
298
+ summary: Categorised lists of things for AI image and media generation on promptcache.com.
299
299
  test_files: []