danger-the_coding_love 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +10 -8
 - data/lib/the_coding_love/gem_version.rb +1 -1
 - data/lib/the_coding_love/plugin.rb +8 -19
 - data/spec/the_coding_love_spec.rb +0 -7
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2f569b083674882023f1cf30789c908099cd2498efaba354a8da527df7c45d54
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1e5337553252749130c1e1c839f4954425894ccb45dcc0af040fd34ba648666e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c39343f7a6a23ad541d7c764aabce3676cc69ee7bb03271803984d02d264efc1dc487ec8d70adf5d1e3decd627ac56f24688d07207dad016460921ac290fbd7b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6b2ee2db779583d54d9bf85017e94bb4231a5f08edf7ca1cb7ae9d895a69d49ff22b27e7ba1feaf5b0beb0183d87ac27ef9996e6439434cdd88637515707fc37
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                danger-the_coding_love (0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
                danger-the_coding_love (0.0.9)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  danger-plugin-api (~> 1.0)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  nokogiri (>= 1.10.8)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -19,14 +19,14 @@ GEM 
     | 
|
| 
       19 
19 
     | 
    
         
             
                colored2 (3.1.2)
         
     | 
| 
       20 
20 
     | 
    
         
             
                cork (0.3.0)
         
     | 
| 
       21 
21 
     | 
    
         
             
                  colored2 (~> 3.1)
         
     | 
| 
       22 
     | 
    
         
            -
                danger ( 
     | 
| 
      
 22 
     | 
    
         
            +
                danger (8.0.0)
         
     | 
| 
       23 
23 
     | 
    
         
             
                  claide (~> 1.0)
         
     | 
| 
       24 
24 
     | 
    
         
             
                  claide-plugins (>= 0.9.2)
         
     | 
| 
       25 
25 
     | 
    
         
             
                  colored2 (~> 3.1)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  cork (~> 0.1)
         
     | 
| 
       27 
     | 
    
         
            -
                  faraday ( 
     | 
| 
      
 27 
     | 
    
         
            +
                  faraday (>= 0.9.0, < 2.0)
         
     | 
| 
       28 
28 
     | 
    
         
             
                  faraday-http-cache (~> 2.0)
         
     | 
| 
       29 
     | 
    
         
            -
                  git (~> 1. 
     | 
| 
      
 29 
     | 
    
         
            +
                  git (~> 1.7)
         
     | 
| 
       30 
30 
     | 
    
         
             
                  kramdown (~> 2.0)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  kramdown-parser-gfm (~> 1.0)
         
     | 
| 
       32 
32 
     | 
    
         
             
                  no_proxy_fix
         
     | 
| 
         @@ -35,13 +35,13 @@ GEM 
     | 
|
| 
       35 
35 
     | 
    
         
             
                danger-plugin-api (1.0.0)
         
     | 
| 
       36 
36 
     | 
    
         
             
                  danger (> 2.0)
         
     | 
| 
       37 
37 
     | 
    
         
             
                diff-lcs (1.3)
         
     | 
| 
       38 
     | 
    
         
            -
                faraday (0. 
     | 
| 
      
 38 
     | 
    
         
            +
                faraday (1.0.1)
         
     | 
| 
       39 
39 
     | 
    
         
             
                  multipart-post (>= 1.2, < 3)
         
     | 
| 
       40 
40 
     | 
    
         
             
                faraday-http-cache (2.2.0)
         
     | 
| 
       41 
41 
     | 
    
         
             
                  faraday (>= 0.8)
         
     | 
| 
       42 
42 
     | 
    
         
             
                ffi (1.12.2)
         
     | 
| 
       43 
43 
     | 
    
         
             
                formatador (0.2.5)
         
     | 
| 
       44 
     | 
    
         
            -
                git (1. 
     | 
| 
      
 44 
     | 
    
         
            +
                git (1.7.0)
         
     | 
| 
       45 
45 
     | 
    
         
             
                  rchardet (~> 1.8)
         
     | 
| 
       46 
46 
     | 
    
         
             
                guard (2.16.2)
         
     | 
| 
       47 
47 
     | 
    
         
             
                  formatador (>= 0.2.4)
         
     | 
| 
         @@ -57,7 +57,8 @@ GEM 
     | 
|
| 
       57 
57 
     | 
    
         
             
                  guard (~> 2.1)
         
     | 
| 
       58 
58 
     | 
    
         
             
                  guard-compat (~> 1.1)
         
     | 
| 
       59 
59 
     | 
    
         
             
                  rspec (>= 2.99.0, < 4.0)
         
     | 
| 
       60 
     | 
    
         
            -
                kramdown (2.1 
     | 
| 
      
 60 
     | 
    
         
            +
                kramdown (2.2.1)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  rexml
         
     | 
| 
       61 
62 
     | 
    
         
             
                kramdown-parser-gfm (1.1.0)
         
     | 
| 
       62 
63 
     | 
    
         
             
                  kramdown (~> 2.0)
         
     | 
| 
       63 
64 
     | 
    
         
             
                listen (3.0.7)
         
     | 
| 
         @@ -82,12 +83,13 @@ GEM 
     | 
|
| 
       82 
83 
     | 
    
         
             
                pry (0.13.1)
         
     | 
| 
       83 
84 
     | 
    
         
             
                  coderay (~> 1.1)
         
     | 
| 
       84 
85 
     | 
    
         
             
                  method_source (~> 1.0)
         
     | 
| 
       85 
     | 
    
         
            -
                public_suffix (4.0. 
     | 
| 
      
 86 
     | 
    
         
            +
                public_suffix (4.0.5)
         
     | 
| 
       86 
87 
     | 
    
         
             
                rake (12.3.3)
         
     | 
| 
       87 
88 
     | 
    
         
             
                rb-fsevent (0.10.3)
         
     | 
| 
       88 
89 
     | 
    
         
             
                rb-inotify (0.10.1)
         
     | 
| 
       89 
90 
     | 
    
         
             
                  ffi (~> 1.0)
         
     | 
| 
       90 
91 
     | 
    
         
             
                rchardet (1.8.0)
         
     | 
| 
      
 92 
     | 
    
         
            +
                rexml (3.2.4)
         
     | 
| 
       91 
93 
     | 
    
         
             
                rspec (3.9.0)
         
     | 
| 
       92 
94 
     | 
    
         
             
                  rspec-core (~> 3.9.0)
         
     | 
| 
       93 
95 
     | 
    
         
             
                  rspec-expectations (~> 3.9.0)
         
     | 
| 
         @@ -17,7 +17,7 @@ module Danger 
     | 
|
| 
       17 
17 
     | 
    
         
             
                # @return  [text, image_url]
         
     | 
| 
       18 
18 
     | 
    
         
             
                #
         
     | 
| 
       19 
19 
     | 
    
         
             
                def random
         
     | 
| 
       20 
     | 
    
         
            -
                  rnd_url =  
     | 
| 
      
 20 
     | 
    
         
            +
                  rnd_url = 'https://thecodinglove.com/random'
         
     | 
| 
       21 
21 
     | 
    
         
             
                  text, image_url = at_url(rnd_url)
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  markdown(
         
     | 
| 
         @@ -31,33 +31,22 @@ module Danger 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  [text, image_url]
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                # Returns url to random post from thecodinglove.com
         
     | 
| 
       35 
     | 
    
         
            -
                #
         
     | 
| 
       36 
     | 
    
         
            -
                # @return [url]
         
     | 
| 
       37 
     | 
    
         
            -
                #
         
     | 
| 
       38 
     | 
    
         
            -
                def random_post_url
         
     | 
| 
       39 
     | 
    
         
            -
                  require 'open-uri'
         
     | 
| 
       40 
     | 
    
         
            -
                  require 'nokogiri'
         
     | 
| 
       41 
     | 
    
         
            -
                  @main_page_doc = Nokogiri::HTML(URI.open('https://thecodinglove.com'))
         
     | 
| 
       42 
     | 
    
         
            -
                  random_love_page_url = @main_page_doc.at_xpath(
         
     | 
| 
       43 
     | 
    
         
            -
                    "//ul[@class='navbar-nav mr-auto']/li/a/@href"
         
     | 
| 
       44 
     | 
    
         
            -
                  ).to_s
         
     | 
| 
       45 
     | 
    
         
            -
                  random_love_page_url
         
     | 
| 
       46 
     | 
    
         
            -
                end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
34 
     | 
    
         
             
                # Returns text and url containing given post from thecodinglove.com url
         
     | 
| 
       49 
35 
     | 
    
         
             
                #
         
     | 
| 
       50 
36 
     | 
    
         
             
                # @return  [text, image_url]
         
     | 
| 
       51 
37 
     | 
    
         
             
                #
         
     | 
| 
       52 
38 
     | 
    
         
             
                def at_url(love_page_url)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  require 'open-uri'
         
     | 
| 
      
 40 
     | 
    
         
            +
                  require 'nokogiri'
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       53 
42 
     | 
    
         
             
                  raise 'Empty coding love page URL' if love_page_url.empty?
         
     | 
| 
       54 
43 
     | 
    
         | 
| 
       55 
44 
     | 
    
         
             
                  @doc = Nokogiri::HTML(URI.parse(love_page_url).open)
         
     | 
| 
       56 
     | 
    
         
            -
                  @ 
     | 
| 
      
 45 
     | 
    
         
            +
                  @article = @doc.at_xpath("//article[@class='blog-post content-single']")
         
     | 
| 
       57 
46 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
                  text = @ 
     | 
| 
       59 
     | 
    
         
            -
                  image_url = @ 
     | 
| 
       60 
     | 
    
         
            -
                  video_gif_url = @ 
     | 
| 
      
 47 
     | 
    
         
            +
                  text = @article.at_xpath('//h1').text
         
     | 
| 
      
 48 
     | 
    
         
            +
                  image_url = @article.at_xpath("//div[@class='blog-post-content']/p/img/@data-src").to_s
         
     | 
| 
      
 49 
     | 
    
         
            +
                  video_gif_url = @article.at_xpath("//div[@class='blog-post-content']/p/video//object[@type='image/gif']/@data").to_s
         
     | 
| 
       61 
50 
     | 
    
         | 
| 
       62 
51 
     | 
    
         
             
                  return [text, video_gif_url] if image_url.empty?
         
     | 
| 
       63 
52 
     | 
    
         | 
| 
         @@ -15,13 +15,6 @@ module Danger 
     | 
|
| 
       15 
15 
     | 
    
         
             
                    @the_coding_love = @dangerfile.the_coding_love
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                  it 'prints a random url' do
         
     | 
| 
       19 
     | 
    
         
            -
                    rnd_url = @the_coding_love.random_post_url
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                    # expect(rnd_url).to eq('') # for development, should not be empty
         
     | 
| 
       22 
     | 
    
         
            -
                    expect(rnd_url).not_to be_empty
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
18 
     | 
    
         
             
                  it 'prints a random post' do
         
     | 
| 
       26 
19 
     | 
    
         
             
                    post = @the_coding_love.random
         
     | 
| 
       27 
20 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: danger-the_coding_love
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Valerio Mazzeo
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2020- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-05-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: danger-plugin-api
         
     |