social_web-webmention 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/webmention.rb +40 -0
- data/lib/webmention/configuration.rb +5 -0
- data/spec/helper.rb +14 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/webmention_spec.rb +37 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cea12330929ba9eb065edc1d1ed0ca14cdabaa3bb2d8b4a19537faf15daa1668
|
4
|
+
data.tar.gz: 5590e9ef90c7e92232b907ffb21ef9f45009d5081e19b66dce0fcae8fa698af4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f456eae5d2694f4990237f5b770679b442f32abd310f2d4d17ba1452d9ac2f946f44df14f7117c8e9dfecd19f769574307122a1f0ec71d7d17d25d8b7ff825d
|
7
|
+
data.tar.gz: 70b12df9d8137294c83cae80f89ce074aa1c14e64b8182680260dc0a4b11b071b75d6191156b44338192419a0c3d66f78377a2897518c65e2bb47a99e93395a2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Shane Cavanaugh
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/lib/webmention.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
require 'roda'
|
6
|
+
|
7
|
+
require 'webmention/configuration'
|
8
|
+
|
9
|
+
module Webmention
|
10
|
+
def self.configure
|
11
|
+
yield config
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.config
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
class Route < ::Roda
|
19
|
+
plugin :json_parser
|
20
|
+
plugin :middleware, env_var: 'social_web.webmention'
|
21
|
+
|
22
|
+
route do |r|
|
23
|
+
r.on('webmentions') do
|
24
|
+
r.post do
|
25
|
+
webmention_params = r.params.
|
26
|
+
slice('source', 'target').
|
27
|
+
reject { |_k, v| v.empty? }
|
28
|
+
|
29
|
+
if webmention_params.count != 2
|
30
|
+
response.status = 400
|
31
|
+
return ''
|
32
|
+
end
|
33
|
+
|
34
|
+
response.status = 201
|
35
|
+
''
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Helper
|
4
|
+
def app
|
5
|
+
builder = Rack::Builder.new
|
6
|
+
builder.run Webmention::Route
|
7
|
+
end
|
8
|
+
|
9
|
+
def configure
|
10
|
+
mock_config = instance_double('Webmention::Configuration')
|
11
|
+
allow(Webmention).to receive(:config).and_return(mock_config)
|
12
|
+
yield mock_config
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.add_filter(/spec/)
|
5
|
+
SimpleCov.start
|
6
|
+
|
7
|
+
require 'webmention'
|
8
|
+
require 'rack/test'
|
9
|
+
require 'helper'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include Rack::Test::Methods, type: :route
|
13
|
+
config.include Helper
|
14
|
+
|
15
|
+
config.expect_with :rspec do |expectations|
|
16
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
17
|
+
end
|
18
|
+
|
19
|
+
config.mock_with :rspec do |mocks|
|
20
|
+
mocks.verify_partial_doubles = true
|
21
|
+
end
|
22
|
+
|
23
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
24
|
+
|
25
|
+
config.example_status_persistence_file_path = 'tmp/examples.txt'
|
26
|
+
|
27
|
+
config.disable_monkey_patching!
|
28
|
+
|
29
|
+
config.warnings = false
|
30
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
31
|
+
|
32
|
+
# Run specs in random order to surface order dependencies. If you find an
|
33
|
+
# order dependency and want to debug it, you can fix the order by providing
|
34
|
+
# the seed, which is printed after each run.
|
35
|
+
# --seed 1234
|
36
|
+
config.order = :random
|
37
|
+
|
38
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
39
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
40
|
+
# test failures related to randomization by passing the same `--seed` value
|
41
|
+
# as the one that triggered the failure.
|
42
|
+
Kernel.srand config.seed
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Webmention
|
6
|
+
class Route
|
7
|
+
RSpec.describe '/webmentions', type: :route do
|
8
|
+
context 'POST /webmentions' do
|
9
|
+
context 'source or target is missing' do
|
10
|
+
it 'returns a 400 status' do
|
11
|
+
post '/webmentions',
|
12
|
+
{ source: 'https://example.com/1', target: '' }
|
13
|
+
expect(last_response.status).to eq(400)
|
14
|
+
|
15
|
+
post '/webmentions',
|
16
|
+
{ source: '', target: 'https://example.com/1' }
|
17
|
+
expect(last_response.status).to eq(400)
|
18
|
+
|
19
|
+
post '/webmentions', { source: '', target: '' }
|
20
|
+
expect(last_response.status).to eq(400)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the request includes source and target' do
|
25
|
+
it 'returns returns a 201 response' do
|
26
|
+
post '/webmentions',
|
27
|
+
{
|
28
|
+
source: 'https://example.com/1',
|
29
|
+
target: 'https://example.com/2'
|
30
|
+
}
|
31
|
+
expect(last_response.status).to eq(201)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: social_web-webmention
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shane Cavanaugh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: roda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack-test
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.1'
|
83
|
+
description: Ednpoint for Webmentions
|
84
|
+
email:
|
85
|
+
- shane@shanecav.net
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- lib/webmention.rb
|
92
|
+
- lib/webmention/configuration.rb
|
93
|
+
- spec/helper.rb
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
- spec/webmention_spec.rb
|
96
|
+
homepage: https://github.com/social_web/webmention
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata:
|
100
|
+
homepage_uri: https://github.com/social_web/webmention
|
101
|
+
source_code_uri: https://github.com/social_web/webmention
|
102
|
+
changelog_uri: https://github.com/social_web/webmention/tree/master/CHANGELOG.md
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.9.2
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubygems_version: 3.0.4
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Ednpoint for Webmentions
|
122
|
+
test_files: []
|