prompt-lists 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +10 -1
  4. data/lib/prompt_lists.rb +24 -20
  5. 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: 470a9a2e1784148f8e3f564e148858b5d6d2282ac0c5be577cdb82b142292f1c
4
+ data.tar.gz: 4a9cc2d872bd350372562a38722c51706be6600d3abc8ae01a92bf53709dd77d
5
5
  SHA512:
6
- metadata.gz: a11c80a4b2df1b536f0f21a2c982f7671c3d5fb27e553b7be30f17028138c9ae53a843704b221e33f639ad537fcfbf9f3730502b4c74ff3fd4a28817e8949322
7
- data.tar.gz: 32eebde5492e826b64d77113cdac16d752c38668e415d19965d75524ca800b2eac32d6b3d2e516159d59084d1866d451334621eb05d09bc11e03e9dea284403d
6
+ metadata.gz: b224390cb3c7acf9b0a925de3da24edb62842219e92a132369f67128da1dd71af2b7c6365e9ab4df4216e5c22a55c9a641068773e340fd63b1c2dedbf9bd2dee
7
+ data.tar.gz: e4b1ecd1cd6d03e3f6001837115c5946e008ec7231f822d82038e7978ac23d78c8cdee7d601e1fc5971b224f7390dffb0ce351ac666a2e8b2e537388c1b62f93
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prompt-lists (0.0.1)
4
+ prompt-lists (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -6,4 +6,13 @@ generation on [PROMPTCACHE](https://promptcache.com).
6
6
  ## Installation
7
7
 
8
8
  ```ruby
9
- gem "prompt-lists"
9
+ gem "prompt-lists", require: '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.3'
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 = File.expand_path("../lists/#{@id}/#{sublist}.yml", __dir__)
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,28 +41,33 @@ 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[File.expand_path("../lists/*", __dir__)].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[File.expand_path("../lists/#{list_name}/*.yml", __dir__)].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)
66
- Dir.exist?("lists/#{list_name}")
70
+ Dir.exist?(File.expand_path("../lists/#{list_name}", __dir__))
67
71
  end
68
72
  end
69
73
  end
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.3
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: []