Sha256: e1500f7f8b45cf55f761b986d8f86567863f330a3d61b0115ba5cad6f236f81a
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Danger # Prints markdown containing a random post from # [thecodinglove.com](http://thecodinglove.com) # # @example Prints markdown containing a random post # # the_coding_love.random # # @see valeriomazzeo/danger-the_coding_love # @tags thecodinglove.com, coding, love, random, gif # class DangerTheCodingLove < Plugin # Prints markdown containing a random post from thecodinglove.com # # @return [text, image_url] # def random require 'open-uri' require 'nokogiri' @main_page_doc = Nokogiri::HTML(open("https://thecodinglove.com")) random_gif_page_url = @main_page_doc.at_xpath("//a[@class='nav-link']/@href").to_s @doc = Nokogiri::HTML(open(random_gif_page_url)) @doc = @doc.at_xpath("//div[@class='blog-post']") text = @doc.at_xpath("//h1").text image_url = @doc.at_xpath("//div[@class='blog-post-content']/p/img/@src").to_s markdown("------\n#{text}\n--\n![alt text](#{image_url} \"thecodinglove.com\")") return text, image_url end def self.instance_name to_s.gsub("Danger", "").danger_underscore.split("/").last end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-the_coding_love-0.0.5 | lib/the_coding_love/plugin.rb |