danger-the_coding_love 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/danger-the_coding_love.gemspec +2 -2
- data/lib/the_coding_love/gem_version.rb +1 -1
- data/lib/the_coding_love/plugin.rb +24 -9
- data/spec/the_coding_love_spec.rb +22 -4
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c000079295312c28efe06f6198dee7fd9df969a91778f9df8698e9fccec97a97
|
4
|
+
data.tar.gz: 431605a4ad0757b66bc70dc2d07f5bb0645a5aa10ed6969def96b525ba8c8e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce85980c614cd0ef9f41264aa0471e6aeb84f2735496b04fdfad839e0cb21bfd1deab4cf55e34c65e9895af6650404b70e04c0e48a823609d7533358cc1c397e
|
7
|
+
data.tar.gz: ac9bccae7b2ef6e2d4797070187ed58751faf11db8c23899cd18da7db53846e7be39e91b23eae74bf6ac09edae9b47b453dd014545fa113149b9f14c0d5c3900
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
-
spec.add_runtime_dependency 'nokogiri'
|
22
|
+
spec.add_runtime_dependency 'nokogiri', '>= 1.8.5'
|
23
23
|
|
24
24
|
# General ruby development
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
30
30
|
|
31
31
|
# Linting code and docs
|
32
|
-
spec.add_development_dependency "yard", "
|
32
|
+
spec.add_development_dependency "yard", ">= 0.9.11"
|
33
33
|
|
34
34
|
# Makes testing easy via `bundle exec guard`
|
35
35
|
spec.add_development_dependency 'guard', '~> 2.14'
|
@@ -18,22 +18,37 @@ module Danger
|
|
18
18
|
require 'open-uri'
|
19
19
|
require 'nokogiri'
|
20
20
|
|
21
|
-
@main_page_doc = Nokogiri::HTML(open(
|
22
|
-
|
23
|
-
|
24
|
-
@doc = Nokogiri::HTML(open(random_gif_page_url))
|
25
|
-
@doc = @doc.at_xpath("//div[@class='blog-post']")
|
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
|
26
23
|
|
27
|
-
text =
|
28
|
-
image_url = @doc.at_xpath("//div[@class='blog-post-content']/p/img/@src").to_s
|
24
|
+
text, image_url = atUrl(random_love_page_url)
|
29
25
|
|
30
26
|
markdown("------\n#{text}\n--\n![alt text](#{image_url} \"thecodinglove.com\")")
|
31
27
|
|
32
|
-
|
28
|
+
[text, image_url]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns text and url containing given post from thecodinglove.com url
|
32
|
+
#
|
33
|
+
# @return [text, image_url]
|
34
|
+
#
|
35
|
+
def atUrl(love_page_url)
|
36
|
+
@doc = Nokogiri::HTML(open(love_page_url))
|
37
|
+
@doc = @doc.at_xpath("//div[@class='blog-post']")
|
38
|
+
|
39
|
+
text = @doc.at_xpath('//h1').text
|
40
|
+
image_url = @doc.at_xpath("//div[@class='blog-post-content']/p/img/@src").to_s
|
41
|
+
video_gif_url = @doc.at_xpath("//div[@class='blog-post-content']/p/video//object[@type='image/gif']/@data").to_s
|
42
|
+
|
43
|
+
if image_url.empty?
|
44
|
+
return [text, video_gif_url]
|
45
|
+
else
|
46
|
+
return [text, image_url]
|
47
|
+
end
|
33
48
|
end
|
34
49
|
|
35
50
|
def self.instance_name
|
36
|
-
to_s.gsub(
|
51
|
+
to_s.gsub('Danger', '').danger_underscore.split('/').last
|
37
52
|
end
|
38
53
|
end
|
39
54
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
|
3
3
|
module Danger
|
4
4
|
describe Danger::DangerTheCodingLove do
|
@@ -12,11 +12,29 @@ module Danger
|
|
12
12
|
@the_coding_love = @dangerfile.the_coding_love
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
15
|
+
it 'prints a random post' do
|
16
16
|
post = @the_coding_love.random
|
17
17
|
|
18
|
-
expect(post[0]).not_to
|
19
|
-
expect(post[1]).not_to
|
18
|
+
expect(post[0]).not_to be_empty
|
19
|
+
expect(post[1]).not_to be_empty
|
20
|
+
expect(@dangerfile.status_report[:markdowns]).not_to be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'prints an image post' do
|
24
|
+
post = @the_coding_love.atUrl('https://thecodinglove.com/ai-in-cars-is-getting-better')
|
25
|
+
|
26
|
+
expect(post[0]).not_to be_empty
|
27
|
+
expect(post[1]).not_to be_empty
|
28
|
+
expect(File.extname(post[1]).strip.downcase).to eq '.jpg'
|
29
|
+
expect(@dangerfile.status_report[:markdowns]).not_to be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'prints a gif post' do
|
33
|
+
post = @the_coding_love.atUrl('https://thecodinglove.com/when-i-commit-push-right-after-someone-has')
|
34
|
+
|
35
|
+
expect(post[0]).not_to be_empty
|
36
|
+
expect(post[1]).not_to be_empty
|
37
|
+
expect(File.extname(post[1]).strip.downcase).to eq '.gif'
|
20
38
|
expect(@dangerfile.status_report[:markdowns]).not_to be_nil
|
21
39
|
end
|
22
40
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valerio Mazzeo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.8.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.8.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.9.11
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 0.9.11
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.6
|
195
|
+
rubygems_version: 2.7.6
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Prints markdown containing a random post from thecodinglove.com.
|