gettextpo 0.1.1 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ac67f013230155611dd5bd8f673a19eb8d84153dbc3240e3f0849a3a78ebf9d
4
- data.tar.gz: 5c3d1ac85ab300ccd98b798948448b64be26d1b69c055b0ec1e11c08641209d9
3
+ metadata.gz: c2eb5f08e68980571ccd30f9bb661e776084f6f87766e9180567b4501b038c3d
4
+ data.tar.gz: b22296f8b7d74673c8328c556acb0cdf59e369c19ec281ca0914b5cbec50817c
5
5
  SHA512:
6
- metadata.gz: 5cd5653bdff4094cbf3b14f57ae30b224ae0a20b775cf072ef008bf851e8fce4f129c8ffeb9071d271223c70c78035d717d82d70f8f00f32d1a2fe5c2ffae4d3
7
- data.tar.gz: 77e26a94e04627ba399495819e25972b6dca2a9742e27e8c6ae9f5fff5032a3987f64e003707631c6a13ce38c4694a9d5a5692179a7e938d40023288d5965aa2
6
+ metadata.gz: d0d2f86a241e358acd074ed86460072382cc7331afdaedae52f711e050b3442cb65e0bdee28d3cdd7967039bd4119f4d4713788dbd9feb8db390ec5ca5956e05
7
+ data.tar.gz: 5aca003840bf9bba6f601c8faea83a3c16dcbbb9eaec1d6baf27bba2f25c4f8d80f265d36e7fd4caeaf20c9ea9ed802ae7c4fbf0ac44ca6d85a899c0405f1c69
data/.env.example ADDED
@@ -0,0 +1,2 @@
1
+ MRUBY_SRC=/path/to/mruby
2
+ DEVELOP_MRUBY=no
data/.envrc CHANGED
@@ -1,3 +1,18 @@
1
+ # Copyright (C) 2026 gemmaro
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
1
16
  use guix \
2
17
  clang \
3
18
  gcc-toolchain \
@@ -7,5 +22,17 @@ use guix \
7
22
  gettext \
8
23
  gdb
9
24
 
10
- path_add C_INCLUDE_PATH "$(ruby -e "puts RbConfig::CONFIG['rubyhdrdir']")"
11
- path_add C_INCLUDE_PATH "$(ruby -e "puts RbConfig::CONFIG['rubyarchhdrdir']")"
25
+ dotenv
26
+
27
+ if [ "$DEVELOP_MRUBY" != 'yes' ]
28
+ then
29
+ # CRuby
30
+ path_add C_INCLUDE_PATH "$(ruby -e "puts RbConfig::CONFIG['rubyhdrdir']")"
31
+ path_add C_INCLUDE_PATH "$(ruby -e "puts RbConfig::CONFIG['rubyarchhdrdir']")"
32
+ else
33
+ # mruby
34
+ env_vars_required MRUBY_SRC
35
+ path_add C_INCLUDE_PATH include
36
+ path_add C_INCLUDE_PATH "$MRUBY_SRC/include"
37
+ path_add C_INCLUDE_PATH "$MRUBY_SRC/build/host/include"
38
+ fi
data/.rdoc_options CHANGED
@@ -5,3 +5,8 @@ exclude:
5
5
  - Rakefile
6
6
  - Gemfile
7
7
  - vendor
8
+ - test.cruby/**/*
9
+ - build_config.rb.lock
10
+ - mrbgem.rake
11
+ - mrblib/mrb_gettextpo.rb
12
+ - mrblib/mrb_gettextpo_version.rb
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## CRuby version 0.1.3
6
+
7
+ - CRuby: Fix file not found case.
8
+
9
+ ## CRuby version 0.1.2 and mruby version 0.1.0 - 2026-03-11
10
+
11
+ - Add mruby version.
12
+ - CRuby: Fix exception error 2 handling.
13
+
5
14
  ## 0.1.1 - 2026-03-09
6
15
 
7
16
  - Fix dangling pointer issue.
data/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  This is a Ruby library for the GNU gettext PO files. This is a C
4
4
  binding of the libgettextpo library, which is provided by the GNU
5
- gettext package. It is designed to promote Ruby's idiomatic coding
6
- style while avoiding memory leaks.
5
+ gettext package. The API of this gem is designed to promote Ruby's
6
+ idiomatic coding style while paying attensiton to memory safety.
7
+ Currently this supports both CRuby and mruby.
7
8
 
8
9
  ## Installation
9
10
 
@@ -23,17 +24,22 @@ apt search libgettextpo
23
24
  # process PO files - shared library
