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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fea81d64cf4d80ba35966cfb2cf36ed00edf206307f46bad9c7d07dc524da732
4
- data.tar.gz: b3d9513020a6db543dd6551214aca212c0bc94124fc2a0debbe4e379357606e0
3
+ metadata.gz: 810f059bbc2e85fe481e437d815c66bcf6961d2a0db10961185760866d668bc3
4
+ data.tar.gz: ecbd3218e749bbfda79dd4844a74f77eb550f1b28d8a95bcc847138a99717f86
5
5
  SHA512:
6
- metadata.gz: 2583aa8b65971bd9c8bf7a34246ae710e5ab315ccc937e7721862bb67b331a2b911b2bce9edc15e020034b5f1e3c4725ace64a8daf15bb0b7472ec51cf835e0a
7
- data.tar.gz: e7008f2fcb80279c398c22fafda4a182346df1d8383c95de181d6489a401d06c587e5f9f5271b39d08e3ce4615c9082cc1ddc9092e91ee00fa0748c3e9d02100
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
@@ -30,4 +30,5 @@ namespace :commitment do
30
30
  end
31
31
 
32
32
  task(default: ['commitment:configure_test_for_code_coverage', :spec, 'commitment:code_coverage'])
33
+ task(build: :default)
33
34
  task(release: :default)
@@ -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
@@ -44,7 +44,12 @@ module Gm
44
44
 
45
45
  private
46
46
 
47
- attr_accessor :table_name, :filename, :config
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)
@@ -34,7 +34,7 @@ module Gm
34
34
  attr_accessor :column_delimiter
35
35
 
36
36
  def lookup_column=(input)
37
- @lookup_column = input.strip.freeze
37
+ @lookup_column = input.strip.downcase.freeze
38
38
  end
39
39
 
40
40
  def entry_column=(input)
@@ -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 = @registry.fetch(table_name)
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
- raise DuplicateKeyError.new(key: table_name, object: self) if @registry.key?(table_name)
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
- require_relative 'line_evaluator'
84
+ require 'gm/notepad/line_evaluator'
84
85
  LineEvaluator.new
85
86
  end
86
87
  end
@@ -1,5 +1,5 @@
1
1
  module Gm
2
2
  module Notepad
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
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.3
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-26 00:00:00.000000000 Z
11
+ date: 2019-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dice_parser