runeblog 0.0.89 → 0.0.90
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/runeblog.rb +21 -3
- data/lib/version.rb +1 -1
- data/test/general.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c710eb461485a787b81a66475ec0144313f06981
|
4
|
+
data.tar.gz: 5f379efd477fdbe371d2f2d3b4fbc121bd504272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaa0d5996589b890c8ce475c9b8d4af6f1cfffc1b1b7ac1c8068b764a749cc0cb4784c06f3ee226cd45b1a51226be1674ac30a26e23fe2fed23d597065a45d7b
|
7
|
+
data.tar.gz: 3179248a5153bc8b920195d9acccf6cc9477166df289394662a29a0a3b0a3aff6a9179bf7846e94d7e777192f90f62fd7fa9d6f6121113ad4d01cd2203703acc
|
data/lib/runeblog.rb
CHANGED
@@ -96,6 +96,7 @@ class RuneBlog
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def viewdir(v = nil)
|
99
|
+
v = str2view(v) if v.is_a?(String)
|
99
100
|
raise ArgumentError unless v.nil? || v.is_a?(RuneBlog::View)
|
100
101
|
v ||= @view
|
101
102
|
@root + "/views/#{v}/"
|
@@ -144,7 +145,7 @@ class RuneBlog
|
|
144
145
|
files.reject! {|f| File.mtime(f) < File.mtime("#{vdir}/last_deployed") }
|
145
146
|
end
|
146
147
|
|
147
|
-
def files_by_id(id)
|
148
|
+
def files_by_id(id) # FIXME get rid of this later
|
148
149
|
raise ArgumentError unless id.is_a?(Integer)
|
149
150
|
files = Find.find(self.view.dir).to_a
|
150
151
|
tag = "#{'%04d' % id}"
|
@@ -304,7 +305,9 @@ class RuneBlog
|
|
304
305
|
|
305
306
|
def remove_post(num)
|
306
307
|
raise ArgumentError unless num.is_a?(Integer)
|
307
|
-
|
308
|
+
files = Find.find("#@root/views/").to_a
|
309
|
+
tag = "#{'%04d' % num.to_i}"
|
310
|
+
list = files.select {|x| File.directory?(x) and x =~ /#{tag}/ }
|
308
311
|
return nil if list.empty?
|
309
312
|
dest = list.map {|f| f.sub(/(?<num>\d{4}-)/, "_\\k<num>") }
|
310
313
|
list.each.with_index do |src, i|
|
@@ -315,6 +318,21 @@ class RuneBlog
|
|
315
318
|
true
|
316
319
|
end
|
317
320
|
|
321
|
+
def undelete_post(num)
|
322
|
+
raise ArgumentError unless num.is_a?(Integer)
|
323
|
+
files = Find.find("#@root/views/").to_a
|
324
|
+
tag = "#{'%04d' % num.to_i}"
|
325
|
+
list = files.select {|x| File.directory?(x) and x =~ /_#{tag}/ }
|
326
|
+
return nil if list.empty?
|
327
|
+
dest = list.map {|f| f.sub(/_(?<num>\d{4}-)/, "\\k<num>") }
|
328
|
+
list.each.with_index do |src, i|
|
329
|
+
cmd = "mv #{src} #{dest[i]} 2>/dev/null"
|
330
|
+
system(cmd)
|
331
|
+
end
|
332
|
+
# FIXME - update index/etc
|
333
|
+
true
|
334
|
+
end
|
335
|
+
|
318
336
|
def delete_draft(num)
|
319
337
|
raise ArgumentError unless num.is_a?(Integer)
|
320
338
|
tag = "#{'%04d' % num.to_i}"
|
@@ -323,7 +341,7 @@ class RuneBlog
|
|
323
341
|
|
324
342
|
def post_exists?(num)
|
325
343
|
raise ArgumentError unless num.is_a?(Integer)
|
326
|
-
list = files_by_id(num)
|
344
|
+
list = files_by_id(num) # FIXME search under view dirs
|
327
345
|
list.empty? ? nil : list
|
328
346
|
end
|
329
347
|
|
data/lib/version.rb
CHANGED
data/test/general.rb
CHANGED
@@ -186,8 +186,11 @@ class TestREPL < Minitest::Test
|
|
186
186
|
out = cmd_kill("1 2 7")
|
187
187
|
out = cmd_list_posts(nil)
|
188
188
|
after = out.split("\n").length
|
189
|
-
|
190
|
-
|
189
|
+
expecting = before - 2
|
190
|
+
assert after == expecting, "list_posts saw #{before} posts, now #{after} (not #{expecting})"
|
191
|
+
@blog.undelete_post(1)
|
192
|
+
@blog.undelete_post(2)
|
193
|
+
@blog.undelete_post(7)
|
191
194
|
end
|
192
195
|
|
193
196
|
if File.exist?("testing.deploy")
|