danger-the_coding_love 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c000079295312c28efe06f6198dee7fd9df969a91778f9df8698e9fccec97a97
4
- data.tar.gz: 431605a4ad0757b66bc70dc2d07f5bb0645a5aa10ed6969def96b525ba8c8e0d
3
+ metadata.gz: b410f9e8a7fff62174696e41797ee1eb61580a3085e0316bedea8bced6f45f97
4
+ data.tar.gz: 81bb3876751e59d78377f7633e16a0a32efe0bf5c74248ca43eb966d26fd6829
5
5
  SHA512:
6
- metadata.gz: ce85980c614cd0ef9f41264aa0471e6aeb84f2735496b04fdfad839e0cb21bfd1deab4cf55e34c65e9895af6650404b70e04c0e48a823609d7533358cc1c397e
7
- data.tar.gz: ac9bccae7b2ef6e2d4797070187ed58751faf11db8c23899cd18da7db53846e7be39e91b23eae74bf6ac09edae9b47b453dd014545fa113149b9f14c0d5c3900
6
+ metadata.gz: 3851ff21832a8f7a6dc78d060a631604234f403761bb3f37761ce47e3e62458b47bcf1e00452549b30d683c2b400697d41471c063ab0b4c56910ae197ae7a443
7
+ data.tar.gz: e8cfd5f69fb64d32c70552e5a8fc51c906ed3edb94c90857f580050f95de48f962d18ae09ad93053d2180f17eeae24edfada708bf59f3234fcce379d613290b4
data/.travis.yml CHANGED
@@ -4,7 +4,6 @@ cache:
4
4
  - bundle
5
5
 
6
6
  rvm:
7
- - 2.1.3
8
7
  - 2.3.1
9
8
 
10
9
  script:
data/Gemfile.lock CHANGED
@@ -1,50 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-the_coding_love (0.0.6)
4
+ danger-the_coding_love (0.0.7)
5
5
  danger-plugin-api (~> 1.0)
