runeblog 0.3.18 → 0.3.19

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
  SHA256:
3
- metadata.gz: d935e36229c36cdae337b72491aad4151824b5c083a48d36f5c73f6a069cc10e
4
- data.tar.gz: 742a6d8a782a39dc0897f4ce9d73d8e6b091c8dceb3f96230c990e556e20d994
3
+ metadata.gz: 2cfbb99881fa66be7a0bcdc30c24851bf8994f3586cd3e888f90da64266f5452
4
+ data.tar.gz: 64040a6450cab790bb2a7db4552ac610a526ea1ccd6d94319ae64c6cc6e3728d
5
5
  SHA512:
6
- metadata.gz: 68fdf37438b0fe6f4de20616896a5ad4d9e9a54d5287d079e318b8751b844e748ab261cec1f4f54e8f7bc3970a2dad280fed7a64cd3854c0672f55e8d3d6146d
7
- data.tar.gz: 5fd8d900cb5de28bdd51fe6d7f9700bf563ace134536e7c4097e36b7ed88520c687f4f6add2ac057677a87716697c5852717a56798a1199cb42a2118f14a034d
6
+ metadata.gz: 3c3df66c1d14c3ccd732949fda5a2b6e9b65bcd5121b2a1de6a60b8d7a8a6c05e38bf4660da4b175268c6f7e9292b1941f5dd1985328ccc9d6180261b5a1b844
7
+ data.tar.gz: 6d673eeaeca255e66db6442551b03dc17817bd2f889e6de3401fda42e47ab426620be21d1647f22382b779be17c739dc981bdde848bb65391bd3018132be2658
@@ -0,0 +1,37 @@
1
+
2
+ def make_exception(sym, str, target_class = Object)
3
+ return if target_class.constants.include?(sym)
4
+
5
+ target_class.const_set(sym, StandardError.dup)
6
+ define_method(sym) do |*args|
7
+ msg = str.dup
8
+ args.each.with_index {|arg, i| msg.sub!("%#{i+1}", arg) }
9
+ target_class.class_eval(sym.to_s).new(msg)
10
+ end
11
+ end
12
+
13
+ make_exception(:NotImplemented, "Feature not yet implemented")
14
+ make_exception(:CantOpen, "Can't open '%1'")
15
+ make_exception(:CantDelete, "Can't open '%1'")
16
+ make_exception(:InternalError, "Glitch: %1 got arg '%2'")
17
+ make_exception(:CantCopy, "Can't copy %1 to %2")
18
+
19
+ make_exception(:FileNotFound, "File %1 was not found")
20
+ make_exception(:FoundNeither, "Found neither %1 nor %2")
21
+ make_exception(:BlogRepoAlreadyExists, "Blog repo %1 already exists")
22
+ make_exception(:CantAssignView, "%1 is not a view")
23
+ make_exception(:ViewAlreadyExists, "View %1 already exists")
24
+ make_exception(:DirAlreadyExists, "Directory %1 already exists")
25
+ make_exception(:CantCreateDir, "Can't create directory %1")
26
+ make_exception(:EditorProblem, "Could not edit %1")
27
+ make_exception(:NoSuchView, "No such view: %1")
28
+ make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
29
+ make_exception(:ExpectedString, "Expected nonempty string but got %1 (%2)")
30
+ make_exception(:ExpectedView, "Expected string or View object but got %1 (%2)")
31
+ make_exception(:ExpectedInteger, "Expected integer but got %1 (%2)")
32
+ make_exception(:NoPostCall, "Method #post not called (no metadata)")
33
+ make_exception(:CantFindWidgetDir, "Can't find widget dir '%1'")
34
+ make_exception(:PublishError, "Error during publishing")
35
+ make_exception(:NoNumericPrefix, "No numeric prefix on slug '%1'")
36
+ make_exception(:NoExtensionExpected, "No file extension expected on '%1'")
37
+
@@ -1,11 +1,7 @@
1
1
 
2
- # Reopening...
3
-
4
- make_exception(:CantOpen, "Can't open '$1'")
5
- make_exception(:CantDelete, "Can't open '$1'")
6
- make_exception(:InternalError, "Glitch: $1 got arg '$2'")
7
- make_exception(:CantCopy, "Can't copy $1 to $2")
2
+ require 'exceptions'
8
3
 
4
+ # Reopening...
9
5
 
10
6
  module RuneBlog::REPL
11
7
  Patterns =
@@ -36,7 +36,6 @@ def init_liveblog # FIXME - a lot of this logic sucks
36
36
  rescue => err
37
37
  STDERR.puts "err = #{err}"
38
38
  STDERR.puts err.backtrace.join("\n")
39
- # raise "Only works inside a blog repo"
40
39
  end
41
40
 
42
41
  ##################
@@ -189,7 +188,7 @@ def banner
189
188
  if File.exist?(src)
190
189
  preprocess src: src, dst: file, call: ".nopara" # , vars: @blog.view.globals
191
190
  else
192
- raise "Neither #{file} nor #{src} found"
191
+ raise FoundNeither(file, src)
193
192
  end
194
193
  end
195
194
  str2 << "<td>" + File.read(file) + "</td>" + "\n"
@@ -362,7 +361,7 @@ def inset
362
361
  end
363
362
 
364
363
  def title
365
- raise "'post' was not called" unless @meta
364
+ raise NoPostCall unless @meta
366
365
  title = @_data.chomp
367
366
  @meta.title = title
368
367
  setvar :title, title
@@ -371,7 +370,7 @@ def title
371
370
  end
372
371
 
373
372
  def pubdate
374
- raise "'post' was not called" unless @meta
373
+ raise NoPostCall unless @meta
375
374
  _debug "data = #@_data"
376
375
  # Check for discrepancy?
377
376
  match = /(\d{4}).(\d{2}).(\d{2})/.match @_data
@@ -383,21 +382,21 @@ def pubdate
383
382
  end
384
383
 
385
384
  def tags
386
- raise "'post' was not called" unless @meta
385
+ raise NoPostCall unless @meta
387
386
  _debug "args = #{_args}"
388
387
  @meta.tags = _args.dup || []
389
388
  _optional_blank_line
390
389
  end
391
390
 
392
391
  def views
393
- raise "'post' was not called" unless @meta
392
+ raise NoPostCall unless @meta
394
393
  _debug "data = #{_args}"
395
394
  @meta.views = _args.dup
396
395
  _optional_blank_line
397
396
  end
398
397
 
399
398
  def pin
400
- raise "'post' was not called" unless @meta
399
+ raise NoPostCall unless @meta
401
400
  _debug "data = #{_args}" # verify only valid views?
402
401
  pinned = @_args
403
402
  @meta.pinned = pinned
@@ -417,7 +416,7 @@ rescue => err
417
416
  end
418
417
 
419
418
  def write_post
420
- raise "'post' was not called" unless @meta
419
+ raise NoPostCall unless @meta
421
420
  @meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
422
421
  @meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
423
422
  _write_metadata
@@ -427,7 +426,7 @@ rescue => err
427
426
  end
428
427
 
429
428
  def teaser
430
- raise "'post' was not called" unless @meta
429
+ raise NoPostCall unless @meta
431
430
  text = _body.join("\n")
432
431
  @meta.teaser = text
433
432
  setvar :teaser, @meta.teaser
@@ -584,9 +583,8 @@ def sidebar
584
583
  _body do |token|
585
584
  tag = token.chomp.strip.downcase
586
585
  wtag = "../../widgets"/tag
587
- raise "Can't find #{wtag}" unless Dir.exist?(wtag)
586
+ raise CantFindWidgetDir(wtag) unless Dir.exist?(wtag)
588
587
  tcard = "#{tag}-card.html"
589
-
590
588
  case
591
589
  when standard.include?(tag)
592
590
  _handle_standard_widget(tag)
@@ -11,7 +11,7 @@ class RuneBlog::Post
11
11
 
12
12
  def self.load(post)
13
13
  log!(enter: __method__, args: [post], level: 3)
14
- raise "Doesn't work right now"
14
+ raise NotImplemented
15
15
  raise NoBlogAccessor if RuneBlog.blog.nil?
16
16
  # "post" is a slug?
17
17
  pdir = RuneBlog.blog.root/:drafts/post
@@ -87,8 +87,8 @@ class RuneBlog::ViewPost
87
87
  attr_accessor :path, :title, :date, :teaser_text
88
88
 
89
89
  def self.make(blog:, view:, nslug:)
90
- raise "No numeric prefix on #{nslug}" unless nslug =~ /^\d{4}-/
91
- raise "Not expecting an extension" if nslug.end_with?(".lt3") || nslug.end_with?(".html")
90
+ raise NoNumericPrefix(nslug) unless nslug =~ /^\d{4}-/
91
+ raise NoExtensionExpected(nslug) if nslug.end_with?(".lt3") || nslug.end_with?(".html")
92
92
  view = view.to_s
93
93
  view.define_singleton_method :path do |subdir = ""|
94
94
  str = blog.root/:views/view
@@ -12,7 +12,7 @@ end
12
12
  def stale?(src, dst, deps, force = false)
13
13
  meh = File.new("/tmp/dammit-#{src.gsub(/\//, "-")}", "w")
14
14
  log!(enter: __method__, args: [src, dst], level: 3)
15
- raise "Source #{src} not found in #{Dir.pwd}" unless File.exist?(src)
15
+ raise FileNotFound("#{Dir.pwd}/#{src}") unless File.exist?(src)
16
16
  return true if force
