lib/repl.rb in runeblog-0.1.39 vs lib/repl.rb in runeblog-0.1.40

- old
+ new

@@ -31,11 +31,11 @@ def cmd_version(arg, testing = false) reset_output check_empty(arg) output RuneBlog::VERSION puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red) unless testing - [true, @out] + @out end def cmd_config(arg, testing = false) check_empty(arg) dir = @blog.view.dir @@ -79,75 +79,75 @@ check_empty(arg) url = @blog.view.publisher.url if url.nil? output! "Publish first." puts "\n Publish first." - return [false, @out] + return @out end result = system("open '#{url}'") raise CantOpen(url) unless result - return [true, @out] + return @out end def cmd_preview(arg, testing = false) reset_output check_empty(arg) local = @blog.view.index result = system("open #{local}") raise CantOpen(local) unless result - [true, @out] + @out end def cmd_publish(arg, testing = false) puts unless testing reset_output check_empty(arg) unless @blog.view.can_publish? puts "Can't publish without entries in #{@blog.view.name}/publish" unless testing output! "Can't publish without entries in #{@blog.view.name}/publish" - return [false, @out] + return @out end # Need to check dirty/clean status first dirty, all, assets = @blog.view.publishable_files files = dirty if dirty.empty? puts fx("\n No files are out of date." + " "*20, :bold) print " Publish anyway? " yn = RubyText.gets.chomp files = all if yn == "y" end - return [false, @out] if files.empty? + return @out if files.empty? ret = RubyText.spinner(label: " Publishing... ") do @blog.view.publisher.publish(files, assets) # FIXME weird? end - return [false, @out] unless ret + return @out unless ret vdir = @blog.view.dir dump("fix this later", "#{vdir}/last_published") if ! testing || ! ret puts " ...finished.\n " output! "...finished.\n" end - return [true, @out] + return @out end def cmd_rebuild(arg, testing = false) debug "Starting cmd_rebuild..." reset_output check_empty(arg) puts unless testing files = @blog.find_src_slugs files.each {|file| @blog.rebuild_post(file) } File.write("#{@blog.root}/src/last_rebuild", Time.now) - [true, @out] + @out end def cmd_relink(arg, testing = false) reset_output check_empty(arg) @blog.relink - [true, @out] + @out end def cmd_change_view(arg, testing = false) reset_output # Simplify this @@ -157,37 +157,37 @@ name = @blog.view.name k, name = STDSCR.menu(title: "Views", items: viewnames, curr: n) unless testing @blog.view = name output name + "\n" puts "\n ", fx(name, :bold), "\n" unless testing - return [false, @out] + return @out else if @blog.view?(arg) @blog.view = arg # reads config output "View: " + @blog.view.name.to_s puts "\n ", fx(arg, :bold), "\n" unless testing end end - return [true, @out] + return @out end def cmd_new_view(arg, testing = false) reset_output @blog.create_view(arg) resp = yesno("Add publishing info now? ") @blog.view.publisher = ask_publishing_info write_config(@blog.view.publisher, @blog.view.dir + "/publish") # change this? - [true, @out] + @out end def cmd_new_post(arg, testing = false) reset_output check_empty(arg) title = ask("\nTitle: ") @blog.create_new_post(title) STDSCR.clear - [true, @out] + @out rescue => err puts err puts err.backtrace.join("\n") end @@ -198,11 +198,11 @@ # FIXME ret = cmd_remove_post(x.to_i, false) puts ret output ret end - [true, @out] + @out end #-- FIXME affects linking, building, publishing... def cmd_remove_post(arg, testing = false, safe=true) @@ -210,11 +210,11 @@ reset_output id = get_integer(arg) result = @blog.remove_post(id) output! "Post #{id} not found" if result.nil? # puts "Post #{id} not found" if result.nil? - [true, @out] + @out end #-- FIXME affects linking, building, publishing... def cmd_edit_post(arg, testing = false) @@ -239,11 +239,11 @@ end file = files.first result = edit_file("#{@blog.root}/src/#{file}") @blog.rebuild_post(file) - [true, @out] + @out end def cmd_list_views(arg, testing = false) reset_output("\n") check_empty(arg) @@ -253,11 +253,11 @@ v = fx(v, :bold) if v == @blog.view.name output v + "\n" puts " ", v unless testing end puts unless testing - [true, @out] + @out end def cmd_list_posts(arg, testing = false) reset_output check_empty(arg) @@ -276,53 +276,53 @@ num, rest = base[0..3], base[4..-1] puts " ", fx(num, Red), fx(rest, Blue) unless testing end end puts unless testing - [true, @out] + @out end def cmd_list_drafts(arg, testing = false) reset_output check_empty(arg) drafts = @blog.drafts # current view if drafts.empty? output! "No drafts" puts "\n No drafts\n " unless testing - return [false, @out] + return @out else puts unless testing drafts.each do |draft| outstr " #{colored_slug(draft.sub(/.lt3$/, ""))}\n" base = draft.sub(/.lt3$/, "") num, rest = base[0..3], base[4..-1] puts " ", fx(num, Red), fx(rest, Blue) unless testing end end puts unless testing - [true, @out] + @out end def cmd_list_assets(arg, testing = false) reset_output check_empty(arg) dir = @blog.view.dir + "/assets" assets = Dir[dir + "/*"] if assets.empty? output! "No assets" puts " No assets" unless testing - return [false, @out] + return @out else puts unless testing assets.each do |name| asset = File.basename(name) outstr asset puts " ", fx(asset, Blue) unless testing end end puts unless testing - [true, @out] + @out end def cmd_ssh(arg, testing = false) pub = @blog.view.publisher system("ssh #{pub.user}@#{pub.server}") @@ -331,11 +331,11 @@ def cmd_INVALID(arg, testing = false) reset_output "\n Command '#{arg}' was not understood." print fx("\n Command ", :bold) print fx(arg, Red, :bold) puts fx(" was not understood.\n ", :bold) - [true, @out] + @out end def cmd_help(arg, testing = false) reset_output check_empty(arg) @@ -385,9 +385,9 @@ s1, s2 = line[0..22], line[23..-1] print fx(s1, :bold) puts s2 end puts unless testing - [true, @out] + @out end end