ruboty-url 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: d91d6be5089da10c7c5913ca4e0de2f8c82f2002
4
- data.tar.gz: 569c8b8820e2be922454fc0573b7c84c2484f58e
3
+ metadata.gz: 81cd33b72d31b926cc1ed0dbb100bf97f33366a9
4
+ data.tar.gz: 5220f5fca994bbf462f566731ac7f90a9ba16513
5
5
  SHA512:
6
- metadata.gz: e90a115f062a6e264301a7de26f7f789403ea2bb96cf81e79ffd9695ed42b2fb7ad92281d2e6192e138bd86a257c309b8109609fab60f76be6e398e6d1134fc7
7
- data.tar.gz: 3e89e85ee0dc70ee231d523147bab6916ea4bf564b9091e27ffdad15c5b93a2274fd7e76c289beccb4ece47165098181dc0524ed8dcb5d2cb251848cfe83cb17
6
+ metadata.gz: cb9cbb4ecca2aeb2a6e3735e427f38cb42c17ff986824231a75393eb21666b0d51ab9da263dc17f1ccdc4f0f7566c08d4007b2e01a6b2bbb3a1848c0402de65e
7
+ data.tar.gz: fa0e987e074823ff585ce87d3022b618a24cd5daedd7d337268fc0b9dbf496b8ad1c891a5ef4b1a1b89d66db7e856bc694462725bc1a96e73c036789651e991e
data/README.md CHANGED
@@ -20,7 +20,7 @@ And then execute:
20
20
 
21
21
  ## Usage
22
22
 
23
- <img width="675" alt="screenshot_ruboty-url" src="https://user-images.githubusercontent.com/105469/37563621-4c825b30-2ac8-11e8-917a-480b5ce74908.png">
23
+ <img width="773" alt="screenshot_ruboty-url" src="https://user-images.githubusercontent.com/105469/37564163-a3ef0bba-2ad3-11e8-886e-58f4c8d73957.png">
24
24
 
25
25
  This plugin responds with messages including specified URL (such as private URL), and shows HTML title.
26
26
 
@@ -8,7 +8,7 @@ module Ruboty
8
8
  def call
9
9
  url = message[0]
10
10
  attachment = {
11
- color: '#EEEEEE',
11
+ color: '#E2E2E2',
12
12
  title_link: url,
13
13
  }
14
14
  open(url) do |f|
@@ -16,16 +16,16 @@ module Ruboty
16
16
  attachment[:title] = html.xpath('/html/head/title').text
17
17
 
18
18
  # optional infos
19
- og_title = html.xpath('/html/head/meta[@property="og:title"]/@content').text
20
- attachment[:title] = og_title if og_title.present?
21
- og_site_name = html.xpath('/html/head/meta[@property="og:site_name"]/@content').text
22
- attachment[:author_name] = og_site_name if og_site_name.present?
23
- favicon_url = html.xpath('/html/head/link[@rel="icon"]/@href').text
24
- attachment[:author_icon] = favicon_url if favicon_url.present?
25
- og_description = html.xpath('/html/head/meta[@property="og:description"]/@content').text
26
- attachment[:text] = og_description if og_description.present?
27
- og_image = html.xpath('/html/head/meta[@property="og:image"]/@content').text
28
- attachment[:thumb_url] = og_image if og_image.present?
19
+ og_title = html.xpath('/html/head/meta[@property="og:title"]/@content').first
20
+ attachment[:title] = og_title.text if og_title.present?
21
+ og_site_name = html.xpath('/html/head/meta[@property="og:site_name"]/@content').first
22
+ attachment[:author_name] = og_site_name.text if og_site_name.present?
23
+ favicon_url = html.xpath('/html/head/link[@rel="icon"]/@href').first
24
+ attachment[:author_icon] = favicon_url.text if favicon_url.present?
25
+ og_description = html.xpath('/html/head/meta[@property="og:description"]/@content').first
26
+ attachment[:text] = og_description.text if og_description.present?
27
+ og_image = html.xpath('/html/head/meta[@property="og:image"]/@content').first
28
+ attachment[:thumb_url] = og_image.text if og_image.present?
29
29
  end
30
30
  message.reply(nil, attachments: [attachment]) if attachment[:title].present?
31
31
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Url
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.1.1'.freeze
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ describe Ruboty::Url::Actions::Title do
18
18
  OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><title>#{title}</title></head></html>"))
19
19
  # mock
20
20
  attachments = [{
21
- color: '#EEEEEE',
21
+ color: '#E2E2E2',
22
22
  title_link: url,
23
23
  title: title,
24
24
  }]
@@ -35,10 +35,10 @@ describe Ruboty::Url::Actions::Title do
35
35
  it 'should get optional infos' do
36
36
  # stub
37
37
  mock_message.stubs(:[]).with(0).returns(url)
38
- OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><meta property=\"og:image\" content=\"#{og_image}\" /><meta property=\"og:site_name\" content=\"#{og_site_name}\" /><meta property=\"og:type\" content=\"object\" /><meta property=\"og:title\" content=\"#{og_title}\" /><meta property=\"og:url\" content=\"https://github.com/zeero/ruboty-url\" /><meta property=\"og:description\" content=\"#{og_description}\" /><title>#{title}</title><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}\"></head></html>"))
38
+ OpenURI.stubs(:open_uri).yields(StringIO.new("<html><head><meta property=\"og:image\" content=\"#{og_image}\" /><meta property=\"og:site_name\" content=\"#{og_site_name}\" /><meta property=\"og:type\" content=\"object\" /><meta property=\"og:title\" content=\"#{og_title}\" /><meta property=\"og:url\" content=\"https://github.com/zeero/ruboty-url\" /><meta property=\"og:description\" content=\"#{og_description}\" /><title>#{title}</title><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}\"><link rel=\"icon\" type=\"image/x-icon\" class=\"js-site-favicon\" href=\"#{favicon_url}/dummy\"></head></html>"))
39
39
  # mock
40
40
  attachments = [{
41
- color: '#EEEEEE',
41
+ color: '#E2E2E2',
42
42
  title_link: url,
43
43
  title: og_title,
44
44
  author_name: og_site_name,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-url
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zeero