foma 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/ext/foma.c +26 -13
- data/foma.gemspec +17 -11
- data/test/test_foma.rb +1 -0
- metadata +23 -43
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.2.0
         | 
    
        data/ext/foma.c
    CHANGED
    
    | @@ -3,6 +3,10 @@ | |
| 3 3 |  | 
| 4 4 | 
             
            /*:enddoc:*/
         | 
| 5 5 |  | 
| 6 | 
            +
            #ifndef RSTRING_PTR /* Ruby 1.8 compatibility */
         | 
| 7 | 
            +
            #define RSTRING_PTR(ptr) RSTRING(ptr)->ptr
         | 
| 8 | 
            +
            #endif
         | 
| 9 | 
            +
             | 
| 6 10 | 
             
            VALUE mFOMA = Qnil;
         | 
| 7 11 | 
             
            VALUE mFSM = Qnil;
         | 
| 8 12 |  | 
| @@ -18,8 +22,8 @@ static void foma_fsm_mark(struct foma_fsm *t) | |
| 18 22 | 
             
            static void foma_fsm_free(struct foma_fsm *t)
         | 
| 19 23 | 
             
            {
         | 
| 20 24 | 
             
              if (t) {
         | 
| 21 | 
            -
                fsm_destroy(t->net);
         | 
| 22 25 | 
             
                apply_clear(t->ah);
         | 
| 26 | 
            +
                fsm_destroy(t->net);
         | 
| 23 27 | 
             
                free(t);
         | 
| 24 28 | 
             
              }
         | 
| 25 29 | 
             
            }
         | 
| @@ -38,24 +42,23 @@ static VALUE foma_fsm_init(VALUE obj, VALUE filename) | |
| 38 42 |  | 
| 39 43 | 
             
              t = malloc(sizeof(struct foma_fsm));
         | 
| 40 44 |  | 
| 41 | 
            -
              if (!t) | 
| 42 | 
            -
                rb_raise(rb_eRuntimeError, " | 
| 43 | 
            -
              }
         | 
| 45 | 
            +
              if (!t)
         | 
| 46 | 
            +
                rb_raise(rb_eRuntimeError, "error allocating memory");
         | 
