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.
- checksums.yaml +4 -4
- data/.dir-locals.el +2 -1
- data/.env.example +2 -0
- data/.envrc +29 -2
- data/.rdoc_options +1 -0
- data/CHANGELOG.md +14 -2
- data/README.md +63 -24
- data/Rakefile +2 -2
- data/build_config.rb +27 -0
- data/ext/gettextpo/gettextpo.c +68 -42
- data/ext/gettextpo/gettextpo.h +3 -3
- data/include/mrb_gettextpo.h +24 -0
- data/lib/gettextpo/version.rb +2 -1
- data/lib/gettextpo.rb +18 -1
- data/mrbgem.rake +24 -0
- data/mrblib/mrb_gettextpo.rb +89 -0
- data/mrblib/version.rb +23 -0
- data/src/mrb_gettextpo.c +825 -0
- data/test.cruby/gettextpo_test.rb +52 -0
- data/test.cruby/resources/a.po +1 -0
- data/test.cruby/resources/bad.po +20 -0
- data/test.cruby/resources/filepos.po +3 -0
- data/test.cruby/resources/format.po +3 -0
- data/test.cruby/resources/ok.po +16 -0
- data/{sample.rb → test.cruby/test_helper.rb} +4 -5
- data/test.cruby/tmp/.keep +0 -0
- metadata +17 -2
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
|