@@ -16,26 +16,20 @@ def render(context)
|
16 | 16 | if (tag_contents = determine_arguments(@markup.strip))
|
17 | 17 | gist_id = tag_contents[0]
|
18 | 18 | filename = tag_contents[1]
|
19 |
| -if context_contains_key?(context, gist_id) |
20 |
| -gist_id = context[gist_id] |
21 |
| -end |
22 |
| -if context_contains_key?(context, filename) |
23 |
| -filename = context[filename] |
24 |
| -end |
| 19 | +gist_id = context[gist_id] if context_contains_key?(context, gist_id) |
| 20 | +filename = context[filename] if context_contains_key?(context, filename) |
25 | 21 | noscript_tag = gist_noscript_tag(gist_id, filename)
|
26 | 22 | script_tag = gist_script_tag(gist_id, filename)
|
27 | 23 | "#{noscript_tag}#{script_tag}"
|
28 | 24 | else
|
29 | 25 | raise ArgumentError, <<~ERROR
|
30 |
| -Syntax error in tag 'gist' while parsing the following markup: |
31 |
| -
|
32 |
| -#{@markup} |
33 |
| -
|
34 |
| -Valid syntax: |
35 |
| -{% gist user/1234567 %} |
36 |
| -{% gist user/1234567 foo.js %} |
37 |
| -{% gist 28949e1d5ee2273f9fd3 %} |
38 |
| -{% gist 28949e1d5ee2273f9fd3 best.md %} |
| 26 | +Syntax error in tag 'gist' while parsing the following markup: |
| 27 | +#{@markup} |
| 28 | +Valid syntax: |
| 29 | +{% gist user/1234567 %} |
| 30 | +{% gist user/1234567 foo.js %} |
| 31 | +{% gist 28949e1d5ee2273f9fd3 %} |
| 32 | +{% gist 28949e1d5ee2273f9fd3 best.md %} |
39 | 33 |
|
40 | 34 | ERROR
|
41 | 35 | end
|
@@ -48,8 +42,6 @@ def determine_arguments(input)
|
48 | 42 | [matched[1].strip, matched[2].strip] if matched && matched.length >= 3
|
49 | 43 | end
|
50 | 44 |
|
51 |
| -private |
52 |
| - |
53 | 45 | def context_contains_key?(context, key)
|
54 | 46 | if context.respond_to?(:has_key?)
|
55 | 47 | context.has_key?(key)
|
@@ -90,8 +82,8 @@ def fetch_raw_code(gist_id, filename = nil)
|
90 | 82 | url = "#{url}/#{filename}" unless filename.to_s.empty?
|
91 | 83 | uri = URI(url)
|
92 | 84 | Net::HTTP.start(uri.host, uri.port,
|
93 |
| -:use_ssl => uri.scheme == "https", |
94 |
| -:read_timeout => 3, :open_timeout => 3) do |http| |
| 85 | +:use_ssl => uri.scheme == "https", |
| 86 | +:read_timeout => 3, :open_timeout => 3) do |http| |
95 | 87 | request = Net::HTTP::Get.new uri.to_s
|
96 | 88 | response = http.request(request)
|
97 | 89 | response.body
|
@@ -100,8 +92,6 @@ def fetch_raw_code(gist_id, filename = nil)
|
100 | 92 | nil
|
101 | 93 | end
|
102 | 94 |
|
103 |
| -private |
104 |
| - |
105 | 95 | def code_from_api(gist_id, filename = nil)
|
106 | 96 | gist = GistTag.client.gist gist_id
|
107 | 97 |
|
|
0 commit comments