html-pipeline-rouge_filter 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: a0795c378efe8982c18b9ba06170198b03a645d8
4
- data.tar.gz: 7a98ea63d2054ec6cab6844584406abcb1710443
3
+ metadata.gz: 25d87148900609c8565744a82dff5b2cff7ff67b
4
+ data.tar.gz: b24f984260a0a56a7f7b93d473aaa488c41259c6
5
5
  SHA512:
6
- metadata.gz: 9e34003bdb322d9976afb85438c1acbd2f55741f881dff4593e4a9c810a0a932debf99da42cf849a985219a6c9d85f2cdec96feea9a6df4ba93157a1a3c7c2a9
7
- data.tar.gz: e747dbaa9ae2a68fb9f66bd89202b6e7219a6ecd07cc9300b2c1f2855cd870d27ebd9fa0c47528cd320f5e7dbb335d9130d9aff53f2ee31a63b24aa3a8e79f39
6
+ metadata.gz: 890d96ef33003c9b30ca84c01482debc827991de61c4bcca7972052d6d30cf019fb76477856f78591260ed4a51884be10f5fb3783f765d6a3a1d2e81595968a4
7
+ data.tar.gz: f6be5266b8d30dc748feafa28afc661c5cb545ae0bc5efef97bbb0f078a5bca6dcbf456df79c7445ac3b287882fb7ab90f6eaf91e5e5cb01eddd0625287cfe07
data/.travis.yml CHANGED
@@ -1,12 +1,24 @@
1
+ bundler_args: --retry=3 --jobs=3
2
+ cache: bundler
1
3
  language: ruby
2
4
  sudo: false
3
- bundler_args: "--retry=3 --jobs=3"
4
5
  rvm:
5
- - 2.0
6
+ - 2.0.0
6
7
  - 2.1
7
- - 2.2
8
+ - 2.2.1
9
+ - 2.2.0
10
+ - jruby-head
11
+ - jruby-9.0.0.0.pre1
12
+ - rbx-2
8
13
  - ruby-head
14
+ env:
15
+ global:
16
+ - JRUBY_OPTS="-J-Xmx1024M --debug"
9
17
  matrix:
10
18
  allow_failures:
19
+ - rvm: 2.2.0
20
+ - rvm: jruby-head
21
+ - rvm: jruby-9.0.0.0.pre1
22
+ - rvm: rbx-2
11
23
  - rvm: ruby-head
12
24
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.2 - 2015.08.06
6
+
7
+ - Allow to use with `HTML::Pipeline` >= 1.11 [#3](https://github.com/JuanitoFatas/html-pipeline-rouge_filter/pull/3) by @townsen
8
+
5
9
  ## 1.0.1 - 2015.03.10
6
10
 
7
11
  - Fix lexer finding logic [#1](https://github.com/JuanitoFatas/html-pipeline-rouge_filter/pull/1) by @JuanitoFatas
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [Rouge](https://github.com/jneen/rouge) integration for [HTML::Pipeline](https://github.com/jch/html-pipeline).
4
4
 
5
+ This RubyGem requires Ruby 2.0+.
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -20,22 +22,29 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- pipeline = HTML::Pipeline.new [
24
- HTML::Pipeline::MarkdownFilter,
25
- HTML::Pipeline::RougeFilter
26
- ]
25
+ ```ruby
26
+ require 'html/pipeline'
27
+ require 'html/pipeline/rouge_filter'
28
+
29
+ pipeline = HTML::Pipeline.new [
30
+ HTML::Pipeline::MarkdownFilter,
31
+ HTML::Pipeline::RougeFilter
32
+ ]
33
+
34
+ result = pipeline.call <<-CODE.gsub(/^\s*/,'')
27
35
 
28
- result = pipeline.call <<-CODE
29
36
  ```ruby
30
37
  def foo
31
38
  puts "foo"
32
39
  end
33
40
  ```
41
+
34
42
  CODE
35
43
 
36
- result[:output].to_s
44
+ puts result[:output]
45
+ ```
37
46
 
38
- Prints
47
+ Prints (without the linebreaks):
39
48
 
40
49
  ```html
41
50
  <pre class="highlight highlight-ruby">
@@ -17,7 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "html-pipeline", "~> 1.11"
20
+ spec.add_dependency "html-pipeline", ">= 1.11"
21
21
  spec.add_dependency "rouge", "~> 1.8"
22
22
  spec.add_dependency "activesupport"
23
+
24
+ spec.required_ruby_version = "~> 2.0"
23
25
  end
@@ -27,10 +27,6 @@ module HTML
27
27
  doc
28
28
  end
29
29
 
30
- def must_str(text)
31
- text && text.to_s
32
- end
33
-
34
30
  def highlight_with(lexer, text)
35
31
  formatter.format(lexer.lex(text))
36
32
  end
@@ -46,6 +42,12 @@ module HTML
46
42
  def lexer_for(lang)
47
43
  Rouge::Lexer.find_fancy(lang) || Rouge::Lexers::PlainText
48
44
  end
45
+
46
+ private
47
+
48
+ def must_str(text)
49
+ text && text.to_s
50
+ end
49
51
  end
50
52
  end
51
53
  end
@@ -2,6 +2,6 @@
2
2
  # and we don't want to define it here inadvertently
3
3
  module HTML_Pipeline
4
4
  class RougeFilter
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
@@ -23,4 +23,55 @@ class HTML::Pipeline::RougeFilterTest < Minitest::Test
23
23
  assert doc.css(".highlight-coffeescript").empty?
24
24
  assert !doc.css(".highlight-ruby").empty?
25
25
  end
26
+
27
+ def test_unrecognized_lexer_will_not_raise_error
28
+ filter = RougeFilter.new \
29
+ "<pre lang='ruby'>hello</pre>"
30
+
31
+ assert_nothing_raised do
32
+ filter.lexer_for("not_exist")
33
+ end
34
+ end
35
+
36
+ def test_highlight_with_ruby
37
+ filter = RougeFilter.new \
38
+ "<pre lang='ruby'>hello</pre>"
39
+
40
+ assert_equal %(<pre class="highlight"><code><span class="n">hello</span></code></pre>), filter.highlight_with(Rouge::Lexers::Ruby, "hello").chomp
41
+ end
42
+
43
+ def test_default_css_class
44
+ filter = RougeFilter.new \
45
+ "<pre lang='ruby'>hello</pre>"
46
+
47
+ assert_equal "highlight", filter.default_css_class
48
+ end
49
+
50
+ def test_default_css_class_can_be_specified_by_context
51
+ filter = RougeFilter.new \
52
+ "<pre lang='ruby'>hello</pre>", css_class: "superlight"
53
+
54
+ assert_equal "superlight", filter.default_css_class
55
+ end
56
+
57
+ def test_default_formatter
58
+ filter = RougeFilter.new \
59
+ "<pre lang='ruby'>hello</pre>"
60
+
61
+ assert_kind_of Rouge::Formatters::HTML, filter.formatter
62
+ end
63
+
64
+ def test_default_lexer
65
+ filter = RougeFilter.new \
66
+ "<pre lang='ruby'>hello</pre>"
67
+
68
+ assert_equal Rouge::Lexers::PlainText, filter.lexer_for("not-exist")
69
+ end
70
+
71
+ def test_lexer_can_be_specified
72
+ filter = RougeFilter.new \
73
+ "<pre lang='ruby'>hello</pre>"
74
+
75
+ assert_kind_of Rouge::Lexers::Shell, filter.lexer_for("shell")
76
+ end
26
77
  end
data/test/test_helper.rb CHANGED
@@ -3,6 +3,9 @@ require "html/pipeline"
3
3
  require "minitest/autorun"
4
4
 
5
5
  module TestHelpers
6
+ def assert_nothing_raised
7
+ yield
8
+ end
6
9
  end
7
10
 
8
11
  Minitest::Test.send(:include, TestHelpers)
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-rouge_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito Fatas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-pipeline
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.11'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
@@ -81,9 +81,9 @@ require_paths:
81
81
  - lib
82
82
  required_ruby_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ">="
84
+ - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '0'
86
+ version: '2.0'
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
@@ -91,8 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.4.5
94
+ rubygems_version: 2.4.8
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Rouge integration with html-pipeline.
98
98
  test_files: []
99
+ has_rdoc: