anpo 1.0.0 → 1.0.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/anpofilter +81 -81
  3. data/lib/anpo/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b86255b8dcc794f8aa38dbd06a8b24840baae8308192061673a1b4c024d2887d
4
- data.tar.gz: 91ae182af6f1f8f398b0ee0c61821ebd829398f486f3001ef10c9f4197c74aa8
3
+ metadata.gz: 865dfb0ef91eb8b7a17ba282145583e4a2d4de71da62428d0eb65a5768527348
4
+ data.tar.gz: '0639a1c73da4e9fb9da5ab041a7079633edd7183700f55311b05cb1ba1807a21'
5
5
  SHA512:
6
- metadata.gz: cfce5c4b50344e28e1ba6a86226206bd1c6c7a80bca17bc45ac42a4cd776db882dc63dc5d09278bf76f5871abb9529734f8da50b2e67e8c65e21845c6157905d
7
- data.tar.gz: aaf924b90685cad5da37f685426548bdd254f6cd13e89ae91c5f943fe7e77ad85cafa6f70adddbbbdb6fc862e798663f9d7e8317e42db2f2cc48d1171d3f9589
6
+ metadata.gz: dbb18ff7943f8a8917a1fb14be97b9aed531e9f17709532d68a708e5f300523b14385c949ca649ed40920842a13ec28318aad01eda9b6e82a6c20fa93080d4c9
7
+ data.tar.gz: 20fb297b8120f98991cf91425c178e59e5175d44a0c7dbe5ee6bac4219870d357206e7814ccfada320bcf514af6be6cf1f353faa08262c911ee754d5226bcb7a
data/bin/anpofilter CHANGED
@@ -1,81 +1,81 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "anpo"
5
- require "optparse"
6
-
7
- def ep(x)
8
- $stderr.print(x.inspect)
9
- $stderr.print("\n")
10
- end
11
-
12
- opt = OptionParser.new
13
-
14
- exclude_not_fuzzy = false
15
- exclude_not_translated = false
16
- exclude_translated = false
17
- exclude_fuzzy = false
18
- matchstr = false
19
-
20
- subtract = false
21
- intersect = false
22
-
23
- argfile = nil
24
-
25
- opt.on("--str") { matchstr = true }
26
-
27
- opt.on("--intersect") { |_f| intersect = true }
28
- opt.on("--and") { |_f| intersect = true }
29
- opt.on("-A") { |_f| intersect = true }
30
- opt.on("--subtract") { |_f| subtract = true }
31
- opt.on("-S") { |_f| subtract = true }
32
-
33
- opt.on("-f") { |_x| exclude_not_fuzzy = true }
34
- opt.on("-F") { |_x| exclude_fuzzy = true }
35
- opt.on("-t") { |_x| exclude_not_translated = true }
36
- opt.on("-T") { |_x| exclude_translated = true }
37
-
38
- argv = opt.parse!(ARGV)
39
-
40
- if intersect || subtract
41
-
42
- inputs = []
43
- inputs = if argv.length == 1
44
- [argv[0], $stdin]
45
- else
46
- [argv[1], argv[0]]
47
- end
48
-
49
- File.open(inputs[0]) do |file|
50
- Anpo::PO.parse(file) do |cmpfile|
51
- infile = Anpo::PO.parse(inputs[1])
52
-
53
- cmpfile.entries.delete_if(&:is_fuzzy?) if exclude_fuzzy
54
- cmpfile.entries.delete_if { |e| !e.is_translated? } if exclude_not_translated
55
-
56
- ids = []
57
- infile.each do |ent|
58
- ids.push(ent.msgid) if !cmpfile.msg[ent.msgid] || ((cmpfile.msg[ent.msgid] != ent.msgstr) && matchstr)
59
- end
60
-
61
- if subtract
62
- infile.filter_by_ids(ids)
63
- elsif intersect
64
- infile.delete_by_ids(ids)
65
- end
66
-
67
- print infile
68
- end
69
- end
70
-
71
- else
72
-
73
- Anpo::PO.parse(argv.empty? ? $stdin : ARGV[0]) do |po|
74
- po.entries.delete_if { |e| !e.is_fuzzy? } if exclude_not_fuzzy
75
- po.entries.delete_if(&:is_fuzzy?) if exclude_fuzzy
76
- po.entries.delete_if { |e| !e.is_translated? } if exclude_translated
77
- po.entries.delete_if(&:is_translated?) if exclude_not_translated
78
- print po
79
- end
80
-
81
- end
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "anpo"
5
+ require "optparse"
6
+
7
+ def ep(x)
8
+ $stderr.print(x.inspect)
9
+ $stderr.print("\n")
10
+ end
11
+
12
+ opt = OptionParser.new
13
+
14
+ exclude_not_fuzzy = false
15
+ exclude_not_translated = false
16
+ exclude_translated = false
17
+ exclude_fuzzy = false
18
+ matchstr = false
19
+
20
+ subtract = false
21
+ intersect = false
22
+
23
+ argfile = nil
24
+
25
+ opt.on("--str") { matchstr = true }
26
+
27
+ opt.on("--intersect") { |_f| intersect = true }
28
+ opt.on("--and") { |_f| intersect = true }
29
+ opt.on("-A") { |_f| intersect = true }
30
+ opt.on("--subtract") { |_f| subtract = true }
31
+ opt.on("-S") { |_f| subtract = true }
32
+
33
+ opt.on("-f") { |_x| exclude_not_fuzzy = true }
34
+ opt.on("-F") { |_x| exclude_fuzzy = true }
35
+ opt.on("-t") { |_x| exclude_not_translated = true }
36
+ opt.on("-T") { |_x| exclude_translated = true }
37
+
38
+ argv = opt.parse!(ARGV)
39
+
40
+ if intersect || subtract
41
+
42
+ inputs = []
43
+ inputs = if argv.length == 1
44
+ [argv[0], $stdin]
45
+ else
46
+ [argv[1], argv[0]]
47
+ end
48
+
49
+ File.open(inputs[0]) do |file|
50
+ Anpo::PO.parse(file) do |cmpfile|
51
+ infile = Anpo::PO.parse(inputs[1])
52
+
53
+ cmpfile.entries.delete_if(&:is_fuzzy?) if exclude_fuzzy
54
+ cmpfile.entries.delete_if { |e| !e.is_translated? } if exclude_not_translated
55
+
56
+ ids = []
57
+ infile.each do |ent|
58
+ ids.push(ent.msgid) if !cmpfile.msg[ent.msgid] || ((cmpfile.msg[ent.msgid] != ent.msgstr) && matchstr)
59
+ end
60
+
61
+ if subtract
62
+ infile.filter_by_ids(ids)
63
+ elsif intersect
64
+ infile.delete_by_ids(ids)
65
+ end
66
+
67
+ print infile
68
+ end
69
+ end
70
+
71
+ else
72
+
73
+ Anpo::PO.parse(argv.empty? ? $stdin : ARGV[0]) do |po|
74
+ po.entries.delete_if { |e| !e.is_fuzzy? } if exclude_not_fuzzy
75
+ po.entries.delete_if(&:is_fuzzy?) if exclude_fuzzy
76
+ po.entries.delete_if { |e| !e.is_translated? } if exclude_translated
77
+ po.entries.delete_if(&:is_translated?) if exclude_not_translated
78
+ print po
79
+ end
80
+
81
+ end
data/lib/anpo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anpo
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anpo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOKITA, Hiroshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler