gettextpo 0.1.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/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # GettextPO
2
+
3
+ This is a Ruby library for the GNU gettext PO files. This is a C
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.
7
+
8
+ ## Installation
9
+
10
+ Prerequisites: `libgettextpo` library. On Linux and similar systems,
11
+ you should be able to install it as a distribution package on most
12
+ platforms. For example, on Ubuntu it was as follows
13
+ (2026-03-07T15:48:13+09:00):
14
+
15
+ ``` shell
16
+ apt search libgettextpo
17
+ # Sorting... Done
18
+ # Full Text Search... Done
19
+ # libgettextpo-dev/noble 0.21-14ubuntu2 amd64 <----- This one!
20
+ # process PO files - static libraries and headers
21
+ #
22
+ # libgettextpo0/noble 0.21-14ubuntu2 amd64
23
+ # process PO files - shared library
24
+ ```
25
+
26
+ Install the gem and add to the application's `Gemfile` by executing:
27
+
28
+ ```bash
29
+ bundle add gettextpo
30
+ ```
31
+
32
+ If Bundler is not being used to manage dependencies, install the gem by executing:
33
+
34
+ ```bash
35
+ gem install gettextpo
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ Say we have a PO file like:
41
+
42
+ ```po
43
+ msgid "msgid1"
44
+ msgstr "msgstr1"
45
+ ```
46
+
47
+ at `po_path`, then,
48
+
49
+ ```ruby
50
+ require "gettextpo"
51
+
52
+ GettextPO::File.read(po_path).message_iterator.each do |message|
53
+ pp({ source: message.msgid, translation: message.msgstr })
54
+ #=> {source: "msgid1", translation: "msgstr1"}
55
+ end
56
+ ```
57
+
58
+ Please refer to the API documentation and test cases for details.
59
+
60
+ ## Development
61
+
62
+ `./bin/debug` to debug when segmentation fault.
63
+
64
+ References: [RubyのC APIの手引き 決定版][def], [Developers'
65
+ documentation for Ruby][dev], [Rubyの拡張ライブラリの作り方][ext],
66
+ [library rdoc/parser/c][parser], and [library rdoc][rdoc].
67
+
68
+ After checking out the repo, run `bin/setup` to install
69
+ dependencies. Then, run `rake test` to run the tests. You can also run
70
+ `bin/console` for an interactive prompt that will allow you to
71
+ experiment.
72
+
73
+ To install this gem onto your local machine, run `bundle exec rake
74
+ install`. To release a new version, update the version number in
75
+ `version.rb`, and then run `bundle exec rake release`, which will
76
+ create a git tag for the version, push git commits and the created
77
+ tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
78
+
79
+ [def]: https://gemmaro.github.io/emberb/
80
+ [dev]: https://docs.ruby-lang.org/capi/en/master/index.html
81
+ [ext]: https://docs.ruby-lang.org/en/master/extension_ja_rdoc.html
82
+ [parser]: https://docs.ruby-lang.org/ja/latest/library/rdoc=2fparser=2fc.html
83
+ [rdoc]: https://docs.ruby-lang.org/ja/latest/library/rdoc.html
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on Disroot at
88
+ <https://git.disroot.org/gemmaro/ruby-gettextpo>.
89
+
90
+ ## License
91
+
92
+ Copyright (C) 2026 gemmaro
93
+
94
+ This program is free software: you can redistribute it and/or modify
95
+ it under the terms of the GNU General Public License as published by
96
+ the Free Software Foundation, either version 3 of the License, or
97
+ (at your option) any later version.
98
+
99
+ This program is distributed in the hope that it will be useful,
100
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
101
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102
+ GNU General Public License for more details.
103
+
104
+ You should have received a copy of the GNU General Public License
105
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2026 gemmaro
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ require "bundler/gem_tasks"
19
+ require "rake/testtask"
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << "test"
23
+ t.libs << "lib"
24
+ t.test_files = FileList["test/**/*_test.rb"]
25
+ end
26
+
27
+ require "rake/extensiontask"
28
+
29
+ task build: :compile
30
+
31
+ GEMSPEC = Gem::Specification.load("gettextpo.gemspec")
32
+
33
+ Rake::ExtensionTask.new("gettextpo", GEMSPEC) do |ext|
34
+ ext.lib_dir = "lib/gettextpo"
35
+ end
36
+
37
+ task default: %i[clobber compile test]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (C) 2026 gemmaro
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ require "mkmf"
19
+
20
+ # Makes all symbols private by default to avoid unintended conflict
21
+ # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
22
+ # selectively, or entirely remove this flag.
23
+ append_cflags("-fvisibility=hidden")
24
+
25
+ have_header("gettext-po.h") or raise "gettext-po.h not found"
26
+ have_library("gettextpo") or raise "gettextpo library not found"
27
+ # TODO: check library function
28
+
29
+ create_makefile("gettextpo/gettextpo")