runeblog 0.0.51 → 0.0.52

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/bin/blog +2 -1
  3. data/data/VERSION +1 -1
  4. data/lib/repl.rb +74 -53
  5. data/lib/runeblog.rb +1 -1
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68148eb4defbbdf649cc895e85c7812d499eb135
4
- data.tar.gz: 134d702ca04162a0067d0a123fe3899eafa9547b
3
+ metadata.gz: 653084ec3ffb8c767d726dae8cc56bd87837845f
4
+ data.tar.gz: 4106abe54f01fd812c0f8fab6d6f1cfa0ddff9a0
5
5
  SHA512:
6
- metadata.gz: 8a34474dd674facbb7f3c5d20ac9c0d22da3d71f622a1719ece79e199c9eda11b3b9f56b60e83f3e766ddd774125ea461aefcc45f53780a5c9c4312d42ad786c
7
- data.tar.gz: a2b395583a84b4425336831cba39e31218bd49ecc56172193915662694190f291b62037967c76db290d9d9dffc2b880458f65c2f0b05233efd5481f7dc47d351
6
+ metadata.gz: ad3086f7ab28e4d28e1e6b1885276d10f23fee0a61314cebc1dac30f1d97438162557161e92033dd9122ff794413b1dddcf12cdfae5f0de2cc183c8b945239e9
7
+ data.tar.gz: 1db09ee9f124cbd2077e71860bfde2f9c06109c6d54948e33941cc72907c93db4935eaefa816c19bcce45def4a740518701dfa0d1a4ba5462d8579dbad8c9159
data/bin/blog CHANGED
@@ -33,7 +33,8 @@ if cmd.nil? # REPL
33
33
  cmd_quit([]) if cmd.nil? # ^D
34
34
  cmd.chomp!
35
35
  meth, params = RuneBlog::REPL.choose_method(cmd)
36
- send(meth, params)
36
+ str = send(meth, params)
37
+ puts str unless str.nil?
37
38
  end
38
39
  else # one command
39
40
  raise "Not working right now"
data/data/VERSION CHANGED
@@ -1 +1 @@
1
- RuneBlog v 0.0.51 2018-09-01
1
+ RuneBlog v 0.0.52 2018-09-01
data/lib/repl.rb CHANGED
@@ -26,18 +26,18 @@ require 'helpers-repl' # FIXME structure
26
26
  module RuneBlog::REPL
27
27
 
28
28
  def cmd_quit(arg)
29
- raise "Glitch: Got an argument" if arg != []
29
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
30
30
  puts "\n "
31
31
  exit
32
32
  end
33
33
 
34
34
  def cmd_version(arg)
35
- raise "Glitch: Got an argument" if arg != []
36
- puts "\n " + RuneBlog::VERSION
35
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
36
+ return "\n " + RuneBlog::VERSION
37
37
  end
38
38
 
39
39
  def new_blog!(arg) # FIXME weird?
40
- raise "Glitch: Got an argument" if arg != []
40
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
41
41
  return if RuneBlog.exist?
42
42
  yn = yesno(red(" No .blog found. Create new blog? "))
43
43
  RuneBlog.create_new_blog if yn
@@ -59,12 +59,13 @@ module RuneBlog::REPL
59
59
  def edit_initial_post(file)
60
60
  result = system("vi #@root/src/#{file} +8 ")
61
61
  raise "Problem editing #@root/src/#{file}" unless result
62
+ nil
62
63
  rescue => err
63
64
  error(err)
64
65
  end
65
66
 
66
67
  def cmd_browse
67
- raise "Glitch: Got an argument" if arg != []
68
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
68
69
  @deploy ||= {}
69
70
  return puts red("\n Deploy first.") unless @deploy[@view]
70
71
 
@@ -72,6 +73,7 @@ module RuneBlog::REPL
72
73
  user, server, sroot, spath = *lines
73
74
  result = system("open 'http://#{server}/#{spath}'")
74
75
  raise "Problem opening http://#{server}/#{spath}" unless result
76
+ nil
75
77
  rescue => err
76
78
  error(err)
77
79
  end
@@ -79,13 +81,14 @@ module RuneBlog::REPL
79
81
  def cmd_open_local
80
82
  result = system("open #{@blog.viewdir(@view)}/index.html")
81
83
  raise "Problem opening #{@blog.viewdir(@view)}/index.html" unless result
84
+ nil
82
85
  rescue => err
83
86
  error(err)
84
87
  end
85
88
 
86
- def cmd_deploy(arg)
89
+ def cmd_deploy(arg) # FIXME non-string return expected in caller?
87
90
  # TBD clunky FIXME
88
- raise "Glitch: Got an argument" if arg != []
91
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
89
92
  @deploy ||= {}
90
93
  deployment = @blog.viewdir(@view) + "deploy"
91
94
  raise "File '#{deployment}' not found" unless File.exist?(deployment)
@@ -97,74 +100,79 @@ module RuneBlog::REPL
97
100
  files = ["#{vdir}/index.html"]
