gettextpo 0.1.2 → 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: 939f88fac034fa8ae14d06943e12163df3a34ca1797c625c7d5c6c591c18756b
4
- data.tar.gz: 972a70b2e9f8c5c623e839a7e8c5d54e2b95cd62d1fe0d3f6c26fe4f3d53b429
3
+ metadata.gz: c2eb5f08e68980571ccd30f9bb661e776084f6f87766e9180567b4501b038c3d
4
+ data.tar.gz: b22296f8b7d74673c8328c556acb0cdf59e369c19ec281ca0914b5cbec50817c
5
5
  SHA512:
6
- metadata.gz: 9d1f6fbf4c89921e78629b4f23b2f120671fb04db1dfcb09d73db5f28c6396d37f4bf792a9f69e034ce5ab077ac5c79b3d310beb0deb7707966be306065e8a2f
7
- data.tar.gz: b9bdbc78813ad3e20c783e5a2745297624c7c629fc2b97a55081a5b7f904fa3be99df556dc0b6664199e4d71e2e4e02c0d59340129f6f273ff3ae2e8607de3ad
6
+ metadata.gz: d0d2f86a241e358acd074ed86460072382cc7331afdaedae52f711e050b3442cb65e0bdee28d3cdd7967039bd4119f4d4713788dbd9feb8db390ec5ca5956e05
7
+ data.tar.gz: 5aca003840bf9bba6f601c8faea83a3c16dcbbb9eaec1d6baf27bba2f25c4f8d80f265d36e7fd4caeaf20c9ea9ed802ae7c4fbf0ac44ca6d85a899c0405f1c69
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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## CRuby version 0.1.3
6
+
7
+ - CRuby: Fix file not found case.
8
+
5
9
  ## CRuby version 0.1.2 and mruby version 0.1.0 - 2026-03-11
6
10
 
7
11
  - Add mruby version.
data/README.md CHANGED
@@ -3,8 +3,8 @@
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
5
  gettext package. The API of this gem is designed to promote Ruby's
6
- idiomatic coding style while avoiding memory safety. Currently this
7
- supports both CRuby and mruby.
6
+ idiomatic coding style while paying attensiton to memory safety.
7
+ Currently this supports both CRuby and mruby.
8
8
 
9
9
  ## Installation
10
10
 
@@ -24,6 +24,7 @@
24
24
  */
25
25
 
26
26
  #include "gettextpo.h"
27
+ #include <gettext-po.h>
27
28
  #include <ruby/internal/core/rdata.h>
28
29
  #include <ruby/internal/intern/variable.h>
29
30
 
@@ -551,10 +552,17 @@ gettextpo_po_message_m_check_format (int argc, VALUE *argv, VALUE self)
551
552
 
552
553
  /* ********** file ********** */
553
554
 
555
+ void
556
+ gettextpo_file_free (void *file)
557
+ {
558
+ if (file)
559
+ po_file_free (file);
560
+ }
561
+
554
562
  static const rb_data_type_t gettextpo_po_file_type = {
555
563
  .wrap_struct_name = "gettextpo PO file",
556
564
  .function = {
557
- .dfree = (void (*)(void *)) po_file_free,
565
+ .dfree = gettextpo_file_free,
558
566
  },
559
567
  .flags = RUBY_TYPED_FREE_IMMEDIATELY,
560
568
  };
@@ -602,13 +610,17 @@ gettextpo_po_file_m_read (int argc, VALUE *argv, VALUE klass)
602
610
  gettextpo_xerror_context.user_xerror = &kwargs_vals[0];
603
611
  if (kwargs_vals[1] != Qundef)
604
612
  gettextpo_xerror_context.user_xerror2 = &kwargs_vals[1];
605
- /* TODO: po_file_read can return NULL when not found? Also check
606
- null at file free. */
607
- DATA_PTR (self)
613
+ po_file_t file
608
614
  = po_file_read (StringValueCStr (filename), &gettextpo_xerror_handler);
