Permalink
Browse files

Added lib/citrus/grammars.rb

Also, moved all example grammars and tests into the main library tree so
that they may easily be used by client code.
  • Loading branch information...
1 parent 303244b commit 983e0e7bf2cb16fbcf64628754105c8c8aa82996 @mjackson committed May 12, 2011
View
@@ -6,7 +6,7 @@ task :default => :test
# TESTS #######################################################################
Rake::TestTask.new(:test) do |t|
- t.test_files = FileList['test/*_test.rb'] + FileList['examples/*_test.rb']
+ t.test_files = FileList['test/**/*_test.rb']
end
# DOCS ########################################################################
View
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
s.files = Dir['benchmark/**'] +
Dir['doc/**'] +
- Dir['examples/**'] +
Dir['extras/**'] +
Dir['lib/**/*.rb'] +
Dir['test/**/*'] +
@@ -0,0 +1,11 @@
+# Require this file to use any of the bundled Citrus grammars.
+#
+# require 'citrus/grammars'
+# Citrus.require 'uri'
+#
+# match = UniformResourceIdentifier.parse(uri_string)
+# # => #<Citrus::Match ... >
+
+require 'citrus'
+
+$LOAD_PATH.unshift(::File.expand_path('../grammars', __FILE__))
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,7 @@
-# This file contains a suite of tests for the Calc grammar found in calc.citrus.
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-require 'citrus'
-Citrus.require File.expand_path('../calc', __FILE__)
-require 'test/unit'
+Citrus.require 'calc'
class CalcTest < Test::Unit::TestCase
# A helper method that tests the successful parsing and evaluation of the
@@ -1,9 +1,7 @@
-# This file contains a suite of tests for the EmailAddress grammar
-# found in email.citrus.
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-require 'citrus'
-Citrus.require File.expand_path('../email', __FILE__)
-require 'test/unit'
+Citrus.require 'email'
class EmailAddressTest < Test::Unit::TestCase
def test_addr_spec_valid
@@ -1,12 +1,7 @@
-examples = File.expand_path('..', __FILE__)
-$LOAD_PATH.unshift(examples) unless $LOAD_PATH.include?(examples)
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-# This file contains a suite of tests for the IPAddress grammar found in
-# ipaddress.citrus.
-
-require 'citrus'
Citrus.require 'ipaddress'
-require 'test/unit'
class IPAddressTest < Test::Unit::TestCase
def test_v4
@@ -1,12 +1,7 @@
-examples = File.expand_path('..', __FILE__)
-$LOAD_PATH.unshift(examples) unless $LOAD_PATH.include?(examples)
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-# This file contains a suite of tests for the IPv4Address grammar found in
-# ipv4address.citrus.
-
-require 'citrus'
Citrus.require 'ipv4address'
-require 'test/unit'
class IPv4AddressTest < Test::Unit::TestCase
def test_dec_octet
@@ -1,12 +1,7 @@
-examples = File.expand_path('..', __FILE__)
-$LOAD_PATH.unshift(examples) unless $LOAD_PATH.include?(examples)
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-# This file contains a suite of tests for the IPv6Address grammar found in
-# ipv6address.citrus.
-
-require 'citrus'
Citrus.require 'ipv6address'
-require 'test/unit'
class IPv6AddressTest < Test::Unit::TestCase
def test_hexdig
@@ -1,12 +1,7 @@
-examples = File.expand_path('..', __FILE__)
-$LOAD_PATH.unshift(examples) unless $LOAD_PATH.include?(examples)
+require File.expand_path('../../helper', __FILE__)
+require 'citrus/grammars'
-# This file contains a suite of tests for the UniformResourceIdentifier grammar
-# found in uri.citrus.
-
-require 'citrus'
Citrus.require 'uri'
-require 'test/unit'
class UniformResourceIdentifierTest < Test::Unit::TestCase
U = UniformResourceIdentifier

0 comments on commit 983e0e7

Please sign in to comment.