98
101
  files += Dir.entries(vdir).grep(/^\d\d\d\d/).map {|x| "#{vdir}/#{x}" }
99
102
  files.reject! {|f| File.mtime(f) < File.mtime("#{vdir}/last_deployed") }
100
- return puts red("\n No files to deploy") if files.empty?
103
+ if files.empty?
104
+ puts red("\n No files to deploy")
105
+ return nil
106
+ end
101
107
 
102
- puts "\n Files:"
103
- files.each {|f| puts " " + f }
104
- puts
108
+ out = "\n Files:"
109
+ files.each {|f| out << (" " + f + "\n") }
110
+ out << "\n"
105
111
  dir = "#{sroot}/#{spath}"
106
112
  # FIXME - may or may not already exist
107
113
  result = system("ssh root@#{server} mkdir #{dir}")
108
114
 
109
115
  cmd = "scp -r #{files.join(' ')} root@#{server}:#{dir} >/dev/null 2>&1"
110
- print red("\n Deploying #{files.size} files... ")
116
+ out << red("\n Deploying #{files.size} files...\n")
111
117
  result = system(cmd)
112
118
  raise "Problem occurred in deployment" unless result
113
119
 
114
120
  File.write("#{vdir}/last_deployed", files)
115
- puts red("finished.")
121
+ out << red("finished.\n")
122
+ out
116
123
  rescue => err
117
124
  error(err)
118
125
  end
119
126
 
120
127
  def cmd_rebuild(arg)
121
- raise "Glitch: Got an argument" if arg != []
128
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
122
129
  puts
123
130
  files = Dir.entries("#@root/src/").grep /\d\d\d\d.*.lt3$/
124
131
  files.map! {|f| File.basename(f) }
125
132
  files = files.sort.reverse
126
133
  files.each {|file| rebuild_post(file) }
134
+ nil
127
135
  rescue => err
128
136
  error(err)
129
137
  end
130
138
 
131
139
  def cmd_relink(arg)
132
- raise "Glitch: Got an argument" if arg != []
140
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
133
141
  @blog.views.each {|view| generate_index(view) }
142
+ nil
134
143
  rescue => err
135
144
  error(err)
136
145
  end
137
146
 
138
147
  def cmd_list_views(arg)
139
148
  abort "Config file not read" unless @blog
140
- raise "Glitch: Got an argument" if arg != []
141
- puts
142
- @blog.views.each {|v| puts " #{v}" }
149
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
150
+ out = "\n"
151
+ @blog.views.each {|v| out << " #{v}\n" }
152
+ out
143
153
  rescue => err
144
154
  error(err)
145
155
  end
146
156
 
147
- ### change_view
148
-
149
157
  def cmd_change_view(arg)
150
158
  if arg.empty?
151
- puts "\n #@view"
159
+ return "\n #@view"
152
160
  else
161
+ out = ""
153
162
  arg = arg.first
154
163
  list = @blog.views.grep /^#{arg}/
155
164
  if list.size == 1
156
165
  @view = @blog.view = list.first
157
- puts red("\n View: #{@view}") if arg != @view
166
+ out << red("\n View: #{@view}\n") if arg != @view
158
167
  else
159
- puts "view #{arg.inspect} does not exist"
168
+ out << "view #{arg.inspect} does not exist\n"
160
169
  end
161
170
  end
171
+ out
162
172
  rescue => err
163
173
  error(err)
164
174
  end
165
175
 
166
- ### new_view
167
-
168
176
  def cmd_new_view(arg)
169
177
  arg = arg.first
170
178
  @blog ||= open_blog
@@ -184,10 +192,8 @@ module RuneBlog::REPL
184
192
  error(err)
185
193
  end
186
194
 
187
- ### new_post
188
-
189
195
  def cmd_new_post(arg)
190
- raise "Glitch: Got an argument" if arg != []
196
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
191
197
  open_blog unless @blog
192
198
  @title = ask("Title: ")
193
199
  @today = Time.now.strftime("%Y%m%d")
@@ -197,6 +203,7 @@ module RuneBlog::REPL
197
203
  edit_initial_post(file)
198
204
  process_post(file) #- FIXME handle each view
199
205
  publish_post(@meta)
206
+ nil
200
207
  rescue => err
201
208
  error(err)
202
209
  end
@@ -204,36 +211,46 @@ module RuneBlog::REPL
204
211
  def cmd_kill(arg)
205
212
  args = arg.first.split
206
213
  args.each {|x| cmd_remove_post([x], false) }
214
+ nil
215
+ rescue => err
216
+ error(err)
207
217
  end
208
218
 
209
219
  #-- FIXME affects linking, building, deployment...
210
220
 
211
221
  def cmd_remove_post(arg, safe=true)
222
+ out = ""
212
223
  arg = arg.first
213
224
  id = Integer(arg) rescue raise("'#{arg}' is not an integer")
214
225
  tag = "#{'%04d' % id}"
215
226
  files = Find.find(@root).to_a
