Skip to content

Commit

Permalink
Rudimentary Ruby 1.9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jan 4, 2009
1 parent ee1207e commit b3f6728
Show file tree
Hide file tree
Showing 49 changed files with 69 additions and 8 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

=== New features
* Pretty formatter shows number of scenarios (#139 Joseph Wilk)
* Rudimentary support for Ruby 1.9. Now it's ok to file Ruby 1.9-related bugs.

=== Bugfixes
* Fixed "No such file or directory -- cucumber (LoadError)" bug with AutoTest (Aslak Hellesøy)
Expand Down
1 change: 1 addition & 0 deletions config/hoe.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'cucumber/version'

AUTHOR = 'Aslak Hellesøy' # can also be an array of Authors
Expand Down
20 changes: 18 additions & 2 deletions examples/i18n/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,29 @@ task :i18n do
Dir["#{dir}/*"].each do |f|
if File.directory?(f)
lang = f[dir.length+1..-1]
Dir.chdir(f) do
rake("features")
if supported?(lang)
Dir.chdir(f) do
rake("features")
end
else
STDERR.puts %{
!!!!!
!!!!! SKIPPING #{lang} (Haven't made it work on Ruby 1.9 yet)
!!!!!
}
end
end
end
end

def supported?(lang)
if RUBY_VERSION =~ /^1\.9/
!%w{ar ja}.index(lang)
else
true
end
end

def rake(args)
ruby(File.join(Gem.bindir, 'rake'), args)
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec/expectations'
$:.unshift(File.dirname(__FILE__) + '/../../lib')
require 'cucumber/formatters/unicode'
Expand Down
2 changes: 1 addition & 1 deletion gem_tasks/treetop.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class FeatureCompiler
require 'yaml'
require 'erb'

@tt = PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'
@tt = RUBY_PLATFORM =~ /mswin|mingw/ ? 'tt.bat' : 'tt'

@template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
@langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
Expand Down
2 changes: 1 addition & 1 deletion lib/autotest/cucumber_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ def make_cucumber_cmd(scenarios_to_run, dirty_scenarios_filename)
else
scenario_args = scenarios_to_run.map { |s| "-s '#{s}'" }.join(' ')
end
return "#{Cucumber::RUBY} #{Cucumber::BINARY} #{args} #{scenario_args}"
return "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args} #{scenario_args}"
end
end
2 changes: 1 addition & 1 deletion lib/cucumber/core_ext/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def gzub(regexp, format=nil, &proc)
s
end

if (Cucumber::JRUBY && Cucumber::RAILS)
if (Cucumber::JRUBY && Cucumber::RAILS) || Cucumber::RUBY_1_9
# Workaround for http://tinyurl.com/55uu3u
alias jlength length
else
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatters/unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'cucumber/platform'
require 'cucumber/formatters/ansicolor'

$KCODE='u'
$KCODE='u' unless Cucumber::RUBY_1_9

if Cucumber::WINDOWS_MRI && `chcp` =~ /Active code page: (\d+)/
codepage = $1.to_i
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module Cucumber
WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
RAILS = defined?(Rails)
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/

class << self
attr_reader :language
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature.treetop.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_ar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_cy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_da.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_de.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_en-lol.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_en-tx.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_en.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_es.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_et.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_fr.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_id.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_it.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_ja.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_lt.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_nl.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_no.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
4 changes: 3 additions & 1 deletion lib/cucumber/treetop_parser/feature_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class << self
end

def parse_feature(file)
ast = parse(IO.read(file))
gherkin = IO.read(file)
gherkin = gherkin.force_encoding('utf-8') if Cucumber::RUBY_1_9
ast = parse(gherkin)
if ast.nil?
raise SyntaxError.new(file, self)
else
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_pl.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_pt.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_ro.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_ro2.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_ru.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_se.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/treetop_parser/feature_zh-CN.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Cucumber
# :stopdoc:
module TreetopParser
Expand Down

0 comments on commit b3f6728

Please sign in to comment.