konjak 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 615052ac1b1aa2ca537376ff7d500b3eca9f2fc5
4
- data.tar.gz: 3a6df86a8b9b4e3f9b11f1cae81b6485e9ff921e
3
+ metadata.gz: 9008e7bea949ed8ab532d799a0df321b906fac80
4
+ data.tar.gz: 48c87e99f9628304f037295b7307a22ad8991e8c
5
5
  SHA512:
6
- metadata.gz: 48ab28755ac877bdd63b8d7f7c56b0c31555b74b5ded5f3a2127568a412b4e3ed8dff58240eb1d432f9103fcc4b4ab725f7958d5222f9667fdd73c843480e2e3
7
- data.tar.gz: a265dd460448990ed016b36ebf192e7adad5969600fc2e585adccc2ddb56e748b9019e720c304badd03a6e680455aa8cd580595b13acb841c05c726f475eb441
6
+ metadata.gz: 21fa22c7a920844f05d7877e97620cb1acfb23503c45719cdbbdf1c80865ee6eea22f3d98d86e2f527fce4d6f5c1fca3aadd7997a3ea4afefe76c3ade9cfbf73
7
+ data.tar.gz: 5f04247db5f844e347d7fb5c02c55724a333a88fe22a60eb3a5358f34127cc07bccff51058413f32b7ef3b61cd88f609122622c2704f9e7d4e86b016c5c00e1f
@@ -17,11 +17,11 @@ module Konjak
17
17
  private
18
18
 
19
19
  def tmx
20
- @options[:tmx] or raise 'tmx option is not set'
20
+ @options.fetch(:tmx)
21
21
  end
22
22
 
23
23
  def lang
24
- @options[:lang] or raise 'lang option is not set'
24
+ @options.fetch(:lang)
25
25
  end
26
26
 
27
27
  def format
@@ -6,7 +6,7 @@ require 'konjak/tmx_segmentor/segment_string'
6
6
 
7
7
  module Konjak
8
8
  class TmxSegmentor < Segmentor
9
- class Strategy
9
+ class BaseStrategy
10
10
  Edge = Struct.new(:prev, :current)
11
11
  Node = Struct.new(:range, :segments) do
12
12
  def <=>(other)
@@ -123,9 +123,10 @@ module Konjak
123
123
 
124
124
  def default_options
125
125
  {
126
- translation_unit_filter: -> (tu) { true },
127
- calc_edge_cost: -> (edge) { edge.current.max_segment_size },
128
- select_next_segment: -> (_, node) { node.segments.first }
126
+ calc_edge_cost: -> (edge) { edge.current.max_segment_size },
127
+ compile_pattern: -> (segment) { segment.compile_pattern },
128
+ select_next_segment: -> (_, node) { node.segments.first },
129
+ translation_unit_filter: -> (tu) { true },
129
130
  }
130
131
  end
131
132
 
@@ -133,6 +134,10 @@ module Konjak
133
134
  @options[:calc_edge_cost].call(edge)
134
135
  end
135
136
 
137
+ def compile_pattern(segment)
138
+ @options[:compile_pattern].call(segment)
139
+ end
140
+
136
141
  def translation_unit_filter
137
142
  @options[:translation_unit_filter]
138
143
  end
@@ -1,14 +1,14 @@
1
1
  require 'konjak/tmx_segmentor/segment_string'
2
- require 'konjak/tmx_segmentor/strategy'
2
+ require 'konjak/tmx_segmentor/base_strategy'
3
3
 
4
4
  module Konjak
5
5
  class TmxSegmentor < Segmentor
6
- class GttHtmlStrategy < Strategy
6
+ class GttHtmlStrategy < BaseStrategy
7
7
 
8
8
  private
9
9
 
10
- def compile_pattern(segment)
11
- segment.compile_gtt_html_pattern
10
+ def default_options
11
+ super.merge(compile_pattern: -> (segment) { segment.compile_gtt_html_pattern })
12
12
  end
13
13
  end
14
14
  end
@@ -1,15 +1,9 @@
1
1
  require 'konjak/tmx_segmentor/segment_string'
2
- require 'konjak/tmx_segmentor/strategy'
2
+ require 'konjak/tmx_segmentor/base_strategy'
3
3
 
4
4
  module Konjak
5
5
  class TmxSegmentor < Segmentor
6
- class TextStrategy < Strategy
7
-
8
- private
9
-
10
- def compile_pattern(segment)
11
- segment.compile_pattern
12
- end
6
+ class TextStrategy < BaseStrategy
13
7
  end
14
8
  end
15
9
  end
@@ -1,3 +1,3 @@
1
1
  module Konjak
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konjak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seiei Higa
@@ -177,9 +177,9 @@ files:
177
177
  - lib/konjak/sub_flow.rb
178
178
  - lib/konjak/tmx.rb
179
179
  - lib/konjak/tmx_segmentor.rb
180
+ - lib/konjak/tmx_segmentor/base_strategy.rb
180
181
  - lib/konjak/tmx_segmentor/gtt_html_strategy.rb
181
182
  - lib/konjak/tmx_segmentor/segment_string.rb
182
- - lib/konjak/tmx_segmentor/strategy.rb
183
183
  - lib/konjak/tmx_segmentor/text_strategy.rb
184
184
  - lib/konjak/translation_unit.rb
185
185
  - lib/konjak/translation_unit_variant.rb