216
227
  files = files.grep(/#{tag}-/)
217
- return puts red("\n No such post found (#{id})") if files.empty?
228
+ if files.empty?
229
+ out = red("\n No such post found (#{id})")
230
+ return out
231
+ end
218
232
 
219
233
  if safe
220
- puts
221
- files.each {|f| puts " #{f}" }
222
- ques = files.size > 1 ? "\n Delete all these? " : "\n Delete? "
234
+ out << "\n"
235
+ files.each {|f| out << " #{f}\n" }
236
+ puts out
237
+ out = ""
238
+ ques = files.size > 1 ? "\n Delete all these?\n " : "\n Delete?\n "
223
239
  yn = ask red(ques)
224
240
  if yn.downcase == "y"
225
241
  result = system("rm -rf #{files.join(' ')}")
226
242
  raise "Problem deleting file(s)" unless result
227
- puts red("\n Deleted")
243
+ out << red("\n Deleted\n")
228
244
  else
229
- puts red("\n No action taken")
245
+ out << red("\n No action taken\n")
230
246
  end
231
247
  else
232
248
  result = system("rm -rf #{files.join(' ')}")
233
- puts red("\n Deleted:")
234
- files.each {|f| puts " #{f}" }
249
+ out << red("\n Deleted:\n")
250
+ files.each {|f| out << " #{f}\n" }
235
251
  raise "Problem mass-deleting file(s)" unless result
236
252
  end
253
+ out
237
254
  rescue => err
238
255
  error(err)
239
256
  end
@@ -247,59 +264,62 @@ module RuneBlog::REPL
247
264
  files = Find.find(@root+"/src").to_a
248
265
  files = files.grep(/#{tag}-/)
249
266
  files = files.map {|f| File.basename(f) }
250
- return puts red("Multiple files: #{files}") if files.size > 1
251
- return puts red("\n No such post found (#{id})") if files.empty?
267
+ return red("Multiple files: #{files}") if files.size > 1
268
+ return red("\n No such post found (#{id})") if files.empty?
252
269
 
253
270
  file = files.first
254
271
  result = system("vi #@root/src/#{file}")
255
272
  raise "Problem editing #{file}" unless result
256
273
 
257
274
  rebuild_post(file)
275
+ nil
258
276
  rescue => err
259
277
  error(err)
260
278
  end
261
279
 
262
280
  def cmd_list_posts(arg)
263
- raise "Glitch: Got an argument" if arg != []
281
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
282
+ out = ""
264
283
  dir = @blog.viewdir(@view)
265
284
  Dir.chdir(dir) do
266
285
  posts = Dir.entries(".").grep(/^0.*/)
267
286
  if posts.empty?
268
- puts "\n " + @view + ":" + red(" No posts")
287
+ out << ("\n " + @view + ":" + red(" No posts\n"))
269
288
  else
270
- puts "\n " + @view + ":\n "
271
- posts.each {|post| puts " #{colored_slug(post)}" }
289
+ out << ("\n " + @view + ":\n ")
290
+ posts.each {|post| out << " #{colored_slug(post)}\n" }
272
291
  end
273
292
  end
293
+ out
274
294
  rescue => err
275
295
  error(err)
276
296
  end
277
297
 
278
298
  def cmd_list_drafts(arg)
279
- raise "Glitch: Got an argument" if arg != []
299
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
300
+ out = ""
280
301
  dir = "#@root/src"
281
302
  Dir.chdir(dir) do
282
303
  posts = Dir.entries(".").grep(/^0.*.lt3/)
283
- puts
304
+ out << "\n"
284
305
  if posts.empty?
285
- puts red(" No posts")
306
+ return red(" No posts")
286
307
  else
287
- posts.each {|post| puts " #{colored_slug(post.sub(/.lt3$/, ""))}" }
308
+ posts.each {|post| out << " #{colored_slug(post.sub(/.lt3$/, ""))}\n" }
288
309
  end
289
310
  end
290
- rescue
291
- puts "Oops? cwd = #{Dir.pwd} dir = #{dir}"
292
- puts err.backtrace
293
- exit
311
+ out
312
+ rescue => err
313
+ error(err)
294
314
  end
295
315
 
296
316
  def cmd_INVALID(arg)
297
- puts "\n Command '#{red(arg)}' was not understood."
317
+ return "\n Command '#{red(arg)}' was not understood."
298
318
  end
299
319
 
300
320
  def cmd_help(arg)
301
- raise "Glitch: Got an argument" if arg != []
302
- puts <<-EOS
321
+ raise "Glitch: #{__callee__} Got an argument" if arg != []
322
+ out = <<-EOS
303
323
 
304
324
  Commands:
305
325
 
@@ -327,6 +347,7 @@ module RuneBlog::REPL
327
347
  #{red('rebuild ')} Regenerate all posts and relink
328
348
  #{red('deploy ')} Deploy (current view)
329
349
  EOS
350
+ out
330
351
  end
331
352
 
332
353
  end
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.51"
6
+ VERSION = "0.0.52"
7
7
 
8
8
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
9
9
  DefaultData = Path + "/../data"
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.51
4
+ version: 0.0.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton