Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Added MaMa documentation.

  • Loading branch information...
commit ca7b64b38aed5d02a9642cac38435acc95533026 1 parent 8be2888
dichodaemon dichodaemon authored
Showing with 161 additions and 32 deletions.
  1. +53 −27 Rakefile
  2. +7 −5 ext/oregexp.c
  3. +101 −0 mm/manual.mm
80 Rakefile
View
@@ -1,41 +1,67 @@
require 'rubygems'
require 'hoe'
-class Hoe
- # Dirty hack to eliminate Hoe from gem dependencies
- def extra_deps
- @extra_deps.delete_if{ |x| x.first == 'hoe' }
+rubyforge_name = "oniguruma"
+
+begin
+
+ class Hoe
+ # Dirty hack to eliminate Hoe from gem dependencies
+ def extra_deps
+ @extra_deps.delete_if{ |x| x.first == 'hoe' }
+ end
+
+ # Dirty hack to package only the required files per platform
+ def spec= s
+ if ENV['PLATFORM'] =~ /win32/
+ s.files = s.files.reject! {|f| f =~ /extconf\.rb/}
+ else
+ s.files = s.files.reject! {|f| f =~ /win\//}
+ end
+ @spec = s
+ end
end
- # Dirty hack to package only the required files per platform
- def spec= s
+ version = /^== *(\d+\.\d+\.\d+)/.match( File.read( 'History.txt' ) )[1]
+
+ h = Hoe.new('oniguruma', version) do |p|
+ p.rubyforge_name = 'oniguruma'
+ p.author = ['Dizan Vasquez', 'Nikolai Lugovoi']
+ p.email = 'dichodaemon@gmail.com'
+ p.summary = 'Bindings for the oniguruma regular expression library'
+ p.description = p.paragraphs_of('README.txt', 1 ).join('\n\n')
+ p.url = 'http://oniguruma.rubyforge.org'
if ENV['PLATFORM'] =~ /win32/
- s.files = s.files.reject! {|f| f =~ /extconf\.rb/}
+ p.lib_files = ["win/oregexp.so"]
+ p.spec_extras[:require_paths] = ["win", "lib", "ext" ]
+ p.spec_extras[:platform] = Gem::Platform::WIN32
else
- s.files = s.files.reject! {|f| f =~ /win\//}
+ p.spec_extras[:extensions] = ["ext/extconf.rb"]
end
- @spec = s
+ p.rdoc_pattern = /^(lib|bin|ext)|txt$/
+ p.changes = p.paragraphs_of('History.txt', 0).join("\n\n")
+ p.clean_globs = ["manual/*"]
end
-end
-version = /^== *(\d+\.\d+\.\d+)/.match( File.read( 'History.txt' ) )[1]
+ desc 'Create MaMa documentation'
+ task :mama => :clean do
+ system "mm -c -t refresh -o manual mm/manual.mm"
+ end
+
+ desc 'Publish MaMa documentation to RubyForge'
+ task :mama_publish => [:clean, :mama] do
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
+ host = "#{config["username"]}@rubyforge.org"
+ remote_dir = "/var/www/gforge-projects/#{h.rubyforge_name}"
+ local_dir = 'manual'
+ system "rsync -av #{local_dir}/ #{host}:#{remote_dir}"
+ end
-Hoe.new('oniguruma', version) do |p|
- p.rubyforge_name = 'oniguruma'
- p.author = ['Dizan Vasquez', 'Nikolai Lugovoi']
- p.email = 'dichodaemon@gmail.com'
- p.summary = 'Bindings for the oniguruma regular expression library'
- p.description = p.paragraphs_of('README.txt', 1 ).join('\n\n')
- p.url = 'http://oniguruma.rubyforge.org'
- if ENV['PLATFORM'] =~ /win32/
- p.lib_files = ["win/oregexp.so"]
- p.spec_extras[:require_paths] = ["win", "lib", "ext" ]
- p.spec_extras[:platform] = Gem::Platform::WIN32
- else
- p.spec_extras[:extensions] = ["ext/extconf.rb"]
- end
- p.rdoc_pattern = /^(lib|bin|ext)|txt$/
- p.changes = p.paragraphs_of('History.txt', 0).join("\n\n")
+rescue LoadError => e
+ desc 'Run the test suite.'
+ task :test do
+ system "ruby -Ibin:lib:test test_#{rubyforge_name}.rb"
+ end
end
12 ext/oregexp.c
View
@@ -179,7 +179,7 @@ static VALUE oregexp_make_match_data(ORegexp * oregexp, OnigRegion * region, VAL
return (VALUE)match;
}
-/*
+/**
* call-seq:
* rxp.match(str) => matchdata or nil
* rxp.match(str, begin, end) => matchdata or nil
@@ -588,7 +588,7 @@ static VALUE oregexp_m_gsub_bang(int argc, VALUE *argv, VALUE self) {
* Performs the substitutions of ORegexp#sub in place, returning
* _str_, or _nil_ if no substitutions were performed.
*
- **/
+ */
static VALUE oregexp_m_sub_bang(int argc, VALUE *argv, VALUE self) {
return oregexp_safe_gsub(self, argc, argv, 1, 1);
}
@@ -653,6 +653,7 @@ struct scan_packet {
static VALUE oregexp_packed_scan( struct scan_packet * args) {
return oregexp_scan(args->self, args->str, args->region);
}
+
/**
* call-seq:
* rxp.scan(str) # => [matchdata1, matchdata2,...] or nil
@@ -671,7 +672,6 @@ static VALUE oregexp_m_scan(VALUE self, VALUE str) {
return rb_ensure( oregexp_packed_scan, (VALUE)&call_args, oregexp_cleanup_region, (VALUE)region);
}
-
/**
* call-seq:
* rxp === str => true or false
@@ -708,7 +708,8 @@ static VALUE oregexp_m_eqq(VALUE self, VALUE str) {
}
return Qtrue;
}
-/*
+
+/**
* call-seq:
* rxp =~ string => int or nil
*
@@ -718,7 +719,8 @@ static VALUE oregexp_m_eqq(VALUE self, VALUE str) {
*
* ORegexp.new( 'SIT' ) =~ "insensitive" #=> nil
* ORegexp.new( 'SIT', :options => OPTION_IGNORECASE ) =~ "insensitive" #=> 5
-**/
+*/
+
static VALUE oregexp_match_op(VALUE self, VALUE str) {
VALUE args[] = {str};
VALUE ret = oregexp_match(1, args, self);
101 mm/manual.mm
View
@@ -0,0 +1,101 @@
+~Oniguruma for Ruby~
+~~Ruby bindings for oniguruma~~
+
+#Main# | index
+
+= About =
+
+This library provides bindings to [Oniguruma http://www.geocities.jp/kosako3/oniguruma/],
+a regular expression library which is standard with Ruby 1.9. It allows users
+of Ruby 1.8 to access the extended functionality without the need to recompile
+or to upgrade Ruby.
+
+This site provides an overview of the library, the api documentation is
+[here http://oniguruma.rubyforge.org/oniguruma].
+
+= Requirements =
+
+* [Oniguruma http://www.geocities.jp/kosako3/oniguruma/] regular expression library (/>= 4.x.x/)
+
+= Installation =
+
+If you have [rubygems http://docs.rubygems.org/] installation is straightforward by typing
+(as root if needed):
+
+--------hl shell-unix-generic,,false------
+gem install -r oniguruma
+------------------------------------------
+
+If you prefer to get the sources, the last stable version may be
+downloaded [here http://rubyforge.org/frs/?group_id=3289].
+
+= Status =
+
+The library interface is mature. Existing bugs are being fixed as they are
+found.
+
+#Use#
+
+= Details =
+
+Oniguruma provides the same functionality (and almost the same interface) than
+standard regexp in Ruby. The main missing feature is the slash syntax to
+declare regular expressions `/regexp/`. On the other hand, oniguruma provides
+additional functionality:
+
+* Extensive multibyte support.
+ -----------hl ruby,,false-----
+ reg = ORegexp.new( 'р(уби.*)', 'i', 'utf8' )
+ matches = reg.match("Text: Ехал Грека Через Реку")
+ puts matches[0] #=> "Ехал"
+ ------------------------------
+
+* Named groups.
+ -----------hl ruby,,false-----
+ reg = ORegex.new( '(?<before>.*)(a)(?<after>.*)' )
+ match = reg.match( 'terraforming' )
+ puts match[0] #=> 'terraforming'
+ puts match[:before] #=> 'terr'
+ puts match[:after] #=> 'forming'
+ ------------------------------
+
+* Named backreferences.
+ -----------hl ruby,,false-----
+ re = ORegexp.new('(?<pre>\w+?)\d+(?<after>\w+)')
+ puts re.sub('abc123def', ' \<after>123\<pre> ') #=> " def123abc "
+ ------------------------------
+
+* Positive and negative Lookbehind.
+ -----------hl ruby,,false-----
+ re = ORegexp.new('(?>!g)ong')
+ m1 = re.match("song")
+ puts m1[0] #=> ong
+ m2 = re.match("gong") #=> nil
+ ------------------------------
+
+* Support for different regexp syntaxes (Python, Perl, etc.).
+ -----------hl ruby,,false-----
+ re = ORegexp.new( 'section{ (?P<name> [^}]* ) }', :syntax => SYNTAX_PYTHON )
+ re.sub('section{First}', 'subsection{\1}') #=> "subsection{First}"
+ ------------------------------
+
+# Links #
+
+
+= Rubyforge project page =
+
+* [Textpow http://rubyforge.org/projects/oniguruma].
+
+= Documentation =
+
+* [Api Documentation http://oniguruma.rubyforge.org/oniguruma].
+
+= Requirements =
+
+* [Oniguruma http://www.geocities.jp/kosako3/oniguruma/].
+
+= Projects using Textpow =
+
+* [Textpow http://textpow.rubyforge.org/].
+* [Ultraviolet Syntax Highlighting Engine http://ultraviolet.rubyforge.org/].
+* [Macaronic markup engine http://mama.rubyforge.org/].
Please sign in to comment.
Something went wrong with that request. Please try again.