runeblog 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/post.rb +80 -64
- data/lib/publish.rb +9 -6
- data/lib/repl.rb +60 -47
- data/lib/runeblog.rb +4 -29
- data/lib/version.rb +1 -1
- data/runeblog.gemspec +1 -0
- data/test/general.rb +16 -17
- data/test/make_blog.rb +4 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d825d310af8777f9434275721f46b05597bf3942abd80abb044937781ac2985c
|
4
|
+
data.tar.gz: 92d087740a685d488745b35d26ff295c30fbde3a4b349427c6d741e782e3dd77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b689cf2a6f7eaad23b6cbce82855dd6028c869b17af9de003415a04d07f8dccddfa87606eff99c37f401a723bf2b1b766f55d973e2ce512717a4a2e365cda34c
|
7
|
+
data.tar.gz: 9b41b9ac7378953f036df1164e92ea8dba199963fe2eacfb3c9757042441b0a5d8f29fcfca3048ae0a33110f9d1d1aa33ea995fc116344fbeba2298804f2ce9e
|
data/lib/post.rb
CHANGED
@@ -32,13 +32,74 @@ class RuneBlog::Post
|
|
32
32
|
meta
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
35
|
+
def create_post_subtree(viewname = nil)
|
36
|
+
viewname ||= @blog.view.dir
|
37
|
+
post_dir = viewname + "/" + @meta.slug
|
38
|
+
create_dir(post_dir) rescue nil # FIXME?
|
39
|
+
Dir.chdir(post_dir) do
|
40
|
+
create_dir("assets") rescue nil
|
41
|
+
system("cp body.txt index.html") # gahhh
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def write_metadata(meta)
|
46
|
+
fname2 = "metadata.txt"
|
47
|
+
hash = meta.to_h
|
48
|
+
|
49
|
+
File.write("teaser.txt", hash[:teaser])
|
50
|
+
File.write("body.txt", hash[:body])
|
51
|
+
hash.delete(:teaser)
|
52
|
+
hash.delete(:body)
|
53
|
+
|
54
|
+
hash[:views] = hash[:views].join(" ")
|
55
|
+
hash[:tags] = hash[:tags].join(" ")
|
56
|
+
|
57
|
+
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
58
|
+
|
59
|
+
f2 = File.new(fname2, "w")
|
60
|
+
fields.each {|fld| f2.puts "#{fld}: #{hash[fld]}" }
|
61
|
+
f2.close
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize
|
65
|
+
# nothing yet...
|
37
66
|
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
38
|
-
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.create(title)
|
70
|
+
post = self.new
|
71
|
+
post.new_metadata(title)
|
72
|
+
post.create_draft
|
73
|
+
post.create_post_subtree # gets done in build anyway
|
74
|
+
# post.build # where livetext gets called
|
75
|
+
post
|
76
|
+
end
|
77
|
+
|
78
|
+
def new_metadata(title)
|
79
|
+
meta = OpenStruct.new
|
80
|
+
meta.title = title
|
81
|
+
meta.teaser = "Teaser goes here."
|
82
|
+
meta.body = "Remainder of post goes here."
|
39
83
|
meta.pubdate = Time.now.strftime("%Y-%m-%d")
|
40
84
|
meta.date = meta.pubdate # fix later
|
41
|
-
meta.views = [
|
85
|
+
meta.views = [@blog.view.to_s]
|
86
|
+
# only place next_sequence is called
|
87
|
+
meta.num = @blog.next_sequence
|
88
|
+
@blog.make_slug(meta) # adds to meta
|
89
|
+
@meta = meta
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_draft
|
93
|
+
html = RuneBlog.post_template(title: @meta.title, date: @meta.pubdate,
|
94
|
+
view: @meta.view, teaser: @meta.teaser, body: @meta.body)
|
95
|
+
@draft = "#{@blog.root}/src/#{slug}.lt3"
|
96
|
+
dump(html, @draft)
|
97
|
+
end
|
98
|
+
|
99
|
+
def old_initialize(meta, view_name)
|
100
|
+
# FIXME weird logic here
|
101
|
+
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
102
|
+
@blog.make_slug(meta) # Post#initialize
|
42
103
|
check_meta(meta, "Post#initialize")
|
43
104
|
html = RuneBlog.post_template(title: meta.title, date: meta.pubdate,
|
44
105
|
view: meta.view, teaser: meta.teaser,
|
@@ -60,76 +121,31 @@ class RuneBlog::Post
|
|
60
121
|
error(err)
|
61
122
|
end
|
62
123
|
|
63
|
-
def build
|
64
|
-
|
65
|
-
|
124
|
+
def build
|
125
|
+
views = @meta.views
|
126
|
+
text = File.read(@draft)
|
127
|
+
Livetext.parameters = [@blog, @meta]
|
66
128
|
livetext = Livetext.new(STDOUT)
|
67
|
-
|
68
|
-
|
69
|
-
@meta2 = livetext.process_file(@draft, binding)
|
70
|
-
@meta2.num = meta.num # dumb?
|
71
|
-
@meta2.views = views # extra dumb
|
72
|
-
check_meta(@meta2, "build2")
|
73
|
-
raise LivetextError(@draft) if @meta2.nil?
|
74
|
-
|
75
|
-
puts "build: cp 2 - meta2 = #{@meta2.inspect}"
|
129
|
+
meta = livetext.process_text(text)
|
130
|
+
raise LivetextError(@draft) if meta.nil?
|
76
131
|
|
77
|
-
|
132
|
+
meta.num = File.basename(@draft).to_i
|
133
|
+
# FIXME what if title changes? slug should change?
|
134
|
+
meta.views = views # FIXME
|
78
135
|
|
79
|
-
#
|
80
|
-
|
81
|
-
@meta2.views.each do |view_name| # Create dir using slug (index.html, metadata?)
|
82
|
-
puts "build: cp 3 - view = #{view_name}"
|
83
|
-
view = @blog.str2view(view_name)
|
84
|
-
vdir = view.dir
|
136
|
+
meta.views.each do |view_name| # Create dir using slug (index.html, metadata?)
|
137
|
+
vdir = "#{@blog.root}/views/#{view_name}/"
|
85
138
|
dir = vdir + meta.slug + "/"
|
86
|
-
|
139
|
+
create_dir(dir) rescue nil
|
87
140
|
Dir.chdir(dir) do
|
88
|
-
|
89
|
-
|
90
|
-
puts "build: cp 5 - view = #{view_name}"
|
91
|
-
@blog.generate_index(view)
|
92
|
-
puts "build: cp 6 - view = #{view_name}"
|
141
|
+
create_post_subtree
|
142
|
+
@blog.generate_index(view_name)
|
93
143
|
end
|
94
144
|
end
|
145
|
+
meta
|
95
146
|
rescue => err
|
96
147
|
p err
|
97
148
|
puts err.backtrace.join("\n")
|
98
149
|
end
|
99
150
|
|
100
|
-
private
|
101
|
-
|
102
|
-
def create_post_subtree(vdir)
|
103
|
-
create_dir("assets")
|
104
|
-
check_meta(@meta2, "create_post_subtree")
|
105
|
-
write_metadata(@meta2)
|
106
|
-
meta = @meta2
|
107
|
-
text = RuneBlog.teaser_template(title: meta.title, date: meta.date,
|
108
|
-
view: meta.view, teaser: meta.teaser,
|
109
|
-
body: meta.body)
|
110
|
-
dump(text, "index.html") # FIXME write_index ?
|
111
|
-
end
|
112
|
-
|
113
|
-
def write_metadata(meta)
|
114
|
-
fname2 = "metadata.txt"
|
115
|
-
hash = meta.to_h
|
116
|
-
debug "write_meta: #{hash.inspect}"
|
117
|
-
|
118
|
-
File.write("teaser.txt", hash[:teaser])
|
119
|
-
File.write("body.txt", hash[:body])
|
120
|
-
hash.delete(:teaser)
|
121
|
-
hash.delete(:body)
|
122
|
-
|
123
|
-
hash[:views] = hash[:views].join(" ")
|
124
|
-
hash[:tags] = hash[:tags].join(" ")
|
125
|
-
|
126
|
-
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
127
|
-
|
128
|
-
f2 = File.new(fname2, "w")
|
129
|
-
fields.each do |fld|
|
130
|
-
f2.puts "#{fld}: #{hash[fld]}"
|
131
|
-
end
|
132
|
-
f2.close
|
133
|
-
end
|
134
|
-
|
135
151
|
end
|
data/lib/publish.rb
CHANGED
@@ -30,28 +30,31 @@ class RuneBlog::Publishing
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def publish(files)
|
33
|
-
|
33
|
+
puts "--- pub 1"
|
34
34
|
if files.empty?
|
35
|
+
STDSCR.up
|
35
36
|
puts "\n No files to publish"
|
36
|
-
|
37
|
-
return @out
|
37
|
+
return false
|
38
38
|
end
|
39
|
+
puts "--- pub 2"
|
39
40
|
debug "files = #{files.inspect}"
|
40
41
|
dir = "#@docroot/#@path"
|
41
42
|
result = system("ssh #@user@#@server -x mkdir -p #{dir}")
|
43
|
+
puts "--- pub 3"
|
42
44
|
list = files.join(' ')
|
43
45
|
cmd = "scp -r #{list} #@user@#@server:#{dir} >/dev/null 2>/tmp/wtf"
|
44
|
-
|
46
|
+
puts "Publishing #{files.size} files...\n "
|
45
47
|
debug "cmd = #{cmd.inspect} - see /tmp/wtf"
|
48
|
+
puts "--- pub 4"
|
46
49
|
result = system(cmd)
|
47
50
|
if not result
|
48
51
|
debug "error = #{File.read("/tmp/wtf")}"
|
52
|
+
getch
|
49
53
|
raise PublishError
|
50
54
|
end
|
51
55
|
|
52
56
|
dump(files, "#{@blog.view.dir}/last_published")
|
53
|
-
|
54
|
-
@out
|
57
|
+
true
|
55
58
|
end
|
56
59
|
|
57
60
|
def remote_login?
|
data/lib/repl.rb
CHANGED
@@ -32,7 +32,8 @@ module RuneBlog::REPL
|
|
32
32
|
reset_output
|
33
33
|
check_empty(arg)
|
34
34
|
output RuneBlog::VERSION
|
35
|
-
|
35
|
+
puts RuneBlog::VERSION unless testing
|
36
|
+
[false, @out]
|
36
37
|
end
|
37
38
|
|
38
39
|
def cmd_config(arg, testing = false)
|
@@ -53,11 +54,12 @@ module RuneBlog::REPL
|
|
53
54
|
# FIXME Bad logic here.
|
54
55
|
if url.nil?
|
55
56
|
output! "Publish first."
|
56
|
-
|
57
|
+
puts "\n Publish first."
|
58
|
+
return [false, @out]
|
57
59
|
end
|
58
60
|
result = system("open '#{url}'")
|
59
61
|
raise CantOpen(url) unless result
|
60
|
-
|
62
|
+
return [false, @out]
|
61
63
|
end
|
62
64
|
|
63
65
|
def cmd_preview(arg, testing = false)
|
@@ -77,11 +79,14 @@ module RuneBlog::REPL
|
|
77
79
|
output! "Can't publish without entries in #{@blog.view.name}/publish"
|
78
80
|
return [false, @out]
|
79
81
|
end
|
80
|
-
RubyText.spinner { @blog.view.publish }
|
82
|
+
ret = RubyText.spinner { @blog.view.publish }
|
83
|
+
return [false, @out] unless ret
|
81
84
|
vdir = @blog.view.dir
|
82
85
|
dump("fix this later", "#{vdir}/last_published")
|
83
|
-
|
84
|
-
|
86
|
+
if ! testing || ! ret
|
87
|
+
puts " ...finished.\n "
|
88
|
+
output! "...finished.\n"
|
89
|
+
end
|
85
90
|
return [false, @out]
|
86
91
|
end
|
87
92
|
|
@@ -90,11 +95,8 @@ module RuneBlog::REPL
|
|
90
95
|
reset_output
|
91
96
|
check_empty(arg)
|
92
97
|
puts unless testing
|
93
|
-
debug "cp1"
|
94
98
|
files = @blog.find_src_slugs
|
95
|
-
debug "cp2"
|
96
99
|
files.each {|file| @blog.rebuild_post(file) }
|
97
|
-
debug "cp3"
|
98
100
|
nil
|
99
101
|
end
|
100
102
|
|
@@ -153,9 +155,10 @@ debug "cp3"
|
|
153
155
|
args.each do |x|
|
154
156
|
# FIXME
|
155
157
|
ret = cmd_remove_post(x.to_i, false)
|
158
|
+
puts ret
|
156
159
|
output ret
|
157
160
|
end
|
158
|
-
return [
|
161
|
+
return [false, @out]
|
159
162
|
end
|
160
163
|
|
161
164
|
#-- FIXME affects linking, building, publishing...
|
@@ -166,7 +169,8 @@ debug "cp3"
|
|
166
169
|
id = get_integer(arg)
|
167
170
|
result = @blog.remove_post(id)
|
168
171
|
output! "Post #{id} not found" if result.nil?
|
169
|
-
|
172
|
+
# puts "Post #{id} not found" if result.nil?
|
173
|
+
return [false, @out]
|
170
174
|
end
|
171
175
|
|
172
176
|
#-- FIXME affects linking, building, publishing...
|
@@ -179,13 +183,23 @@ debug "cp3"
|
|
179
183
|
files = Find.find(@blog.root+"/src").to_a
|
180
184
|
files = files.grep(/#{tag}-/)
|
181
185
|
files = files.map {|f| File.basename(f) }
|
182
|
-
|
183
|
-
|
186
|
+
if files.size > 1
|
187
|
+
msg = "Multiple files: #{files}"
|
188
|
+
output msg
|
189
|
+
puts msg unless testing
|
190
|
+
return [false, msg]
|
191
|
+
end
|
192
|
+
if files.empty?
|
193
|
+
msg = "\n Can't edit post #{id}"
|
194
|
+
output msg
|
195
|
+
puts msg unless testing
|
196
|
+
return [false, msg]
|
197
|
+
end
|
184
198
|
|
185
199
|
file = files.first
|
186
200
|
result = edit_file("#{@blog.root}/src/#{file}")
|
187
201
|
@blog.rebuild_post(file)
|
188
|
-
|
202
|
+
return [false, @out]
|
189
203
|
end
|
190
204
|
|
191
205
|
def cmd_list_views(arg, testing = false)
|
@@ -195,9 +209,8 @@ debug "cp3"
|
|
195
209
|
@blog.views.each do |v|
|
196
210
|
v = v.to_s
|
197
211
|
v = fx(v, :bold) if v == @blog.view.name
|
198
|
-
print " "
|
199
212
|
output v + "\n"
|
200
|
-
puts v unless testing
|
213
|
+
puts " ", v unless testing
|
201
214
|
end
|
202
215
|
puts unless testing
|
203
216
|
return [false, @out]
|
@@ -210,8 +223,7 @@ debug "cp3"
|
|
210
223
|
str = @blog.view.name + ":\n"
|
211
224
|
output str
|
212
225
|
puts unless testing
|
213
|
-
|
214
|
-
puts fx(str, :bold) unless testing
|
226
|
+
puts " ", fx(str, :bold) unless testing
|
215
227
|
if posts.empty?
|
216
228
|
output! bold("No posts")
|
217
229
|
puts fx(" No posts", :bold) unless testing
|
@@ -220,8 +232,7 @@ debug "cp3"
|
|
220
232
|
outstr " #{colored_slug(post)}\n"
|
221
233
|
base = post.sub(/.lt3$/, "")
|
222
234
|
num, rest = base[0..3], base[4..-1]
|
223
|
-
|
224
|
-
puts fx(num, Red), fx(rest, Blue) unless testing
|
235
|
+
puts " ", fx(num, Red), fx(rest, Blue) unless testing
|
225
236
|
end
|
226
237
|
end
|
227
238
|
puts unless testing
|
@@ -235,15 +246,14 @@ debug "cp3"
|
|
235
246
|
if drafts.empty?
|
236
247
|
output! "No drafts"
|
237
248
|
puts " No drafts" unless testing
|
238
|
-
return [
|
249
|
+
return [false, @out]
|
239
250
|
else
|
240
251
|
puts unless testing
|
241
252
|
drafts.each do |draft|
|
242
253
|
outstr " #{colored_slug(draft.sub(/.lt3$/, ""))}\n"
|
243
254
|
base = draft.sub(/.lt3$/, "")
|
244
255
|
num, rest = base[0..3], base[4..-1]
|
245
|
-
|
246
|
-
puts fx(num, Red), fx(rest, Blue) unless testing
|
256
|
+
puts " ", fx(num, Red), fx(rest, Blue) unless testing
|
247
257
|
end
|
248
258
|
end
|
249
259
|
puts unless testing
|
@@ -252,46 +262,49 @@ debug "cp3"
|
|
252
262
|
|
253
263
|
def cmd_INVALID(arg, testing = false)
|
254
264
|
reset_output "\n Command '#{red(arg)}' was not understood."
|
255
|
-
|
265
|
+
puts "\n Command ", fx(arg, Red), " was not understood."
|
266
|
+
return [false, @out]
|
256
267
|
end
|
257
268
|
|
258
269
|
def cmd_help(arg, testing = false)
|
259
270
|
reset_output
|
260
271
|
check_empty(arg)
|
261
|
-
|
272
|
+
msg = <<-EOS
|
262
273
|
Commands:
|
263
274
|
|
264
|
-
|
265
|
-
|
266
|
-
|
275
|
+
h, help This message
|
276
|
+
q, quit Exit the program
|
277
|
+
v, version Print version information
|
267
278
|
|
268
|
-
|
269
|
-
|
279
|
+
change view VIEW Change current view
|
280
|
+
cv VIEW Change current view
|
270
281
|
|
271
|
-
|
282
|
+
new view Create a new view
|
272
283
|
|
273
|
-
|
274
|
-
|
284
|
+
list views List all views available
|
285
|
+
lsv Same as: list views
|
275
286
|
|
276
|
-
|
277
|
-
|
287
|
+
p, post Create a new post
|
288
|
+
new post Same as post (create a post)
|
278
289
|
|
279
|
-
|
290
|
+
lsp, list posts List posts in current view
|
280
291
|
|
281
|
-
|
292
|
+
lsd, list drafts List all posts regardless of view
|
282
293
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
294
|
+
rm ID Remove a post
|
295
|
+
kill ID ID ID... Remove multiple posts
|
296
|
+
undelete ID Undelete a post
|
297
|
+
edit ID Edit a post
|
287
298
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
299
|
+
preview Look at current (local) view in browser
|
300
|
+
browse Look at current (published) view in browser
|
301
|
+
relink Regenerate index for all views
|
302
|
+
rebuild Regenerate all posts and relink
|
303
|
+
publish Publish (current view)
|
293
304
|
EOS
|
294
|
-
|
305
|
+
output msg
|
306
|
+
puts msg unless testing
|
307
|
+
return [false, @out]
|
295
308
|
end
|
296
309
|
|
297
310
|
end
|
data/lib/runeblog.rb
CHANGED
@@ -102,7 +102,7 @@ class RuneBlog
|
|
102
102
|
|
103
103
|
def next_sequence
|
104
104
|
@sequence += 1
|
105
|
-
|
105
|
+
# debug "seq = #@sequence caller = #{caller.join("\n")}"
|
106
106
|
dump(@sequence, "#@root/sequence")
|
107
107
|
@sequence
|
108
108
|
end
|
@@ -167,19 +167,9 @@ class RuneBlog
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def create_new_post(title, testing = false)
|
170
|
-
|
171
|
-
debug "cnp title = #{title.inspect}"
|
172
|
-
meta = OpenStruct.new
|
173
|
-
meta.title = title
|
174
|
-
meta.teaser = "Teaser goes here."
|
175
|
-
meta.body = "Remainder of post goes here."
|
176
|
-
meta.num = self.next_sequence
|
177
|
-
check_meta(meta, "cnp1")
|
178
|
-
post = RuneBlog::Post.new(meta, @view.name) #???
|
170
|
+
post = Post.create(title)
|
179
171
|
post.edit unless testing
|
180
|
-
|
181
|
-
post.build(meta)
|
182
|
-
check_meta(meta, "cnp3")
|
172
|
+
meta = post.build
|
183
173
|
meta.num
|
184
174
|
rescue => err
|
185
175
|
puts err
|
@@ -218,6 +208,7 @@ debug "cnp title = #{title.inspect}"
|
|
218
208
|
raise ArgumentError unless file.is_a?(String)
|
219
209
|
path = @root + "/src/#{file}"
|
220
210
|
raise FileNotFound(path) unless File.exist?(path)
|
211
|
+
Livetext.parameters = [@blog, @meta]
|
221
212
|
live = Livetext.new(STDOUT) # (nil)
|
222
213
|
text = File.read(file)
|
223
214
|
live.process_text(path, binding)
|
@@ -226,19 +217,6 @@ debug "cnp title = #{title.inspect}"
|
|
226
217
|
end
|
227
218
|
|
228
219
|
def build_post_view(view)
|
229
|
-
# Create dir using slug (index.html, metadata?)
|
230
|
-
vdir = self.viewdir(view) # FIXME
|
231
|
-
check_meta(@meta, "build_post_view")
|
232
|
-
dir = vdir + @meta.slug + "/"
|
233
|
-
create_dir(dir + "assets")
|
234
|
-
Dir.chdir(dir) do
|
235
|
-
dump(@meta.teaser, "teaser.txt")
|
236
|
-
dump(@meta.body, "body.txt")
|
237
|
-
# FIXME make get_post_template method
|
238
|
-
template = File.read("#{vdir}/custom/post_template.html")
|
239
|
-
post = interpolate(template)
|
240
|
-
dump(post, "index.html")
|
241
|
-
end
|
242
220
|
generate_index(view)
|
243
221
|
rescue => err
|
244
222
|
error(err)
|
@@ -362,12 +340,9 @@ debug "cnp title = #{title.inspect}"
|
|
362
340
|
|
363
341
|
def make_slug(meta)
|
364
342
|
check_meta(meta, "makeslug")
|
365
|
-
debug "mkslug 1: meta = #{meta.inspect}"
|
366
343
|
raise ArgumentError unless meta.title.is_a?(String)
|
367
344
|
label = '%04d' % meta.num # FIXME can do better
|
368
|
-
debug "mkslug 2: label = #{label.inspect}"
|
369
345
|
slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
370
|
-
debug "mkslug 2: slug0 = #{slug0.inspect}"
|
371
346
|
str = "#{label}-#{slug0}"
|
372
347
|
meta.slug = str
|
373
348
|
str
|
data/lib/version.rb
CHANGED
data/runeblog.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.email = 'rubyhacker@gmail.com'
|
17
17
|
s.executables << "blog"
|
18
18
|
s.add_runtime_dependency 'livetext', '~> 0.8', '>= 0.8.20'
|
19
|
+
s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.0'
|
19
20
|
|
20
21
|
# Files...
|
21
22
|
main = Find.find("bin").to_a +
|
data/test/general.rb
CHANGED
@@ -66,8 +66,8 @@ class TestREPL < Minitest::Test
|
|
66
66
|
assert lines == 10, "Expecting 10 lines; got #{show_lines(out)}"
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
|
69
|
+
def test_006_lsp!
|
70
|
+
# puts __method__
|
71
71
|
flag, out = cmd_list_posts(nil, true)
|
72
72
|
assert out.is_a?(String), "Expected a string returned; got: #{out.inspect}"
|
73
73
|
lines = out.split("\n").length
|
@@ -153,15 +153,14 @@ class TestREPL < Minitest::Test
|
|
153
153
|
"After delete: #{sorted_views.inspect}"
|
154
154
|
end
|
155
155
|
|
156
|
-
def
|
156
|
+
def test_012_create_remove_post!
|
157
157
|
# puts __method__
|
158
158
|
@blog.change_view("beta_view")
|
159
159
|
assert @blog.view.to_s == "beta_view", "Expected beta_view"
|
160
160
|
nposts = @blog.posts.size
|
161
161
|
ndrafts = @blog.drafts.size
|
162
|
-
|
163
|
-
|
164
|
-
num = @blog.create_new_post(meta, true)
|
162
|
+
title = "Uninteresting title"
|
163
|
+
num = @blog.create_new_post(title, true)
|
165
164
|
|
166
165
|
assert @blog.posts.size == nposts + 1, "Don't see new post"
|
167
166
|
@blog.remove_post(num)
|
@@ -173,7 +172,7 @@ class TestREPL < Minitest::Test
|
|
173
172
|
@blog.change_view("alpha_view")
|
174
173
|
end
|
175
174
|
|
176
|
-
def
|
175
|
+
def xtest_013_slug_tests
|
177
176
|
hash = { "abcxyz" => "abcxyz", # 0-based
|
178
177
|
"abc'xyz" => "abcxyz",
|
179
178
|
'abc"xyz' => "abcxyz",
|
@@ -192,14 +191,14 @@ class TestREPL < Minitest::Test
|
|
192
191
|
end
|
193
192
|
end
|
194
193
|
|
195
|
-
def
|
194
|
+
def xtest_014_remove_nonexistent_post!
|
196
195
|
# puts __method__
|
197
196
|
@blog.change_view("alpha_view")
|
198
197
|
flag, out = cmd_remove_post(99, true)
|
199
198
|
assert out =~ /Post 99 not found/, "Expected error about nonexistent post, got: #{out}"
|
200
199
|
end
|
201
200
|
|
202
|
-
def
|
201
|
+
def xtest_015_kill_multiple_posts!
|
203
202
|
# puts __method__
|
204
203
|
@blog.change_view("alpha_view")
|
205
204
|
flag, out = cmd_list_posts(nil, true)
|
@@ -216,7 +215,7 @@ class TestREPL < Minitest::Test
|
|
216
215
|
|
217
216
|
if File.exist?("testing.publish")
|
218
217
|
|
219
|
-
def
|
218
|
+
def xtest_016_can_publish
|
220
219
|
# puts __method__
|
221
220
|
x = OpenStruct.new
|
222
221
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
@@ -228,7 +227,7 @@ if File.exist?("testing.publish")
|
|
228
227
|
assert result == true, "Valid mkdir doesn't work"
|
229
228
|
end
|
230
229
|
|
231
|
-
def
|
230
|
+
def xtest_017_cannot_publish_wrong_user
|
232
231
|
# puts __method__
|
233
232
|
x = OpenStruct.new
|
234
233
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
@@ -238,7 +237,7 @@ if File.exist?("testing.publish")
|
|
238
237
|
assert result.nil?, "Expected to detect login error (bad user)"
|
239
238
|
end
|
240
239
|
|
241
|
-
def
|
240
|
+
def xtest_018_cannot_publish_bad_server
|
242
241
|
# puts __method__
|
243
242
|
x = OpenStruct.new
|
244
243
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
@@ -250,12 +249,12 @@ if File.exist?("testing.publish")
|
|
250
249
|
|
251
250
|
end # conditional tests
|
252
251
|
|
253
|
-
def
|
252
|
+
def xtest_019_exception_existing_blog
|
254
253
|
# puts __method__
|
255
254
|
assert_raises(BlogAlreadyExists) { RuneBlog.create_new_blog }
|
256
255
|
end
|
257
256
|
|
258
|
-
def
|
257
|
+
def xtest_020_exception_missing_blog_accessor
|
259
258
|
# puts __method__
|
260
259
|
save = RuneBlog.blog
|
261
260
|
RuneBlog.blog = nil
|
@@ -263,17 +262,17 @@ end # conditional tests
|
|
263
262
|
RuneBlog.blog = save
|
264
263
|
end
|
265
264
|
|
266
|
-
def
|
265
|
+
def xtest_021_exception_cant_assign_view
|
267
266
|
# puts __method__
|
268
267
|
assert_raises(CantAssignView) { @blog.view = 99 }
|
269
268
|
end
|
270
269
|
|
271
|
-
def
|
270
|
+
def xtest_022_exception_no_such_view
|
272
271
|
# puts __method__
|
273
272
|
assert_raises(NoSuchView) { @blog.view = 'not_a_view_name' }
|
274
273
|
end
|
275
274
|
|
276
|
-
def
|
275
|
+
def xtest_023_exception_view_already_exists
|
277
276
|
# puts __method__
|
278
277
|
assert_raises(ViewAlreadyExists) { @blog.create_view('alpha_view') }
|
279
278
|
end
|
data/test/make_blog.rb
CHANGED
@@ -25,6 +25,10 @@ system("rm -rf .blog")
|
|
25
25
|
RuneBlog.create_new_blog(".blog/data_test")
|
26
26
|
x = RuneBlog.new
|
27
27
|
x.create_view("alpha_view")
|
28
|
+
|
29
|
+
# Hack:
|
30
|
+
system("cp publish .blog/data_test/views/alpha_view/publish")
|
31
|
+
|
28
32
|
x.create_view("beta_view")
|
29
33
|
x.create_view("gamma_view")
|
30
34
|
|
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.1.
|
4
|
+
version: 0.1.15
|
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-12-
|
11
|
+
date: 2018-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|
@@ -30,6 +30,26 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.8.20
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubytext
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.1.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.1'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.1.0
|
33
53
|
description: A blog system based on Ruby and Livetext
|
34
54
|
email: rubyhacker@gmail.com
|
35
55
|
executables:
|