17
17
  return true unless File.exist?(dst)
18
18
  return true if newer?(src, dst)
@@ -2,35 +2,28 @@ require 'runeblog'
2
2
  require 'ostruct'
3
3
  require 'helpers-repl' # FIXME structure
4
4
  require 'pathmagic'
5
+ require 'exceptions'
5
6
 
6
7
  require 'menus'
7
8
 
8
- make_exception(:PublishError, "Error during publishing")
9
- make_exception(:EditorProblem, "Could not edit $1")
10
-
11
9
  Signal.trap("INT") { puts "Don't :)" }
12
10
 
13
11
  module RuneBlog::REPL
14
12
  def edit_file(file, vim: "")
15
- # STDSCR.saveback
16
13
  ed = @blog.editor
17
14
  params = vim if ed =~ /vim$/
18
15
  result = system!("#{@blog.editor} #{file} #{params}")
19
16
  raise EditorProblem(file) unless result
20
- # STDSCR.restback
21
17
  cmd_clear
22
18
  end
23
19
 
24
20
  def cmd_quit
25
21
  STDSCR.rows.times { puts " "*(STDSCR.cols-1) }
26
- # FIXME please?
27
- # sleep 0.1
28
22
  STDSCR.clear
29
23
  sleep 0.1
30
24
  RubyText.stop
31
25
  sleep 0.1
32
26
  system("clear")
33
- # sleep 0.1
34
27
  exit
35
28
  end
36
29
 
@@ -441,7 +434,6 @@ module RuneBlog::REPL
441
434
  cmd = "cp #{name} #{@blog.root}/drafts/#@fname"
442
435
  result = system!(cmd)
443
436
  raise CantCopy(name, "#{@blog.root}/drafts/#@fname") unless result
444
- # post = Post.load(@slug)
445
437
  draft = "#{@blog.root}/drafts/#@fname"
446
438
  @meta = @blog.generate_post(draft)
447
439
  puts
@@ -15,6 +15,7 @@ require 'publish'
15
15
  require 'post'
16
16
 
17
17
  require 'pathmagic'
18
+ require 'exceptions'
18
19
 
19
20
  ###
20
21
 
@@ -48,19 +49,6 @@ class RuneBlog
48
49
  ConfigFile = "config"
49
50
  Themes = RuneBlog::Path/"../themes"
50
51
 
51
- make_exception(:FileNotFound, "File $1 was not found")
52
- make_exception(:BlogRepoAlreadyExists, "Blog repo $1 already exists")
53
- make_exception(:CantAssignView, "$1 is not a view")
54
- make_exception(:ViewAlreadyExists, "View $1 already exists")
55
- make_exception(:DirAlreadyExists, "Directory $1 already exists")
56
- make_exception(:CantCreateDir, "Can't create directory $1")
57
- make_exception(:EditorProblem, "Could not edit $1")
58
- make_exception(:NoSuchView, "No such view: $1")
59
- make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
60
- make_exception(:ExpectedString, "Expected nonempty string but got $1 ($2)")
61
- make_exception(:ExpectedView, "Expected string or View object but got $1 ($2)")
62
- make_exception(:ExpectedInteger, "Expected integer but got $1 ($2)")
63
-
64
52
  include ErrorChecks
65
53
 
66
54
  class << self
@@ -1,9 +1,7 @@
1
1
  if !defined?(RuneBlog::Path)
2
2
 
3
- # if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
4
-
5
3
  class RuneBlog
6
- VERSION = "0.3.18"
4
+ VERSION = "0.3.19"
7
5
 
8
6
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
9
7
  Path = File.dirname(path)
@@ -28,18 +26,7 @@ class RuneBlog
28
26
  end
29
27
  end
30
28
 
31
- # Refactor, move stuff elsewhere?
32
-
33
- def make_exception(sym, str, target_class = Object)
34
- return if target_class.constants.include?(sym)
35
-
36
- target_class.const_set(sym, StandardError.dup)
37
- define_method(sym) do |*args|
38
- msg = str.dup
39
- args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
40
- target_class.class_eval(sym.to_s).new(msg)
41
- end
42
- end
29
+ # Refactor, move elsewhere?
43
30
 
44
31
  def prefix(num)
45
32
  log!(enter: __method__, args: [num], level: 3)
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.3.18
4
+ version: 0.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-06 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -143,6 +143,7 @@ files:
143
143
  - empty_view/themes/standard/post/index.lt3
144
144
  - empty_view/themes/standard/post/permalink.lt3
145
145
  - lib/Javascript.stuff
146
+ - lib/exceptions.rb
146
147
  - lib/helpers-blog.rb
147
148
  - lib/helpers-repl.rb
148
149
  - lib/liveblog.rb