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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 279af347657d41b3c002ff54d34e79eca6d93f22
4
- data.tar.gz: b89b25911aec6c0079ac0ce05967a9b29e6a21e7
3
+ metadata.gz: c710eb461485a787b81a66475ec0144313f06981
4
+ data.tar.gz: 5f379efd477fdbe371d2f2d3b4fbc121bd504272
5
5
  SHA512:
6
- metadata.gz: 24df9dac9012ad36e7f4ac843793503adb9a217248af435d13b2f970f0aa551c7aaa2c0d8faa24bd5a400996a9892d956d6eb2fecb05d522b0c75b1b0334c62e
7
- data.tar.gz: 110379d1d0883963dfa1d45d4ecdf5d08991dd3617b716aa55fd8b2c038a6717c0d946685702637335fbd9280313c1dfe69a2d9fae2b97a333ba26d6b771706b
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
- list = files_by_id(num)
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
@@ -1,6 +1,6 @@
1
1
 
2
2
  class RuneBlog
3
- VERSION = "0.0.89"
3
+ VERSION = "0.0.90"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
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
- assert after == before - 3, "list_posts saw #{before} posts, now #{after} (not #{before-3})"
190
- system("ruby test/make_blog.rb") # This is hellish, I admit
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")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.89
4
+ version: 0.0.90
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton