lib/onebox/mixins/git_blob_onebox.rb in onebox-2.2.14 vs lib/onebox/mixins/git_blob_onebox.rb in onebox-2.2.15

- old
+ new

@@ -23,12 +23,12 @@ MAX_LINES: 20, MAX_CHARS: 5000 } module InstanceMethods - def initialize(link, timeout = nil) - super link, timeout + def initialize(url, timeout = nil) + super url, timeout # merge engine options from global Onebox.options interface # self.options = Onebox.options["GithubBlobOnebox"] # self.class.name.split("::").last.to_s # self.options = Onebox.options[self.class.name.split("::").last.to_s] #We can use this a more generic approach. extract the engine class name automatically self.options = DEFAULTS @@ -161,14 +161,12 @@ to = /\d+/.match(m[:to]) #get numeric should only match a positive interger @file = m[:file] @lang = Onebox::FileTypeFinder.from_file_name(m[:file]) - if @lang == "stl" && link.match(/^https?:\/\/(www\.)?github\.com.*\/blob\//) - + if @lang == "stl" && link.match?(/^https?:\/\/(www\.)?github\.com.*\/blob\//) @model_file = @lang.dup @raw = "https://render.githubusercontent.com/view/solid?url=" + self.raw_template(m) - else contents = URI.open(self.raw_template(m), read_timeout: timeout).read contents_lines = contents.lines #get contents lines contents_lines_size = contents_lines.size #get number of lines