webmention 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/webmention.rb +3 -3
- data/lib/webmention/client.rb +13 -22
- data/lib/webmention/version.rb +1 -1
- data/test/lib/webmention/mention_test.rb +4 -4
- data/webmention.gemspec +1 -0
- metadata +17 -1
data/lib/webmention.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'httparty'
|
3
3
|
require 'nokogiri'
|
4
4
|
require 'open-uri'
|
5
5
|
require 'set'
|
6
6
|
require 'uri'
|
7
7
|
|
8
|
-
require '
|
9
|
-
require '
|
8
|
+
require 'webmention/version'
|
9
|
+
require 'webmention/client'
|
data/lib/webmention/client.rb
CHANGED
@@ -70,16 +70,11 @@ module Webmention
|
|
70
70
|
}
|
71
71
|
|
72
72
|
begin
|
73
|
-
|
74
|
-
|
73
|
+
response = HTTParty.post(endpoint, {
|
74
|
+
:body => data
|
75
|
+
})
|
75
76
|
|
76
|
-
|
77
|
-
request.set_form_data(data)
|
78
|
-
request['Content-Type'] = "application/x-www-form-urlencoded"
|
79
|
-
request['Accept'] = 'application/json'
|
80
|
-
response = http.request(request)
|
81
|
-
|
82
|
-
return response.code.to_i == 200
|
77
|
+
return response.code == 200 || response.code == 202
|
83
78
|
rescue
|
84
79
|
return false
|
85
80
|
end
|
@@ -97,21 +92,17 @@ module Webmention
|
|
97
92
|
doc = nil
|
98
93
|
|
99
94
|
begin
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
request["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36 (https://rubygems.org/gems/webmention)"
|
108
|
-
request["Accept"] = "*/*"
|
109
|
-
|
110
|
-
response = http.request(request)
|
95
|
+
response = HTTParty.get(url, {
|
96
|
+
:timeout => 3,
|
97
|
+
:headers => {
|
98
|
+
'User-Agent' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36 (https://rubygems.org/gems/webmention)",
|
99
|
+
'Accept' => '*/*'
|
100
|
+
}
|
101
|
+
})
|
111
102
|
|
112
103
|
# First check the HTTP Headers
|
113
|
-
if !response['Link'].nil?
|
114
|
-
endpoint = self.discover_webmention_endpoint_from_header response['Link']
|
104
|
+
if !response.headers['Link'].nil?
|
105
|
+
endpoint = self.discover_webmention_endpoint_from_header response.headers['Link']
|
115
106
|
return endpoint if endpoint
|
116
107
|
end
|
117
108
|
|
data/lib/webmention/version.rb
CHANGED
@@ -3,19 +3,19 @@ require_relative '../../test_helper'
|
|
3
3
|
describe Webmention::Client do
|
4
4
|
before do
|
5
5
|
WebMock.stub_request(:any, 'http://source.example.com/post/100').to_return(
|
6
|
-
:status =>
|
6
|
+
:status => 202,
|
7
7
|
:body => SampleData.sample_source_post_html,
|
8
8
|
:headers => {}
|
9
9
|
)
|
10
10
|
|
11
11
|
WebMock.stub_request(:any, 'http://target.example.com/post/4').to_return(
|
12
|
-
:status =>
|
12
|
+
:status => 202,
|
13
13
|
:body => SampleData.rel_webmention_href,
|
14
14
|
:headers => {}
|
15
15
|
)
|
16
16
|
|
17
17
|
WebMock.stub_request(:any, 'http://target.example.com/post/5').to_return(
|
18
|
-
:status =>
|
18
|
+
:status => 202,
|
19
19
|
:body => '',
|
20
20
|
:headers => {
|
21
21
|
'Link' => 'rel="webmention"; <http://webmention.io/example/webmention>'
|
@@ -23,7 +23,7 @@ describe Webmention::Client do
|
|
23
23
|
)
|
24
24
|
|
25
25
|
WebMock.stub_request(:any, 'http://webmention.io/example/webmention').to_return(
|
26
|
-
:status =>
|
26
|
+
:status => 202
|
27
27
|
)
|
28
28
|
|
29
29
|
@client = Webmention::Client.new "http://source.example.com/post/100"
|
data/webmention.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmention
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -44,6 +44,22 @@ dependencies:
|
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: httparty
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.13.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.13.1
|
47
63
|
- !ruby/object:Gem::Dependency
|
48
64
|
name: bundler
|
49
65
|
requirement: !ruby/object:Gem::Requirement
|