x_ray 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -14
- data/app/assets/stylesheets/x_ray/prettifier.scss +0 -2
- data/app/helpers/x_ray/helper.rb +21 -3
- data/app/views/layouts/x_ray/_erb_render_scan.html.erb +12 -0
- data/app/views/layouts/x_ray/_erb_scan.html.erb +11 -0
- data/app/views/layouts/x_ray/_scan.html.erb +2 -4
- data/lib/x_ray/version.rb +1 -1
- data/lib/x_ray.rb +0 -2
- data/x_ray.gemspec +0 -1
- metadata +3 -16
- data/app/assets/stylesheets/x_ray/highlight.css +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bfbbb0efb83ed74530d2ce5e4d57ffc1d2d239b
|
4
|
+
data.tar.gz: 197b09fbb571beec222a2d449998b5c7523f5cad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad831d894011b81e0924dbd23d08cac4668a8f7d05656df81d65d3f3cbfd85f6840b31d0ee918f92388bac8751b5e6120c77e2114bceb5f4389cc1e438558638
|
7
|
+
data.tar.gz: f34a40cf5155eddbe82aa4e4fc3abdf1255b476f51e989850cb732f1503ba071f22ff2ce3ed1ba29f4755a960fa596434a2066c96ff7872620914d8bea7eb2b9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# x_ray
|
2
2
|
|
3
|
-
x_ray is a gem that helps easily display code examples
|
3
|
+
x_ray is a gem that helps easily display code examples, supports plain HTML and ERB.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -24,29 +24,34 @@ include XRay::Helper
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
Works with plain html and embedded helper methods
|
28
|
-
|
29
27
|
```erb
|
28
|
+
<!-- Render HTML from HTML -->
|
30
29
|
<%= x_ray do %>
|
31
|
-
<
|
32
|
-
<
|
33
|
-
|
34
|
-
|
35
|
-
<li>Third thing</li>
|
36
|
-
</ol>
|
37
|
-
</div>
|
30
|
+
<ol>
|
31
|
+
<li>First thing</li>
|
32
|
+
<li>Second thing</li>
|
33
|
+
</ol>
|
38
34
|
<% end %>
|
39
35
|
|
36
|
+
<!-- Render HTML from ERB -->
|
40
37
|
<%= x_ray do %>
|
41
|
-
<%= submit_tag 'Set Time Zone', class: 'button' %>
|
38
|
+
<%= submit_tag 'Set Time Zone', class: 'button button-primary' %>
|
42
39
|
<% end %>
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
<!-- Render ERB from ERB -->
|
42
|
+
<%= x_ray_erb do %>
|
43
|
+
<%= submit_tag 'Set Time Zone', class: 'button button-primary' %>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<!-- Render ERB from ERB for `render` (inserting ERB with block requires one-off logic) -->
|
47
|
+
<%= x_ray_erb_render(layout: 'components/collapsable', locals: { heading: 'My virtual training plan'}) do %>
|
48
|
+
<div class="box-small">
|
49
|
+
<p class="outer-box-none">look at all this fun stuff in here!</p>
|
50
|
+
</div>
|
46
51
|
<% end %>
|
47
52
|
```
|
48
53
|
|
49
|
-
<img src="http://i.imgur.com/
|
54
|
+
<img src="http://i.imgur.com/X1QeI6M.png">
|
50
55
|
|
51
56
|
### Customization
|
52
57
|
|
data/app/helpers/x_ray/helper.rb
CHANGED
@@ -4,12 +4,30 @@ module XRay
|
|
4
4
|
render(layout: 'layouts/x_ray/scan', &block)
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def x_ray_erb(&block)
|
8
|
+
render(layout: 'layouts/x_ray/erb_scan', &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def x_ray_erb_render(context, options={}, &block)
|
12
|
+
render(partial: 'layouts/x_ray/erb_render_scan', locals: { context: context, options: options, block: block})
|
13
|
+
end
|
14
|
+
|
15
|
+
def x_ray_erb_render_code(context, options, raw_block)
|
16
|
+
code = if raw_block
|
17
|
+
"<%= render #{context}, #{options} do %>\n#{x_ray_scan(raw_block)}\n<% end %>"
|
18
|
+
else
|
19
|
+
"<%= render #{context}, #{options} %>"
|
20
|
+
end
|
21
|
+
|
22
|
+
x_ray_scan(code)
|
23
|
+
end
|
24
|
+
|
25
|
+
def x_ray_scan(code)
|
8
26
|
text = <<-HTML.strip_heredoc
|
9
|
-
#{
|
27
|
+
#{code}
|
10
28
|
HTML
|
11
29
|
|
12
|
-
|
30
|
+
text.strip
|
13
31
|
end
|
14
32
|
end
|
15
33
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="x-ray-block">
|
2
|
+
<div class="example">
|
3
|
+
<%= render(context, options, &block) %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="code-scan">
|
7
|
+
<pre>
|
8
|
+
<div hidden><% raw_block = block.try(:call) %></div>
|
9
|
+
<%= x_ray_erb_render_code(context, options, raw_block) %>
|
10
|
+
</pre>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="x-ray-block">
|
2
|
+
<div class="example">
|
3
|
+
<%= ERB.new(yield.gsub('<', '<').gsub('>', '>')).result(binding).html_safe %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="code-scan">
|
7
|
+
<pre>
|
8
|
+
<%= x_ray_scan(yield.gsub('<', '<').gsub('>', '>')) %>
|
9
|
+
</pre>
|
10
|
+
</div>
|
11
|
+
</div>
|
@@ -1,13 +1,11 @@
|
|
1
1
|
<div class="x-ray-block">
|
2
2
|
<div class="example">
|
3
|
-
<%=
|
3
|
+
<%= yield %>
|
4
4
|
</div>
|
5
5
|
|
6
6
|
<div class="code-scan">
|
7
7
|
<pre>
|
8
|
-
|
9
|
-
<%= x_ray_scan { yield } %>
|
10
|
-
<% end %>
|
8
|
+
<%= x_ray_scan(yield) %>
|
11
9
|
</pre>
|
12
10
|
</div>
|
13
11
|
</div>
|
data/lib/x_ray/version.rb
CHANGED
data/lib/x_ray.rb
CHANGED
data/x_ray.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: x_ray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiffany Huang
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: highlight
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: sqlite3
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,9 +49,10 @@ files:
|
|
63
49
|
- MIT-LICENSE
|
64
50
|
- README.md
|
65
51
|
- app/assets/javascripts/x_ray/application.js
|
66
|
-
- app/assets/stylesheets/x_ray/highlight.css
|
67
52
|
- app/assets/stylesheets/x_ray/prettifier.scss
|
68
53
|
- app/helpers/x_ray/helper.rb
|
54
|
+
- app/views/layouts/x_ray/_erb_render_scan.html.erb
|
55
|
+
- app/views/layouts/x_ray/_erb_scan.html.erb
|
69
56
|
- app/views/layouts/x_ray/_scan.html.erb
|
70
57
|
- lib/x_ray.rb
|
71
58
|
- lib/x_ray/engine.rb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
.c { color: #408080; font-style: italic } /* Comment */
|
2
|
-
.err { border: 1px solid #FF0000 } /* Error */
|
3
|
-
.k { color: #008000; font-weight: bold } /* Keyword */
|
4
|
-
.o { color: #666666 } /* Operator */
|
5
|
-
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
6
|
-
.cp { color: #BC7A00 } /* Comment.Preproc */
|
7
|
-
.c1 { color: #408080; font-style: italic } /* Comment.Single */
|
8
|
-
.cs { color: #408080; font-style: italic } /* Comment.Special */
|
9
|
-
.gd { color: #A00000 } /* Generic.Deleted */
|
10
|
-
.ge { font-style: italic } /* Generic.Emph */
|
11
|
-
.gr { color: #FF0000 } /* Generic.Error */
|
12
|
-
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
13
|
-
.gi { color: #00A000 } /* Generic.Inserted */
|
14
|
-
.go { color: #808080 } /* Generic.Output */
|
15
|
-
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
16
|
-
.gs { font-weight: bold } /* Generic.Strong */
|
17
|
-
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
18
|
-
.gt { color: #0040D0 } /* Generic.Traceback */
|
19
|
-
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
|
20
|
-
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
|
21
|
-
.kp { color: #008000 } /* Keyword.Pseudo */
|
22
|
-
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
|
23
|
-
.kt { color: #B00040 } /* Keyword.Type */
|
24
|
-
.m { color: #666666 } /* Literal.Number */
|
25
|
-
.s { color: #BA2121 } /* Literal.String */
|
26
|
-
.na { color: #7D9029 } /* Name.Attribute */
|
27
|
-
.nb { color: #008000 } /* Name.Builtin */
|
28
|
-
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
29
|
-
.no { color: #880000 } /* Name.Constant */
|
30
|
-
.nd { color: #AA22FF } /* Name.Decorator */
|
31
|
-
.ni { color: #999999; font-weight: bold } /* Name.Entity */
|
32
|
-
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
33
|
-
.nf { color: #0000FF } /* Name.Function */
|
34
|
-
.nl { color: #A0A000 } /* Name.Label */
|
35
|
-
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
36
|
-
.nt { color: #008000; font-weight: bold } /* Name.Tag */
|
37
|
-
.nv { color: #19177C } /* Name.Variable */
|
38
|
-
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
39
|
-
.w { color: #bbbbbb } /* Text.Whitespace */
|
40
|
-
.mf { color: #666666 } /* Literal.Number.Float */
|
41
|
-
.mh { color: #666666 } /* Literal.Number.Hex */
|
42
|
-
.mi { color: #666666 } /* Literal.Number.Integer */
|
43
|
-
.mo { color: #666666 } /* Literal.Number.Oct */
|
44
|
-
.sb { color: #BA2121 } /* Literal.String.Backtick */
|
45
|
-
.sc { color: #BA2121 } /* Literal.String.Char */
|
46
|
-
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
|
47
|
-
.s2 { color: #BA2121 } /* Literal.String.Double */
|
48
|
-
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
49
|
-
.sh { color: #BA2121 } /* Literal.String.Heredoc */
|
50
|
-
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
51
|
-
.sx { color: #008000 } /* Literal.String.Other */
|
52
|
-
.sr { color: #BB6688 } /* Literal.String.Regex */
|
53
|
-
.s1 { color: #BA2121 } /* Literal.String.Single */
|
54
|
-
.ss { color: #19177C } /* Literal.String.Symbol */
|
55
|
-
.bp { color: #008000 } /* Name.Builtin.Pseudo */
|
56
|
-
.vc { color: #19177C } /* Name.Variable.Class */
|
57
|
-
.vg { color: #19177C } /* Name.Variable.Global */
|
58
|
-
.vi { color: #19177C } /* Name.Variable.Instance */
|
59
|
-
.il { color: #666666 } /* Literal.Number.Integer.Long */
|