minisyntax 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -23,7 +23,6 @@ Jeweler::Tasks.new do |gem|
23
23
  gem.authors = ["Nico Hagenburger"]
24
24
  # Include your dependencies below. Runtime dependencies are required when using your gem,
25
25
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
- gem.add_runtime_dependency 'nokogiri', '~> 1.4.4'
27
26
  # gem.add_development_dependency 'rspec', '> 1.2.3'
28
27
  end
29
28
  Jeweler::RubygemsDotOrgTasks.new
data/lib/minisyntax.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module MiniSyntax
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 2
4
+ MINOR = 2
5
+ PATCH = 0
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -29,7 +29,3 @@ module MiniSyntax
29
29
  end
30
30
 
31
31
  require 'minisyntax/highlighter'
32
-
33
- if defined? Rack
34
- require 'minisyntax/integration/rack'
35
- end
data/minisyntax.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "minisyntax"
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nico Hagenburger"]
12
- s.date = "2013-01-08"
12
+ s.date = "2013-02-20"
13
13
  s.description = "A simple powerful syntax highlighter with minimal HTML output"
14
14
  s.email = "nico@hagenburger.net"
15
15
  s.extra_rdoc_files = [
@@ -35,7 +35,6 @@ Gem::Specification.new do |s|
35
35
  "lib/minisyntax/highlighter/php.rb",
36
36
  "lib/minisyntax/highlighter/ruby.rb",
37
37
  "lib/minisyntax/highlighter/yaml.rb",
38
- "lib/minisyntax/integration/rack.rb",
39
38
  "minisyntax.gemspec",
40
39
  "spec/minisyntax_spec.rb",
41
40
  "spec/spec_helper.rb"
@@ -58,20 +57,17 @@ Gem::Specification.new do |s|
58
57
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
59
58
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
60
59
  s.add_development_dependency(%q<rcov>, [">= 0"])
61
- s.add_runtime_dependency(%q<nokogiri>, ["~> 1.4.4"])
62
60
  else
63
61
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
62
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
63
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
64
  s.add_dependency(%q<rcov>, [">= 0"])
67
- s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
68
65
  end
69
66
  else
70
67
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
71
68
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
72
69
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
73
70
  s.add_dependency(%q<rcov>, [">= 0"])
74
- s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
75
71
  end
76
72
  end
77
73
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minisyntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-08 00:00:00.000000000Z
12
+ date: 2013-02-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70219057981500 !ruby/object:Gem::Requirement
16
+ requirement: &70153028824840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70219057981500
24
+ version_requirements: *70153028824840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70219057980520 !ruby/object:Gem::Requirement
27
+ requirement: &70153028824300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70219057980520
35
+ version_requirements: *70153028824300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70219057978940 !ruby/object:Gem::Requirement
38
+ requirement: &70153028823720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70219057978940
46
+ version_requirements: *70153028823720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &70219057977660 !ruby/object:Gem::Requirement
49
+ requirement: &70153028823200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,18 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70219057977660
58
- - !ruby/object:Gem::Dependency
59
- name: nokogiri
60
- requirement: &70219057976200 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ~>
64
- - !ruby/object:Gem::Version
65
- version: 1.4.4
66
- type: :runtime
67
- prerelease: false
68
- version_requirements: *70219057976200
57
+ version_requirements: *70153028823200
69
58
  description: A simple powerful syntax highlighter with minimal HTML output
70
59
  email: nico@hagenburger.net
71
60
  executables: []
@@ -92,7 +81,6 @@ files:
92
81
  - lib/minisyntax/highlighter/php.rb
93
82
  - lib/minisyntax/highlighter/ruby.rb
94
83
  - lib/minisyntax/highlighter/yaml.rb
95
- - lib/minisyntax/integration/rack.rb
96
84
  - minisyntax.gemspec
97
85
  - spec/minisyntax_spec.rb
98
86
  - spec/spec_helper.rb
@@ -111,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
99
  version: '0'
112
100
  segments:
113
101
  - 0
114
- hash: 506257264124259129
102
+ hash: -741612678810631426
115
103
  required_rubygems_version: !ruby/object:Gem::Requirement
116
104
  none: false
117
105
  requirements:
@@ -1,61 +0,0 @@
1
- require 'rack/utils'
2
- require 'nokogiri'
3
-
4
- # “Inspired” by Wlodek Bzyl’s rack-codehighlighter:
5
- # https://github.com/wbzyl/rack-codehighlighter
6
- # Thanks!
7
-
8
- module Rack
9
- class MiniSyntax
10
- include Rack::Utils
11
-
12
- def initialize(app, options = {})
13
- @app = app
14
- @options = {
15
- :element => 'code',
16
- :pattern => /^##+\s*([-_\w\+ ]+)[\s#]*(\n|&#x000A;|$)/i
17
- }
18
- @options.merge! options
19
- end
20
-
21
- def call(env)
22
- status, headers, response = @app.call(env)
23
- headers = HeaderHash.new(headers)
24
-
25
- if !STATUS_WITH_NO_ENTITY_BODY.include?(status) and
26
- !headers['transfer-encoding'] and
27
- headers['content-type'] and
28
- headers['content-type'].include?("text/html")
29
-
30
- content = ""
31
- response.each { |part| content += part }
32
- doc = Nokogiri::HTML(content, nil, 'UTF-8')
33
- nodes = doc.search(@options[:element])
34
- nodes.each do |node|
35
- code = node.inner_html || ''
36
- node.swap(highlight(code, node.name))
37
- end
38
-
39
- body = doc.to_html
40
- headers['content-length'] = bytesize(body).to_s
41
-
42
- [status, headers, [body]]
43
- else
44
- [status, headers, response]
45
- end
46
- end
47
-
48
- private
49
- def highlight(code, tag_name)
50
- if code =~ @options[:pattern]
51
- lang = $1
52
- code.gsub! @options[:pattern], ''
53
- if code =~ /^([ \t]+)/
54
- code.gsub! /^#{$1}/, ''
55
- end
56
- code = ::MiniSyntax.highlight(code, lang)
57
- end
58
- %Q(<#{tag_name}>#{code}</#{tag_name}>)
59
- end
60
- end
61
- end