gherkin 1.0.29-java → 1.0.30-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 1.0.30 (2010-05-18)
2
+
3
+ === New Features
4
+ * Native gems for IronRuby. Bundles IKVM OpenJDK dlls as well as ikvmc-compiled gherkin.dll. Experimental! (Aslak Hellesøy)
5
+
1
6
  == 1.0.29 (2010-05-18)
2
7
 
3
8
  === Bugfixes
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ begin
20
20
  gem.executables = ["gherkin"]
21
21
  gem.add_dependency "trollop", ">= 1.16.2"
22
22
  gem.add_development_dependency "rspec", ">= 1.3.0"
23
- # gem.add_development_dependency "cucumber", ">= 0.7.2"
23
+ gem.add_development_dependency "cucumber", ">= 0.7.2"
24
24
  gem.add_development_dependency "rake-compiler", ">= 0.7.0" unless defined?(JRUBY_VERSION)
25
25
 
26
26
  gem.files -= FileList['ikvm/**/*']
@@ -34,6 +34,10 @@ begin
34
34
  gem.platform = ENV['PLATFORM']
35
35
  gem.files += FileList['lib/*/*.so']
36
36
  gem.extensions = []
37
+ when 'universal-dotnet'
38
+ gem.platform = ENV['PLATFORM']
39
+ gem.files += FileList['lib/*.dll']
40
+ gem.extensions = []
37
41
  else
38
42
  gem.files += FileList['lib/gherkin/rb_lexer/*.rb']
39
43
  gem.files += FileList['ext/**/*.c']
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 0
4
4
  :build:
5
- :patch: 29
5
+ :patch: 30
@@ -17,11 +17,11 @@ module Gherkin
17
17
 
18
18
  cmd_name = args.shift
19
19
  die("Missing command") if cmd_name.nil?
20
- cmd = Tools.const_get(cmd_name.capitalize.to_sym).new(args) rescue die("Unknown command #{cmd_name}")
21
20
  begin
21
+ cmd = Tools.const_get(cmd_name.capitalize.to_sym).new(args)
22
22
  cmd.run
23
23
  rescue => e
24
- Trollop::die(e.message)
24
+ Trollop::die(e.message + "\nCommand: #{cmd_name}")
25
25
  end
26
26
  end
27
27
 
@@ -1,9 +1,9 @@
1
+ require 'gherkin/native'
2
+
1
3
  module Gherkin
2
4
  module Formatter
3
5
  class Argument
4
- require 'gherkin/java_impl'
5
- java_impl('gherkin.jar')
6
-
6
+ native_impl('gherkin')
7
7
  attr_reader :byte_offset, :val
8
8
 
9
9
  def initialize(byte_offset, val)
@@ -1,15 +1,14 @@
1
1
  # encoding: utf-8
2
-
3
2
  require 'gherkin/formatter/colors'
4
3
  require 'gherkin/formatter/monochrome_format'
5
4
  require 'gherkin/formatter/argument'
6
5
  require 'gherkin/formatter/escaping'
6
+ require 'gherkin/native'
7
7
 
8
8
  module Gherkin
9
9
  module Formatter
10
10
  class PrettyFormatter
11
- require 'gherkin/java_impl'
12
- java_impl('gherkin.jar')
11
+ native_impl('gherkin')
13
12
 
14
13
  include Colors
15
14
  include Escaping
@@ -1,12 +1,10 @@
1
1
  require 'yaml'
2
2
  require 'gherkin/rubify'
3
+ require 'gherkin/native'
3
4
 
4
5
  module Gherkin
5
6
  class I18n
6
- unless defined?(BYPASS_JAVA_IMPL)
7
- require 'gherkin/java_impl'
8
- java_impl('gherkin.jar')
9
- end
7
+ native_impl('gherkin') unless defined?(BYPASS_NATIVE_IMPL)
10
8
 
11
9
  FEATURE_ELEMENT_KEYS = %w{feature background scenario scenario_outline examples}
12
10
  STEP_KEYWORD_KEYS = %w{given when then and but}
