summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2011-07-09 17:23:55 +0200
committerKornelius Kalnbach <murphy@rubychan.de>2011-07-09 17:23:55 +0200
commit8eed7f3854be44f83aaa6a50e40cda62da942a39 (patch)
treeef981b04cf8ecdf3f87745b445ceb8baff261f23
parentaf5fef051d041384910377fcc004b33470175e5c (diff)
downloadcoderay-8eed7f3854be44f83aaa6a50e40cda62da942a39.tar.gz
new version scheme; use bundler + git for releasesv1.0.0.800pre
-rw-r--r--.gitignore4
-rw-r--r--coderay.gemspec35
-rw-r--r--lib/coderay.rb29
-rw-r--r--lib/coderay/version.rb3
-rw-r--r--rake_tasks/bundler.rake2
-rw-r--r--rake_tasks/gem.rake39
-rwxr-xr-xtest/functional/basic.rb2
7 files changed, 36 insertions, 78 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8827e10
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+test/executable/source.rb.html
+test/executable/source.rb.json
+pkg
+Gemfile.lock
diff --git a/coderay.gemspec b/coderay.gemspec
index a3b9199..f52b8f9 100644
--- a/coderay.gemspec
+++ b/coderay.gemspec
@@ -1,34 +1,27 @@
-# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
-def svn_head_revision
- $svn_head_revision ||= `svnversion`.scan(/\d+/).map { |r| r.to_i }.max
-end
+require 'coderay/version'
-def coderay_version
- $coderay_version ||= begin
- $:.unshift './lib'
- require 'coderay'
-
- version = CodeRay::VERSION
- unless ENV['final']
- version << ".#{svn_head_revision}.pre"
- end
-
- version
+Gem::Specification.new do |s|
+ s.name = 'coderay'
+
+ if ENV['final'] == 'yes'
+ 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}pre"
end
-end
-
-$gemspec = Gem::Specification.new do |s|
- s.name = 'coderay'
- s.version = coderay_version
- s.platform = Gem::Platform::RUBY
+
s.authors = ['Kornelius Kalnbach']
s.email = ['murphy@rubychan.de']
s.homepage = 'http://coderay.rubychan.de'
s.summary = 'Fast syntax highlighting for selected languages.'
s.description = 'Fast and easy syntax highlighting for selected languages, written in Ruby. Comes with RedCloth integration and LOC counter.'
+ s.platform = Gem::Platform::RUBY
+ s.required_ruby_version = '>= 1.8.7'
+
# s.add_dependency "paint", '~> 0.8.2'
# s.files = `git ls-files`.split("\n")
diff --git a/lib/coderay.rb b/lib/coderay.rb
index 9b81772..d2d7331 100644
--- a/lib/coderay.rb
+++ b/lib/coderay.rb
@@ -127,12 +127,7 @@ module CodeRay
$CODERAY_DEBUG ||= false
- # Version: Major.Minor.Teeny[.Revision]
- # Major: 0 for pre-stable, 1 for stable
- # Minor: feature milestone
- # Teeny: development state, 0 for pre-release
- # Revision: Subversion Revision number (generated on rake gem:make)
- VERSION = '1.0.0'
+ require 'coderay/version'
# helpers
autoload :FileType, 'coderay/helpers/file_type'
@@ -166,7 +161,7 @@ module CodeRay
scanner = Scanners[lang].new code, options, &block
scanner.tokenize
end
-
+
# Scans +filename+ (a path to a code file) with the Scanner for +lang+.
#
# If +lang+ is :auto or omitted, the CodeRay::FileType module is used to
@@ -185,7 +180,7 @@ module CodeRay
end
scan file, lang, options = {}, &block
end
-
+
# Encode a string.
#
# This scans +code+ with the the Scanner for +lang+ and then
@@ -196,7 +191,7 @@ module CodeRay
def encode code, lang, format, options = {}
encoder(format, options).encode code, lang, options
end
-
+
# Encode pre-scanned Tokens.
# Use this together with CodeRay.scan:
#
@@ -209,7 +204,7 @@ module CodeRay
def encode_tokens tokens, format, options = {}
encoder(format, options).encode_tokens tokens, options
end
-
+
# Encodes +filename+ (a path to a code file) with the Scanner for +lang+.
#
# See CodeRay.scan_file.
@@ -222,7 +217,7 @@ module CodeRay
tokens = scan_file filename, :auto, get_scanner_options(options)
encode_tokens tokens, format, options
end
-
+
# Highlight a string into a HTML <div>.
#
# CSS styles use classes, so you have to include a stylesheet
@@ -232,7 +227,7 @@ module CodeRay
def highlight code, lang, options = { :css => :class }, format = :div
encode code, lang, format, options
end
-
+
# Highlight a file into a HTML <div>.
#
# CSS styles use classes, so you have to include a stylesheet
@@ -242,7 +237,7 @@ module CodeRay
def highlight_file filename, options = { :css => :class }, format = :div
encode_file filename, format, options
end
-
+
# Finds the Encoder class for +format+ and creates an instance, passing
# +options+ to it.
#
@@ -260,7 +255,7 @@ module CodeRay
def encoder format, options = {}
Encoders[format].new options
end
-
+
# Finds the Scanner class for +lang+ and creates an instance, passing
# +options+ to it.
#
@@ -268,7 +263,7 @@ module CodeRay
def scanner lang, options = {}
Scanners[lang].new '', options
end
-
+
# Extract the options for the scanner from the +options+ hash.
#
# Returns an empty Hash if <tt>:scanner_options</tt> is not set.
@@ -278,7 +273,7 @@ module CodeRay
def get_scanner_options options
options.fetch :scanner_options, {}
end
-
+
end
-
+
end
diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb
new file mode 100644
index 0000000..8bed603
--- /dev/null
+++ b/lib/coderay/version.rb
@@ -0,0 +1,3 @@
+module CodeRay
+ VERSION = '1.0.0'
+end
diff --git a/rake_tasks/bundler.rake b/rake_tasks/bundler.rake
new file mode 100644
index 0000000..38b103b
--- /dev/null
+++ b/rake_tasks/bundler.rake
@@ -0,0 +1,2 @@
+require 'bundler'
+Bundler::GemHelper.install_tasks
diff --git a/rake_tasks/gem.rake b/rake_tasks/gem.rake
deleted file mode 100644
index 2b09a68..0000000
--- a/rake_tasks/gem.rake
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'rubygems/package_task'
-
-load File.expand_path('../../coderay.gemspec', __FILE__)
-
-def gem_path
- "pkg/coderay-#{coderay_version}.gem"
-end
-
-namespace :gem do
- Gem::PackageTask.new $gemspec do |pkg|
- pkg.need_zip = true
- pkg.need_tar = true
- end
-
- desc 'Create the Gem again'
- task :make => [:clean, :gem] do
- puts "Created #{coderay_version}"
- end
-
- desc 'Delete previously created Gems'
- task :clean do
- rm_r Dir['pkg/*']
- end
-
- desc 'Install the gem'
- task :install => [:make] do
- sh "gem install #{gem_path}"
- end
-
- desc 'Release the gem on rubygems.org'
- task :release => [:make] do
- print "Releasing CodeRay #{coderay_version}. Are you sure? "
- if $stdin.gets.chomp == 'yes'
- sh "gem push #{gem_path}"
- end
- end
-end
-
-task :gem => 'gem:make' \ No newline at end of file
diff --git a/test/functional/basic.rb b/test/functional/basic.rb
index dae7de6..94e1dd7 100755
--- a/test/functional/basic.rb
+++ b/test/functional/basic.rb
@@ -18,7 +18,7 @@ class BasicTest < Test::Unit::TestCase
def test_version
assert_nothing_raised do
- assert_match(/\A\d\.\d\.\d\z/, CodeRay::VERSION)
+ assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION)
end
end