highlight 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +10 -3
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +2 -4
- data/generators/highlight_styles_generator/highlight_styles_generator.rb +3 -1
- data/generators/highlight_styles_generator/templates/NOTES +0 -0
- data/generators/highlight_styles_generator/templates/highlight.css +0 -0
- data/lib/simplabs/highlight.rb +2 -2
- data/lib/simplabs/highlight/pygments_wrapper.rb +0 -0
- data/lib/simplabs/highlight/railtie.rb +0 -0
- data/rails/init.rb +0 -0
- data/spec/boot.rb +1 -9
- data/spec/lib/highlight_spec.rb +16 -14
- data/spec/lib/pygments_wrapper_spec.rb +6 -4
- data/spec/lib/view_methods_spec.rb +8 -10
- data/spec/spec_helper.rb +0 -0
- metadata +31 -54
- data/Rakefile +0 -30
- data/spec/spec.opts +0 -4
data/HISTORY.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
+
v1.1.2
|
2
|
+
------
|
3
|
+
|
4
|
+
* first gem version
|
5
|
+
|
1
6
|
v1.1.3
|
2
7
|
------
|
3
8
|
|
4
|
-
*
|
9
|
+
* added new supported language NASM
|
5
10
|
|
6
|
-
v1.1.
|
11
|
+
v1.1.4
|
7
12
|
------
|
8
13
|
|
9
|
-
*
|
14
|
+
* switched to new web API
|
15
|
+
* cleaned up internals
|
16
|
+
* fixed Rails 3 generator
|
data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ wrapper around the popular [http://pygments.org](http://pygments.org) highlighte
|
|
6
6
|
written in Python and supports an impressive number of languages.
|
7
7
|
|
8
8
|
If pygments is installed on the machine and in the `PATH`, that binary is used, otherwise
|
9
|
-
the plugin falls back to the web API at [http://pygments.
|
9
|
+
the plugin falls back to the web API at [http://pygments.simplabs.com/](http://pygments.simplabs.com/),
|
10
10
|
created by Trevor Turk.
|
11
11
|
|
12
12
|
See the API docs at [http://rdoc.info/projects/simplabs/highlight](http://rdoc.info/projects/simplabs/highlight).
|
@@ -108,7 +108,7 @@ your application's `public/stylesheets` directory via
|
|
108
108
|
|
109
109
|
for Rails 2.x or via
|
110
110
|
|
111
|
-
rails generate highlight_styles
|
111
|
+
./script/rails generate highlight_styles
|
112
112
|
|
113
113
|
for Rails 3.
|
114
114
|
|
@@ -128,5 +128,3 @@ Acknowledgements
|
|
128
128
|
----------------
|
129
129
|
|
130
130
|
The actual highlighting is done by Pygments ([http://pygments.org](http://pygments.org)).
|
131
|
-
|
132
|
-
The pygments web API at [http://pygments.appspot.com/](http://pygments.appspot.com/) was created by Trevor Turk.
|
@@ -4,10 +4,12 @@ if Rails::VERSION::MAJOR >= 3
|
|
4
4
|
|
5
5
|
include Rails::Generators::Actions
|
6
6
|
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
7
9
|
def create_stylesheet_file
|
8
10
|
empty_directory('public/stylesheets')
|
9
11
|
copy_file(
|
10
|
-
|
12
|
+
'highlight.css',
|
11
13
|
'public/stylesheets/highlight.css'
|
12
14
|
)
|
13
15
|
readme(File.join(File.dirname(__FILE__), 'templates', 'NOTES'))
|
File without changes
|
File without changes
|
data/lib/simplabs/highlight.rb
CHANGED
@@ -13,7 +13,7 @@ module Simplabs
|
|
13
13
|
# highlighter that's written in Python and supports an impressive
|
14
14
|
# number of languages. If pygments is installed on the machine and in
|
15
15
|
# the +PATH+, that binary is used, otherwise the plugin falls back
|
16
|
-
# to the web API at (http://pygments.
|
16
|
+
# to the web API at (http://pygments.simplabs.com/), created by Trevor
|
17
17
|
# Turk.
|
18
18
|
#
|
19
19
|
# <b>Supported Languages</b>
|
@@ -95,7 +95,7 @@ module Simplabs
|
|
95
95
|
:yaml => ['yaml', 'yml']
|
96
96
|
}
|
97
97
|
|
98
|
-
WEB_API_URL = 'http://pygments.
|
98
|
+
WEB_API_URL = 'http://pygments.simplabs.com/'
|
99
99
|
|
100
100
|
# Highlights the passed +code+ with the appropriate rules
|
101
101
|
# according to the specified +language+.
|
File without changes
|
File without changes
|
data/rails/init.rb
CHANGED
File without changes
|
data/spec/boot.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
plugin_root = File.join(File.dirname(__FILE__), '..')
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Bundler.require
|
3
|
+
require 'activesupport'
|
6
4
|
require 'initializer'
|
7
5
|
|
8
|
-
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../')
|
9
|
-
Rails::Initializer.run(:set_load_path)
|
10
|
-
Rails::Initializer.run(:set_autoload_paths)
|
11
|
-
|
12
6
|
require File.join(File.dirname(__FILE__), '/../rails/init.rb')
|
13
|
-
|
14
|
-
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), 'log'))
|
data/spec/lib/highlight_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Simplabs::Highlight do
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
let(:code) do
|
6
|
+
<<-EOC
|
7
7
|
class Test
|
8
8
|
def method test
|
9
9
|
end
|
@@ -13,12 +13,12 @@ EOC
|
|
13
13
|
|
14
14
|
describe '#highlight' do
|
15
15
|
|
16
|
-
|
16
|
+
shared_examples 'the highlight method' do
|
17
17
|
|
18
18
|
describe 'when the language is not supported' do
|
19
19
|
|
20
20
|
it 'should only escape HTML in the passed code' do
|
21
|
-
Simplabs::Highlight.highlight(:unsupported,
|
21
|
+
expect(Simplabs::Highlight.highlight(:unsupported, code)).to eq(CGI.escapeHTML(code))
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -26,7 +26,9 @@ EOC
|
|
26
26
|
describe 'when the language is supported' do
|
27
27
|
|
28
28
|
it 'should correctly highlight source code passed as parameter' do
|
29
|
-
Simplabs::Highlight.highlight(:ruby,
|
29
|
+
expect(Simplabs::Highlight.highlight(:ruby, code)).to eq(
|
30
|
+
%Q(<span class="k">class</span> <span class="nc">Test</span>\n <span class="k">def</span> <span class="nf">method</span> <span class="nb">test</span>\n <span class="k">end</span>\n<span class="k">end</span>)
|
31
|
+
)
|
30
32
|
end
|
31
33
|
|
32
34
|
end
|
@@ -39,14 +41,14 @@ EOC
|
|
39
41
|
Simplabs::Highlight.use_web_api = false
|
40
42
|
end
|
41
43
|
|
42
|
-
|
44
|
+
it_behaves_like 'the highlight method'
|
43
45
|
|
44
46
|
it 'should initialize a Simplabs::PygmentsWrapper.highlight with the language and code' do
|
45
|
-
wrapper = Simplabs::Highlight::PygmentsWrapper.new(
|
47
|
+
wrapper = Simplabs::Highlight::PygmentsWrapper.new(code, :ruby)
|
46
48
|
|
47
|
-
Simplabs::Highlight::PygmentsWrapper.should_receive(:new).once.with(
|
49
|
+
Simplabs::Highlight::PygmentsWrapper.should_receive(:new).once.with(code, :ruby).and_return(wrapper)
|
48
50
|
|
49
|
-
Simplabs::Highlight.highlight(:ruby,
|
51
|
+
Simplabs::Highlight.highlight(:ruby, code)
|
50
52
|
end
|
51
53
|
|
52
54
|
end
|
@@ -57,7 +59,7 @@ EOC
|
|
57
59
|
Simplabs::Highlight.use_web_api = true
|
58
60
|
end
|
59
61
|
|
60
|
-
|
62
|
+
it_behaves_like 'the highlight method'
|
61
63
|
|
62
64
|
end
|
63
65
|
|
@@ -68,7 +70,7 @@ EOC
|
|
68
70
|
describe 'for an unsupported language' do
|
69
71
|
|
70
72
|
it 'should return false' do
|
71
|
-
Simplabs::Highlight.send(:get_language_sym, 'unsupported language').
|
73
|
+
expect(Simplabs::Highlight.send(:get_language_sym, 'unsupported language')).to be_false
|
72
74
|
end
|
73
75
|
|
74
76
|
end
|
@@ -76,11 +78,11 @@ EOC
|
|
76
78
|
describe 'for a supported language' do
|
77
79
|
|
78
80
|
it 'should return the respective symbol when the languages was given as String' do
|
79
|
-
Simplabs::Highlight.send(:get_language_sym, 'ruby').
|
81
|
+
expect(Simplabs::Highlight.send(:get_language_sym, 'ruby')).to eq(:ruby)
|
80
82
|
end
|
81
83
|
|
82
84
|
it 'should return the respective symbol when the languages was given as Symbol' do
|
83
|
-
Simplabs::Highlight.send(:get_language_sym, :rb).
|
85
|
+
expect(Simplabs::Highlight.send(:get_language_sym, :rb)).to eq(:ruby)
|
84
86
|
end
|
85
87
|
|
86
88
|
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Simplabs::Highlight::PygmentsWrapper do
|
4
4
|
|
5
|
-
|
5
|
+
let(:wrapper) do
|
6
6
|
code = <<-EOC
|
7
7
|
class Test
|
8
8
|
def method test
|
9
9
|
end
|
10
10
|
end
|
11
11
|
EOC
|
12
|
-
|
12
|
+
Simplabs::Highlight::PygmentsWrapper.new(code, :ruby)
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#highlight' do
|
16
16
|
|
17
17
|
it 'should correctly highlight source code passed as parameter' do
|
18
|
-
|
18
|
+
expect(wrapper.highlight).to eq(
|
19
|
+
%Q(<span class="k">class</span> <span class="nc">Test</span>\n <span class="k">def</span> <span class="nf">method</span> <span class="nb">test</span>\n <span class="k">end</span>\n<span class="k">end</span>)
|
20
|
+
)
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Simplabs::Highlight::ViewMethods do
|
4
4
|
|
5
5
|
include Simplabs::Highlight::ViewMethods
|
6
6
|
|
7
|
-
|
8
|
-
@ruby_code = 'class Test; end'
|
9
|
-
end
|
7
|
+
let(:code) { 'class Test; end' }
|
10
8
|
|
11
9
|
describe '#highlight_code' do
|
12
10
|
|
13
11
|
describe 'when invoked with a language and a string' do
|
14
12
|
|
15
13
|
it 'should highlight the code' do
|
16
|
-
Simplabs::Highlight.should_receive(:highlight).once.with(:ruby,
|
14
|
+
Simplabs::Highlight.should_receive(:highlight).once.with(:ruby, code)
|
17
15
|
|
18
|
-
highlight_code(:ruby,
|
16
|
+
highlight_code(:ruby, code)
|
19
17
|
end
|
20
18
|
|
21
19
|
end
|
@@ -23,10 +21,10 @@ describe Simplabs::Highlight::ViewMethods do
|
|
23
21
|
describe 'when invoked with a language and a block' do
|
24
22
|
|
25
23
|
it 'should highlight the code' do
|
26
|
-
Simplabs::Highlight.should_receive(:highlight).once.with(:ruby,
|
24
|
+
Simplabs::Highlight.should_receive(:highlight).once.with(:ruby, code)
|
27
25
|
|
28
26
|
highlight_code(:ruby) do
|
29
|
-
|
27
|
+
code
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
@@ -35,7 +33,7 @@ describe Simplabs::Highlight::ViewMethods do
|
|
35
33
|
describe 'when invoked with both a string and a block' do
|
36
34
|
|
37
35
|
it 'should raise an ArgumentError' do
|
38
|
-
|
36
|
+
expect { highlight_code(:ruby, code) { code } }.to raise_error(ArgumentError)
|
39
37
|
end
|
40
38
|
|
41
39
|
end
|
@@ -43,7 +41,7 @@ describe Simplabs::Highlight::ViewMethods do
|
|
43
41
|
describe 'when invoked with neither a string nor a block' do
|
44
42
|
|
45
43
|
it 'should raise an ArgumentError' do
|
46
|
-
|
44
|
+
expect { highlight_code(:ruby) }.to raise_error(ArgumentError)
|
47
45
|
end
|
48
46
|
|
49
47
|
end
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,51 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: highlight
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 1.1.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Marco Otte-Witte
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activesupport
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70334546100500 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 15
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 0
|
32
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 2.0.0
|
34
22
|
type: :runtime
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70334546100500
|
25
|
+
description: Highlight highlights code in more than 20 languages. It uses the Pygments
|
26
|
+
syntax highlighter and adds a simple Ruby API over it. It also provides helpers
|
27
|
+
for use in your Ruby on Rails views.
|
37
28
|
email: info@simplabs.com
|
38
29
|
executables: []
|
39
|
-
|
40
30
|
extensions: []
|
41
|
-
|
42
31
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
32
|
+
files:
|
45
33
|
- README.md
|
46
34
|
- HISTORY.md
|
47
|
-
-
|
48
|
-
- MIT-LICENSE
|
35
|
+
- LICENSE
|
49
36
|
- generators/highlight_styles_generator/highlight_styles_generator.rb
|
50
37
|
- generators/highlight_styles_generator/templates/highlight.css
|
51
38
|
- generators/highlight_styles_generator/templates/NOTES
|
@@ -58,39 +45,29 @@ files:
|
|
58
45
|
- spec/lib/pygments_wrapper_spec.rb
|
59
46
|
- spec/lib/view_methods_spec.rb
|
60
47
|
- spec/spec_helper.rb
|
61
|
-
- spec/spec.opts
|
62
48
|
homepage: http://github.com/simplabs/highlight
|
63
49
|
licenses: []
|
64
|
-
|
65
50
|
post_install_message:
|
66
51
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
52
|
+
require_paths:
|
69
53
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
55
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
- 0
|
78
|
-
version: "0"
|
79
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
61
|
none: false
|
81
|
-
requirements:
|
82
|
-
- -
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
|
85
|
-
segments:
|
86
|
-
- 0
|
87
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
88
66
|
requirements: []
|
89
|
-
|
90
67
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.11
|
92
69
|
signing_key:
|
93
70
|
specification_version: 2
|
94
71
|
summary: Syntax Higlighting plugin for Ruby on Rails
|
95
72
|
test_files: []
|
96
|
-
|
73
|
+
has_rdoc: false
|
data/Rakefile
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
|
4
|
-
Bundler.setup
|
5
|
-
Bundler.require
|
6
|
-
|
7
|
-
require 'spec/rake/spectask'
|
8
|
-
require 'simplabs/excellent/rake'
|
9
|
-
|
10
|
-
desc 'Default: run specs.'
|
11
|
-
task :default => :spec
|
12
|
-
|
13
|
-
desc 'Run the specs'
|
14
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
15
|
-
t.rcov_opts << '--exclude "gems/*,spec/*,init.rb"'
|
16
|
-
t.rcov = true
|
17
|
-
t.rcov_dir = 'doc/coverage'
|
18
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'Generate The Highlight documentation'
|
22
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
23
|
-
t.files = ['lib/**/*.rb']
|
24
|
-
t.options = ['--no-private', '--title', 'Highlight Documentation']
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'Analyse the Highlight source with Excellent.'
|
28
|
-
Simplabs::Excellent::Rake::ExcellentTask.new(:excellent) do |t|
|
29
|
-
t.paths = ['lib']
|
30
|
-
end
|
data/spec/spec.opts
DELETED