@@ -1,4 +1,5 @@
1
1
  require 'gherkin/i18n'
2
+ require 'gherkin/native'
2
3
 
3
4
  module Gherkin
4
5
  I18nLexerNotFound = Class.new(LoadError)
@@ -6,8 +7,7 @@ module Gherkin
6
7
 
7
8
  # The main entry point to lexing Gherkin source.
8
9
  class I18nLexer
9
- require 'gherkin/java_impl'
10
- java_impl('gherkin.jar')
10
+ native_impl('gherkin')
11
11
 
12
12
  LANGUAGE_PATTERN = /language\s*:\s*(.*)/ #:nodoc:
13
13
  attr_reader :i18n_language
@@ -0,0 +1,7 @@
1
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
2
+ require 'gherkin/native/ikvm'
3
+ elsif defined?(JRUBY_VERSION)
4
+ require 'gherkin/native/java'
5
+ else
6
+ require 'gherkin/native/null'
7
+ end
@@ -0,0 +1,55 @@
1
+ class Class
2
+
3
+ def implements(java_class_name)
4
+ m = java_class_name.split('.').inject(Object) do |mod, name|
5
+ mod = mod.const_get(name)
6
+ end
7
+ include m
8
+ end
9
+
10
+ # Causes a .NET class to be instantiated instead of the Ruby class when
11
+ # running on IronRuby. This is used to test both pure .NET and pure Ruby classes
12
+ # from the same Ruby based test suite. The .NET Class must have a package name
13
+ # that corresponds with the Ruby class.
14
+ def native_impl(lib)
15
+ begin
16
+ load_assembly(lib)
17
+ rescue LoadError => e
18
+ e.message << "\nTry this: SET MONO_PATH=#{File.expand_path(File.dirname(__FILE__) + '/../..')} (or export MONO_PATH=...)"
19
+ raise e
20
+ end
21
+
22
+ class << self
23
+ def ikvmify(arg)
24
+ if Array === arg
25
+ arg.map{|a| ikvmify(a)}
26
+ else
27
+ case(arg)
28
+ when Regexp
29
+ Object.const_get('java').const_get('util').const_get('regex').const_get('Pattern').compile(arg.source)
30
+ else
31
+ arg
32
+ end
33
+ end
34
+ end
35
+
36
+ def new(*args)
37
+ ikvm_class.new(*ikvmify(args))
38
+ end
39
+
40
+ def ===(object)
41
+ super || object.java_kind_of?(java_class)
42
+ end
43
+
44
+ def ikvm_class
45
+ names = self.name.split('::')
46
+ namespace = Object
47
+ names[0..-2].each do |module_name|
48
+ namespace = namespace.const_get(module_name.downcase)
49
+ end
50
+
51
+ namespace.const_get(names[-1])
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,47 @@
1
+ class Class
2
+
3
+ def implements(java_class_name)
4
+ # no-op
5
+ end
6
+
7
+ # Causes a Java class to be instantiated instead of the Ruby class when
8
+ # running on JRuby. This is used to test both pure Java and pure Ruby classes
9
+ # from the same Ruby based test suite. The Java Class must have a package name
10
+ # that corresponds with the Ruby class.
11
+ def native_impl(lib)
12
+ require "#{lib}.jar"
13
+
14
+ class << self
15
+ def javaify(arg)
16
+ if Array === arg
17
+ arg.map{|a| javaify(a)}
18
+ else
19
+ case(arg)
20
+ when Regexp
21
+ java.util.regex.Pattern.compile(arg.source)
22
+ else
23
+ arg
24
+ end
25
+ end
26
+ end
27
+
28
+ def new(*args)
29
+ java_class.new(*javaify(args))
30
+ end
31
+
32
+ def ===(object)
33
+ super || object.java_kind_of?(java_class)
34
+ end
35
+
36
+ def java_class
37
+ names = self.name.split('::')
38
+ package = Java
39
+ names[0..-2].each do |module_name|
40
+ package = package.__send__(module_name.downcase)
41
+ end
42
+
43
+ package.__send__(names[-1])
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ class Class
2
+ def implements(java_class_name)
3
+ # no-op
4
+ end
5
+
6
+ def native_impl(lib)
7
+ # no-op
8
+ end
9
+ end
@@ -1,12 +1,12 @@
1
1
  require 'gherkin/parser/event'
