konjak 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +4 -4
- data/konjak.gemspec +1 -1
- data/lib/konjak/begin_paired_tag.rb +4 -2
- data/lib/konjak/body.rb +4 -5
- data/lib/konjak/element.rb +22 -2
- data/lib/konjak/end_paired_tag.rb +2 -1
- data/lib/konjak/header.rb +22 -24
- data/lib/konjak/highlight.rb +4 -1
- data/lib/konjak/isolated_tag.rb +4 -2
- data/lib/konjak/map.rb +5 -8
- data/lib/konjak/note.rb +6 -8
- data/lib/konjak/parser.rb +2 -2
- data/lib/konjak/placeholder.rb +4 -1
- data/lib/konjak/property.rb +7 -10
- data/lib/konjak/segment.rb +3 -4
- data/lib/konjak/sub_flow.rb +4 -1
- data/lib/konjak/tmx.rb +7 -9
- data/lib/konjak/translation_unit.rb +24 -22
- data/lib/konjak/translation_unit_variant.rb +23 -22
- data/lib/konjak/unknown_tag.rb +2 -1
- data/lib/konjak/user_defined_encoding.rb +6 -9
- data/lib/konjak/version.rb +1 -1
- data/spec/fixtures/konjak_modify_spec.rb +41 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/equal_xml_matcher.rb +14 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea6b25de9fe1bb666b02b8db7a3253619fe6cc5b
|
4
|
+
data.tar.gz: 4bf4b8cdc708b5904c16e8d3b656c37b15c26f4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94607b5df832840753b9a863dec409c98a283d9be758f40be2af1522cdd0815fe7615390f868fd2afa89133046a9418de25b1c568146cc5f3ceb491854c423c6
|
7
|
+
data.tar.gz: bef5ef91e252bfadde9f6b8f6cb8fd6674efd4ae4e2d4c28a4f65e88c9a0330e365faf7fe4ced678a56a876f185dd8dac0d87f3877ef4d13f7d12be4939a94f1
|
data/.travis.yml
CHANGED
@@ -3,4 +3,5 @@ rvm:
|
|
3
3
|
- 2.2
|
4
4
|
env:
|
5
5
|
global:
|
6
|
-
|
6
|
+
- secure: V8yG0G03Dsabc5mK4ubx3wSd0FyW0tazC/4DsJrvQTXSNytab1tXpwQbaN1XUyWTGnOj58mSZAPk/36n/5sGEwq3HIYCvPbJrqrCRODTDzmYy5uA1N+/Mo2uA55lPBjCbfcEvO1oy9tQIcH3I3R29nqiTsIRXax8XoFXHlJdP7I=
|
7
|
+
- secure: MghViLairF+zNTbCoH/ibECjud2Wf+6K3qKDIbo1dkxqzU4xIILDtODUmlLTQh0Da/IbAmTIc0XV5GgnftoiDIg9s6PQRhNeQX3heA6ElxwmOZmKNvcSutxZLm0AT3/PPZluykg5KBoETZQEAXLVamwbKiGCM9eIlTwOqRrHDRI=
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Konjak
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
4
|
-
[![Code Climate](https://codeclimate.com/github/
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/
|
3
|
+
[![Build Status](https://travis-ci.org/yasslab/konjak.svg?branch=v0.0.1)](https://travis-ci.org/yasslab/konjak)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/yasslab/konjak/badges/gpa.svg)](https://codeclimate.com/github/yasslab/konjak)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/yasslab/konjak/badges/coverage.svg)](https://codeclimate.com/github/yasslab/konjak/coverage)
|
6
6
|
|
7
7
|
TMX(Translation Memory eXchange) tools for ruby
|
8
8
|
|
@@ -26,7 +26,7 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Contributing
|
28
28
|
|
29
|
-
1. Fork it ( http://github.com/
|
29
|
+
1. Fork it ( http://github.com/yasslab/konjak/fork )
|
30
30
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
31
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
32
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/konjak.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["hanachin@gmail.com"]
|
11
11
|
spec.summary = %q{TMX(Translation Memory exChange) tools for ruby}
|
12
12
|
spec.description = %q{TMX(Translation Memory exChange) tools for ruby}
|
13
|
-
spec.homepage = "https://github.com/
|
13
|
+
spec.homepage = "https://github.com/yasslab/konjak"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Konjak
|
2
2
|
class BeginPairedTag < InlineElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:i, required: true)
|
5
5
|
|
6
6
|
# optional attrs
|
7
|
-
|
7
|
+
tmx_attr_accessor(:x)
|
8
|
+
tmx_attr_accessor(:type)
|
8
9
|
|
10
|
+
# methods
|
9
11
|
def can_contain?(element)
|
10
12
|
CodeData === element || SubFlow === element
|
11
13
|
end
|
data/lib/konjak/body.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Body < StructuralElement
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(body)
|
7
|
-
@translation_units = body.children.select {|c| c.name == 'tu' }.map {|tu| TranslationUnit.new tu }
|
3
|
+
# childrens
|
4
|
+
def translation_units
|
5
|
+
children.select {|c| c.name == 'tu' }.map {|tu| TranslationUnit.new(tu) }
|
8
6
|
end
|
9
7
|
|
8
|
+
# methods
|
10
9
|
def can_contain?(element)
|
11
10
|
TranslationUnit === element
|
12
11
|
end
|
data/lib/konjak/element.rb
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
1
3
|
module Konjak
|
2
|
-
class Element
|
3
|
-
|
4
|
+
class Element < Delegator
|
5
|
+
def initialize(__element__)
|
6
|
+
@__element__ = __element__
|
7
|
+
end
|
8
|
+
|
9
|
+
def __getobj__
|
10
|
+
@__element__
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.tmx_attr_accessor(name, attr_name=name, required: false)
|
16
|
+
define_method(name) do
|
17
|
+
self[attr_name]
|
18
|
+
end
|
19
|
+
|
20
|
+
define_method("#{name}=") do |value|
|
21
|
+
self[attr_name] = value
|
22
|
+
end
|
23
|
+
end
|
4
24
|
end
|
5
25
|
end
|
data/lib/konjak/header.rb
CHANGED
@@ -1,37 +1,35 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Header < StructuralElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:creation_tool, :creationtool, required: true)
|
5
|
+
tmx_attr_accessor(:creation_tool_version, :creationtoolversion, required: true)
|
6
|
+
tmx_attr_accessor(:seg_type, :segtype, required: true)
|
7
|
+
tmx_attr_accessor(:o_tmf, :"o-tmf", required: true)
|
8
|
+
tmx_attr_accessor(:admin_lang, :adminlang, required: true)
|
9
|
+
tmx_attr_accessor(:src_lang, :srclang, required: true)
|
10
|
+
tmx_attr_accessor(:data_type, :datatype, required: true)
|
5
11
|
|
6
12
|
# optional attrs
|
7
|
-
|
13
|
+
tmx_attr_accessor(:o_encoding, :"o-encoding")
|
14
|
+
tmx_attr_accessor(:creation_date, :creationdate)
|
15
|
+
tmx_attr_accessor(:creation_id, :creationid)
|
16
|
+
tmx_attr_accessor(:change_date, :changedate)
|
17
|
+
tmx_attr_accessor(:change_id, :changeid)
|
8
18
|
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# required attrs
|
14
|
-
@creation_tool = header[:creationtool]
|
15
|
-
@creation_tool_version = header[:creationtoolversion]
|
16
|
-
@seg_type = header[:segtype]
|
17
|
-
@o_tmf = header[:"o-tmf"]
|
18
|
-
@admin_lang = header[:adminlang]
|
19
|
-
@src_lang = header[:srclang]
|
20
|
-
@data_type = header[:datatype]
|
19
|
+
# childrens
|
20
|
+
def notes
|
21
|
+
children.select {|c| c.name == 'note' }.map {|n| Note.new(n) }
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@creation_id = header[:creationid]
|
26
|
-
@change_date = header[:changedate]
|
27
|
-
@change_id = header[:changeid]
|
24
|
+
def user_defined_encodings
|
25
|
+
children.select {|c| c.name == 'ude' }.map {|n| UserDefinedEncoding.new(n) }
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
@user_defined_encodings = header.children.select {|c| c.name == 'ude' }.map {|n| UserDefinedEncoding.new n }
|
32
|
-
@properties = header.children.select {|c| c.name == 'prop' }.map {|n| Property.new n }
|
28
|
+
def properties
|
29
|
+
children.select {|c| c.name == 'prop' }.map {|n| Property.new(n) }
|
33
30
|
end
|
34
31
|
|
32
|
+
# methods
|
35
33
|
def can_contain?(element)
|
36
34
|
[Note, UserDefinedEncoding, Property].any? {|c| c === element }
|
37
35
|
end
|
data/lib/konjak/highlight.rb
CHANGED
data/lib/konjak/isolated_tag.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Konjak
|
2
2
|
class IsolatedTag < InlineElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:pos, required: true)
|
5
5
|
|
6
6
|
# optional attrs
|
7
|
-
|
7
|
+
tmx_attr_accessor(:x)
|
8
|
+
tmx_attr_accessor(:type)
|
8
9
|
|
10
|
+
# methods
|
9
11
|
def can_contain?(element)
|
10
12
|
CodeData === element || SubFlow === element
|
11
13
|
end
|
data/lib/konjak/map.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Map < StructuralElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:unicode, required: true)
|
5
5
|
|
6
6
|
# optional attrs
|
7
|
-
|
7
|
+
tmx_attr_accessor(:code)
|
8
|
+
tmx_attr_accessor(:entity, :ent)
|
9
|
+
tmx_attr_accessor(:substitution, :subst)
|
8
10
|
|
9
|
-
|
10
|
-
@unicode = map[:unicode]
|
11
|
-
@code = map[:code]
|
12
|
-
@entity = map[:ent]
|
13
|
-
@substitution = map[:subst]
|
14
|
-
end
|
11
|
+
# methods
|
15
12
|
|
16
13
|
# FIXME:
|
17
14
|
# code, ent and subst. At least one of these attributes should be specified.
|
data/lib/konjak/note.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Note < StructuralElement
|
3
3
|
# optional attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:xml_lang, :'xml:lang')
|
5
|
+
tmx_attr_accessor(:o_encoding, :"o-encoding")
|
5
6
|
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(note)
|
10
|
-
@xml_lang = note["xml:lang"]
|
11
|
-
@o_encoding = note["o-encoding"]
|
12
|
-
@text = Text.new(note.text)
|
7
|
+
# childrens
|
8
|
+
def text
|
9
|
+
Text.new(super)
|
13
10
|
end
|
14
11
|
|
12
|
+
# methods
|
15
13
|
def can_contain?(element)
|
16
14
|
Text === element
|
17
15
|
end
|
data/lib/konjak/parser.rb
CHANGED
data/lib/konjak/placeholder.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Placeholder < InlineElement
|
3
3
|
# optional attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:x)
|
5
|
+
tmx_attr_accessor(:type)
|
6
|
+
tmx_attr_accessor(:assoc)
|
5
7
|
|
8
|
+
# methods
|
6
9
|
def can_contain?(element)
|
7
10
|
CodeData === element || SubFlow === element
|
8
11
|
end
|
data/lib/konjak/property.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Property < StructuralElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:type, required: true)
|
5
5
|
|
6
6
|
# optional attrs
|
7
|
-
|
7
|
+
tmx_attr_accessor(:xml_lang, :'xml:lang')
|
8
|
+
tmx_attr_accessor(:o_encoding, :"o-encoding")
|
8
9
|
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
def initialize(property)
|
13
|
-
@type = property[:type]
|
14
|
-
@xml_lang = property['xml:lang']
|
15
|
-
@o_encoding = property['o-encoding']
|
16
|
-
@text = Text.new(property.text)
|
10
|
+
# childrens
|
11
|
+
def text
|
12
|
+
Text.new(super)
|
17
13
|
end
|
18
14
|
|
15
|
+
# methods
|
19
16
|
def can_contain?(element)
|
20
17
|
# FIXME
|
21
18
|
# Tool-specific data or text.
|
data/lib/konjak/segment.rb
CHANGED
@@ -2,12 +2,11 @@ module Konjak
|
|
2
2
|
# container
|
3
3
|
class Segment < StructuralElement
|
4
4
|
# children
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(seg)
|
8
|
-
@text = Text.new(seg.text)
|
5
|
+
def text
|
6
|
+
Text.new(super)
|
9
7
|
end
|
10
8
|
|
9
|
+
# methods
|
11
10
|
def can_contain?(element)
|
12
11
|
[Text, BeginPairedTag, EndPairedTag, IsolatedTag, Placeholder, Highlight].any? {|c| c === element }
|
13
12
|
end
|
data/lib/konjak/sub_flow.rb
CHANGED
data/lib/konjak/tmx.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module Konjak
|
2
2
|
class Tmx < StructuralElement
|
3
|
-
# required
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(tmx)
|
7
|
-
@version = tmx[:version]
|
8
|
-
# TODO - better error handling
|
9
|
-
@header, @body = tmx.children
|
3
|
+
# required attr
|
4
|
+
def version
|
5
|
+
root[:version]
|
10
6
|
end
|
11
7
|
|
8
|
+
# required element
|
12
9
|
def header
|
13
|
-
Header.new
|
10
|
+
Header.new(root.at_xpath('header'))
|
14
11
|
end
|
15
12
|
|
13
|
+
# required element
|
16
14
|
def body
|
17
|
-
Body.new
|
15
|
+
Body.new(root.at_xpath('body'))
|
18
16
|
end
|
19
17
|
|
20
18
|
# FIXME
|
@@ -1,33 +1,35 @@
|
|
1
1
|
module Konjak
|
2
2
|
class TranslationUnit < StructuralElement
|
3
3
|
# optional attrs
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
tmx_attr_accessor(:tuid)
|
5
|
+
tmx_attr_accessor(:o_encoding, :"o-encoding")
|
6
|
+
tmx_attr_accessor(:data_type, :datatype)
|
7
|
+
tmx_attr_accessor(:usage_count, :usagecount)
|
8
|
+
tmx_attr_accessor(:last_usage_date, :lastusagedate)
|
9
|
+
tmx_attr_accessor(:src_lang, :srclang)
|
10
|
+
tmx_attr_accessor(:creation_tool, :creationtool)
|
11
|
+
tmx_attr_accessor(:creation_tool_version, :creationtoolversion)
|
12
|
+
tmx_attr_accessor(:creation_date, :creationdate)
|
13
|
+
tmx_attr_accessor(:creation_id, :creationid)
|
14
|
+
tmx_attr_accessor(:change_date, :changedate)
|
15
|
+
tmx_attr_accessor(:seg_type, :segtype)
|
16
|
+
tmx_attr_accessor(:change_id, :changeid)
|
17
|
+
tmx_attr_accessor(:o_tmf, :"o-tmf")
|
18
|
+
tmx_attr_accessor(:src_lang, :srclang)
|
19
|
+
|
20
|
+
# childrens
|
21
|
+
def variants
|
22
|
+
children.select {|c| c.name == 'tuv' }.map {|tuv| TranslationUnitVariant.new(tuv) }
|
23
|
+
end
|
24
|
+
|
25
|
+
# methods
|
24
26
|
def can_contain?(element)
|
25
27
|
[Note, Property, TranslationUnitVariant].any? {|c| c === element }
|
26
28
|
end
|
27
29
|
|
28
30
|
# Logically, a complete translation-memory database will contain at least two <tuv> elements in each translation unit.
|
29
31
|
def complete?
|
30
|
-
|
32
|
+
variants.count >= 2
|
31
33
|
end
|
32
34
|
|
33
35
|
def has_translation?(src_lang, target_lang)
|
@@ -50,7 +52,7 @@ module Konjak
|
|
50
52
|
# Zero, one or more <note>, or <prop> elements in any order, followed by
|
51
53
|
# One or more <tuv> elements.
|
52
54
|
def valid?
|
53
|
-
|
55
|
+
variants.count >= 1
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -1,35 +1,36 @@
|
|
1
1
|
module Konjak
|
2
2
|
class TranslationUnitVariant < StructuralElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:xml_lang, :'xml:lang', required: true)
|
5
5
|
|
6
6
|
# optional attrs
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
tmx_attr_accessor(:o_encoding, :"o-encoding")
|
8
|
+
tmx_attr_accessor(:data_type, :datatype)
|
9
|
+
tmx_attr_accessor(:usage_count, :usagecount)
|
10
|
+
tmx_attr_accessor(:last_usage_date, :lastusagedate)
|
11
|
+
tmx_attr_accessor(:creation_tool, :creationtool)
|
12
|
+
tmx_attr_accessor(:creation_tool_version, :creationtoolversion)
|
13
|
+
tmx_attr_accessor(:creation_date, :creationdate)
|
14
|
+
tmx_attr_accessor(:creation_id, :creationid)
|
15
|
+
tmx_attr_accessor(:change_date, :changedate)
|
16
|
+
tmx_attr_accessor(:change_id, :changeid)
|
17
|
+
tmx_attr_accessor(:o_tmf, :"o-tmf")
|
10
18
|
|
11
|
-
#
|
12
|
-
|
19
|
+
# childrens
|
20
|
+
def notes
|
21
|
+
children.select {|c| c.name == 'note' }.map {|n| Note.new(n) }
|
22
|
+
end
|
13
23
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
@data_type = tuv['datatype']
|
18
|
-
@usage_count = tuv['usagecount']
|
19
|
-
@last_usage_date = tuv['lastusagedate']
|
20
|
-
@creation_tool = tuv['creationtool']
|
21
|
-
@creation_tool_version = tuv['creationtoolversion']
|
22
|
-
@creation_date = tuv['creationdate']
|
23
|
-
@creation_id = tuv['creationid']
|
24
|
-
@change_date = tuv['changedate']
|
25
|
-
@change_id = tuv['changeid']
|
26
|
-
@o_tmf = tuv['o-tmf']
|
24
|
+
def properties
|
25
|
+
children.select {|c| c.name == 'prop' }.map {|n| Property.new(n) }
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
@segment = Segment.new(tuv.children.detect {|c| c.name == 'seg' })
|
28
|
+
def segment
|
29
|
+
Segment.new(children.detect {|c| c.name == 'seg' })
|
31
30
|
end
|
32
31
|
|
32
|
+
# methods
|
33
|
+
|
33
34
|
# FIXME
|
34
35
|
# Zero, one or more <note>, or <prop> elements in any order, followed by
|
35
36
|
# One <seg> element.
|
data/lib/konjak/unknown_tag.rb
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
module Konjak
|
2
2
|
class UserDefinedEncoding < StructuralElement
|
3
3
|
# required attrs
|
4
|
-
|
4
|
+
tmx_attr_accessor(:name, required: true)
|
5
5
|
|
6
6
|
# FIXME
|
7
7
|
# base (required if one or more of the <map/> elements contains a code attribute).
|
8
8
|
# optional attrs
|
9
|
-
|
9
|
+
tmx_attr_accessor(:base)
|
10
10
|
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(ude)
|
15
|
-
@name = ude[:name]
|
16
|
-
@base = ude[:base]
|
17
|
-
@maps = ude.children.select {|c| c.name == 'map' }.map {|n| Map.new n }
|
11
|
+
# childrens
|
12
|
+
def maps
|
13
|
+
children.select {|c| c.name == 'map' }.map {|n| Map.new(n) }
|
18
14
|
end
|
19
15
|
|
16
|
+
# methods
|
20
17
|
def can_contain?(element)
|
21
18
|
Map === element
|
22
19
|
end
|
data/lib/konjak/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Konjak do
|
4
|
+
let(:sample_tmx) { File.read('spec/fixtures/sample.tmx') }
|
5
|
+
|
6
|
+
let(:tmx) { Konjak.parse(sample_tmx) }
|
7
|
+
|
8
|
+
subject { tmx.to_xml }
|
9
|
+
|
10
|
+
context 'not modified' do
|
11
|
+
it { is_expected.to equal_xml(sample_tmx) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'modified' do
|
15
|
+
context 'element attribute' do
|
16
|
+
before do
|
17
|
+
tmx.header.change_id = 'john doe'
|
18
|
+
end
|
19
|
+
|
20
|
+
it { is_expected.not_to equal_xml(sample_tmx) }
|
21
|
+
|
22
|
+
specify do
|
23
|
+
expect(Konjak.parse(subject).header.change_id).to eq 'john doe'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'segment text' do
|
28
|
+
before do
|
29
|
+
tu = tmx.body.translation_units.first
|
30
|
+
tu.variant('EN').segment.content = 'hello world'
|
31
|
+
end
|
32
|
+
|
33
|
+
it { is_expected.not_to equal_xml(sample_tmx) }
|
34
|
+
|
35
|
+
specify do
|
36
|
+
tu = Konjak.parse(subject).body.translation_units.first
|
37
|
+
expect(tu.variant('EN').segment.text).to eq 'hello world'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
RSpec::Matchers.define :equal_xml do |expected|
|
4
|
+
match do |actual|
|
5
|
+
Nokogiri::XML(expected).to_s == Nokogiri::XML(actual).to_s
|
6
|
+
end
|
7
|
+
|
8
|
+
failure_message do |actual|
|
9
|
+
actual_xml = Nokogiri::XML(actual).to_s
|
10
|
+
expected_xml = Nokogiri::XML(expected).to_s
|
11
|
+
|
12
|
+
"#{actual_xml}\n\nis not equal\n\n#{expected_xml}"
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konjak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seiei Higa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mem
|
@@ -169,12 +169,14 @@ files:
|
|
169
169
|
- lib/konjak/user_defined_encoding.rb
|
170
170
|
- lib/konjak/version.rb
|
171
171
|
- spec/fixtures/gtt.tmx
|
172
|
+
- spec/fixtures/konjak_modify_spec.rb
|
172
173
|
- spec/fixtures/sample.tmx
|
173
174
|
- spec/konjak_parse_spec.rb
|
174
175
|
- spec/konjak_spec.rb
|
175
176
|
- spec/konjak_translate_spec.rb
|
176
177
|
- spec/spec_helper.rb
|
177
|
-
|
178
|
+
- spec/support/equal_xml_matcher.rb
|
179
|
+
homepage: https://github.com/yasslab/konjak
|
178
180
|
licenses:
|
179
181
|
- MIT
|
180
182
|
metadata: {}
|
@@ -200,9 +202,11 @@ specification_version: 4
|
|
200
202
|
summary: TMX(Translation Memory exChange) tools for ruby
|
201
203
|
test_files:
|
202
204
|
- spec/fixtures/gtt.tmx
|
205
|
+
- spec/fixtures/konjak_modify_spec.rb
|
203
206
|
- spec/fixtures/sample.tmx
|
204
207
|
- spec/konjak_parse_spec.rb
|
205
208
|
- spec/konjak_spec.rb
|
206
209
|
- spec/konjak_translate_spec.rb
|
207
210
|
- spec/spec_helper.rb
|
211
|
+
- spec/support/equal_xml_matcher.rb
|
208
212
|
has_rdoc:
|