Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test CodeClimate #244

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions lib/coderay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def scan code, lang, options = {}, &block
# Example:
# require 'coderay'
# page = CodeRay.scan_file('some_c_code.c').html
def scan_file filename, lang = :auto, options = {}, &block
lang = CodeRay::FileType.fetch filename, :text, true if lang == :auto
code = File.read filename
def scan_file file_name, lang = :auto, options = {}, &block
lang = CodeRay::FileType.fetch file_name, :text, true if lang == :auto
code = File.read file_name
scan code, lang, options, &block
end

Expand All @@ -197,6 +197,10 @@ def encode code, lang, format, options = {}
encoder(format, options).encode code, lang, options
end

def encode2 code, lang, format, options = {}
encoder(format, options).encode code, lang, options
end

# Encode pre-scanned Tokens.
# Use this together with CodeRay.scan:
#
Expand Down
6 changes: 6 additions & 0 deletions spec/coderay_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
end
end

describe '.encode2' do
it 'covers' do
expect(CodeRay.encode2('test', :python, :count)).to eq(1)
end
end

describe '.scan' do
let(:code) { 'puts "Hello, World!"' }
let(:tokens) do
Expand Down