Class: Onebox::Engine::GithubBlobOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::GithubBlobOnebox
show all
- Includes:
- Mixins::GitBlobOnebox
- Defined in:
- lib/onebox/engine/github_blob_onebox.rb
Constant Summary
Mixins::GitBlobOnebox::DEFAULTS, Mixins::GitBlobOnebox::EXPAND_AFTER, Mixins::GitBlobOnebox::EXPAND_BEFORE, Mixins::GitBlobOnebox::EXPAND_NONE
Class Method Summary
collapse
Instance Method Summary
collapse
included
Class Method Details
.git_regexp ⇒ Object
6
7
8
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 6
def self.git_regexp
/^https?:\/\/(www\.)?github\.com.*\/blob\//
end
|
.onebox_name ⇒ Object
9
10
11
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 9
def self.onebox_name
"githubblob"
end
|
Instance Method Details
#raw_regexp ⇒ Object
14
15
16
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 14
def raw_regexp
/github\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+)\/blob\/(?<sha1>[^\/]+)\/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?/mi
end
|
#raw_template(m) ⇒ Object
17
18
19
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 17
def raw_template(m)
"https://raw.github.com/#{m[:user]}/#{m[:repo]}/#{m[:sha1]}/#{m[:file]}"
end
|
#title ⇒ Object
20
21
22
|
# File 'lib/onebox/engine/github_blob_onebox.rb', line 20
def title
Sanitize.fragment(URI.unescape(link).sub(/^https?\:\/\/github\.com\//, ''))
end
|