2
2
  require 'gherkin/parser/tag_expression'
3
+ require 'gherkin/native'
3
4
 
4
5
  module Gherkin
5
6
  module Parser
6
7
  # This class filters events based on filter criteria.
7
8
  class FilterListener
8
- require 'gherkin/java_impl'
9
- java_impl('gherkin.jar')
9
+ native_impl('gherkin')
10
10
 
11
11
  # Creates a new instance that replays events to +listener+, filtered by +filters+,
12
12
  # an Array that can contain one of the following:
@@ -1,3 +1,5 @@
1
+ require 'gherkin/native'
2
+
1
3
  module Gherkin
2
4
  module Parser
3
5
  class ParseError < StandardError
@@ -7,8 +9,7 @@ module Gherkin
7
9
  end
8
10
 
9
11
  class Parser
10
- require 'gherkin/java_impl'
11
- java_impl('gherkin.jar')
12
+ native_impl('gherkin')
12
13
 
13
14
  # Initialize the parser. +machine_name+ refers to a state machine table.
14
15
  def initialize(listener, raise_on_error=true, machine_name='root')
@@ -1,8 +1,9 @@
1
+ require 'gherkin/native'
2
+
1
3
  module Gherkin
2
4
  module Parser
3
5
  class TagExpression
4
- require 'gherkin/java_impl'
5
- java_impl('gherkin.jar')
6
+ native_impl('gherkin')
6
7
 
7
8
  attr_reader :limits
8
9
 
@@ -1,7 +1,11 @@
1
+ require 'gherkin/native'
2
+
1
3
  # encoding: utf-8
2
4
  module Gherkin
3
5
  module Tools
4
6
  class StatsListener
7
+ implements 'gherkin.Listener'
8
+
5
9
  attr_reader :features, :scenarios, :steps
6
10
 
7
11
  def initialize
@@ -142,7 +142,7 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
142
142
 
143
143
  %% write data noerror;
144
144
 
