# HG changeset patch # User Mahlon E. Smith # Date 1295667676 28800 # Node ID 01a3332bfe0a86be39ff1fa7461929fa22c82c48 # Parent 233041485364403f75e86a76884ec5ba7f85a37f Bump Chunker to 1.0.0 (release), updates for rspec 2. diff -r 233041485364 -r 01a3332bfe0a .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Fri Jan 21 19:41:16 2011 -0800 @@ -0,0 +1,1 @@ +^chunker/pkg diff -r 233041485364 -r 01a3332bfe0a chunker/.rspec --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chunker/.rspec Fri Jan 21 19:41:16 2011 -0800 @@ -0,0 +1,2 @@ +-r ~/.vim/bundle/specky/ruby/specky_formatter +-f SpeckyFormatter diff -r 233041485364 -r 01a3332bfe0a chunker/Rakefile --- a/chunker/Rakefile Thu Jun 04 17:28:02 2009 +0000 +++ b/chunker/Rakefile Fri Jan 21 19:41:16 2011 -0800 @@ -1,17 +1,14 @@ #!/usr/bin/env rake # -# Chunker Rakefile -# require 'rubygems' require 'pathname' require 'rake' -require 'spec' -require 'rake/testtask' +require 'rspec' +require 'rspec/core/rake_task' require 'rake/packagetask' require 'rake/gempackagetask' -require 'spec/rake/spectask' require 'rubygems/installer' require 'rubygems/uninstaller' @@ -25,10 +22,10 @@ TEXT_FILES = %w{ Rakefile README LICENSE }.collect {|f| BASEDIR + f } SPECDIR = BASEDIR + 'spec' -SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).reject {|f| f =~ /^\.svn/ } +SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ) LIBDIR = BASEDIR + 'lib' -LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb').reject {|i| i =~ /\.svn/ } +LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb') RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES @@ -56,27 +53,32 @@ ###################################################################### PKG_NAME = 'chunker' -PKG_VERSION = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](\d\.\d(?:\/\d)?)['"]/ ) -PKG_REVISION = find_pattern( LIBDIR + 'chunker.rb', /SVNRev = .+Rev: (\d+)/ ) -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}.#{PKG_REVISION}" +PKG_VERSION = find_pattern( LIBDIR + 'chunker.rb', /VERSION = ['"](.+)['"]/ ) +PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" ###################################################################### ### T A S K S ###################################################################### -task :default => [ :test, :package ] - +task :test => 'test:spec' +task :default => :test +# task :default => [ :test, :package ] -### Task: run rspec tests -### -desc "Run tests" -Spec::Rake::SpecTask.new('test') do |task| - task.spec_files = SPEC_FILES - task.spec_opts = %w{ -c -fs } +namespace :test do + desc 'Generate verbose and pretty output' + RSpec::Core::RakeTask.new( :spec ) do |task| + task.pattern = SPEC_FILES + task.rspec_opts = ['-b', '-fd', '-c'] + end + + desc 'Generate quiet non-colored plain-text output' + RSpec::Core::RakeTask.new( :quiet ) do |task| + task.pattern = SPEC_FILES + task.rspec_opts = ['-f', 'p'] + end end - ### Task: generate ctags ### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway. ### @@ -89,15 +91,12 @@ ### Task: Create gem from source ### gem = Gem::Specification.new do |gem| - pkg_build = PKG_REVISION || 0 - gem.summary = "A convenience library for parsing __END__ tokens consistently." gem.name = PKG_NAME - gem.version = "%s.%s" % [ PKG_VERSION, pkg_build ] + gem.version = PKG_VERSION gem.author = 'Mahlon E. Smith' gem.email = 'mahlon@martini.nu' gem.homepage = 'http://projects.martini.nu/ruby-modules/wiki/Chunker' - gem.rubyforge_project = 'mahlon' gem.has_rdoc = true gem.files = RELEASE_FILES. diff -r 233041485364 -r 01a3332bfe0a chunker/lib/chunker.rb --- a/chunker/lib/chunker.rb Thu Jun 04 17:28:02 2009 +0000 +++ b/chunker/lib/chunker.rb Fri Jan 21 19:41:16 2011 -0800 @@ -1,4 +1,8 @@ -#!/usr/bin/ruby +# vim: set nosta noet ts=4 sw=4: + +require 'strscan' +require 'stringio' + # # Chunker: A convenience library for parsing __END__ tokens consistently. # @@ -17,20 +21,14 @@ ### module Chunker - require 'strscan' - require 'stringio' + # VCS Revision + VCSRev = %q$Rev$ - # SVN Revision - # - SVNRev = %q$Rev$ - - # SVN Id - # - SVNId = %q$Id$ + # VCS Id + VCSId = %q$Id$ # Package version - # - VERSION = '0.1' + VERSION = '1.0.0' ### Parser class for __END__ data blocks. @@ -40,11 +38,9 @@ class DataParser # The mark for a DATA block. - # END_TOKEN = /^__END__\r?\n/ # The mark for a 'sub' block. - # CHUNK_TOKEN = /^__([A-Z\_0-9]+)__\r?\n/ @@ -59,11 +55,14 @@ @scanner = StringScanner.new( end_string ) io.close + # put each chunk into its own constant + # if @scanner.check_until( CHUNK_TOKEN ) - # put each chunk into its own constant self.extract_blocks + + # no sub blocks, put the whole mess into DATA_END + # else - # no sub blocks, put the whole mess into DATA_END @klass.const_set( :DATA_END, StringIO.new( end_string ) ) end end @@ -93,20 +92,20 @@ else label = @scanner[1] + # Pull the next token text out of the data, set up the next pass + # if data = @scanner.scan_until( CHUNK_TOKEN ) - # Pull the next token text out of the data, set up the next pass - # - data = data[ 0, data.length - @scanner[0].length ] + data = data[ 0, data.length - @scanner[0].length ] @scanner.pos = self.next_position + + # No additional blocks + # else - # No additional blocks - # data = @scanner.rest end end # Add the IO constant to the class that included me. - # @klass.const_set( "DATA_#{label}".to_sym, StringIO.new( data ) ) end end @@ -126,7 +125,6 @@ def self.included( klass ) # klass.instance_eval{ __FILE__ } awww, nope. # __FILE__ won't work here, so we find the filename via caller(). - # io = File.open( caller(1).last.sub(/:.*?$/, ''), 'r' ) DataParser.new( klass, io ) diff -r 233041485364 -r 01a3332bfe0a chunker/spec/chunker_spec.rb --- a/chunker/spec/chunker_spec.rb Thu Jun 04 17:28:02 2009 +0000 +++ b/chunker/spec/chunker_spec.rb Fri Jan 21 19:41:16 2011 -0800 @@ -1,4 +1,4 @@ -#!/usr/bin/env ruby +# vim: set nosta noet ts=4 sw=4 ft=rspec: BEGIN { require 'pathname' @@ -8,9 +8,8 @@ $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir ) } +require 'rspec' require 'chunker' -require 'rubygems' -require 'spec' ENDSTUFF = <