sources: rename Sources::Strategies to Source::Extractor.

Rename Sources::Strategies to Source::Extractor. A Source::Extractor
represents a thing that extracts information from a given URL.
This commit is contained in:
evazion
2022-03-24 03:05:10 -05:00
parent 34aa22f90b
commit d9d3c1dfe4
63 changed files with 622 additions and 606 deletions

View File

@@ -6,8 +6,8 @@ module Sources
setup do
@img = "https://imglf4.lf127.net/img/S1d2QlVsWkJhSW1qcnpIS0ZSa3ZJUFczb2RKSVlpMHJkNy9kc3BSQVQvQm5DNzB4eVhxay9nPT0.png?imageView&thumbnail=1680x0&quality=96&stripmeta=0"
@ref = "https://gengar563.lofter.com/post/1e82da8c_1c98dae1b"
@source = Sources::Strategies.find(@img, @ref)
@source2 = Sources::Strategies.find(@ref)
@source = Source::Extractor.find(@img, @ref)
@source2 = Source::Extractor.find(@ref)
end
should "get the artist name" do
@@ -47,7 +47,7 @@ module Sources
context "A different CSS schema" do
should "still find all the data" do
source1 = Sources::Strategies.find("https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d")
source1 = Source::Extractor.find("https://yuli031458.lofter.com/post/3163d871_1cbdc5f6d")
assert_equal(["https://imglf5.lf127.net/img/Mm55d3lNK2tJUWpNTjVLN0MvaTRDc1UvQUFLMGszOHRvSjV6S3VSa1lwa3BDWUtVOWpBTHBnPT0.jpg"], source1.image_urls)
assert_not_empty(source1.tags)
@@ -56,7 +56,7 @@ module Sources
context "A bad link" do
should "correctly get the full size" do
source = Sources::Strategies.find("https://imglf4.lf127.net/img/S1d2QlVsWkJhSW1qcnpIS0ZSa3ZJUFczb2RKSVlpMHJkNy9kc3BSQVQvQm5DNzB4eVhxay9nPT0.png?imageView&thumbnail=1680x0&quality=96&stripmeta=0")
source = Source::Extractor.find("https://imglf4.lf127.net/img/S1d2QlVsWkJhSW1qcnpIS0ZSa3ZJUFczb2RKSVlpMHJkNy9kc3BSQVQvQm5DNzB4eVhxay9nPT0.png?imageView&thumbnail=1680x0&quality=96&stripmeta=0")
assert_equal(["https://imglf4.lf127.net/img/S1d2QlVsWkJhSW1qcnpIS0ZSa3ZJUFczb2RKSVlpMHJkNy9kc3BSQVQvQm5DNzB4eVhxay9nPT0.png"], source.image_urls)
assert_nothing_raised { source.to_h }
end
@@ -64,7 +64,7 @@ module Sources
context "A dead link" do
should "not raise anything" do
source = Sources::Strategies.find("https://gxszdddd.lofter.com/post/322595b1_1ca5e6f66")
source = Source::Extractor.find("https://gxszdddd.lofter.com/post/322595b1_1ca5e6f66")
assert_nothing_raised { source.to_h }
end
end