6
- nokogiri
6
+ nokogiri (>= 1.8.5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
11
+ addressable (2.6.0)
12
12
  public_suffix (>= 2.0.2, < 4.0)
13
13
  claide (1.0.2)
14
14
  claide-plugins (0.9.2)
15
15
  cork
16
16
  nap
17
17
  open4 (~> 1.3)
18
- coderay (1.1.1)
18
+ coderay (1.1.2)
19
19
  colored2 (3.1.2)
20
20
  cork (0.3.0)
21
21
  colored2 (~> 3.1)
22
- danger (5.6.1)
22
+ danger (6.0.9)
23
23
  claide (~> 1.0)
24
24
  claide-plugins (>= 0.9.2)
25
25
  colored2 (~> 3.1)
26
26
  cork (~> 0.1)
27
27
  faraday (~> 0.9)
28
- faraday-http-cache (~> 1.0)
29
- git (~> 1)
30
- kramdown (~> 1.5)
28
+ faraday-http-cache (~> 2.0)
29
+ git (~> 1.5)
30
+ kramdown (~> 2.0)
31
+ kramdown-parser-gfm (~> 1.0)
31
32
  no_proxy_fix
32
33
  octokit (~> 4.7)
33
34
  terminal-table (~> 1)
34
35
  danger-plugin-api (1.0.0)
35
36
  danger (> 2.0)
36
- diff-lcs (1.2.5)
37
- faraday (0.15.2)
37
+ diff-lcs (1.3)
38
+ faraday (0.15.4)
38
39
  multipart-post (>= 1.2, < 3)
39
- faraday-http-cache (1.3.1)
40
+ faraday-http-cache (2.0.0)
40
41
  faraday (~> 0.8)
41
- ffi (1.9.14)
42
+ ffi (1.11.1)
42
43
  formatador (0.2.5)
43
- git (1.4.0)
44
- guard (2.14.0)
44
+ git (1.5.0)
45
+ guard (2.15.0)
45
46
  formatador (>= 0.2.4)
46
47
  listen (>= 2.7, < 4.0)
47
- lumberjack (~> 1.0)
48
+ lumberjack (>= 1.0.12, < 2.0)
48
49
  nenv (~> 0.1)
49
50
  notiffany (~> 0.0)
50
51
  pry (>= 0.9.12)
@@ -55,57 +56,57 @@ GEM
55
56
  guard (~> 2.1)
56
57
  guard-compat (~> 1.1)
57
58
  rspec (>= 2.99.0, < 4.0)
58
- kramdown (1.16.2)
59
+ kramdown (2.1.0)
60
+ kramdown-parser-gfm (1.1.0)
61
+ kramdown (~> 2.0)
59
62
  listen (3.0.7)
60
63
  rb-fsevent (>= 0.9.3)
61
64
  rb-inotify (>= 0.9.7)
62
- lumberjack (1.0.10)
63
- method_source (0.8.2)
64
- mini_portile2 (2.3.0)
65
- multipart-post (2.0.0)
65
+ lumberjack (1.0.13)
66
+ method_source (0.9.2)
67
+ mini_portile2 (2.4.0)
68
+ multipart-post (2.1.1)
66
69
  nap (1.1.0)
67
70
  nenv (0.3.0)
68
71
  no_proxy_fix (0.1.2)
69
- nokogiri (1.8.2)
70
- mini_portile2 (~> 2.3.0)
71
- notiffany (0.1.1)
72
+ nokogiri (1.10.3)
73
+ mini_portile2 (~> 2.4.0)
74
+ notiffany (0.1.3)
72
75
  nenv (~> 0.1)
73
76
  shellany (~> 0.0)
74
- octokit (4.9.0)
77
+ octokit (4.14.0)
75
78
  sawyer (~> 0.8.0, >= 0.5.3)
76
79
  open4 (1.3.4)
77
- pry (0.10.4)
80
+ pry (0.12.2)
78
81
  coderay (~> 1.1.0)
79
- method_source (~> 0.8.1)
80
- slop (~> 3.4)
81
- public_suffix (2.0.5)
82
+ method_source (~> 0.9.0)
83
+ public_suffix (3.1.1)
82
84
  rake (10.5.0)
83
- rb-fsevent (0.9.8)
84
- rb-inotify (0.9.7)
85
- ffi (>= 0.5.0)
86
- rspec (3.5.0)
87
- rspec-core (~> 3.5.0)
88
- rspec-expectations (~> 3.5.0)
89
- rspec-mocks (~> 3.5.0)
90
- rspec-core (3.5.4)
91
- rspec-support (~> 3.5.0)
92
- rspec-expectations (3.5.0)
85
+ rb-fsevent (0.10.3)
86
+ rb-inotify (0.10.0)
87
+ ffi (~> 1.0)
88
+ rspec (3.8.0)
89
+ rspec-core (~> 3.8.0)
90
+ rspec-expectations (~> 3.8.0)
91
+ rspec-mocks (~> 3.8.0)
92
+ rspec-core (3.8.2)
93
+ rspec-support (~> 3.8.0)
94
+ rspec-expectations (3.8.4)
93
95
  diff-lcs (>= 1.2.0, < 2.0)
94
- rspec-support (~> 3.5.0)
95
- rspec-mocks (3.5.0)
96
+ rspec-support (~> 3.8.0)
97
+ rspec-mocks (3.8.1)
96
98
  diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.5.0)
98
- rspec-support (3.5.0)
99
- sawyer (0.8.1)
100
- addressable (>= 2.3.5, < 2.6)
101
- faraday (~> 0.8, < 1.0)
99
+ rspec-support (~> 3.8.0)
100
+ rspec-support (3.8.2)
101
+ sawyer (0.8.2)
102
+ addressable (>= 2.3.5)
103
+ faraday (> 0.8, < 2.0)
102
104
  shellany (0.0.1)
103
- slop (3.6.0)
104
105
  terminal-table (1.8.0)
105
106
  unicode-display_width (~> 1.1, >= 1.1.1)
106
- thor (0.19.4)
107
- unicode-display_width (1.3.3)
108
- yard (0.9.5)
107
+ thor (0.20.3)
108
+ unicode-display_width (1.6.0)
109
+ yard (0.9.20)
109
110
 
110
111
  PLATFORMS
111
112
  ruby
@@ -119,7 +120,7 @@ DEPENDENCIES
119
120
  pry
120
121
  rake (~> 10.0)
121
122
  rspec (~> 3.4)