24
25
  ```
25
26
 
26
- Install the gem and add to the application's `Gemfile` by executing:
27
+ For CRuby:
27
28
 
28
- ```bash
29
- bundle add gettextpo
30
- ```
29
+ * Install the gem and add to the application's `Gemfile` by executing:
31
30
 
32
- If Bundler is not being used to manage dependencies, install the gem by executing:
31
+ ```bash
32
+ bundle add gettextpo
33
+ ```
33
34
 
34
- ```bash
35
- gem install gettextpo
36
- ```
35
+ * If Bundler is not being used to manage dependencies, install the gem by executing:
36
+
37
+ ```bash
38
+ gem install gettextpo
39
+ ```
40
+
41
+ For mruby, modify `build_config.rb` as you like, set `MRUBY_SRC` to
42
+ mruby source repository, and run `./bin/compile` or `./bin/test`.
37
43
 
38
44
  ## Usage
39
45
 
@@ -56,14 +62,12 @@ end
56
62
  ```
57
63
 
58
64
  Please refer to the [API documentation][api] and test cases for
59
- details.
65
+ details. The mruby version has same API.
60
66
 
61
67
  [api]: https://gemmaro.github.io/ruby-gettextpo/
62
68
 
63
69
  ## Development
64
70
 
65
- `./bin/debug` to debug when segmentation fault.
66
-
67
71
  After checking out the repo, run `bin/setup` to install
68
72
  dependencies. Then, run `rake test` to run the tests. You can also run
69
73
  `bin/console` for an interactive prompt that will allow you to
@@ -75,6 +79,42 @@ install`. To release a new version, update the version number in
75
79
  create a git tag for the version, push git commits and the created
76
80
  tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
81
 
82
+ File structure:
83
+
84
+ ```text
85
+ bin : script ifles
86
+ build_config.rb : for mruby
87
+ * build_config.rb.lock
88
+ CHANGELOG.md
89
+ COPYING
90
+ * doc : generated by RDoc from CRuby sources
91
+ ext : for CRuby
92
+ Gemfile : for CRuby
93
+ gettextpo.gemspec : for CRuby
94
+ include : for mruby
95
+ lib : for CRuby
96
+ mrbgem.rake : for mruby
97
+ mrblib : for mruby
98
+ * pkg : generated by RubyGem
99
+ Rakefile : for CRuby
100
+ README.md
101
+ - sample.rb : for debug purpose especially with GDB
102
+ sig : for CRuby
103
+ src : for mruby
104
+ test : common test cases for both CRuby and mruby
105
+ test.cruby : CRuby specific tests
106
+ * tmp
107
+ - .env
108
+ .env.example
109
+ .envrc : Direnv config
110
+ .clang-format
111
+ .dir-locals.el : Emacs config
112
+ .gitignore
113
+
114
+ * generated files
115
+ - ignored by version control
116
+ ```
117
+
78
118
  ## Contributing
79
119
 
80
120
  Bug reports and pull requests are welcome on [Disroot][disroot].
data/Rakefile CHANGED
@@ -19,9 +19,9 @@ require "bundler/gem_tasks"
19
19
  require "rake/testtask"
20
20
 
21
21
  Rake::TestTask.new(:test) do |t|
22
- t.libs << "test"
22
+ t.libs << "test.cruby"
23
23
  t.libs << "lib"
24
- t.test_files = FileList["test/**/*_test.rb"]
24
+ t.test_files = FileList["test.cruby/**/*_test.rb"]
25
25
  end
26
26
 
27
27
  require "rake/extensiontask"
data/build_config.rb ADDED
@@ -0,0 +1,27 @@
1
+ # Copyright (C) 2026 gemmaro
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ MRuby::Build.new do |conf|
17
+ toolchain :gcc
18
+ conf.gem File.expand_path(File.dirname(__FILE__))
19
+ conf.linker.libraries << 'gettextpo'
20
+ conf.enable_test
21
+ conf.gem core: 'hal-posix-io'
22
+ conf.gem core: 'mruby-bin-mruby'
23
+ conf.gem core: 'mruby-bin-mirb'
24
+ conf.cc do |cc|
25
+ cc.flags << '-O0'
26
+ end
27
+ end
@@ -14,13 +14,6 @@
14
14
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
15
15
  */
16
16
 
17
- #include "gettextpo.h"
18
-
19
- VALUE rb_cMessage;
20
- VALUE rb_cMessageIterator;
21
- VALUE rb_cFilePos;
22
- VALUE rb_eError;
23
-
24
17
  /* FilePos, Message, and MessageIterator each hold a @file instance
25
18
  * variable (ivar) pointing to the GettextPO::File object that owns
26
19
  * the underlying po_file_t. This prevents the File object from being
@@ -30,6 +23,19 @@ VALUE rb_eError;
30
23
  * the parent object: File -> MessageIterator -> Message -> FilePos.
31
24
  */
32
25
 
26
+ #include "gettextpo.h"
27
+ #include <gettext-po.h>
28
+ #include <ruby/internal/core/rdata.h>
29
+ #include <ruby/internal/intern/variable.h>
30
+
31
+ #define ERROR \
32
+ rb_const_get (rb_const_get (rb_cObject, rb_intern ("GettextPO")), \
33
+ rb_intern ("Error"))
34
+
35
+ VALUE rb_cMessage;
36
+ VALUE rb_cMessageIterator;
37
+ VALUE rb_cFilePos;
38
+
33
39
  /* ********** error ********** */
34
40
 
35
41
  static struct
@@ -146,7 +152,7 @@ gettextpo_xerror2 (const int severity, const po_message_t message1,
146
152
  rb_str_new_cstr (message_text2));
147
153
  VALUE args = rb_ary_new ();
148
154
  rb_ary_push (args, kwargs);
149
- rb_proc_call_kw (*gettextpo_xerror_context.user_xerror, args,
155
+ rb_proc_call_kw (*gettextpo_xerror_context.user_xerror2, args,
150
156
  RB_PASS_KEYWORDS);
151
157
  if (severity == PO_SEVERITY_FATAL_ERROR)
152
158
  abort ();
@@ -415,7 +421,7 @@ gettextpo_po_message_m_format_set (int argc, VALUE *argv, VALUE self)
415
421
  bool opposite = !RB_UNDEF_P (kwargs_vals[0]) && RB_TEST (kwargs_vals[0]);
416
422
  bool remove = !RB_UNDEF_P (kwargs_vals[1]) && RB_TEST (kwargs_vals[1]);
417
423
  if (opposite && remove)
418
- rb_raise (rb_eError, "opposite and remove cannot be set at the same time");
424
+ rb_raise (ERROR, "opposite and remove cannot be set at the same time");
419
425
  po_message_set_format (DATA_PTR (self), StringValueCStr (format),
420
426
  opposite ? 0 : (remove ? -1 : 1));
421
427
  return Qnil;
@@ -514,7 +520,7 @@ gettextpo_po_message_m_check_all (int argc, VALUE *argv, VALUE self)
514
520
  po_message_check_all (DATA_PTR (self), DATA_PTR (iterator),
515
521
  &gettextpo_xerror_handler);
516
522
  if (gettextpo_xerror_context.error)
517
- rb_raise (rb_eError, "check all for message failed");
523
+ rb_raise (ERROR, "check all for message failed");
518
524
  return Qnil;
519
525
  }
520
526
 
@@ -540,16 +546,23 @@ gettextpo_po_message_m_check_format (int argc, VALUE *argv, VALUE self)
540
546
  gettextpo_xerror_context.user_xerror2 = &kwargs_vals[1];
541
547
  po_message_check_format (DATA_PTR (self), &gettextpo_xerror_handler);
542
548
  if (gettextpo_xerror_context.error)
543
- rb_raise (rb_eError, "check format for message failed");
549
+ rb_raise (ERROR, "check format for message failed");
544
550
  return Qnil;
545
551
  }
546
552
 
547
553
  /* ********** file ********** */
548
554
 
555
+ void
556
+ gettextpo_file_free (void *file)
557
+ {
558
+ if (file)
559
+ po_file_free (file);
560
+ }
561
+
549
562
  static const rb_data_type_t gettextpo_po_file_type = {
550
563
  .wrap_struct_name = "gettextpo PO file",
551
564
  .function = {
552
- .dfree = (void (*)(void *)) po_file_free,
565
+ .dfree = gettextpo_file_free,
553
566
  },
554
567
  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
555
568
  };
@@ -597,11 +610,17 @@ gettextpo_po_file_m_read (int argc, VALUE *argv, VALUE klass)
597
610
  gettextpo_xerror_context.user_xerror = &kwargs_vals[0];
598
611
  if (kwargs_vals[1] != Qundef)
599
612
  gettextpo_xerror_context.user_xerror2 = &kwargs_vals[1];
600
- DATA_PTR (self)
613
+ po_file_t file
601
614
  = po_file_read (StringValueCStr (filename), &gettextpo_xerror_handler);
602
- if (gettextpo_xerror_context.error)
603
- rb_raise (rb_eError, "failed to read");
604
- return self;
615
+ if (file)
616
+ {
617
+ DATA_PTR (self) = file;
618
+ if (gettextpo_xerror_context.error)
619
+ rb_raise (ERROR, "failed to read");
620
+ return self;
621
+ }
622
+ else
623
+ rb_raise (ERROR, "failed to read file, maybe file not found?");
605
624
  }
606
625
 
607
626
  /**
@@ -626,7 +645,7 @@ gettextpo_po_file_m_write (int argc, VALUE *argv, VALUE self)
626
645
  po_file_write (DATA_PTR (self), StringValueCStr (filename),
627
646
  &gettextpo_xerror_handler);
628
647
  if (gettextpo_xerror_context.error)
629
- rb_raise (rb_eError, "failed to write");
648
+ rb_raise (ERROR, "failed to write");
630
649
  return Qnil;
631
650
  }
632
651
 
@@ -693,7 +712,7 @@ gettextpo_po_file_m_check_all (int argc, VALUE *argv, VALUE self)
693
712
  gettextpo_xerror_context.user_xerror2 = &kwargs_vals[1];
694
713
  po_file_check_all (DATA_PTR (self), &gettextpo_xerror_handler);
695
714
  if (gettextpo_xerror_context.error)
696
- rb_raise (rb_eError, "check all for file failed");
715
+ rb_raise (ERROR, "check all for file failed");
697
716
  return Qnil;
698
717
  }
699
718
 
@@ -961,6 +980,4 @@ Init_gettextpo (void)
961
980
  rb_define_method (rb_cFilePos, "file", gettextpo_po_filepos_m_file, 0);
962
981
  rb_define_method (rb_cFilePos, "start_line",
963
982
  gettextpo_po_filepos_m_start_line, 0);
964
- rb_eError
965
- = rb_define_class_under (rb_mGettextPO, "Error", rb_eStandardError);
966
983
  }
@@ -0,0 +1,24 @@
1
+ /* Copyright (C) 2026 gemmaro
2
+ *
3
+ * This program is free software: you can redistribute it and/or modify
4
+ * it under the terms of the GNU General Public License as published by
5
+ * the Free Software Foundation, either version 3 of the License, or
6
+ * (at your option) any later version.
7
+
8
+ * This program is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ * GNU General Public License for more details.
12
+
13
+ * You should have received a copy of the GNU General Public License
14
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+ */
16
+
17
+ #ifndef MRB_GETTEXTPO_H
18
+ #define MRB_GETTEXTPO_H
19
+
20
+ #include <mruby.h>
21
+
22
+ void mrb_gettextpo_gem_init(mrb_state *mrb);
23
+
24
+ #endif
@@ -19,5 +19,5 @@
19
19
 
20
20
  module GettextPO
21
21
  # Version of this gem.
22
- VERSION = "0.1.1"
22
+ VERSION = "0.1.3"
23
23
  end
data/lib/gettextpo.rb CHANGED
@@ -17,50 +17,4 @@
17
17
 
18
18
  require_relative "gettextpo/version"
19
19
  require_relative "gettextpo/gettextpo"
20
-
21
- # The main entrypoints to parse PO files are GettextPO::File.new and
22
- # GettextPO::File.read.
23
- #
24
- # == Error handling
25
- #
26
- # Some functions takes exception error handling paramters like
27
- # +xerror+ and +xerror2+. These parameters expect +Proc+ object which
28
- # takes several parameters. See also the description of
29
- # GettextPO::File.read method. The +severity+ parameter among these
30
- # parameters is either SEVERITY_WARNING, SEVERITY_ERROR, or
31
- # SEVERITY_FATAL_ERROR.
32
- #
33
- module GettextPO
34
- class Error < StandardError; end
35
-
36
- # This class doesn't provide the +new+ class method. Refre to
37
- # GettextPO::MessageIterator#next or
38
- # GettextPO::MessageIterator#insert.
39
- class Message
40
- private_class_method :new
41
- end
42
-
43
- # This class doesn't provide the +new+ class method. See also
44
- # GettextPO::File#message_iterator.
45
- class MessageIterator
46
- private_class_method :new
47
-
48
- def each # yields: message
49
- while true
50
- begin
51
- yield self.next
52
- rescue StopIteration
53
- return self
54
- end
55
- end
56
- end
57
-
58
- include Enumerable
59
- end
60
-
61
- # This class doesn't provide the +new+ class method. See also
62
- # GettextPO::Message#filepos.
63
- class FilePos
64
- private_class_method :new
65
- end
66
- end
20
+ require_relative "../mrblib/mrb_gettextpo_common"
data/mrbgem.rake ADDED
@@ -0,0 +1,24 @@
1
+ # Copyright (C) 2026 gemmaro
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ MRuby::Gem::Specification.new('mruby-gettextpo') do |spec|
17
+ spec.license = 'GPL-3.0-or-later'
18
+ spec.authors = 'gemmaro'
19
+ spec.summary = 'GNU gettext PO parser for mruby'
20
+ spec.version = '0.1.0'
21
+ spec.homepage = 'https://git.disroot.org/gemmaro/ruby-gettextpo'
22
+ spec.linker.libraries << 'gettextpo'
23
+ spec.add_test_dependency 'mruby-io'
24
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2026 gemmaro
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ module GettextPO
17
+ Error = Class.new(StandardError)
18
+
19
+ class File
20
+ class << self
21
+ # It seems that calling Proc with keyword arguments is not yet
22
+ # supported.
23
+ alias original_read read
24
+ def read(filename, xerror: nil, xerror2: nil)
25
+ original_read(filename,
26
+ xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
27
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
28
+ end
29
+ end
30
+
31
+ # It seems that calling Proc with keyword arguments is not yet
32
+ # supported.
33
+ alias original_check_all check_all
34
+ def check_all(xerror: nil, xerror2: nil)
35
+ original_check_all(xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
36
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
37
+ end
38
+ end
39
+
40
+ class Message
41
+ # It seems that calling Proc with keyword arguments is not yet
42
+ # supported.
43
+ alias original_check_all check_all
44
+ def check_all(iterator, xerror: nil, xerror2: nil)
45
+ original_check_all(iterator,
46
+ xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
47
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
48
+ end
49
+
50
+ # It seems that calling Proc with keyword arguments is not yet
51
+ # supported.
52
+ alias original_check_format check_format
53
+ def check_format(xerror: nil, xerror2: nil)
54
+ original_check_format(xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
55
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,79 @@
1
+ #--
2
+ # Copyright (C) 2026 gemmaro
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ #++
17
+
18
+ # The main entrypoints to parse PO files are GettextPO::File.new and
19
+ # GettextPO::File.read.
20
+ #
21
+ # == Error handling
22
+ #
23
+ # There are two kinds of errors in this gem. The first is for
24
+ # exception handlings of libgettextpo. The second is regular error
25
+ # raising from this gem.
26
+ #
27
+ # Some functions takes exception error handling paramters like
28
+ # +xerror+ and +xerror2+. These parameters expect +Proc+ object which
29
+ # takes several parameters. See also the description of
30
+ # GettextPO::File.read method. The +severity+ parameter among these
31
+ # parameters is either SEVERITY_WARNING, SEVERITY_ERROR, or
32
+ # SEVERITY_FATAL_ERROR.
33
+ #
34
+ # This gem normally raises +GettextPO::Error+ object, except for the
35
+ # standard ones, +StopIteration+ for example.
36
+ #
37
+ module GettextPO
38
+ Error = Class.new(StandardError) # :nodoc:
39
+
40
+ # This class doesn't provide the +new+ class method. See also
41
+ # GettextPO::File#message_iterator.
42
+ class MessageIterator
43
+ def self.new
44
+ raise NoMethodError,
45
+ "please use other methods instead, such as GettextPO::File#message_iterator"
46
+ end
47
+
48
+ def each # yields: message
49
+ while true
50
+ begin
51
+ yield self.next
52
+ rescue StopIteration
53
+ return self
54
+ end
55
+ end
56
+ end
57
+
58
+ include Enumerable
59
+ end
60
+
61
+ # This class doesn't provide the +new+ class method. Refre to
62
+ # GettextPO::MessageIterator#next or
63
+ # GettextPO::MessageIterator#insert.
64
+ class Message
65
+ def self.new
66
+ raise NoMethodError,
67
+ "please use other methods instead, such as GettextPO::MessageIterator#next"
68
+ end
69
+ end
70
+
71
+ # This class doesn't provide the +new+ class method. See also
72
+ # GettextPO::Message#filepos.
73
+ class FilePos
74
+ def self.new
75
+ raise NoMethodError,
76
+ "please use other methods instead, such as GettextPO::Message#filepos"
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Copyright (C) 2026 gemmaro
5
+ #
6
+ # This program is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module GettextPO
21
+ # Version of this gem.
22
+ VERSION = "0.1.0"
23
+ end