Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ on:
tags-ignore: [ '**' ]
pull_request:
jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Rubocop
run: bundle exec rubocop
build:
strategy:
matrix:
Expand Down
18 changes: 18 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Layout/LineLength:
Max: 120
Metrics/MethodLength:
Enabled: false
Security/MarshalLoad:
Enabled: false
Style/StructInheritance:
Enabled: false
Style/Documentation:
Enabled: false
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ task default: :test
# Packaging
# ==========================================================

GEMSPEC = eval(File.read('pygments.rb.gemspec'))

require 'rubygems/package_task'

# ==========================================================
Expand All @@ -36,7 +34,7 @@ end

# Write all the lexers to a file for easy lookup
task :lexers do
sh 'ruby cache-lexers.rb'
sh 'ruby cache_lexers.rb'
end

task(:test).enhance([:lexers])
Expand Down
13 changes: 9 additions & 4 deletions bench.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require File.join(File.dirname(__FILE__), '/lib/pygments.rb')
require 'benchmark'

include Benchmark
# number of iterations
num = ARGV[0] ? ARGV[0].to_i : 10

Expand All @@ -17,7 +16,13 @@
puts 'Iterations: ' + num.to_s + "\n"

Benchmark.bm(40) do |x|
x.report('pygments popen ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
x.report('pygments popen (process already started) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
x.report('pygments popen (process already started 2) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } }
x.report('pygments popen ') do
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
end
x.report('pygments popen (process already started) ') do
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
end
x.report('pygments popen (process already started 2) ') do
(1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); }
end
end
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/pygments/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.create(hash)
extnames = []

extname = File.extname(filename)
if m = extname.match(/\[(.+)\]/)
if (m = extname.match(/\[(.+)\]/))
m[1].scan(/./).each do |s|
extnames << extname.sub(m[0], s)
end
Expand Down
Loading