From 5a8f952568016b1e6668f54d0afec3d7fd1eac6a Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 7 Jan 2023 10:04:25 +0100 Subject: [PATCH] manifest: fix attribution --- lib/docs/core/doc.rb | 2 +- test/lib/docs/core/manifest_test.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index 17f83082..9f58cacd 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -88,7 +88,7 @@ module Docs def as_json_extra(store) json = self.as_json - json[:attribution] = options[:attribution].strip if self.class.method_defined?(:options) and options[:attribution].present? + json[:attribution] = options[:attribution].strip json[:db_size] = store.size(self.db_path) if store.exist?(self.db_path) json[:mtime] = store.mtime(self.meta_path).to_i if store.exist?(self.meta_path) json diff --git a/test/lib/docs/core/manifest_test.rb b/test/lib/docs/core/manifest_test.rb index 9bb59447..8e4c8e1f 100644 --- a/test/lib/docs/core/manifest_test.rb +++ b/test/lib/docs/core/manifest_test.rb @@ -3,8 +3,9 @@ require 'docs' class ManifestTest < MiniTest::Spec let :doc do - doc = Class.new Docs::Doc + doc = Class.new Docs::Scraper doc.name = 'TestDoc' + doc.options[:attribution] = 'foo' doc end @@ -63,7 +64,7 @@ class ManifestTest < MiniTest::Spec it "includes the doc's meta representation" do json = manifest.as_json assert_equal 1, json.length - assert_equal "{:name=>\"TestDoc\", :slug=>\"testdoc\", :type=>nil, :mtime=>0}", json[0].to_s + assert_equal "{:name=>\"TestDoc\", :slug=>\"testdoc\", :type=>nil, :attribution=>\"foo\", :mtime=>0}", json[0].to_s end end