gm-notepad 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/lib/gm/notepad/line_evaluator.rb +1 -1
- data/lib/gm/notepad/table.rb +6 -1
- data/lib/gm/notepad/table_entry.rb +1 -1
- data/lib/gm/notepad/table_registry.rb +5 -4
- data/lib/gm/notepad/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: 810f059bbc2e85fe481e437d815c66bcf6961d2a0db10961185760866d668bc3
|
4
|
+
data.tar.gz: ecbd3218e749bbfda79dd4844a74f77eb550f1b28d8a95bcc847138a99717f86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038db1de31070662c1014545d0b812ddea79ce9e79cf2cce5d30483b6149ce9bdab3a4dcf8367bd22fbb719ac63d6b409ea7a88c41586c1caea2442a7784fbe5'
|
7
|
+
data.tar.gz: aed9015c6102810fbe795654ecf4e2ba5adcfb2f9b038471f32ec44f97452437a8549dfd3fcbecd10efb439f7206639e1f8bc1611eae4c60b0a05465a7498fd9
|
data/README.md
CHANGED
@@ -237,3 +237,6 @@ entry has a 1 in 3 chance of being randomly chosen.
|
|
237
237
|
- [ ] Create a configuration object that captures the initial input (reduce passing around parameters and persisting copies of the config)
|
238
238
|
- [ ] Aspiration: Enable `{{monster}[ac]}` to pick a random monster and then fetch that monster's AC
|
239
239
|
- [ ] Add concept of "journal entry"; its not a table (perhaps) but something that you could capture notes.
|
240
|
+
- [ ] Add column handling `{table[][]}`
|
241
|
+
- [X] Support `{{table}-name}` You should be able to do `{{culture}-name}` and first evaluate to `{arabic-name}` and then get a value from the `arabic-name` table
|
242
|
+
- [X] Ensure index names are lower-case
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ module Gm
|
|
3
3
|
module Notepad
|
4
4
|
# Responsible for recording entries and then dumping them accordingly.
|
5
5
|
class LineEvaluator
|
6
|
-
TABLE_NAME_REGEXP = %r{(?<table_name_container>\{(?<table_name>[^\}]+)\})}
|
6
|
+
TABLE_NAME_REGEXP = %r{(?<table_name_container>\{(?<table_name>[^\{\}]+)\})}
|
7
7
|
DICE_REGEXP = %r{(?<dice_container>\[(?<dice>[^\]]+)\])}
|
8
8
|
def call(line:, table_lookup_function:, expand_line: true)
|
9
9
|
return line unless expand_line
|
data/lib/gm/notepad/table.rb
CHANGED
@@ -44,7 +44,12 @@ module Gm
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
attr_accessor :
|
47
|
+
attr_accessor :filename, :config
|
48
|
+
attr_reader :table_name
|
49
|
+
|
50
|
+
def table_name=(input)
|
51
|
+
@table_name = input.downcase
|
52
|
+
end
|
48
53
|
|
49
54
|
def random_index
|
50
55
|
rand(@table.size)
|
@@ -38,7 +38,7 @@ module Gm
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def fetch_table(name:)
|
41
|
-
@registry.fetch(name)
|
41
|
+
@registry.fetch(name.downcase)
|
42
42
|
end
|
43
43
|
|
44
44
|
def append(table_name:, line:, write:)
|
@@ -62,7 +62,7 @@ module Gm
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def lookup(table_name:, **kwargs)
|
65
|
-
table =
|
65
|
+
table = fetch_table(name: table_name)
|
66
66
|
table.lookup(**kwargs)
|
67
67
|
rescue KeyError
|
68
68
|
"(undefined #{table_name})"
|
@@ -75,12 +75,13 @@ module Gm
|
|
75
75
|
private
|
76
76
|
|
77
77
|
def register(table_name:, lines:, filename: nil)
|
78
|
-
|
78
|
+
table_name = table_name.downcase
|
79
|
+
raise DuplicateKeyError.new(key: table_name, object: self) if @registry.key?(table_name.downcase)
|
79
80
|
@registry[table_name] = Table.new(table_name: table_name, lines: lines, filename: filename, **config)
|
80
81
|
end
|
81
82
|
|
82
83
|
def default_line_evaluator
|
83
|
-
|
84
|
+
require 'gm/notepad/line_evaluator'
|
84
85
|
LineEvaluator.new
|
85
86
|
end
|
86
87
|
end
|
data/lib/gm/notepad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gm-notepad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dice_parser
|