145
- public void scan(CharSequence inputSequence) {
145
+ public void scan(String inputSequence) {
146
146
  String input = inputSequence.toString() + "\n%_FEATURE_END_%";
147
147
  byte[] data = null;
148
148
  try {
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/ragel_task'
2
- BYPASS_JAVA_IMPL = true
2
+ BYPASS_NATIVE_IMPL = true
3
3
  require 'gherkin/i18n'
4
4
 
5
5
  CLEAN.include [
@@ -27,6 +27,12 @@ namespace :gems do
27
27
  mv "pkg/gherkin-#{GHERKIN_VERSION}-java.gem", 'release'
28
28
  end
29
29
 
30
+ desc 'Build IronRuby gem'
31
+ task :ironruby => [:jruby, 'ikvm:dll', 'ikvm:copy_ikvm_dlls'] do
32
+ sh "rake gemspec build PLATFORM=universal-dotnet"
33
+ mv "pkg/gherkin-#{GHERKIN_VERSION}-universal-dotnet.gem", 'release'
34
+ end
35
+
30
36
  task :release_dir do
31
37
  mkdir 'release' unless File.directory?('release')
32
38
  end
@@ -36,4 +42,4 @@ namespace :gems do
36
42
  end
37
43
  end
38
44
 
39
- task :gems => ['gems:clean_release_dir', 'gems:posix', 'gems:mswin32', 'gems:mingw32', 'gems:jruby']
45
+ task :gems => ['gems:clean_release_dir', 'gems:posix', 'gems:mswin32', 'gems:mingw32', 'gems:jruby', 'gems:ironruby']
@@ -20,25 +20,23 @@
20
20
  #
21
21
  namespace :ikvm do
22
22
  desc 'Make a .NET .exe'
23
- task :exe => 'pkg/gherkin.exe'
24
-
25
- desc 'Make a .NET .dll'
26
- task :dll => 'pkg/gherkin.dll'
27
-
28
- file 'pkg/gherkin.exe' => 'lib/gherkin.jar' do
23
+ task :exe => 'lib/gherkin.jar' do
29
24
  mkdir_p 'release' unless File.directory?('release')
30
25
  sh("mono /usr/local/ikvm/bin/ikvmc.exe -target:exe lib/gherkin.jar -out:release/gherkin-#{GHERKIN_VERSION}.exe")
31
26
  end
32
27
 
33
- file 'pkg/gherkin.dll' => 'lib/gherkin.jar' do
28
+ desc 'Make a .NET .dll'
29
+ task :dll => 'lib/gherkin.jar' do
34
30
  mkdir_p 'release' unless File.directory?('release')
35
31
  sh("mono /usr/local/ikvm/bin/ikvmc.exe -target:library lib/gherkin.jar -out:release/gherkin-#{GHERKIN_VERSION}.dll")
32
+ cp "release/gherkin-#{GHERKIN_VERSION}.dll", 'lib/gherkin.dll'
36
33
  end
37
34
 
38
35
  desc 'Copy the IKVM .dll files over to the pkg dir'
39
36
  task :copy_ikvm_dlls do
40
37
  Dir['/usr/local/ikvm/bin/{IKVM.OpenJDK.Core,IKVM.OpenJDK.Text,IKVM.OpenJDK.Security,IKVM.Runtime}.dll'].each do |dll|
41
38
  cp dll, 'release'
39
+ cp dll, 'lib'
42
40
  end
43
41
  end
44
42
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 29
9
- version: 1.0.29
8
+ - 30
9
+ version: 1.0.30
10
10
  platform: java
11
11
  authors:
12
12
  - Mike Sassak
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-18 00:00:00 +02:00
19
+ date: 2010-05-20 00:00:00 +02:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,20 @@ dependencies:
47
47
  version: 1.3.0
48
48
  type: :development
49
49
  version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: cucumber
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ - 7
60
+ - 2
61
+ version: 0.7.2
62
+ type: :development
63
+ version_requirements: *id003
50
64
  description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
51
65
  email: cukes@googlegroups.com
52
66
  executables:
@@ -94,7 +108,10 @@ files:
94
108
  - lib/gherkin/i18n.rb
95
109
  - lib/gherkin/i18n.yml
96
110
  - lib/gherkin/i18n_lexer.rb
97
- - lib/gherkin/java_impl.rb
111
+ - lib/gherkin/native.rb
112
+ - lib/gherkin/native/ikvm.rb
113
+ - lib/gherkin/native/java.rb
114
+ - lib/gherkin/native/null.rb
98
115
  - lib/gherkin/parser/event.rb
99
116
  - lib/gherkin/parser/filter_listener.rb
100
117
  - lib/gherkin/parser/meta.txt
@@ -1,43 +0,0 @@
1
- class Class
2
- # Causes a Java class to be instantiated instead of the Ruby class when
3
- # running on JRuby. This is used to test both pure Java and pure Ruby classes
4
- # from the same Ruby based test suite. The Java Class must have a package name
5
- # that corresponds with the Ruby class.
6
- def java_impl(jar)
7
- if defined?(JRUBY_VERSION)
8
- require jar
9
- class << self
10
- def javaify(arg)
11
- if Array === arg
12
- arg.map{|a| javaify(a)}
13
- else
14
- case(arg)
15
- when Regexp
16
- java.util.regex.Pattern.compile(arg.source)
17
- else
18
- arg
19
- end
20
- end
21
- end
22
-
23
- def new(*args)
24
- java_class.new(*javaify(args))
25
- end
26
-
27
- def ===(object)
28
- super || object.java_kind_of?(java_class)
29
- end
30
-
31
- def java_class
32
- names = self.name.split('::')
33
- package = Java
34
- names[0..-2].each do |module_name|
35
- package = package.__send__(module_name.downcase)
36
- end
37
-
38
- package.__send__(names[-1])
39
- end
40
- end
41
- end
42
- end
43
- end