showcase-rails 0.4.3 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62a983038704732db89c5b41327a4787c562920c8ad849809e400a09990bc5b1
4
- data.tar.gz: 02d378f6e837f91d623d09547469b4bce8c7b07ffc47d394c1d8df0621c28257
3
+ metadata.gz: 88e437d814d89cdc6a3d023edce093a5ebe92da961b5658013cd57bae84af123
4
+ data.tar.gz: 7eef04b815c656c4c2eba45164ed0c1e7c6d2352053e5dc3c11854959b88e726
5
5
  SHA512:
6
- metadata.gz: ede2f638590dd154fc5e45d0ab186ff25bea725033655361a286ea2677cf3406fd042dd459e82b00a8b0dcf266ea128ec02df3bbd352ba602e889254dfdc1181
7
- data.tar.gz: 4f0a46f8364fa27e8066c20313e3c6a10abf3e7dbfa893f656e439367d444438c34c667e713374aa3ea124e86eb205bd7d14f01b34675c23831fd6aabe108ff9
6
+ metadata.gz: 96caaccee98301814f06c6e3022a7e01b222a865deedb5c5198da5b39540596174f5f03a4b4f6b7746a973d81050cd2a747fba3b7241b19a82d3c57d7d8c9e7e
7
+ data.tar.gz: c59ef24d8e7a378ab4151f092be16aafd7a8e8027a745256f5d96e050ed7c703b2101c0fa361773673f5c07e4f5f7f4a42288cf6dd6bda0e34f38d7e66077a20
data/README.md CHANGED
@@ -175,7 +175,7 @@ Add these lines to your application's Gemfile. See next section for why Showcase
175
175
  ```ruby
176
176
  group :development, :test do
177
177
  gem "showcase-rails"
178
- gem "rouge" # Optional. For out-of-the-box syntax highlighting.
178
+ gem "rouge", require: false # Syntax highlighting, `require: false` lets Showcase handle loading and saves boot time.
179
179
  end
180
180
  ```
181
181
 
@@ -228,7 +228,7 @@ end
228
228
 
229
229
  ### Syntax Highlighting
230
230
 
231
- Add `gem "rouge"` to your Gemfile and Showcase will set syntax highlighting up for you. Any denoted syntaxes in your samples are then highlighted, e.g.:
231
+ Add `gem "rouge", require: false` to your Gemfile and Showcase will set syntax highlighting up for you. Any denoted syntaxes in your samples are then highlighted, e.g.:
232
232
 
233
233
  ```erb
234
234
  # app/views/showcase/previews/_plain_ruby.ruby
@@ -1,3 +1,3 @@
1
1
  module Showcase
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.5"
3
3
  end
data/lib/showcase.rb CHANGED
@@ -1,12 +1,5 @@
1
1
  require_relative "showcase/version"
2
2
 
3
- # Activate the app-bundled Rouge gem to setup default syntax highlighting.
4
- begin
5
- gem "rouge"
6
- require "rouge"
7
- rescue LoadError
8
- end
9
-
10
3
  module Showcase
11
4
  autoload :PreviewsTest, "showcase/previews_test"
12
5
  autoload :RouteHelper, "showcase/route_helper"
@@ -19,16 +12,22 @@ module Showcase
19
12
  end
20
13
  self.tree_opens = true # All open by default
21
14
 
22
- singleton_class.attr_accessor :sample_renderer
23
- @sample_renderer = proc { _1 }
24
-
25
- if defined?(Rouge)
26
- Formatter = Rouge::Formatters::HTML.new
27
-
28
- @sample_renderer = ->(source, syntax) do
29
- lexed = Rouge::Lexer.find(syntax).lex(source)
30
- Showcase::Formatter.format(lexed).html_safe
31
- end
15
+ singleton_class.attr_writer :sample_renderer
16
+
17
+ def self.sample_renderer
18
+ @sample_renderer ||=
19
+ begin
20
+ gem "rouge" # Activate the app-bundled Rouge gem to setup default syntax highlighting.
21
+ require "rouge"
22
+
23
+ formatter = Rouge::Formatters::HTML.new
24
+ @sample_renderer = ->(source, syntax) do
25
+ lexed = Rouge::Lexer.find(syntax).lex(source)
26
+ formatter.format(lexed).html_safe
27
+ end
28
+ rescue LoadError
29
+ proc { _1 }
30
+ end
32
31
  end
33
32
 
34
33
  def self.previews
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showcase-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pence
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-06-05 00:00:00.000000000 Z
12
+ date: 2023-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails