Skip to content

Commit b17a4d1

Browse files
committed
Remove hexpress dependency
1 parent dd6c3b5 commit b17a4d1

11 files changed

+7
-66
lines changed

lib/onebox.rb

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
require "multi_json"
33
require "nokogiri"
44
require "mustache"
5-
require "hexpress"
6-
require "hexpress/web"
75
require "ostruct"
86
require "moneta"
97
require "cgi"

lib/onebox/engine.rb

-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ def priority
8181
100
8282
end
8383

84-
def matches(&block)
85-
matches_regexp(Hexpress.new(&block).to_r)
86-
end
87-
8884
def matches_regexp(r)
8985
class_variable_set :@@matcher, r
9086
end

lib/onebox/engine/github_commit_onebox.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ class GithubCommitOnebox
55
include LayoutSupport
66
include JSON
77

8-
matches do
9-
http
10-
maybe("www.")
11-
domain("github")
12-
tld("com")
13-
anything
14-
with("/commit/")
15-
end
8+
matches_regexp Regexp.new("^http(?:s)?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
169

1710
def url
1811
"https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/commits/#{match[:sha]}"

lib/onebox/engine/github_gist_onebox.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ module Engine
55
class GithubGistOnebox
66
include Engine
77

8-
matches do
9-
http
10-
with("gist.")
11-
domain("github")
12-
tld("com")
13-
end
8+
matches_regexp Regexp.new("^http(?:s)?://gist\\.(?:(?:\\w)+\\.)?(github)\\.com(?:/)?")
149

1510
def url
1611
"https://api.github.com/gists/#{match[:sha]}"

lib/onebox/engine/github_pullrequest_onebox.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ class GithubPullRequestOnebox
55
include LayoutSupport
66
include JSON
77

8-
matches do
9-
http
10-
maybe("www.")
11-
domain("github")
12-
tld("com")
13-
anything
14-
with("/pull/")
15-
end
8+
matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(github)\\.com(?:/)?(?:.)*/pull/")
169

1710
def url
1811
"https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}"

lib/onebox/engine/google_play_app_onebox.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ class GooglePlayAppOnebox
55
include LayoutSupport
66
include HTML
77

8-
matches do
9-
http
10-
with("play.")
11-
domain("google")
12-
tld("com")
13-
with("/store/apps/")
14-
end
8+
matches_regexp Regexp.new("^http(?:s)?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
159

1610
private
1711

lib/onebox/engine/pubmed_onebox.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ class PubmedOnebox
44
include Engine
55
include LayoutSupport
66

7-
matches do
8-
http
9-
domain("www.ncbi.nlm.nih")
10-
tld("gov")
11-
has("/pubmed/")
12-
end
7+
matches_regexp Regexp.new("^http(?:s)?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/")
138

149
private
1510

lib/onebox/engine/twitter_status_onebox.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ class TwitterStatusOnebox
55
include LayoutSupport
66
include HTML
77

8-
matches do
9-
http
10-
maybe("www.")
11-
domain("twitter")
12-
tld("com")
13-
anything
14-
has("/status/")
15-
end
8+
matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(twitter)\\.com(?:/)?(?:.)*/status/")
169

1710
private
1811

lib/onebox/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Onebox
2-
VERSION = "1.3.8"
2+
VERSION = "1.3.9"
33
end

onebox.gemspec

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
2121
spec.add_runtime_dependency "multi_json", "~> 1.7"
2222
spec.add_runtime_dependency "mustache", "~> 0.99"
2323
spec.add_runtime_dependency "nokogiri", "~> 1.6.1"
24-
spec.add_runtime_dependency "hexpress", "~> 1.2"
2524
spec.add_runtime_dependency "moneta", "~> 0.7"
2625

2726
spec.add_development_dependency "bundler", "~> 1.3"

spec/lib/onebox/engine_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ class OneboxEngineTripleEqual
6666
end
6767
end
6868

69-
describe ".matches" do
70-
class OneboxEngineMatches
71-
include Onebox::Engine
72-
73-
matches do
74-
find "foo.com"
75-
end
76-
end
77-
78-
it "sets @@matcher to a regular expression" do
79-
regex = OneboxEngineMatches.class_variable_get(:@@matcher)
80-
expect(regex).to be_a(Regexp)
81-
end
82-
end
83-
8469
end
8570

8671
describe ".onebox_name" do

0 commit comments

Comments
 (0)