609
- if (gettextpo_xerror_context.error)
610
- rb_raise (ERROR, "failed to read");
611
- 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?");
612
624
  }
613
625
 
614
626
  /**
@@ -19,5 +19,5 @@
19
19
 
20
20
  module GettextPO
21
21
  # Version of this gem.
22
- VERSION = "0.1.2"
22
+ VERSION = "0.1.3"
23
23
  end
data/lib/gettextpo.rb CHANGED
@@ -17,57 +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
- # There are two kinds of errors in this gem. The first is for
27
- # exception handlings of libgettextpo. The second is regular error
28
- # raising from this gem.
29
- #
30
- # Some functions takes exception error handling paramters like
31
- # +xerror+ and +xerror2+. These parameters expect +Proc+ object which
32
- # takes several parameters. See also the description of
33
- # GettextPO::File.read method. The +severity+ parameter among these
34
- # parameters is either SEVERITY_WARNING, SEVERITY_ERROR, or
35
- # SEVERITY_FATAL_ERROR.
36
- #
37
- # This gem normally raises +GettextPO::Error+ object, except for the
38
- # standard ones, +StopIteration+ for example.
39
- #
40
- module GettextPO
41
- class Error < StandardError; end # :nodoc:
42
-
43
- # This class doesn't provide the +new+ class method. Refre to
44
- # GettextPO::MessageIterator#next or
45
- # GettextPO::MessageIterator#insert.
46
- class Message
47
- private_class_method :new
48
- end
49
-
50
- # This class doesn't provide the +new+ class method. See also
51
- # GettextPO::File#message_iterator.
52
- class MessageIterator
53
- private_class_method :new
54
-
55
- def each # yields: message
56
- while true
57
- begin
58
- yield self.next
59
- rescue StopIteration
60
- return self
61
- end
62
- end
63
- end
64
-
65
- include Enumerable
66
- end
67
-
68
- # This class doesn't provide the +new+ class method. See also
69
- # GettextPO::Message#filepos.
70
- class FilePos
71
- private_class_method :new
72
- end
73
- end
20
+ require_relative "../mrblib/mrb_gettextpo_common"
@@ -37,31 +37,7 @@ module GettextPO
37
37
  end
38
38
  end
39
39
 
40
- class MessageIterator
41
- def self.new
42
- raise NoMethodError,
43
- "please use other methods instead, such as GettextPO::File#message_iterator"
44
- end
45
-
46
- def each # yields: message
47
- while true
48
- begin
49
- yield self.next
50
- rescue StopIteration
51
- return self
52
- end
53
- end
54
- end
55
-
56
- include Enumerable
57
- end
58
-
59
40
  class Message
60
- def self.new
61
- raise NoMethodError,
62
- "please use other methods instead, such as GettextPO::MessageIterator#next"
63
- end
64
-
65
41
  # It seems that calling Proc with keyword arguments is not yet
66
42
  # supported.
67
43
  alias original_check_all check_all
@@ -79,11 +55,4 @@ module GettextPO
79
55
  xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
80
56
  end
81
57
  end
82
-
83
- class FilePos
84
- def self.new
85
- raise NoMethodError,
86
- "please use other methods instead, such as GettextPO::Message#filepos"
87
- end
88
- end
89
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettextpo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gemmaro
@@ -36,7 +36,8 @@ files:
36
36
  - lib/gettextpo/version.rb
37
37
  - mrbgem.rake
38
38
  - mrblib/mrb_gettextpo.rb
39
- - mrblib/version.rb
39
+ - mrblib/mrb_gettextpo_common.rb
40
+ - mrblib/mrb_gettextpo_version.rb
40
41
  - sig/gettextpo.rbs
41
42
  - src/mrb_gettextpo.c
42
43
  - test.cruby/gettextpo_test.rb
@@ -71,7 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - - ">="
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
- requirements: []
75
+ requirements:
76
+ - libgettextpo
75
77
  rubygems_version: 3.6.9
76
78
  specification_version: 4
77
79
  summary: GNU gettext PO file parser library
File without changes