| 44 47 |  | 
| 45 | 
            -
              file = fopen( | 
| 48 | 
            +
              file = fopen(RSTRING_PTR(filename), "rb");
         | 
| 46 49 |  | 
| 47 50 | 
             
              if (!file) {
         | 
| 48 51 | 
             
                free(t);
         | 
| 49 | 
            -
                rb_raise(rb_eRuntimeError, " | 
| 52 | 
            +
                rb_raise(rb_eRuntimeError, "unable to open file");
         | 
| 50 53 | 
             
              }
         | 
| 51 54 |  | 
| 52 55 | 
             
              fclose(file);
         | 
| 53 56 |  | 
| 54 | 
            -
              t->net = fsm_read_binary_file( | 
| 57 | 
            +
              t->net = fsm_read_binary_file(RSTRING_PTR(filename));
         | 
| 55 58 |  | 
| 56 59 | 
             
              if (!t->net) {
         | 
| 57 60 | 
             
                free(t);
         | 
| 58 | 
            -
                rb_raise(rb_eRuntimeError, " | 
| 61 | 
            +
                rb_raise(rb_eRuntimeError, "unable to read file");
         | 
| 59 62 | 
             
              }
         | 
| 60 63 |  | 
| 61 64 | 
             
              t->ah = apply_init(t->net);
         | 
| @@ -66,6 +69,7 @@ static VALUE foma_fsm_init(VALUE obj, VALUE filename) | |
| 66 69 |  | 
| 67 70 | 
             
            static VALUE foma_fsm_apply(VALUE self, VALUE string, char *(*applyer)())
         | 
| 68 71 | 
             
            {
         | 
| 72 | 
            +
              int enc = rb_enc_find_index("UTF-8");
         | 
| 69 73 | 
             
              struct foma_fsm *t;
         | 
| 70 74 | 
             
              char *result;
         | 
| 71 75 |  | 
| @@ -73,14 +77,23 @@ static VALUE foma_fsm_apply(VALUE self, VALUE string, char *(*applyer)()) | |
| 73 77 |  | 
| 74 78 | 
             
              Data_Get_Struct(self, struct foma_fsm, t);
         | 
| 75 79 |  | 
| 76 | 
            -
              result = applyer(t->ah,  | 
| 80 | 
            +
              result = applyer(t->ah, RSTRING_PTR(string));
         | 
| 77 81 |  | 
| 78 82 | 
             
              if (result) {
         | 
| 79 83 | 
             
                if (rb_block_given_p()) {
         | 
| 80 | 
            -
                   | 
| 81 | 
            -
             | 
| 82 | 
            -
                   | 
| 83 | 
            -
             | 
| 84 | 
            +
                  VALUE string = rb_str_new2(result);
         | 
| 85 | 
            +
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 86 | 
            +
                  rb_enc_associate_index(string, enc);
         | 
| 87 | 
            +
            #endif
         | 
| 88 | 
            +
                  rb_yield(string);
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  while (result = applyer(t->ah, NULL)) {
         | 
| 91 | 
            +
                    VALUE string = rb_str_new2(result);
         | 
| 92 | 
            +
            #ifdef HAVE_RUBY_ENCODING_H
         | 
| 93 | 
            +
                    rb_enc_associate_index(string, enc);
         | 
| 94 | 
            +
            #endif
         | 
| 95 | 
            +
                    rb_yield(string);
         | 
| 96 | 
            +
                  }
         | 
| 84 97 | 
             
                }
         | 
| 85 98 |  | 
| 86 99 | 
             
                return Qtrue;
         | 
    
        data/foma.gemspec
    CHANGED
    
    | @@ -4,31 +4,37 @@ | |
| 4 4 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 | 
            -
              s.name =  | 
| 8 | 
            -
              s.version = "0. | 
| 7 | 
            +
              s.name = "foma"
         | 
| 8 | 
            +
              s.version = "0.2.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            -
              s.authors = ["Marius L. J\ | 
| 12 | 
            -
              s.date =  | 
| 13 | 
            -
              s.description =  | 
| 14 | 
            -
              s.email =  | 
| 11 | 
            +
              s.authors = ["Marius L. J\u{f8}hndal"]
         | 
| 12 | 
            +
              s.date = "2012-01-26"
         | 
| 13 | 
            +
              s.description = "A wrapper for the FOMA finite state library"
         | 
| 14 | 
            +
              s.email = "mariuslj (at) ifi [dot] uio (dot) no"
         | 
| 15 | 
            +
              s.extensions = ["ext/extconf.rb"]
         | 
| 15 16 | 
             
              s.extra_rdoc_files = [
         | 
| 16 17 | 
             
                "README.rdoc"
         | 
| 17 18 | 
             
              ]
         | 
| 18 19 | 
             
              s.files = [
         | 
| 19 20 | 
             
                "CHANGELOG",
         | 
| 21 | 
            +
                "README.rdoc",
         | 
| 22 | 
            +
                "Rakefile",
         | 
| 23 | 
            +
                "VERSION",
         | 
| 24 | 
            +
                "ext/extconf.rb",
         | 
| 20 25 | 
             
                "ext/foma.c",
         | 
| 21 26 | 
             
                "foma.gemspec",
         | 
| 27 | 
            +
                "test/.gitignore",
         | 
| 28 | 
            +
                "test/test_foma.bin",
         | 
| 22 29 | 
             
                "test/test_foma.rb"
         | 
| 23 30 | 
             
              ]
         | 
| 24 | 
            -
              s.homepage =  | 
| 31 | 
            +
              s.homepage = "http://github.com/mlj/ruby-foma"
         | 
| 25 32 | 
             
              s.require_paths = ["lib"]
         | 
| 26 | 
            -
              s.rubyforge_project =  | 
| 27 | 
            -
              s.rubygems_version =  | 
| 28 | 
            -
              s.summary =  | 
| 33 | 
            +
              s.rubyforge_project = "foma"
         | 
| 34 | 
            +
              s.rubygems_version = "1.8.11"
         | 
| 35 | 
            +
              s.summary = "FOMA finite state library interface"
         | 
| 29 36 |  | 
| 30 37 | 
             
              if s.respond_to? :specification_version then
         | 
| 31 | 
            -
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 32 38 | 
             
                s.specification_version = 3
         | 
| 33 39 |  | 
| 34 40 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
    
        data/test/test_foma.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,34 +1,26 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: foma
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 5 | 
            -
              prerelease:  | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 0
         | 
| 8 | 
            -
              - 1
         | 
| 9 | 
            -
              - 0
         | 
| 10 | 
            -
              version: 0.1.0
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 11 6 | 
             
            platform: ruby
         | 
| 12 | 
            -
            authors: | 
| 13 | 
            -
            -  | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Marius L. Jøhndal
         | 
| 14 9 | 
             
            autorequire: 
         | 
| 15 10 | 
             
            bindir: bin
         | 
| 16 11 | 
             
            cert_chain: []
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            date: 2011-10-05 00:00:00 +01:00
         | 
| 19 | 
            -
            default_executable: 
         | 
| 12 | 
            +
            date: 2012-01-26 00:00:00.000000000 Z
         | 
| 20 13 | 
             
            dependencies: []
         | 
| 21 | 
            -
             | 
| 22 14 | 
             
            description: A wrapper for the FOMA finite state library
         | 
| 23 15 | 
             
            email: mariuslj (at) ifi [dot] uio (dot) no
         | 
| 24 16 | 
             
            executables: []
         | 
| 25 | 
            -
             | 
| 26 | 
            -
            extensions: 
         | 
| 17 | 
            +
            extensions:
         | 
| 27 18 | 
             
            - ext/extconf.rb
         | 
| 28 | 
            -
            extra_rdoc_files: | 
| 19 | 
            +
            extra_rdoc_files:
         | 
| 29 20 | 
             
            - README.rdoc
         | 
| 30 | 
            -
            files: | 
| 21 | 
            +
            files:
         | 
| 31 22 | 
             
            - CHANGELOG
         | 
| 23 | 
            +
            - README.rdoc
         | 
| 32 24 | 
             
            - Rakefile
         | 
| 33 25 | 
             
            - VERSION
         | 
| 34 26 | 
             
            - ext/extconf.rb
         | 
| @@ -37,40 +29,28 @@ files: | |
| 37 29 | 
             
            - test/.gitignore
         | 
| 38 30 | 
             
            - test/test_foma.bin
         | 
| 39 31 | 
             
            - test/test_foma.rb
         | 
| 40 | 
            -
            - README.rdoc
         | 
| 41 | 
            -
            has_rdoc: true
         | 
| 42 32 | 
             
            homepage: http://github.com/mlj/ruby-foma
         | 
| 43 33 | 
             
            licenses: []
         | 
| 44 | 
            -
             | 
| 45 34 | 
             
            post_install_message: 
         | 
| 46 35 | 
             
            rdoc_options: []
         | 
| 47 | 
            -
             | 
| 48 | 
            -
            require_paths: 
         | 
| 36 | 
            +
            require_paths:
         | 
| 49 37 | 
             
            - lib
         | 
| 50 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 38 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 51 39 | 
             
              none: false
         | 
| 52 | 
            -
              requirements: | 
| 53 | 
            -
              - -  | 
| 54 | 
            -
                - !ruby/object:Gem::Version | 
| 55 | 
            -
                   | 
| 56 | 
            -
             | 
| 57 | 
            -
                  - 0
         | 
| 58 | 
            -
                  version: "0"
         | 
| 59 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 40 | 
            +
              requirements:
         | 
| 41 | 
            +
              - - ! '>='
         | 
| 42 | 
            +
                - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                  version: '0'
         | 
| 44 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 60 45 | 
             
              none: false
         | 
| 61 | 
            -
              requirements: | 
| 62 | 
            -
              - -  | 
| 63 | 
            -
                - !ruby/object:Gem::Version | 
| 64 | 
            -
                   | 
| 65 | 
            -
                  segments: 
         | 
| 66 | 
            -
                  - 0
         | 
| 67 | 
            -
                  version: "0"
         | 
| 46 | 
            +
              requirements:
         | 
| 47 | 
            +
              - - ! '>='
         | 
| 48 | 
            +
                - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                  version: '0'
         | 
| 68 50 | 
             
            requirements: []
         | 
| 69 | 
            -
             | 
| 70 51 | 
             
            rubyforge_project: foma
         | 
| 71 | 
            -
            rubygems_version: 1. | 
| 52 | 
            +
            rubygems_version: 1.8.11
         | 
| 72 53 | 
             
            signing_key: 
         | 
| 73 54 | 
             
            specification_version: 3
         | 
| 74 55 | 
             
            summary: FOMA finite state library interface
         | 
| 75 56 | 
             
            test_files: []
         | 
| 76 | 
            -
             |