Class: Onebox::Engine::GithubBlobOnebox
- Inherits:
-
Object
- Object
- Onebox::Engine::GithubBlobOnebox
- Includes:
- Onebox::Engine, LayoutSupport
- Defined in:
- lib/onebox/engine/github_blob_onebox.rb
Constant Summary collapse
- EXPAND_AFTER =
0b001
- EXPAND_BEFORE =
0b010
- EXPAND_NONE =
0b0
- DEFAULTS =
{ EXPAND_ONE_LINER: EXPAND_AFTER | EXPAND_BEFORE, #set how to expand a one liner. user EXPAND_NONE to disable expand LINES_BEFORE: 10, LINES_AFTER: 10, SHOW_LINE_NUMBER: true, MAX_LINES: 20, MAX_CHARS: 5000 }
Constants included from Onebox::Engine
Instance Attribute Summary
Attributes included from Onebox::Engine
Instance Method Summary collapse
-
#initialize(link, cache = nil, timeout = nil) ⇒ GithubBlobOnebox
constructor
A new instance of GithubBlobOnebox.
Methods included from LayoutSupport
Methods included from Onebox::Engine
engines, included, #options, #options=, #placeholder_html, #to_html
Constructor Details
#initialize(link, cache = nil, timeout = nil) ⇒ GithubBlobOnebox
Returns a new instance of GithubBlobOnebox.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/onebox/engine/github_blob_onebox.rb', line 23 def initialize(link, cache = nil, timeout = nil) super link, cache , 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. = DEFAULTS # Define constant after merging options set in Onebox.options # We can define constant automatically. .each_pair do |constant_name, value| constant_name_u = constant_name.to_s.upcase if constant_name_u == constant_name.to_s #define a constant if not already defined self.class.const_set constant_name_u.to_sym , [constant_name_u.to_sym] unless self.class.const_defined? constant_name_u.to_sym end end end |