runeblog 0.0.52 → 0.0.55
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 +4 -4
- data/data/VERSION +1 -1
- data/lib/helpers-repl.rb +3 -2
- data/lib/repl.rb +2 -1
- data/lib/runeblog.rb +7 -3
- data/test/repl.rb +71 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3230f2f1ce1ac7d38765560c832a5acb40189b47
|
4
|
+
data.tar.gz: c6692b68329296918053f618ff0efc909cd33c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4934899d445ad1064a16e4e8c60c7122721b58b9d838dbee718c41c3680a0305f8b0ee5d34731d4e7a98d4cceb839fcb9fc87f0d006d8842dd15947e9966e53c
|
7
|
+
data.tar.gz: 3cc0e19544bb1ebb3907096182c10af03c75322057813a03e9cd993644542af26ab14da6152c00af72561a146590c78c5522ade8d904fe39b7314b219ad7c111
|
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RuneBlog v 0.0.
|
1
|
+
RuneBlog v 0.0.55 2018-09-10
|
data/lib/helpers-repl.rb
CHANGED
@@ -59,13 +59,13 @@ module RuneBlog::REPL
|
|
59
59
|
rx.gsub!(/\$(\w+) */) { " *(?<#{$1}>\\w+)" }
|
60
60
|
# How to handle multiple optional args?
|
61
61
|
rx.sub!(/>(\w+)$/) { "(.+)" }
|
62
|
-
p rx if rx =~ /kill/
|
63
62
|
rx << "$"
|
64
63
|
rx = Regexp.new(rx)
|
65
64
|
Regexes[rx] = meth
|
66
65
|
end
|
67
66
|
|
68
67
|
def self.choose_method(cmd)
|
68
|
+
cmd = cmd.strip
|
69
69
|
found = nil
|
70
70
|
params = []
|
71
71
|
Regexes.each_pair do |rx, meth|
|
@@ -78,8 +78,9 @@ p rx if rx =~ /kill/
|
|
78
78
|
end
|
79
79
|
meth = found || :cmd_INVALID
|
80
80
|
params = cmd if meth == :cmd_INVALID
|
81
|
-
[meth, params]
|
81
|
+
[meth, params.first]
|
82
82
|
end
|
83
|
+
|
83
84
|
def error(err)
|
84
85
|
str = "\n Error: #{red(err)}"
|
85
86
|
puts str
|
data/lib/repl.rb
CHANGED
@@ -156,7 +156,7 @@ module RuneBlog::REPL
|
|
156
156
|
|
157
157
|
def cmd_change_view(arg)
|
158
158
|
if arg.empty?
|
159
|
-
return "\n
|
159
|
+
return "\n #{@blog.view}"
|
160
160
|
else
|
161
161
|
out = ""
|
162
162
|
arg = arg.first
|
@@ -280,6 +280,7 @@ module RuneBlog::REPL
|
|
280
280
|
def cmd_list_posts(arg)
|
281
281
|
raise "Glitch: #{__callee__} Got an argument" if arg != []
|
282
282
|
out = ""
|
283
|
+
@view = @blog.view
|
283
284
|
dir = @blog.viewdir(@view)
|
284
285
|
Dir.chdir(dir) do
|
285
286
|
posts = Dir.entries(".").grep(/^0.*/)
|
data/lib/runeblog.rb
CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'livetext'
|
4
4
|
|
5
5
|
class RuneBlog
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.55"
|
7
7
|
|
8
8
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
9
9
|
DefaultData = Path + "/../data"
|
@@ -36,8 +36,7 @@ class RuneBlog
|
|
36
36
|
lines = File.readlines(cfg_file).map {|x| x.chomp }
|
37
37
|
@root = lines[0]
|
38
38
|
@view = lines[1]
|
39
|
-
dirs =
|
40
|
-
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
39
|
+
dirs = subdirs("#@root/views/")
|
41
40
|
@root = root
|
42
41
|
@views = dirs
|
43
42
|
@sequence = File.read(root + "/sequence").to_i
|
@@ -85,4 +84,9 @@ EOS
|
|
85
84
|
"#{num}-#{slug}"
|
86
85
|
end
|
87
86
|
|
87
|
+
def subdirs(dir)
|
88
|
+
dirs = Dir.entries(dir) - %w[. ..]
|
89
|
+
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
90
|
+
dirs
|
91
|
+
end
|
88
92
|
end
|
data/test/repl.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
$LOAD_PATH << "."
|
2
|
+
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require 'lib/repl'
|
6
|
+
|
7
|
+
class TestREPL < Minitest::Test
|
8
|
+
include RuneBlog::REPL
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Dir.chdir("/Users/Hal/Dropbox/files/blog") # temp code!!
|
12
|
+
@blog ||= open_blog
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_001_cmd_help
|
16
|
+
out = cmd_help([])
|
17
|
+
assert out.is_a?(String), "Expected a string returned"
|
18
|
+
lines = out.split("\n").length
|
19
|
+
assert lines > 25, "Expecting lengthy help message"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_002_cmd_version
|
23
|
+
out = cmd_version([])
|
24
|
+
assert out.is_a?(String), "Expected a string returned"
|
25
|
+
lines = out.split("\n")[1]
|
26
|
+
assert lines =~ /\d+\.\d+\.\d+/m,
|
27
|
+
"Couldn't find version number"
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_003_list_views
|
31
|
+
out = cmd_list_views([])
|
32
|
+
assert out.is_a?(String), "Expected a string returned"
|
33
|
+
lines = out.split("\n").length
|
34
|
+
assert lines >= 2, "Expecting at least 2 lines"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_004_change_view
|
38
|
+
out = cmd_change_view([]) # no param
|
39
|
+
assert out.is_a?(String), "Expected a string returned"
|
40
|
+
assert out =~ /computing/m, "Expecting 'computing' as default; got: #{out.inspect}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_005_lsd
|
44
|
+
out = cmd_list_drafts([])
|
45
|
+
assert out.is_a?(String), "Expected a string returned"
|
46
|
+
lines = out.split("\n").length
|
47
|
+
assert lines >= 15, "Expecting more lines; got: #{out.inspect}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_006_lsp
|
51
|
+
out = cmd_list_posts([])
|
52
|
+
assert out.is_a?(String), "Expected a string returned; got: #{out.inspect}"
|
53
|
+
lines = out.split("\n").length
|
54
|
+
assert lines >= 20, "Expecting more lines; got: #{out.inspect}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_007_parser
|
58
|
+
parse_tests = {
|
59
|
+
"kill 81 82 83" => [:cmd_kill, "81 82 83"],
|
60
|
+
" kill 81 82 83" => [:cmd_kill, "81 82 83"],
|
61
|
+
"kill 81 82 83 " => [:cmd_kill, "81 82 83"],
|
62
|
+
" kill 81 82 83 " => [:cmd_kill, "81 82 83"]
|
63
|
+
}
|
64
|
+
|
65
|
+
parse_tests.each_pair do |cmd, expected|
|
66
|
+
result = RuneBlog::REPL.choose_method(cmd)
|
67
|
+
assert result == expected, "Expected #{expected.inspect} but got #{result.inspect}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runeblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.55
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/repl.rb
|
52
52
|
- lib/runeblog.rb
|
53
53
|
- runeblog.gemspec
|
54
|
+
- test/repl.rb
|
54
55
|
homepage: https://github.com/Hal9000/runeblog
|
55
56
|
licenses:
|
56
57
|
- Ruby's license
|