gm-notepad 0.0.12 → 0.0.13
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7132b07f0d60930e2ee6872e5b61cdc7c316b948911b73ba3a03ea2b55425b85
|
4
|
+
data.tar.gz: 06a8a66713c90f704e1756510f799a810b96e98233141100a17c122a99bbcc2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb74e6192b9d77c1d48b46be76651a6fea524d481a88537f63ae20f041a8b3b0a370773ca7c6efe0c2ea293c4ddaa9bfa1e6b1196885829a8a35e7b5847a12a4
|
7
|
+
data.tar.gz: '04984f322e40f16053b54210262691e0336024bb73b9dd72c78a9b0f1262d1597e9d6f9bef4969970179366c0d62c16ba8a08bb6a78ed6a269059cb502756582'
|
data/README.md
CHANGED
@@ -220,8 +220,7 @@ columns. _I am still working on retrieving by column names as well as rendering
|
|
220
220
|
- [X] Allow configuration to specify table delimiter
|
221
221
|
- [ ] Raise load error if table index is a "dice" expression
|
222
222
|
- [X] Allow configuration for where to dump data
|
223
|
-
- [
|
224
|
-
- [ ] Normalize `WriteToTableHandler` to deliver on `grep` and `index` behavior
|
223
|
+
- [X] Normalize `WriteToTableHandler` to use a renderer
|
225
224
|
- [X] Gracefully handle requesting an entry from a table with an index that does not exist (e.g. with test data try `+name[23]`)
|
226
225
|
- [X] Gracefully handle `+name[]`, where "name" is a registered table
|
227
226
|
- [X] Add time to live for line expansion (to prevent infinite loops); I suspect 100 to be reasonable
|
@@ -238,9 +237,9 @@ columns. _I am still working on retrieving by column names as well as rendering
|
|
238
237
|
- [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
|
239
238
|
- [X] Ensure index names are lower-case
|
240
239
|
- [ ] Hit 100% spec coverage
|
241
|
-
- [
|
240
|
+
- [X] Create a "To Render Object"; When you parse the input, you push relevant lines to that "To Render Object". When you look at a table, you want to know what the column names are.
|
242
241
|
- [X] Remove "defer" printing concept
|
243
|
-
- [
|
242
|
+
- [X] Add ability to shell out; I would love to leverage the [swnt](https://github.com/nboughton/swnt) command line tool
|
244
243
|
|
245
244
|
### Stretch TODO
|
246
245
|
|
@@ -255,3 +254,4 @@ columns. _I am still working on retrieving by column names as well as rendering
|
|
255
254
|
- [ ] Add force write results to `output`
|
256
255
|
- [ ] Add option to dump all tables to the given directory
|
257
256
|
- [ ] Add config that expands dice results while including the requested roll
|
257
|
+
- [ ] Normalize `WriteToTableHandler` to deliver on `grep` and `index` behavior
|
data/lib/gm/notepad/container.rb
CHANGED
@@ -26,9 +26,11 @@ module Gm
|
|
26
26
|
require "gm/notepad/input_handlers/query_table_names_handler"
|
27
27
|
require "gm/notepad/input_handlers/write_to_table_handler"
|
28
28
|
require "gm/notepad/input_handlers/write_line_handler"
|
29
|
+
require "gm/notepad/input_handlers/shell_out_handler"
|
29
30
|
InputHandlerRegistry.new do |registry|
|
30
31
|
registry.register(handler: InputHandlers::HelpHandler)
|
31
32
|
registry.register(handler: InputHandlers::CommentHandler)
|
33
|
+
registry.register(handler: InputHandlers::ShellOutHandler)
|
32
34
|
registry.register(handler: InputHandlers::QueryTableHandler)
|
33
35
|
registry.register(handler: InputHandlers::QueryTableNamesHandler)
|
34
36
|
registry.register(handler: InputHandlers::WriteToTableHandler)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "gm/notepad/input_handlers/default_handler"
|
2
|
+
require "shellwords"
|
3
|
+
module Gm
|
4
|
+
module Notepad
|
5
|
+
module InputHandlers
|
6
|
+
class ShellOutHandler < DefaultHandler
|
7
|
+
SHELL_OUT_HANDLER_REGEXP = /^`/.freeze
|
8
|
+
TO_OUTPUT_REGEXP = /^\>/.freeze
|
9
|
+
|
10
|
+
def self.handles?(input:)
|
11
|
+
return false unless input.match(SHELL_OUT_HANDLER_REGEXP)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_initialize!
|
16
|
+
input.sub!(SHELL_OUT_HANDLER_REGEXP,'')
|
17
|
+
if input.match(TO_OUTPUT_REGEXP)
|
18
|
+
input.sub!(TO_OUTPUT_REGEXP, '')
|
19
|
+
to_output = true
|
20
|
+
else
|
21
|
+
to_output = false
|
22
|
+
end
|
23
|
+
command = input.to_s.split
|
24
|
+
response = `#{command.shelljoin}`.strip
|
25
|
+
|
26
|
+
input.for_rendering(
|
27
|
+
text: response,
|
28
|
+
to_interactive: true,
|
29
|
+
to_output: to_output,
|
30
|
+
expand_line: false
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -9,7 +9,6 @@ module Gm
|
|
9
9
|
return true if input.match(/^\</)
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_accessor :index, :grep, :table_name, :line
|
13
12
|
NON_EXPANDING_CHARATER = '!'.freeze
|
14
13
|
WITH_INDEX_REGEXP = %r{(?<declaration>\[(?<index>[^\]]+)\])}
|
15
14
|
WITH_GREP_REGEXP = %r{(?<declaration>\/(?<grep>[^\/]+)/)}
|
@@ -20,12 +19,12 @@ module Gm
|
|
20
19
|
table_name = match[:table_name]
|
21
20
|
if index_match = WITH_INDEX_REGEXP.match(table_name)
|
22
21
|
table_name = table_name.sub(index_match[:declaration], '')
|
23
|
-
|
22
|
+
index = index_match[:index]
|
24
23
|
elsif grep_match = WITH_GREP_REGEXP.match(table_name)
|
25
24
|
table_name = table_name.sub(grep_match[:declaration], '')
|
26
|
-
|
25
|
+
grep = grep_match[:grep]
|
27
26
|
end
|
28
|
-
|
27
|
+
table_name = table_name.downcase
|
29
28
|
else
|
30
29
|
raise "I don't know what to do"
|
31
30
|
end
|
data/lib/gm/notepad/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/gm/notepad/input_handlers/help_handler.rb
|
199
199
|
- lib/gm/notepad/input_handlers/query_table_handler.rb
|
200
200
|
- lib/gm/notepad/input_handlers/query_table_names_handler.rb
|
201
|
+
- lib/gm/notepad/input_handlers/shell_out_handler.rb
|
201
202
|
- lib/gm/notepad/input_handlers/write_line_handler.rb
|
202
203
|
- lib/gm/notepad/input_handlers/write_to_table_handler.rb
|
203
204
|
- lib/gm/notepad/input_processor.rb
|