Hello community, here is the log from the commit of package rubygem-coderay for openSUSE:Factory checked in at 2017-09-12 19:57:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-coderay (Old) and /work/SRC/openSUSE:Factory/.rubygem-coderay.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-coderay" Tue Sep 12 19:57:26 2017 rev:12 rq:523576 version:1.1.2 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-coderay/rubygem-coderay.changes 2016-03-07 13:27:51.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-coderay.new/rubygem-coderay.changes 2017-09-12 19:57:27.577658173 +0200 @@ -1,0 +2,6 @@ +Mon Sep 11 12:36:34 UTC 2017 - [email protected] + +- updated to version 1.1.2 + no changelog found + +------------------------------------------------------------------- Old: ---- coderay-1.1.1.gem New: ---- coderay-1.1.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-coderay.spec ++++++ --- /var/tmp/diff_new_pack.MFzBV5/_old 2017-09-12 19:57:28.157576630 +0200 +++ /var/tmp/diff_new_pack.MFzBV5/_new 2017-09-12 19:57:28.165575506 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-coderay # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-coderay -Version: 1.1.1 +Version: 1.1.2 Release: 0 %define mod_name coderay %define mod_full_name %{mod_name}-%{version} @@ -35,7 +35,7 @@ BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives Url: http://coderay.rubychan.de -Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source: https://rubygems.org/gems/%{mod_full_name}.gem Source1: gem2rpm.yml Summary: Fast syntax highlighting for selected languages License: MIT @@ -53,6 +53,7 @@ %install %gem_install \ --symlink-binaries \ + --doc-files="MIT-LICENSE" \ -f %gem_packages ++++++ coderay-1.1.1.gem -> coderay-1.1.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MIT-LICENSE new/MIT-LICENSE --- old/MIT-LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/MIT-LICENSE 2017-09-03 12:12:06.000000000 +0200 @@ -0,0 +1,22 @@ +Copyright (C) 2005-2012 Kornelius Kalnbach <[email protected]> (@murphy_karasu) + +http://coderay.rubychan.de/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2016-02-20 17:34:58.000000000 +0100 +++ new/Rakefile 1970-01-01 01:00:00.000000000 +0100 @@ -1,37 +0,0 @@ -require 'bundler/gem_tasks' - -$:.unshift File.dirname(__FILE__) unless $:.include? '.' - -ROOT = '.' -LIB_ROOT = File.join ROOT, 'lib' - -task :default => :test - -if File.directory? 'rake_tasks' - - # load rake tasks from subfolder - for task_file in Dir['rake_tasks/*.rake'].sort - load task_file - end - -else - - # fallback tasks when rake_tasks folder is not present (eg. in the distribution package) - desc 'Run CodeRay tests (basic)' - task :test do - ruby './test/functional/suite.rb' - ruby './test/functional/for_redcloth.rb' - end - - gem 'rdoc' if defined? gem - require 'rdoc/task' - desc 'Generate documentation for CodeRay' - Rake::RDocTask.new :doc do |rd| - rd.title = 'CodeRay Documentation' - rd.main = 'README_INDEX.rdoc' - rd.rdoc_files.add Dir['lib'] - rd.rdoc_files.add rd.main - rd.rdoc_dir = 'doc' - end - -end Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/encoders/encoder.rb new/lib/coderay/encoders/encoder.rb --- old/lib/coderay/encoders/encoder.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/encoders/encoder.rb 2017-09-03 12:12:06.000000000 +0200 @@ -146,7 +146,7 @@ end def get_output options - options[:out] || '' + options[:out] || ''.dup end # Append data.to_s to the output. Returns the argument. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/encoders/html.rb new/lib/coderay/encoders/html.rb --- old/lib/coderay/encoders/html.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/encoders/html.rb 2017-09-03 12:12:06.000000000 +0200 @@ -176,7 +176,7 @@ if options[:wrap] || options[:line_numbers] @real_out = @out - @out = '' + @out = ''.dup end @break_lines = (options[:break_lines] == true) @@ -314,7 +314,7 @@ end def break_lines text, style - reopen = '' + reopen = ''.dup @opened.each_with_index do |kind, index| reopen << (@span_for_kinds[index > 0 ? [kind, *@opened[0...index]] : kind] || '<span>') end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/scanners/cpp.rb new/lib/coderay/scanners/cpp.rb --- old/lib/coderay/scanners/cpp.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/scanners/cpp.rb 2017-09-03 12:12:06.000000000 +0200 @@ -2,14 +2,14 @@ module Scanners # Scanner for C++. - # + # # Aliases: +cplusplus+, c++ class CPlusPlus < Scanner register_for :cpp file_extension 'cpp' title 'C++' - + #-- http://www.cppreference.com/wiki/keywords/start KEYWORDS = [ 'and', 'and_eq', 'asm', 'bitand', 'bitor', 'break', @@ -17,28 +17,30 @@ 'continue', 'default', 'delete', 'do', 'dynamic_cast', 'else', 'enum', 'export', 'for', 'goto', 'if', 'namespace', 'new', 'not', 'not_eq', 'or', 'or_eq', 'reinterpret_cast', 'return', - 'sizeof', 'static_cast', 'struct', 'switch', 'template', - 'throw', 'try', 'typedef', 'typeid', 'typename', 'union', + 'sizeof', 'static_assert', 'static_cast', 'struct', 'switch', + 'template', 'throw', 'try', 'typedef', 'typeid', 'typename', 'union', 'while', 'xor', 'xor_eq', ] # :nodoc: - + PREDEFINED_TYPES = [ - 'bool', 'char', 'double', 'float', 'int', 'long', - 'short', 'signed', 'unsigned', 'wchar_t', 'string', + 'bool', 'char', 'char16_t', 'char32_t', 'double', 'float', + 'int', 'long', 'short', 'signed', 'unsigned', + 'wchar_t', 'string', ] # :nodoc: PREDEFINED_CONSTANTS = [ 'false', 'true', - 'EOF', 'NULL', + 'EOF', 'NULL', 'nullptr' ] # :nodoc: PREDEFINED_VARIABLES = [ 'this', ] # :nodoc: DIRECTIVES = [ - 'auto', 'const', 'explicit', 'extern', 'friend', 'inline', 'mutable', 'operator', - 'private', 'protected', 'public', 'register', 'static', 'using', 'virtual', 'void', - 'volatile', + 'alignas', 'alignof', 'auto', 'const', 'constexpr', 'decltype', 'explicit', + 'extern', 'final', 'friend', 'inline', 'mutable', 'noexcept', 'operator', + 'override', 'private', 'protected', 'public', 'register', 'static', + 'thread_local', 'using', 'virtual', 'void', 'volatile', ] # :nodoc: - + IDENT_KIND = WordList.new(:ident). add(KEYWORDS, :keyword). add(PREDEFINED_TYPES, :predefined_type). @@ -48,9 +50,9 @@ ESCAPE = / [rbfntv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x # :nodoc: UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x # :nodoc: - + protected - + def scan_tokens encoder, options state = :initial @@ -107,7 +109,7 @@ elsif match = scan(/\$/) encoder.text_token match, :ident - + elsif match = scan(/L?"/) encoder.begin_group :string if match[0] == ?L @@ -180,7 +182,7 @@ state = :initial end - + when :class_name_expected if match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x) encoder.text_token match, :class @@ -194,7 +196,7 @@ state = :initial end - + else raise_inspect 'Unknown state', encoder diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/scanners/haml.rb new/lib/coderay/scanners/haml.rb --- old/lib/coderay/scanners/haml.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/scanners/haml.rb 2017-09-03 12:12:06.000000000 +0200 @@ -75,7 +75,7 @@ tag = false - if match = scan(/%[\w:]+\/?/) + if match = scan(/%[-\w:]+\/?/) encoder.text_token match, :tag # if match = scan(/( +)(.+)/) # encoder.text_token self[1], :space diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/scanners/java.rb new/lib/coderay/scanners/java.rb --- old/lib/coderay/scanners/java.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/scanners/java.rb 2017-09-03 12:12:06.000000000 +0200 @@ -44,7 +44,7 @@ '"' => /[^\\"]+/, '/' => /[^\\\/]+/, } # :nodoc: - IDENT = /[a-zA-Z_][A-Za-z_0-9]*/ # :nodoc: + IDENT = RUBY_VERSION < '1.9' ? /[a-zA-Z_][A-Za-z_0-9]*/ : Regexp.new('[[[:alpha:]]_][[[:alnum:]]_]*') # :nodoc: protected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/coderay/version.rb new/lib/coderay/version.rb --- old/lib/coderay/version.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/lib/coderay/version.rb 2017-09-03 12:12:06.000000000 +0200 @@ -1,3 +1,3 @@ module CodeRay - VERSION = '1.1.1' + VERSION = '1.1.2' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-02-20 17:34:58.000000000 +0100 +++ new/metadata 2017-09-03 12:12:06.000000000 +0200 @@ -1,27 +1,29 @@ ---- !ruby/object:Gem::Specification +--- !ruby/object:Gem::Specification name: coderay -version: !ruby/object:Gem::Version - version: 1.1.1 +version: !ruby/object:Gem::Version + version: 1.1.2 platform: ruby -authors: +authors: - Kornelius Kalnbach autorequire: bindir: bin cert_chain: [] -date: 2016-02-20 00:00:00.000000000 Z + +date: 2017-09-03 00:00:00 Z dependencies: [] -description: Fast and easy syntax highlighting for selected languages, written in - Ruby. Comes with RedCloth integration and LOC counter. -email: + +description: Fast and easy syntax highlighting for selected languages, written in Ruby. Comes with RedCloth integration and LOC counter. +email: - [email protected] -executables: +executables: - coderay extensions: [] -extra_rdoc_files: + +extra_rdoc_files: - README_INDEX.rdoc -files: +files: +- MIT-LICENSE - README_INDEX.rdoc -- Rakefile - bin/coderay - lib/coderay.rb - lib/coderay/duo.rb @@ -95,39 +97,34 @@ - lib/coderay/tokens.rb - lib/coderay/tokens_proxy.rb - lib/coderay/version.rb -- test/functional/basic.rb -- test/functional/examples.rb -- test/functional/for_redcloth.rb -- test/functional/suite.rb homepage: http://coderay.rubychan.de -licenses: +licenses: - MIT metadata: {} + post_install_message: -rdoc_options: -- "-SNw2" -- "-mREADME_INDEX.rdoc" -- "-t CodeRay Documentation" -require_paths: +rdoc_options: +- -SNw2 +- -mREADME_INDEX.rdoc +- -t CodeRay Documentation +require_paths: - lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: +required_ruby_version: !ruby/object:Gem::Requirement + requirements: - - ">=" - - !ruby/object:Gem::Version + - !ruby/object:Gem::Version version: 1.8.6 -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: +required_rubygems_version: !ruby/object:Gem::Requirement + requirements: - - ">=" - - !ruby/object:Gem::Version - version: '0' + - !ruby/object:Gem::Version + version: "0" requirements: [] + rubyforge_project: coderay -rubygems_version: 2.5.1 +rubygems_version: 2.6.13 signing_key: specification_version: 4 summary: Fast syntax highlighting for selected languages. -test_files: -- test/functional/basic.rb -- test/functional/examples.rb -- test/functional/for_redcloth.rb -- test/functional/suite.rb +test_files: [] + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/basic.rb new/test/functional/basic.rb --- old/test/functional/basic.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/test/functional/basic.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,318 +0,0 @@ -# encoding: utf-8 -require 'test/unit' -require File.expand_path('../../lib/assert_warning', __FILE__) - -$:.unshift File.expand_path('../../../lib', __FILE__) -require 'coderay' - -class BasicTest < Test::Unit::TestCase - - def test_version - assert_nothing_raised do - assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION) - end - end - - def with_empty_load_path - old_load_path = $:.dup - $:.clear - yield - ensure - $:.replace old_load_path - end - - def test_autoload - with_empty_load_path do - assert_nothing_raised do - CodeRay::Scanners::Java::BuiltinTypes - end - end - end - - RUBY_TEST_CODE = 'puts "Hello, World!"' - - RUBY_TEST_TOKENS = [ - ['puts', :ident], - [' ', :space], - [:begin_group, :string], - ['"', :delimiter], - ['Hello, World!', :content], - ['"', :delimiter], - [:end_group, :string] - ].flatten - def test_simple_scan - assert_nothing_raised do - assert_equal RUBY_TEST_TOKENS, CodeRay.scan(RUBY_TEST_CODE, :ruby).tokens - end - end - - RUBY_TEST_HTML = 'puts <span class="string"><span class="delimiter">"</span>' + - '<span class="content">Hello, World!</span><span class="delimiter">"</span></span>' - def test_simple_highlight - assert_nothing_raised do - assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html - end - end - - def test_scan_file - CodeRay.scan_file __FILE__ - end - - def test_encode - assert_equal 1, CodeRay.encode('test', :python, :count) - end - - def test_encode_tokens - assert_equal 1, CodeRay.encode_tokens(CodeRay::Tokens['test', :string], :count) - end - - def test_encode_file - assert_equal File.read(__FILE__), CodeRay.encode_file(__FILE__, :text) - end - - def test_highlight - assert_match '<pre>test</pre>', CodeRay.highlight('test', :python) - end - - def test_highlight_file - assert_match "require <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">test/unit</span><span class=\"delimiter\">'</span></span>\n", CodeRay.highlight_file(__FILE__) - end - - def test_duo - assert_equal(RUBY_TEST_CODE, - CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE)) - assert_equal(RUBY_TEST_CODE, - CodeRay::Duo[:plain => :text].highlight(RUBY_TEST_CODE)) - end - - def test_duo_stream - assert_equal(RUBY_TEST_CODE, - CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE, :stream => true)) - end - - def test_comment_filter - assert_equal <<-EXPECTED, CodeRay.scan(<<-INPUT, :ruby).comment_filter.text -#!/usr/bin/env ruby - -code - -more code - EXPECTED -#!/usr/bin/env ruby -=begin -A multi-line comment. -=end -code -# A single-line comment. -more code # and another comment, in-line. - INPUT - end - - def test_lines_of_code - assert_equal 2, CodeRay.scan(<<-INPUT, :ruby).lines_of_code -#!/usr/bin/env ruby -=begin -A multi-line comment. -=end -code -# A single-line comment. -more code # and another comment, in-line. - INPUT - rHTML = <<-RHTML -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> - <title><%= controller.controller_name.titleize %>: <%= controller.action_name %></title> - <%= stylesheet_link_tag 'scaffold' %> -</head> -<body> - -<p style="color: green"><%= flash[:notice] %></p> - -<div id="main"> - <%= yield %> -</div> - -</body> -</html> - RHTML - assert_equal 0, CodeRay.scan(rHTML, :html).lines_of_code - assert_equal 0, CodeRay.scan(rHTML, :php).lines_of_code - assert_equal 0, CodeRay.scan(rHTML, :yaml).lines_of_code - assert_equal 4, CodeRay.scan(rHTML, :erb).lines_of_code - end - - def test_list_of_encoders - assert_kind_of(Array, CodeRay::Encoders.list) - assert CodeRay::Encoders.list.include?(:count) - end - - def test_list_of_scanners - assert_kind_of(Array, CodeRay::Scanners.list) - assert CodeRay::Scanners.list.include?(:text) - end - - def test_token_kinds - assert_kind_of Hash, CodeRay::TokenKinds - for kind, css_class in CodeRay::TokenKinds - assert_kind_of Symbol, kind - if css_class != false - assert_kind_of String, css_class, "TokenKinds[%p] == %p" % [kind, css_class] - end - end - assert_equal 'reserved', CodeRay::TokenKinds[:reserved] - assert_equal false, CodeRay::TokenKinds[:shibboleet] - end - - class Milk < CodeRay::Encoders::Encoder - FILE_EXTENSION = 'cocoa' - end - - class HoneyBee < CodeRay::Encoders::Encoder - end - - def test_encoder_file_extension - assert_nothing_raised do - assert_equal 'html', CodeRay::Encoders::Page::FILE_EXTENSION - assert_equal 'cocoa', Milk::FILE_EXTENSION - assert_equal 'cocoa', Milk.new.file_extension - assert_equal 'honeybee', HoneyBee::FILE_EXTENSION - assert_equal 'honeybee', HoneyBee.new.file_extension - end - assert_raise NameError do - HoneyBee::MISSING_CONSTANT - end - end - - def test_encoder_tokens - encoder = CodeRay::Encoders::Encoder.new - encoder.send :setup, {} - assert_raise(ArgumentError) { encoder.token :strange, '' } - encoder.token 'test', :debug - end - - def test_encoder_deprecated_interface - encoder = CodeRay::Encoders::Encoder.new - encoder.send :setup, {} - assert_warning 'Using old Tokens#<< interface.' do - encoder << ['test', :content] - end - assert_raise ArgumentError do - encoder << [:strange, :input] - end - assert_raise ArgumentError do - encoder.encode_tokens [['test', :token]] - end - end - - def encoder_token_interface_deprecation_warning_given - CodeRay::Encoders::Encoder.send :class_variable_get, :@@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN - end - - def test_scanner_file_extension - assert_equal 'rb', CodeRay::Scanners::Ruby.file_extension - assert_equal 'rb', CodeRay::Scanners::Ruby.new.file_extension - assert_equal 'java', CodeRay::Scanners::Java.file_extension - assert_equal 'java', CodeRay::Scanners::Java.new.file_extension - end - - def test_scanner_lang - assert_equal :ruby, CodeRay::Scanners::Ruby.lang - assert_equal :ruby, CodeRay::Scanners::Ruby.new.lang - assert_equal :java, CodeRay::Scanners::Java.lang - assert_equal :java, CodeRay::Scanners::Java.new.lang - end - - def test_scanner_tokenize - assert_equal ['foo', :plain], CodeRay::Scanners::Plain.new.tokenize('foo') - assert_equal [['foo', :plain], ['bar', :plain]], CodeRay::Scanners::Plain.new.tokenize(['foo', 'bar']) - CodeRay::Scanners::Plain.new.tokenize 42 - end - - def test_scanner_tokens - scanner = CodeRay::Scanners::Plain.new - scanner.tokenize('foo') - assert_equal ['foo', :plain], scanner.tokens - scanner.string = '' - assert_equal ['', :plain], scanner.tokens - end - - def test_scanner_line_and_column - scanner = CodeRay::Scanners::Plain.new "foo\nbär+quux" - assert_equal 0, scanner.pos - assert_equal 1, scanner.line - assert_equal 1, scanner.column - scanner.scan(/foo/) - assert_equal 3, scanner.pos - assert_equal 1, scanner.line - assert_equal 4, scanner.column - scanner.scan(/\n/) - assert_equal 4, scanner.pos - assert_equal 2, scanner.line - assert_equal 1, scanner.column - scanner.scan(/b/) - assert_equal 5, scanner.pos - assert_equal 2, scanner.line - assert_equal 2, scanner.column - scanner.scan(/a/) - assert_equal 5, scanner.pos - assert_equal 2, scanner.line - assert_equal 2, scanner.column - scanner.scan(/ä/) - assert_equal 7, scanner.pos - assert_equal 2, scanner.line - assert_equal 4, scanner.column - scanner.scan(/r/) - assert_equal 8, scanner.pos - assert_equal 2, scanner.line - assert_equal 5, scanner.column - end - - def test_scanner_use_subclasses - assert_raise NotImplementedError do - CodeRay::Scanners::Scanner.new - end - end - - class InvalidScanner < CodeRay::Scanners::Scanner - end - - def test_scanner_scan_tokens - assert_raise NotImplementedError do - InvalidScanner.new.tokenize '' - end - end - - class RaisingScanner < CodeRay::Scanners::Scanner - def scan_tokens encoder, options - raise_inspect 'message', [], :initial - end - end - - def test_scanner_raise_inspect - assert_raise CodeRay::Scanners::Scanner::ScanError do - RaisingScanner.new.tokenize '' - end - end - - def test_scan_a_frozen_string - assert_nothing_raised do - CodeRay.scan RUBY_VERSION, :ruby - CodeRay.scan RUBY_VERSION, :plain - end - end - - def test_scan_a_non_string - assert_nothing_raised do - CodeRay.scan 42, :ruby - CodeRay.scan nil, :ruby - CodeRay.scan self, :ruby - CodeRay.encode ENV.to_hash, :ruby, :page - CodeRay.highlight CodeRay, :plain - end - end - -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/examples.rb new/test/functional/examples.rb --- old/test/functional/examples.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/test/functional/examples.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,129 +0,0 @@ -require 'test/unit' - -$:.unshift File.expand_path('../../../lib', __FILE__) -require 'coderay' - -class ExamplesTest < Test::Unit::TestCase - - def test_examples - # output as HTML div (using inline CSS styles) - div = CodeRay.scan('puts "Hello, world!"', :ruby).div - assert_equal <<-DIV, div -<div class="CodeRay"> - <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">Hello, world!</span><span style="color:#710">"</span></span></pre></div> -</div> - DIV - - # ...with line numbers - div = CodeRay.scan(<<-CODE.chomp, :ruby).div(:line_numbers => :table) -5.times do - puts 'Hello, world!' -end - CODE - assert_equal <<-DIV, div -<table class="CodeRay"><tr> - <td class="line-numbers"><pre><a href="#n1" name="n1">1</a> -<a href="#n2" name="n2">2</a> -<a href="#n3" name="n3">3</a> -</pre></td> - <td class="code"><pre><span style="color:#00D">5</span>.times <span style="color:#080;font-weight:bold">do</span> - puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span> -<span style="color:#080;font-weight:bold">end</span></pre></td> -</tr></table> - DIV - - # output as standalone HTML page (using CSS classes) - page = CodeRay.scan('puts "Hello, world!"', :ruby).page - assert_match <<-PAGE, page -<body> - -<table class="CodeRay"><tr> - <td class="line-numbers"><pre><a href="#n1" name="n1">1</a> -</pre></td> - <td class="code"><pre>puts <span class="string"><span class="delimiter">"</span><span class="content">Hello, world!</span><span class="delimiter">"</span></span></pre></td> -</tr></table> - -</body> - PAGE - - # keep scanned tokens for later use - tokens = CodeRay.scan('{ "just": "an", "example": 42 }', :json) - assert_kind_of CodeRay::TokensProxy, tokens - - assert_equal ["{", :operator, " ", :space, :begin_group, :key, - "\"", :delimiter, "just", :content, "\"", :delimiter, - :end_group, :key, ":", :operator, " ", :space, - :begin_group, :string, "\"", :delimiter, "an", :content, - "\"", :delimiter, :end_group, :string, ",", :operator, - " ", :space, :begin_group, :key, "\"", :delimiter, - "example", :content, "\"", :delimiter, :end_group, :key, - ":", :operator, " ", :space, "42", :integer, - " ", :space, "}", :operator], tokens.tokens - - # produce a token statistic - assert_equal <<-STATISTIC, tokens.statistic - -Code Statistics - -Tokens 26 - Non-Whitespace 15 -Bytes Total 31 - -Token Types (7): - type count ratio size (average) -------------------------------------------------------------- - TOTAL 26 100.00 % 1.2 - delimiter 6 23.08 % 1.0 - operator 5 19.23 % 1.0 - space 5 19.23 % 1.0 - key 4 15.38 % 0.0 - :begin_group 3 11.54 % 0.0 - :end_group 3 11.54 % 0.0 - content 3 11.54 % 4.3 - string 2 7.69 % 0.0 - integer 1 3.85 % 2.0 - - STATISTIC - - # count the tokens - assert_equal 26, tokens.count - - # produce a HTML div, but with CSS classes - div = tokens.div(:css => :class) - assert_equal <<-DIV, div -<div class="CodeRay"> - <div class="code"><pre>{ <span class="key"><span class="delimiter">"</span><span class="content">just</span><span class="delimiter">"</span></span>: <span class="string"><span class="delimiter">"</span><span class="content">an</span><span class="delimiter">"</span></span>, <span class="key"><span class="delimiter">"</span><span class="content">example</span><span class="delimiter">"</span></span>: <span class="integer">42</span> }</pre></div> -</div> - DIV - - # highlight a file (HTML div); guess the file type base on the extension - assert_equal :ruby, CodeRay::FileType[__FILE__] - - # get a new scanner for Python - python_scanner = CodeRay.scanner :python - assert_kind_of CodeRay::Scanners::Python, python_scanner - - # get a new encoder for terminal - terminal_encoder = CodeRay.encoder :term - assert_kind_of CodeRay::Encoders::Terminal, terminal_encoder - - # scanning into tokens - tokens = python_scanner.tokenize 'import this; # The Zen of Python' - assert_equal ["import", :keyword, " ", :space, "this", :include, - ";", :operator, " ", :space, "# The Zen of Python", :comment], tokens - - # format the tokens - term = terminal_encoder.encode_tokens(tokens) - assert_equal "\e[32mimport\e[0m \e[31mthis\e[0m; \e[1;30m# The Zen of Python\e[0m", term - - # re-using scanner and encoder - ruby_highlighter = CodeRay::Duo[:ruby, :div] - div = ruby_highlighter.encode('puts "Hello, world!"') - assert_equal <<-DIV, div -<div class="CodeRay"> - <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">Hello, world!</span><span style="color:#710">"</span></span></pre></div> -</div> - DIV - end - -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/for_redcloth.rb new/test/functional/for_redcloth.rb --- old/test/functional/for_redcloth.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/test/functional/for_redcloth.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -require 'test/unit' - -$:.unshift File.expand_path('../../../lib', __FILE__) -require 'coderay' - -begin - require 'rubygems' unless defined? Gem - gem 'RedCloth', '>= 4.0.3' rescue nil - require 'redcloth' -rescue LoadError - warn 'RedCloth not found - skipping for_redcloth tests.' - undef RedCloth if defined? RedCloth -end - -class BasicTest < Test::Unit::TestCase - - def test_for_redcloth - require 'coderay/for_redcloth' - assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">puts <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">"</span><span style=\"color:#D20\">Hello, World!</span><span style=\"color:#710\">"</span></span></span></p>", - RedCloth.new('@[ruby]puts "Hello, World!"@').to_html - assert_equal <<-BLOCKCODE.chomp, -<div lang="ruby" class="CodeRay"> - <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">"</span><span style="color:#D20">Hello, World!</span><span style="color:#710">"</span></span></pre></div> -</div> - BLOCKCODE - RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html - end - - def test_for_redcloth_no_lang - require 'coderay/for_redcloth' - assert_equal "<p><code>puts \"Hello, World!\"</code></p>", - RedCloth.new('@puts "Hello, World!"@').to_html - assert_equal <<-BLOCKCODE.chomp, -<pre><code>puts \"Hello, World!\"</code></pre> - BLOCKCODE - RedCloth.new('bc. puts "Hello, World!"').to_html - end - - def test_for_redcloth_style - require 'coderay/for_redcloth' - assert_equal <<-BLOCKCODE.chomp, -<pre style=\"color: red;\"><code style=\"color: red;\">puts \"Hello, World!\"</code></pre> - BLOCKCODE - RedCloth.new('bc{color: red}. puts "Hello, World!"').to_html - end - - def test_for_redcloth_escapes - require 'coderay/for_redcloth' - assert_equal '<p><span lang="ruby" class="CodeRay">></span></p>', - RedCloth.new('@[ruby]>@').to_html - assert_equal <<-BLOCKCODE.chomp, -<div lang="ruby" class="CodeRay"> - <div class="code"><pre>&</pre></div> -</div> - BLOCKCODE - RedCloth.new('bc[ruby]. &').to_html - end - - def test_for_redcloth_escapes2 - require 'coderay/for_redcloth' - assert_equal "<p><span lang=\"c\" class=\"CodeRay\"><span style=\"color:#579\">#include</span> <span style=\"color:#B44;font-weight:bold\"><test.h></span></span></p>", - RedCloth.new('@[c]#include <test.h>@').to_html - end - - # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets. - def test_for_redcloth_false_positive - require 'coderay/for_redcloth' - assert_equal '<p><code>[project]_dff.skjd</code></p>', - RedCloth.new('@[project]_dff.skjd@').to_html - # false positive, but expected behavior / known issue - assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">_dff.skjd</span></p>", - RedCloth.new('@[ruby]_dff.skjd@').to_html - assert_equal <<-BLOCKCODE.chomp, RedCloth.new('bc. [project]_dff.skjd').to_html -<pre><code>[project]_dff.skjd</code></pre> - BLOCKCODE - end - -end if defined? RedCloth \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/functional/suite.rb new/test/functional/suite.rb --- old/test/functional/suite.rb 2016-02-20 17:34:58.000000000 +0100 +++ new/test/functional/suite.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -require 'test/unit' - -$VERBOSE = $CODERAY_DEBUG = true -$:.unshift File.expand_path('../../../lib', __FILE__) -require 'coderay' - -mydir = File.dirname(__FILE__) -suite = Dir[File.join(mydir, '*.rb')]. - map { |tc| File.basename(tc).sub(/\.rb$/, '') } - %w'suite for_redcloth' - -puts "Running basic CodeRay #{CodeRay::VERSION} tests: #{suite.join(', ')}" - -for test_case in suite - load File.join(mydir, test_case + '.rb') -end
