runeblog 0.0.93 → 0.0.94

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: d401049bff7f80d13c2708674608b2c2c418d77e
4
- data.tar.gz: 0a8dead9268c46004a4a31d8977724d119adabeb
3
+ metadata.gz: b8720cc6cf31c380400565dcc8868cd9ac9f6d72
4
+ data.tar.gz: ca565aeecf8cd0532f2bdd415923fab0240400d1
5
5
  SHA512:
6
- metadata.gz: d0d9364fa2a1dc901ebd178fa7f5b7544ec519ee756dcad417cdcb7542cbed97129f3e2b814025b12e884feb5e9142a74bc03c2f64b9b946d68a5f0771cc4a46
7
- data.tar.gz: 4f47211d17dab06700c3afd9f956c3f20b0b9ccd7f6b69d1fcdd2cded31efd6f1d68d2ab47059a102c983b4dca19094c4c63ca8fe8f685a5a639b6215d1c4eb3
6
+ metadata.gz: 0c923e9f2283b3bbd51852f421821243c526b98d880fd12b7061d8dcba41254d0b7bbfb1b43fadf8ff302d516bb68466f406a260b5969b0d0b0829e7da8e8224
7
+ data.tar.gz: 87c4b6432312db1c69bde589df6df01913829a4e7b54f6d064b6cc0ceaa5c8360176da304ad8e8602c9f482193dc13c8b5755017f15acb984d6c05f88748f08c
@@ -27,3 +27,7 @@ def make_exception(sym, str)
27
27
  end
28
28
  end
29
29
 
30
+ def prefix(num)
31
+ "#{'%04d' % num.to_i}"
32
+ end
33
+
data/lib/helpers-repl.rb CHANGED
@@ -32,6 +32,7 @@ module RuneBlog::REPL
32
32
  "lsd" => :cmd_list_drafts,
33
33
 
34
34
  "rm $postid" => :cmd_remove_post,
35
+ "undel $postid" => :cmd_undelete_post,
35
36
 
36
37
  "kill >postid" => :cmd_kill,
37
38
 
@@ -179,7 +180,7 @@ module RuneBlog::REPL
179
180
 
180
181
  def import(arg = nil)
181
182
  # open_blog unless @blog
182
-
183
+ raise "Not implemented at present..."
183
184
  arg = nil if arg == ""
184
185
  arg ||= ask("Filename: ") # check validity later
185
186
  name = arg
data/lib/post.rb CHANGED
@@ -11,7 +11,7 @@ class RuneBlog::Post
11
11
 
12
12
  def self.files(num, root)
13
13
  files = Find.find(root).to_a
14
- result = files.grep(/#{tag(num)}-/)
14
+ result = files.grep(/#{prefix(num)}-/)
15
15
  result
16
16
  end
17
17
 
@@ -86,34 +86,30 @@ class RuneBlog::Post
86
86
 
87
87
  def make_slug(postnum = nil)
88
88
  postnum ||= @blog.next_sequence
89
- num = tag(postnum) # FIXME can do better
89
+ num = prefix(postnum) # FIXME can do better
90
90
  slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
91
91
  [postnum, "#{num}-#{slug}"]
92
92
  end
93
93
 
94
- def tag(num)
95
- "#{'%04d' % num}"
96
- end
97
-
98
- def write_metadata(meta)
99
- fname2 = "metadata.txt"
100
- hash = meta.to_h
101
-
102
- File.write("teaser.txt", hash[:teaser])
103
- File.write("body.txt", hash[:body])
104
- hash.delete(:teaser)
105
- hash.delete(:body)
106
-
107
- hash[:views] = hash[:views].join(" ")
108
- hash[:tags] = hash[:tags].join(" ")
109
-
110
- fields = [:title, :date, :pubdate, :views, :tags]
111
-
112
- f2 = File.new(fname2, "w")
113
- fields.each do |fld|
114
- f2.puts "#{fld}: #{hash[fld]}"
94
+ def write_metadata(meta)
95
+ fname2 = "metadata.txt"
96
+ hash = meta.to_h
97
+
98
+ File.write("teaser.txt", hash[:teaser])
99
+ File.write("body.txt", hash[:body])
100
+ hash.delete(:teaser)
101
+ hash.delete(:body)
102
+
103
+ hash[:views] = hash[:views].join(" ")
104
+ hash[:tags] = hash[:tags].join(" ")
105
+
106
+ fields = [:title, :date, :pubdate, :views, :tags]
107
+
108
+ f2 = File.new(fname2, "w")
109
+ fields.each do |fld|
110
+ f2.puts "#{fld}: #{hash[fld]}"
111
+ end
112
+ f2.close
115
113
  end
116
- f2.close
117
- end
118
114
 
119
115
  end
data/lib/repl.rb CHANGED
@@ -274,6 +274,7 @@ module RuneBlog::REPL
274
274
 
275
275
  #{red('rm ID ')} Remove a post
276
276
  #{red('kill ID ID ID... ')} Remove multiple posts
277
+ #{red('undelete ID ')} Undelete a post
277
278
  #{red('edit ID ')} Edit a post
278
279
 
279
280
  #{red('preview ')} Look at current (local) view in browser
data/lib/runeblog.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'find'
2
2
  require 'livetext'
3
- require 'skeleton'
3
+ require 'global'
4
4
  require 'helpers-blog'
5
5
  require 'default'
6
6
  require 'view'
@@ -158,7 +158,7 @@ class RuneBlog
158
158
  def files_by_id(id) # FIXME get rid of this later
159
159
  raise ArgumentError unless id.is_a?(Integer)
160
160
  files = Find.find(self.view.dir).to_a
161
- tag = "#{'%04d' % id}"
161
+ tag = prefix(id)
162
162
  result = files.grep(/#{tag}-/)
163
163
  result
164
164
  end
@@ -175,9 +175,9 @@ class RuneBlog
175
175
  puts err # error(err)
176
176
  end
177
177
 
178
- def edit_initial_post(file)
179
- sourcefile "#@root/src/#{file}"
180
- result = system("#@editor #{sourcefile} +8")
178
+ def edit_initial_post(file, testing = false)
179
+ sourcefile = "#@root/src/#{file}"
180
+ result = system("#@editor #{sourcefile} +8") unless testing
181
181
  raise EditorProblem(sourcefile) unless result
182
182
  nil
183
183
  rescue => err
@@ -314,8 +314,8 @@ class RuneBlog
314
314
 
315
315
  def remove_post(num)
316
316
  raise ArgumentError unless num.is_a?(Integer)
317
- files = Find.find("#@root/views/").to_a
318
- tag = "#{'%04d' % num.to_i}"
317
+ tag = prefix(num)
318
+ files = Find.find(self.view.dir).to_a
319
319
  list = files.select {|x| File.directory?(x) and x =~ /#{tag}/ }
320
320
  return nil if list.empty?
321
321
  dest = list.map {|f| f.sub(/(?<num>\d{4}-)/, "_\\k<num>") }
@@ -330,7 +330,7 @@ class RuneBlog
330
330
  def undelete_post(num)
331
331
  raise ArgumentError unless num.is_a?(Integer)
332
332
  files = Find.find("#@root/views/").to_a
333
- tag = "#{'%04d' % num.to_i}"
333
+ tag = prefix(num)
334
334
  list = files.select {|x| File.directory?(x) and x =~ /_#{tag}/ }
335
335
  return nil if list.empty?
336
336
  dest = list.map {|f| f.sub(/_(?<num>\d{4}-)/, "\\k<num>") }
@@ -344,7 +344,7 @@ class RuneBlog
344
344
 
345
345
  def delete_draft(num)
346
346
  raise ArgumentError unless num.is_a?(Integer)
347
- tag = "#{'%04d' % num.to_i}"
347
+ tag = prefix(num)
348
348
  system("rm -rf #@root/src/#{tag}-*")
349
349
  end
350
350
 
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  class RuneBlog
3
- VERSION = "0.0.93"
3
+ VERSION = "0.0.94"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
data/test/general.rb CHANGED
@@ -246,14 +246,10 @@ end # conditional tests
246
246
  end
247
247
 
248
248
  def test_023_exception_view_already_exists
249
- assert_raises(ViewAlreadyExists) { @blog.view = 'alpha_view' }
249
+ assert_raises(ViewAlreadyExists) { @blog.create_view('alpha_view') }
250
250
  end
251
251
 
252
- def test_024_exception_cant_edit_file
253
- assert_raises(EditorProblem) { @blog.edit_initial_post(999) }
254
- end
255
-
256
- def xtest_025_exception_livetext_error # FIXME Doesn't work! Change Livetext
252
+ def xtest_024_exception_livetext_error # FIXME Doesn't work! Change Livetext
257
253
  testfile = "testfile.lt3"
258
254
  path = @blog.root + "/src/" + testfile
259
255
  cmd = "echo .no_such_command > #{path}"
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.93
4
+ version: 0.0.94
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-10-25 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -43,12 +43,12 @@ files:
43
43
  - bin/blog
44
44
  - lib/default.rb
45
45
  - lib/deploy.rb
46
+ - lib/global.rb
46
47
  - lib/helpers-blog.rb
47
48
  - lib/helpers-repl.rb
48
49
  - lib/post.rb
49
50
  - lib/repl.rb
50
51
  - lib/runeblog.rb
51
- - lib/skeleton.rb
52
52
  - lib/version.rb
53
53
  - lib/view.rb
54
54
  - test/general.rb