From 3affb0b62355d96c35c643c6bdb20d6ecd1b5d58 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Mon, 12 Dec 2011 05:00:38 +0100 Subject: update to shoulda-context 1.0.0 after release! --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ce4735c..80fe57c 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :development do gem "rake", "~> 0.9.2" gem "RedCloth", RUBY_PLATFORM == 'java' ? "= 4.2.7" : ">= 4.0.3" gem "term-ansicolor" - gem "shoulda-context", "= 1.0.0.beta1" if RUBY_VERSION >= '1.8.7' + gem "shoulda-context", "~> 1.0.0" if RUBY_VERSION >= '1.8.7' gem "json" unless RUBY_VERSION >= '1.9.1' gem "rdoc" if RUBY_VERSION >= '1.8.7' end -- cgit v1.2.1 From 27084f115e4cddb3cccc30055641842f8043f9f1 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Thu, 15 Dec 2011 17:37:55 +0100 Subject: use bright blue because dark blue is hard to see on black terminal --- lib/coderay/encoders/terminal.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coderay/encoders/terminal.rb b/lib/coderay/encoders/terminal.rb index 15c8a52..005032d 100644 --- a/lib/coderay/encoders/terminal.rb +++ b/lib/coderay/encoders/terminal.rb @@ -24,14 +24,14 @@ module CodeRay :attribute_value => '31', :binary => '1;35', :char => { - :self => '36', :delimiter => '34' + :self => '36', :delimiter => '1;34' }, :class => '1;35', :class_variable => '36', :color => '32', :comment => '37', - :complex => '34', - :constant => ['34', '4'], + :complex => '1;34', + :constant => ['1;34', '4'], :decoration => '35', :definition => '1;32', :directive => ['32', '4'], @@ -56,7 +56,7 @@ module CodeRay :predefined_type => '1;30', :predefined => ['4', '1;34'], :preprocessor => '36', - :pseudo_class => '34', + :pseudo_class => '1;34', :regexp => { :self => '31', :content => '31', @@ -77,10 +77,10 @@ module CodeRay :delimiter => '1;32', }, :symbol => '1;32', - :tag => '34', + :tag => '1;34', :type => '1;34', :value => '36', - :variable => '34', + :variable => '1;34', :insert => '42', :delete => '41', -- cgit v1.2.1 From d05c28cdba1715b1defb4e8a02b557cf86049343 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Thu, 15 Dec 2011 17:39:38 +0100 Subject: Remove TODO --- TODO | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/TODO b/TODO index c389705..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,47 +0,0 @@ -Fix the docu after moving to CodeRay namespace. - -// vim:ts=4:ft=c: -Category = X (done), / (partly done), T (test), L (later), (else) - Planned = planned in version 0.x - Priority = 3 (low) .. 1 (high), 0 (extrem high) - Expense = 0 (trivial), 1 (low) .. 3 (high) - Assigned Day - -Project: - Documentation: -3/4 0 2 ? Doc the interface - 0 2 ? Cleanup/Read Doc -3/4 0 1 write examples - - 1 2 Code Cleanup: Indentation -L 2 2 Rewrite Tools: - coderay, bench.rb, highlight.rb - - - -Plugins: - - -Scanners: - 2 1 Unicode support -L 1 2 More Languages! (See Roadmap) - - Ruby: -L 3 2 Regexp comment highlighting -L 3 2 Options: Highlight characters/escapes/inline code -L 2 1 Meta characters - - -Encoders: - HTML: -L 1 2 dynamic CSS creation: new CSS class - Colors: -3/4 1 2 colorschemes - Statistic: -L 3 1 return Statistic object with to_s method instead of String - - - -Tools: - testfox: -L 2 3 wxRuby and HTML output -- cgit v1.2.1 From cf9339049776eb83f4d6a66e29171fa3db726f83 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Thu, 15 Dec 2011 17:40:05 +0100 Subject: Remove TODO file --- TODO | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.1 From f65ad422bac16a5e5b962ff04f2d0752f72a4b00 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Thu, 15 Dec 2011 17:41:02 +0100 Subject: remove IDEA file --- IDEA | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 IDEA diff --git a/IDEA b/IDEA deleted file mode 100644 index 52cdbd6..0000000 --- a/IDEA +++ /dev/null @@ -1,30 +0,0 @@ -Website tools: -- convertor: reads and writes HTML (filter) - bla - => - ... - -- manual highlighter: - 1. idea: - special scanner (simply reading raydebug code should be enough) - => makes it possible, easy to write - - 2. idea: - => cooler, but more advanced - => still easy to implement for all scanners at once - preamble function (wrapper for scanners): - for example, a method def: - def foo - shall be shown in the same color as method(foo), but - without the def. so write: - !def !foo - Input is read into def foo and 4 (number of chars in preamble) - Ruby scanner outputs some Tokens: - reserved(def) method(foo) - and chopped by a chop_preamble method giving: - method(foo) - PreambleTokens subclass? - Tokens instance that takes options? - - 3. idea: - Scanner handled solution --> forget it. -- cgit v1.2.1 From 3d80f03434ba20544a410c13228738f4362d731b Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Thu, 15 Dec 2011 17:41:54 +0100 Subject: update FOLDERS --- FOLDERS | 1 - 1 file changed, 1 deletion(-) diff --git a/FOLDERS b/FOLDERS index 37fca2f..f29255a 100644 --- a/FOLDERS +++ b/FOLDERS @@ -17,7 +17,6 @@ Run rake bench to perform an example benchmark. Executional files for CodeRay. coderay:: The CodeRay executable. -coderay_stylesheet:: Prints the default stylesheet. == demo - Demos and functional tests -- cgit v1.2.1 From ac2d6f1898a5aa1aad7cc254290ec9341d2cdf60 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 23 Dec 2011 08:33:21 -0800 Subject: Remove assumption about a stable $: In some environments (e.g. [1]) $: can change between loading the library and using it. To avoid this problem, we always pass an absolute path to autoload internal modules. [1] https://github.com/pry/pry/issues/280 --- lib/coderay.rb | 13 ++++++++++++- lib/coderay/encoders/html.rb | 6 +++--- lib/coderay/scanner.rb | 2 +- lib/coderay/scanners/java.rb | 2 +- lib/coderay/scanners/ruby.rb | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/coderay.rb b/lib/coderay.rb index c897220..63ec555 100644 --- a/lib/coderay.rb +++ b/lib/coderay.rb @@ -127,7 +127,18 @@ module CodeRay $CODERAY_DEBUG ||= false - require 'coderay/version' + # Assuming the rel_path is a subpath of lib/ + def self.abs_path(rel_path) + File.join(File.dirname(__FILE__), rel_path) + end + + # In order to work in environments that alter $:, we need to + # set the absolute path when autoloading files. + def self.autoload(const_name, rel_path) + super const_name, abs_path(rel_path) + end + + require abs_path('coderay/version') # helpers autoload :FileType, 'coderay/helpers/file_type' diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 60dfad1..c5d680c 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -109,9 +109,9 @@ module Encoders :hint => false, } - autoload :Output, 'coderay/encoders/html/output' - autoload :CSS, 'coderay/encoders/html/css' - autoload :Numbering, 'coderay/encoders/html/numbering' + autoload :Output, CodeRay.abs_path('coderay/encoders/html/output') + autoload :CSS, CodeRay.abs_path('coderay/encoders/html/css') + autoload :Numbering, CodeRay.abs_path('coderay/encoders/html/numbering') attr_reader :css diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index 7ecbe4f..f102163 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -320,4 +320,4 @@ surrounding code: end end -end \ No newline at end of file +end diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index d3502e3..50c82c2 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -6,7 +6,7 @@ module Scanners register_for :java - autoload :BuiltinTypes, 'coderay/scanners/java/builtin_types' + autoload :BuiltinTypes, CodeRay.abs_path('coderay/scanners/java/builtin_types') # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html KEYWORDS = %w[ diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index 4244ab7..e2e3d1b 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -13,8 +13,8 @@ module Scanners register_for :ruby file_extension 'rb' - autoload :Patterns, 'coderay/scanners/ruby/patterns' - autoload :StringState, 'coderay/scanners/ruby/string_state' + autoload :Patterns, CodeRay.abs_path('coderay/scanners/ruby/patterns') + autoload :StringState, CodeRay.abs_path('coderay/scanners/ruby/string_state') def interpreted_string_state StringState.new :string, true, '"' -- cgit v1.2.1 From b3807c5aa09901f50dca09b7927f37b1902ee32f Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 02:38:08 +0100 Subject: add test for #6 (pry autoload issue) --- test/functional/basic.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/functional/basic.rb b/test/functional/basic.rb index bf289b3..3053b54 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -13,6 +13,22 @@ class BasicTest < Test::Unit::TestCase 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 = [ -- cgit v1.2.1 From 5c4c0065784c6420224516e13a0c50d86e792363 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 02:39:02 +0100 Subject: Bug #6: merge ConradIrwin's approach with korny's --- lib/coderay.rb | 40 ++++++++++++++++++---------------------- lib/coderay/encoders/html.rb | 6 +++--- lib/coderay/scanners/java.rb | 2 +- lib/coderay/scanners/ruby.rb | 4 ++-- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/coderay.rb b/lib/coderay.rb index 63ec555..e54a73b 100644 --- a/lib/coderay.rb +++ b/lib/coderay.rb @@ -127,38 +127,34 @@ module CodeRay $CODERAY_DEBUG ||= false - # Assuming the rel_path is a subpath of lib/ - def self.abs_path(rel_path) - File.join(File.dirname(__FILE__), rel_path) - end - - # In order to work in environments that alter $:, we need to - # set the absolute path when autoloading files. - def self.autoload(const_name, rel_path) - super const_name, abs_path(rel_path) + require 'coderay/version' + + CODERAY_PATH = File.join File.dirname(__FILE__), 'coderay' + + # Assuming the path is a subpath of lib/coderay/ + def self.coderay_path *path + File.join CODERAY_PATH, *path end - - require abs_path('coderay/version') # helpers - autoload :FileType, 'coderay/helpers/file_type' + autoload :FileType, coderay_path('helpers', 'file_type') # Tokens - autoload :Tokens, 'coderay/tokens' - autoload :TokensProxy, 'coderay/tokens_proxy' - autoload :TokenKinds, 'coderay/token_kinds' + autoload :Tokens, coderay_path('tokens') + autoload :TokensProxy, coderay_path('tokens_proxy') + autoload :TokenKinds, coderay_path('token_kinds') # Plugin system - autoload :PluginHost, 'coderay/helpers/plugin' - autoload :Plugin, 'coderay/helpers/plugin' + autoload :PluginHost, coderay_path('helpers', 'plugin') + autoload :Plugin, coderay_path('helpers', 'plugin') # Plugins - autoload :Scanners, 'coderay/scanner' - autoload :Encoders, 'coderay/encoder' - autoload :Styles, 'coderay/style' + autoload :Scanners, coderay_path('scanner') + autoload :Encoders, coderay_path('encoder') + autoload :Styles, coderay_path('style') - # Convenience access and reusable Encoder/Scanner pair - autoload :Duo, 'coderay/duo' + # convenience access and reusable Encoder/Scanner pair + autoload :Duo, coderay_path('duo') class << self diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index c5d680c..c32dbd1 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -109,9 +109,9 @@ module Encoders :hint => false, } - autoload :Output, CodeRay.abs_path('coderay/encoders/html/output') - autoload :CSS, CodeRay.abs_path('coderay/encoders/html/css') - autoload :Numbering, CodeRay.abs_path('coderay/encoders/html/numbering') + autoload :Output, CodeRay.coderay_path('encoders', 'html', 'output') + autoload :CSS, CodeRay.coderay_path('encoders', 'html', 'css') + autoload :Numbering, CodeRay.coderay_path('encoders', 'html', 'numbering') attr_reader :css diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index 50c82c2..c1490ac 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -6,7 +6,7 @@ module Scanners register_for :java - autoload :BuiltinTypes, CodeRay.abs_path('coderay/scanners/java/builtin_types') + autoload :BuiltinTypes, CodeRay.coderay_path('scanners', 'java', 'builtin_types') # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html KEYWORDS = %w[ diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index e2e3d1b..2be98a6 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -13,8 +13,8 @@ module Scanners register_for :ruby file_extension 'rb' - autoload :Patterns, CodeRay.abs_path('coderay/scanners/ruby/patterns') - autoload :StringState, CodeRay.abs_path('coderay/scanners/ruby/string_state') + autoload :Patterns, CodeRay.coderay_path('scanners', 'ruby', 'patterns') + autoload :StringState, CodeRay.coderay_path('scanners', 'ruby', 'string_state') def interpreted_string_state StringState.new :string, true, '"' -- cgit v1.2.1 From c8e21f2e6c83fffcb18e4e1b130bf4b3cf6b50de Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 02:45:00 +0100 Subject: use coderay_path to load version.rb --- lib/coderay.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coderay.rb b/lib/coderay.rb index e54a73b..876d770 100644 --- a/lib/coderay.rb +++ b/lib/coderay.rb @@ -127,8 +127,6 @@ module CodeRay $CODERAY_DEBUG ||= false - require 'coderay/version' - CODERAY_PATH = File.join File.dirname(__FILE__), 'coderay' # Assuming the path is a subpath of lib/coderay/ @@ -136,6 +134,8 @@ module CodeRay File.join CODERAY_PATH, *path end + require coderay_path('version') + # helpers autoload :FileType, coderay_path('helpers', 'file_type') -- cgit v1.2.1 From 964397d4bfbcbbd27d51e252faf25e291429e7d9 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 02:45:32 +0100 Subject: let autoloading to the work (fix test warnings) --- lib/coderay/scanners/diff.rb | 4 +--- test/functional/examples.rb | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb index 52e23d5..9e899c3 100644 --- a/lib/coderay/scanners/diff.rb +++ b/lib/coderay/scanners/diff.rb @@ -16,8 +16,6 @@ module Scanners protected - require 'coderay/helpers/file_type' - def scan_tokens encoder, options line_kind = nil @@ -50,7 +48,7 @@ module Scanners if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/) encoder.text_token match, :filename if options[:highlight_code] && match != '/dev/null' - file_type = FileType.fetch(match, :text) + file_type = CodeRay::FileType.fetch(match, :text) file_type = :text if file_type == :diff content_scanner = scanners[file_type] content_scanner_entry_state = nil diff --git a/test/functional/examples.rb b/test/functional/examples.rb index 8540ac9..ff64af3 100755 --- a/test/functional/examples.rb +++ b/test/functional/examples.rb @@ -97,7 +97,6 @@ Token Types (7): DIV # highlight a file (HTML div); guess the file type base on the extension - require 'coderay/helpers/file_type' assert_equal :ruby, CodeRay::FileType[__FILE__] # get a new scanner for Python -- cgit v1.2.1 From f32eb2da2272e298006021e235ea64455f7d35b5 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 03:41:17 +0100 Subject: use coderay_path on all autoload calls --- lib/coderay/scanner.rb | 4 ++-- lib/coderay/tokens.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index f102163..907cf00 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -2,8 +2,8 @@ require 'strscan' module CodeRay - - autoload :WordList, 'coderay/helpers/word_list' + + autoload :WordList, coderay_path('helpers', 'word_list') # = Scanners # diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb index 045cf4a..c747017 100644 --- a/lib/coderay/tokens.rb +++ b/lib/coderay/tokens.rb @@ -1,7 +1,7 @@ module CodeRay # GZip library for writing and reading token dumps. - autoload :GZip, 'coderay/helpers/gzip' + autoload :GZip, coderay_path('helpers', 'gzip') # = Tokens TODO: Rewrite! # -- cgit v1.2.1 From 9836def48da099979a3a769f9951de54664062e5 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 03:41:41 +0100 Subject: prepare CodeRay 1.0.5.rc1 --- coderay.gemspec | 5 +++-- lib/coderay/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/coderay.gemspec b/coderay.gemspec index 0eabd66..ad7a2bb 100644 --- a/coderay.gemspec +++ b/coderay.gemspec @@ -9,8 +9,9 @@ Gem::Specification.new do |s| s.version = CodeRay::VERSION else # thanks to @Argorak for this solution - revision = 134 + (`git log --oneline | wc -l`.to_i) - s.version = "#{CodeRay::VERSION}.#{revision}rc3" + # revision = 134 + (`git log --oneline | wc -l`.to_i) + # s.version = "#{CodeRay::VERSION}.#{revision}rc1" + s.version = "#{CodeRay::VERSION}.rc1" end s.authors = ['Kornelius Kalnbach'] diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb index 9ffb7a9..e2797b5 100644 --- a/lib/coderay/version.rb +++ b/lib/coderay/version.rb @@ -1,3 +1,3 @@ module CodeRay - VERSION = '1.0.4' + VERSION = '1.0.5' end -- cgit v1.2.1 From 9f7faa3c348c0de7075b3d50462ef70eac1346ff Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 03:52:10 +0100 Subject: update changelog --- Changes.textile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Changes.textile b/Changes.textile index 9b93fa4..04416b3 100644 --- a/Changes.textile +++ b/Changes.textile @@ -4,6 +4,13 @@ p=. _This files lists all changes in the CodeRay library since the 0.9.8 release {{toc}} +h2. Changes in 1.0.5 + +Fixes: + +* @autoload@ do not depend on @coderay/lib@ being in the load path (GitHub issue #6; thanks to banister, envygeeks, and ConradIrwin) +* avoid dark blue as terminal color (GitHub issue #9; thanks to shevegen) + h2. Changes in 1.0.4 Fixes in the CSS scanner: -- cgit v1.2.1 From 9c3837e0086ca07f241e9cc74c9fabbeb2d39987 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Tue, 27 Dec 2011 03:54:25 +0100 Subject: also thank tvon for reposting the autoload issue --- Changes.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changes.textile b/Changes.textile index 04416b3..60382f5 100644 --- a/Changes.textile +++ b/Changes.textile @@ -8,7 +8,7 @@ h2. Changes in 1.0.5 Fixes: -* @autoload@ do not depend on @coderay/lib@ being in the load path (GitHub issue #6; thanks to banister, envygeeks, and ConradIrwin) +* @autoload@ calls do not depend on @coderay/lib@ being in the load path (GitHub issue #6; thanks to tvon, banister, envygeeks, and ConradIrwin) * avoid dark blue as terminal color (GitHub issue #9; thanks to shevegen) h2. Changes in 1.0.4 -- cgit v1.2.1