x_ray 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34ed5795f6313768146cea8000adcb96db2b2b37
4
- data.tar.gz: 49a9f5d7c00e763581844f86469b5a49fee378e4
3
+ metadata.gz: 6c2839f925cb026d35c366e76c7454b8280fd27b
4
+ data.tar.gz: 1056154f7182932f32c7bb0305ec3c6fe3fafdb0
5
5
  SHA512:
6
- metadata.gz: 7f93364e4607905f3e71ef68e168f1d89fc218bf643f306bb806c5596f69cd4871a607752b3e0f50e79f4f5a831a5678a939db42b2a9be1268ebc98facf7e70c
7
- data.tar.gz: 2fc4221be3d64b6844d95a98a52bac8725f8343dd27152fb3583ebffe10e55fd6bdbb654b099a672aa4a45c5f2977ae7f7f72286ea93db54c5ce3abe67c8e415
6
+ metadata.gz: 34cc05581d2d8883090d52cdfbdaef3e3ae75ef44a066df20fa6569cef72c29a2e83e954153ff1d27a7d763676d4abe6aa527c9257e6596c7008fac0e7fd3e02
7
+ data.tar.gz: f513e47dbb8d2451e46bb37e7d1e732f4bb30bdd82a26dcf2eb7c66053867b7b7a11b1fa0b875e93008d3aab1906dde06101ca06fc414f5327ac98037356dfc7
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- x-ray (0.0.1)
4
+ x_ray (0.0.2)
5
+ highlight
5
6
  rails (~> 4.0)
6
7
 
7
8
  GEM
@@ -48,6 +49,7 @@ GEM
48
49
  erubis (2.7.0)
49
50
  globalid (0.3.6)
50
51
  activesupport (>= 4.1.0)
52
+ highlight (2.0.0)
51
53
  i18n (0.7.0)
52
54
  json (1.8.3)
53
55
  loofah (2.0.3)
@@ -107,4 +109,4 @@ PLATFORMS
107
109
 
108
110
  DEPENDENCIES
109
111
  sqlite3
110
- x-ray!
112
+ x_ray!
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # x_ray
2
2
 
3
- A gem to help display code examples
3
+ x_ray is a gem that helps easily display code examples. Uses https://github.com/simplabs/highlight for syntax highlighting which is supported by http://pygments.org
4
4
 
5
5
  ## Installation
6
6
 
@@ -24,6 +24,8 @@ include XRay::Helper
24
24
 
25
25
  ## Usage
26
26
 
27
+ Works with plain html and embedded helper methods
28
+
27
29
  ```erb
28
30
  <%= x_ray do %>
29
31
  <div>
@@ -34,4 +36,29 @@ include XRay::Helper
34
36
  </ol>
35
37
  </div>
36
38
  <% end %>
39
+
40
+ <%= x_ray do %>
41
+ <%= submit_tag 'Set Time Zone', class: 'button primary-button mobile-full-button' %>
42
+ <% end %>
43
+ ```
44
+
45
+ <img src="http://i.imgur.com/jdxzuRw.png">
46
+
47
+ ### Customization
48
+
49
+ You can customize the output by overriding the default styles.
50
+
51
+ Example:
52
+ ```css
53
+ .x-ray-block {
54
+ .example {
55
+ background-color: blue;
56
+ padding: 40px;
57
+ }
58
+
59
+ .code-scan {
60
+ background-color: red;
61
+ padding: 40px;
62
+ }
63
+ }
37
64
  ```
@@ -0,0 +1,59 @@
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 */
@@ -1,8 +1,10 @@
1
+ @import 'highlight';
2
+
1
3
  $x-ray-bg-color: #eceff1;
2
4
  $x-ray-border-color: darken($x-ray-bg-color, 30);
3
5
  $x-ray-border-radius: 3px;
4
6
 
5
- .codeExample {
7
+ .x-ray-block {
6
8
  border: 1px solid $x-ray-border-color;
7
9
  border-radius: $x-ray-border-radius;
8
10
  margin-bottom: 30px;
@@ -27,16 +29,17 @@ $x-ray-border-radius: 3px;
27
29
  pre {
28
30
  margin: 0;
29
31
  }
30
- }
31
32
 
32
- .exampleOutput {
33
- padding: 20px;
34
- }
33
+ .example {
34
+ padding: 15px;
35
+ }
35
36
 
36
- .codeBlock {
37
- background-color: $x-ray-bg-color;
38
- border-top: 1px solid $x-ray-border-color;
39
- border-bottom-left-radius: $x-ray-border-radius;
40
- border-bottom-right-radius: $x-ray-border-radius;
41
- padding: 20px;
37
+ .code-scan {
38
+ background-color: $x-ray-bg-color;
39
+ border-top: 1px solid $x-ray-border-color;
40
+ border-bottom-left-radius: $x-ray-border-radius;
41
+ border-bottom-right-radius: $x-ray-border-radius;
42
+ padding: 15px 15px 0px 15px;
43
+ overflow-x: auto;
44
+ }
42
45
  }
@@ -3,5 +3,12 @@ module XRay
3
3
  def x_ray(&block)
4
4
  render(layout: 'layouts/x_ray/scan', &block)
5
5
  end
6
+
7
+ def x_ray_scan(&block)
8
+ text = <<-HTML.strip_heredoc
9
+ #{Simplabs::Highlight.highlight(:erb, yield)}
10
+ HTML
11
+ sanitize(text.strip).html_safe
12
+ end
6
13
  end
7
14
  end
@@ -1,11 +1,11 @@
1
- <div class="codeExample">
2
- <div class="exampleOutput">
1
+ <div class="x-ray-block">
2
+ <div class="example">
3
3
  <%= yield %>
4
4
  </div>
5
5
 
6
- <div class="codeBlock">
6
+ <div class="code-scan">
7
7
  <pre>
8
- <%= "#{yield}" %>
8
+ <%= x_ray_scan { yield } %>
9
9
  </pre>
10
10
  </div>
11
11
  </div>
data/lib/x_ray/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module XRay
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
data/lib/x_ray.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'simplabs/highlight'
2
+
1
3
  module XRay
2
4
  class << self
3
5
  attr_accessor :configuration
data/x_ray.gemspec CHANGED
@@ -18,5 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n")
19
19
 
20
20
  s.add_dependency 'rails', '~> 4.0'
21
+ s.add_dependency 'highlight'
21
22
  s.add_development_dependency 'sqlite3'
22
23
  end
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiffany Huang
@@ -24,6 +24,20 @@ 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'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sqlite3
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +64,7 @@ files:
50
64
  - MIT-LICENSE
51
65
  - README.md
52
66
  - app/assets/javascripts/x_ray/application.js
67
+ - app/assets/stylesheets/x_ray/highlight.css
53
68
  - app/assets/stylesheets/x_ray/prettifier.scss
54
69
  - app/helpers/x_ray/helper.rb
55
70
  - app/views/layouts/x_ray/_scan.html.erb