gettextpo 0.1.0 → 0.1.2

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/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,89 @@
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 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
+ class Message
60
+ def self.new
61
+ raise NoMethodError,
62
+ "please use other methods instead, such as GettextPO::MessageIterator#next"
63
+ end
64
+
65
+ # It seems that calling Proc with keyword arguments is not yet
66
+ # supported.
67
+ alias original_check_all check_all
68
+ def check_all(iterator, xerror: nil, xerror2: nil)
69
+ original_check_all(iterator,
70
+ xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
71
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
72
+ end
73
+
74
+ # It seems that calling Proc with keyword arguments is not yet
75
+ # supported.
76
+ alias original_check_format check_format
77
+ def check_format(xerror: nil, xerror2: nil)
78
+ original_check_format(xerror: xerror && Proc.new { |kwargs| xerror.(**kwargs) },
79
+ xerror2: xerror2 && Proc.new { |kwargs| xerror2.(**kwargs) })
80
+ end
81
+ 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
+ end
data/mrblib/version.rb ADDED
@@ -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