122
- yard (~> 0.8)
123
+ yard (>= 0.9.11)
123
124
 
124
125
  BUNDLED WITH
125
- 1.16.1
126
+ 1.17.2
@@ -1,3 +1,3 @@
1
1
  module TheCodingLove
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Danger
2
4
  # Prints markdown containing a random post from
3
5
  # [thecodinglove.com](http://thecodinglove.com)
@@ -15,36 +17,40 @@ module Danger
15
17
  # @return [text, image_url]
16
18
  #
17
19
  def random
18
- require 'open-uri'
19
- require 'nokogiri'
20
-
21
- @main_page_doc = Nokogiri::HTML(open('https://thecodinglove.com'))
22
- random_love_page_url = @main_page_doc.at_xpath("//a[@class='nav-link']/@href").to_s
23
-
24
- text, image_url = atUrl(random_love_page_url)
20
+ text, image_url = at_url(random_post_url)
25
21
 
26
22
  markdown("------\n#{text}\n--\n![alt text](#{image_url} \"thecodinglove.com\")")
27
23
 
28
24
  [text, image_url]
29
25
  end
30
26
 
27
+ # Returns url to random post from thecodinglove.com
28
+ #
29
+ # @return [url]
30
+ #
31
+ def random_post_url
32
+ require 'open-uri'
33
+ require 'nokogiri'
34
+ @main_page_doc = Nokogiri::HTML(open('https://thecodinglove.com'))
35
+ random_love_page_url = @main_page_doc.at_xpath("//ul[@class='navbar-nav mr-auto']/a/@href").to_s
36
+ random_love_page_url
37
+ end
38
+
31
39
  # Returns text and url containing given post from thecodinglove.com url
32
40
  #
33
41
  # @return [text, image_url]
34
42
  #
35
- def atUrl(love_page_url)
36
- @doc = Nokogiri::HTML(open(love_page_url))
37
- @doc = @doc.at_xpath("//div[@class='blog-post']")
43
+ def at_url(love_page_url)
44
+ @doc = Nokogiri::HTML(URI.parse(love_page_url).open)
45
+ @doc = @doc.at_xpath("//div[@class='blog-post content-single']")
38
46
 
39
47
  text = @doc.at_xpath('//h1').text
40
48
  image_url = @doc.at_xpath("//div[@class='blog-post-content']/p/img/@src").to_s
41
49
  video_gif_url = @doc.at_xpath("//div[@class='blog-post-content']/p/video//object[@type='image/gif']/@data").to_s
42
50
 
43
- if image_url.empty?
44
- return [text, video_gif_url]
45
- else
46
- return [text, image_url]
47
- end
51
+ return [text, video_gif_url] if image_url.empty?
52
+
53
+ [text, image_url]
48
54
  end
49
55
 
50
56
  def self.instance_name
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('spec_helper', __dir__)
2
4
 
5
+ # Module tests
3
6
  module Danger
4
7
  describe Danger::DangerTheCodingLove do
5
8
  it 'should be a plugin' do
@@ -12,6 +15,13 @@ module Danger
12
15
  @the_coding_love = @dangerfile.the_coding_love
13
16
  end
14
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
+
15
25
  it 'prints a random post' do
16
26
  post = @the_coding_love.random
17
27
 
@@ -21,7 +31,7 @@ module Danger
21
31
  end
22
32
 
23
33
  it 'prints an image post' do
24
- post = @the_coding_love.atUrl('https://thecodinglove.com/ai-in-cars-is-getting-better')
34
+ post = @the_coding_love.at_url('https://thecodinglove.com/ai-in-cars-is-getting-better')
25
35
 
26
36
  expect(post[0]).not_to be_empty
27
37
  expect(post[1]).not_to be_empty
@@ -30,7 +40,7 @@ module Danger
30
40
  end
31
41
 
32
42
  it 'prints a gif post' do
33
- post = @the_coding_love.atUrl('https://thecodinglove.com/when-i-commit-push-right-after-someone-has')
43
+ post = @the_coding_love.at_url('https://thecodinglove.com/when-i-commit-push-right-after-someone-has')
34
44
 
35
45
  expect(post[0]).not_to be_empty
36
46
  expect(post[1]).not_to be_empty
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valerio Mazzeo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api