xliffer 0.0.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 +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +20 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/lib/xliffer.rb +4 -0
- data/lib/xliffer/exceptions.rb +5 -0
- data/lib/xliffer/version.rb +3 -0
- data/lib/xliffer/xliff.rb +43 -0
- data/lib/xliffer/xliff/file.rb +32 -0
- data/lib/xliffer/xliff/string.rb +46 -0
- data/spec/files/empty.xliff +1 -0
- data/spec/files/file.foobar +1 -0
- data/spec/files/wiki.xliff +36 -0
- data/spec/files/xliffspec1.xliff +15 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/xliffer/file_spec.rb +100 -0
- data/spec/xliffer/string_spec.rb +93 -0
- data/spec/xliffer/xliff_spec.rb +59 -0
- data/spec/xliffer_spec.rb +4 -0
- data/xliffer.gemspec +23 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea276a483651e8f0e534280a3fef9329a52c4321
|
4
|
+
data.tar.gz: 141a20279f0de253021ecc64d8d7427b40ab4aec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce7148866423e954f0febc89505518ad0110a8bc075fea789f25174f0b2ca27dcda2339f3c393f20ddf7d63eabf3c053610fb7e03ae9f47dcea0c24641127c7c
|
7
|
+
data.tar.gz: 334fed09e496be5d4770ae67ab3113491458e7f58acf744121ffeaab221220532078c4e225d9ebfb8157bd332d405ec1a2ac2e22afa6966343c60b96499d3f44
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.5)
|
5
|
+
nokogiri (1.5.9)
|
6
|
+
rspec (2.99.0)
|
7
|
+
rspec-core (~> 2.99.0)
|
8
|
+
rspec-expectations (~> 2.99.0)
|
9
|
+
rspec-mocks (~> 2.99.0)
|
10
|
+
rspec-core (2.99.2)
|
11
|
+
rspec-expectations (2.99.2)
|
12
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
13
|
+
rspec-mocks (2.99.3)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
nokogiri
|
20
|
+
rspec (~> 2)
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
xliffer
|
2
|
+
=======
|
3
|
+
|
4
|
+
A XLIFF parser gem.
|
5
|
+
|
6
|
+
Currently implementing the [version 1.2](http://docs.oasis-open.org/xliff/xliff-core/xliff-core.html) from xliff. It is on a very alpha phase.
|
7
|
+
|
8
|
+
Usage
|
9
|
+
-----
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'xliffer'
|
13
|
+
|
14
|
+
# Opens a xliff file - can be a file descriptor or a string.
|
15
|
+
xliff = XLIFFer::XLIFF.new(File.open('file.xml'))
|
16
|
+
|
17
|
+
# get the first file definition on this XLIFF.
|
18
|
+
file = xliff.files.first
|
19
|
+
|
20
|
+
# prints the name of this file
|
21
|
+
puts file.original
|
22
|
+
|
23
|
+
# Prints the source and target languages from this file.
|
24
|
+
puts file.source_language
|
25
|
+
puts file.target_language
|
26
|
+
|
27
|
+
# Prints all string and the translations on this file.
|
28
|
+
file.strings.each do |string|
|
29
|
+
puts "#{string.source} => #{string.target}"
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
Roadmap
|
35
|
+
------
|
36
|
+
|
37
|
+
* Read all fields according to 1.2 specification
|
38
|
+
* Be able to modify/add contents on the xliff files
|
39
|
+
* Regenerate the XML from the file
|
data/Rakefile
ADDED
data/lib/xliffer.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'xliffer/xliff/file'
|
3
|
+
|
4
|
+
module XLIFFer
|
5
|
+
class XLIFF
|
6
|
+
attr_reader :version, :files
|
7
|
+
def initialize(xliff = nil)
|
8
|
+
text = case xliff
|
9
|
+
when ::IO then xliff.read
|
10
|
+
when ::String then xliff
|
11
|
+
else fail ArgumentError, "Expects an IO or String"
|
12
|
+
end
|
13
|
+
|
14
|
+
parse(text)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def parse(text)
|
19
|
+
begin
|
20
|
+
xml = Nokogiri::XML(text)
|
21
|
+
rescue
|
22
|
+
fail FormatError, "Not a XML file"
|
23
|
+
end
|
24
|
+
|
25
|
+
xml.remove_namespaces!
|
26
|
+
root = xml.xpath('/xliff')
|
27
|
+
raise FormatError, "Not a XLIFF file" unless root.any?
|
28
|
+
|
29
|
+
@version = get_version(root)
|
30
|
+
@files = parse_files(root)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_version(root)
|
34
|
+
version = root.attr('version')
|
35
|
+
version ? version.value : nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_files(root)
|
39
|
+
root.xpath('//file').map{|f| File.new(f)}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'xliffer/xliff'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module XLIFFer
|
5
|
+
class XLIFF
|
6
|
+
class File
|
7
|
+
attr_reader :source_language, :target_language, :original, :strings
|
8
|
+
alias_method :file_name, :original
|
9
|
+
def initialize(xml)
|
10
|
+
unless xml_element?(xml) and file?(xml)
|
11
|
+
raise ArgumentError, "can't create a File without a file subtree"
|
12
|
+
end
|
13
|
+
|
14
|
+
@original = xml.attr("original")
|
15
|
+
@source_language = xml.attr("source-language")
|
16
|
+
@target_language = xml.attr("target-language")
|
17
|
+
@strings = xml.xpath('.//trans-unit').map{|tu| String.new(tu)}
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
# TODO: move to public method on XLIFF
|
23
|
+
def xml_element?(xml)
|
24
|
+
xml.kind_of? Nokogiri::XML::Element
|
25
|
+
end
|
26
|
+
|
27
|
+
def file?(xml)
|
28
|
+
xml.name.downcase == "file"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module XLIFFer
|
2
|
+
class XLIFF
|
3
|
+
class String
|
4
|
+
attr_reader :id, :source, :target, :note
|
5
|
+
def initialize(xml)
|
6
|
+
unless xml_element?(xml) and trans_unit?(xml)
|
7
|
+
raise ArgumentError, "can't create a String without a trans-unit subtree"
|
8
|
+
end
|
9
|
+
|
10
|
+
@id = xml.attr('id')
|
11
|
+
@source = get_source(xml)
|
12
|
+
@target = get_target(xml)
|
13
|
+
@note = get_note(xml)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
# TODO: move to public method on XLIFF
|
18
|
+
def xml_element?(xml)
|
19
|
+
xml.kind_of? Nokogiri::XML::Element
|
20
|
+
end
|
21
|
+
|
22
|
+
def trans_unit?(xml)
|
23
|
+
xml.name.downcase == "trans-unit"
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_source(xml)
|
27
|
+
sources = xml.xpath("./source")
|
28
|
+
raise MultipleElement, "Should have only one source tag" if sources.size > 1
|
29
|
+
raise NoElement, "Should have one source tag" unless sources.size == 1
|
30
|
+
sources.first.text
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_target(xml)
|
34
|
+
targets = xml.xpath("./target")
|
35
|
+
raise MultipleElement, "Should have only one target tag" if targets.size > 1
|
36
|
+
targets.first ? targets.first.text : ''
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_note(xml)
|
40
|
+
notes = xml.xpath("./note")
|
41
|
+
raise MultipleElement, "Should have only one target tag" if notes.size > 1
|
42
|
+
notes.first ? notes.first.text : ''
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<xliff version="1.2"></xliff>
|
@@ -0,0 +1 @@
|
|
1
|
+
foobar
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<xliff version="1.2">
|
2
|
+
<file original="Graphic Example.psd"
|
3
|
+
source-language="en-US" target-language="ja-JP"
|
4
|
+
tool="Rainbow" datatype="photoshop">
|
5
|
+
<header>
|
6
|
+
<skl>
|
7
|
+
<external-file uid="3BB236513BB24732" href="Graphic Example.psd.skl"/>
|
8
|
+
</skl>
|
9
|
+
<phase-group>
|
10
|
+
<phase phase-name="extract" process-name="extraction"
|
11
|
+
tool="Rainbow" date="20010926T152258Z"
|
12
|
+
company-name="NeverLand Inc." job-id="123"
|
13
|
+
contact-name="Peter Pan" contact-email="ppan@example.com">
|
14
|
+
<note>Make sure to use the glossary I sent you yesterday.
|
15
|
+
Thanks.</note>
|
16
|
+
</phase>
|
17
|
+
</phase-group>
|
18
|
+
</header>
|
19
|
+
<body>
|
20
|
+
<trans-unit id="1" maxbytes="14">
|
21
|
+
<source xml:lang="en-US">Quetzal</source>
|
22
|
+
<target xml:lang="ja-JP">Quetzal</target>
|
23
|
+
</trans-unit>
|
24
|
+
<trans-unit id="3" maxbytes="114">
|
25
|
+
<source xml:lang="en-US">An application to manipulate and
|
26
|
+
process XLIFF documents</source>
|
27
|
+
<target xml:lang="ja-JP">XLIFF 文書を編集、または処理
|
28
|
+
するアプリケーションです。</target>
|
29
|
+
</trans-unit>
|
30
|
+
<trans-unit id="4" maxbytes="36">
|
31
|
+
<source xml:lang="en-US">XLIFF Data Manager</source>
|
32
|
+
<target xml:lang="ja-JP">XLIFF データ・マネージャ</target>
|
33
|
+
</trans-unit>
|
34
|
+
</body>
|
35
|
+
</file>
|
36
|
+
</xliff>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<xliff version='1.2'
|
2
|
+
xmlns='urn:oasis:names:tc:xliff:document:1.2'>
|
3
|
+
<file original='hello.txt' source-language='en' target-language='fr'
|
4
|
+
datatype='plaintext'>
|
5
|
+
<body>
|
6
|
+
<trans-unit id='hi'>
|
7
|
+
<source>Hello world</source>
|
8
|
+
<target>Bonjour le monde</target>
|
9
|
+
<alt-trans>
|
10
|
+
<target xml:lang='es'>Hola mundo</target>
|
11
|
+
</alt-trans>
|
12
|
+
</trans-unit>
|
13
|
+
</body>
|
14
|
+
</file>
|
15
|
+
</xliff>
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module XLIFFer
|
5
|
+
describe XLIFF::File do
|
6
|
+
context "#new" do
|
7
|
+
it "is created with a nokogiri file node" do
|
8
|
+
file_node = Nokogiri::XML.parse("<file></file>").xpath("/file").first
|
9
|
+
XLIFF::File.new(file_node).should be
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can't be created with a string" do
|
13
|
+
expect{XLIFF::File.new("<file></file>")}.to raise_error ArgumentError
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can't be created with a node that is not a file node" do
|
17
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("/xliff").first
|
18
|
+
expect{XLIFF::File.new(file_node)}.to raise_error ArgumentError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "#original" do
|
23
|
+
it "is nil if not defined" do
|
24
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
25
|
+
XLIFF::File.new(file_node).original.should be nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "is the original attribute on file tag" do
|
29
|
+
file_node = Nokogiri::XML.parse('<xliff><file original="neat file.c"></file></xliff>').xpath("//file").first
|
30
|
+
XLIFF::File.new(file_node).original.should eql("neat file.c")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "#original" do
|
35
|
+
it "is nil if not defined" do
|
36
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
37
|
+
XLIFF::File.new(file_node).original.should be nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "is the original attribute on file tag" do
|
41
|
+
file_node = Nokogiri::XML.parse('<xliff><file original="neat file.c"></file></xliff>').xpath("//file").first
|
42
|
+
XLIFF::File.new(file_node).original.should eql("neat file.c")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "#source_language" do
|
47
|
+
it "is nil if not defined" do
|
48
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
49
|
+
XLIFF::File.new(file_node).source_language.should be nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is the original attribute on file tag" do
|
53
|
+
file_node = Nokogiri::XML.parse('<xliff><file source-language="en"></file></xliff>').xpath("//file").first
|
54
|
+
XLIFF::File.new(file_node).source_language.should eql("en")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "#target_language" do
|
59
|
+
it "is nil if not defined" do
|
60
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
61
|
+
XLIFF::File.new(file_node).target_language.should be nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "is the original attribute on file tag" do
|
65
|
+
file_node = Nokogiri::XML.parse('<xliff><file target-language="fr"></file></xliff>').xpath("//file").first
|
66
|
+
XLIFF::File.new(file_node).target_language.should eql("fr")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "#strings" do
|
71
|
+
before(:all) do
|
72
|
+
@trans_unit = <<-EOF
|
73
|
+
<trans-unit id="my id">
|
74
|
+
<source>Hello World</source>
|
75
|
+
<target>Bonjour le monde</target>
|
76
|
+
</trans-unit>
|
77
|
+
EOF
|
78
|
+
end
|
79
|
+
it "is an array " do
|
80
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
81
|
+
XLIFF::File.new(file_node).strings.should be_kind_of(Array)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "can be empty" do
|
85
|
+
file_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
86
|
+
XLIFF::File.new(file_node).strings.should be_empty
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have a string" do
|
90
|
+
file_node = Nokogiri::XML.parse("<xliff><file>#{@trans_unit}</file></xliff>").xpath("//file").first
|
91
|
+
XLIFF::File.new(file_node).strings.size.should eql(1)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have multiple strings" do
|
95
|
+
file_node = Nokogiri::XML.parse("<xliff><file>#{@trans_unit * 10}</file></xliff>").xpath("//file").first
|
96
|
+
XLIFF::File.new(file_node).strings.size.should eql(10)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module XLIFFer
|
5
|
+
describe XLIFF::String do
|
6
|
+
context "#new" do
|
7
|
+
before(:all) do
|
8
|
+
@minimal_trans_unit = <<-EOF
|
9
|
+
<trans-unit id="my id">
|
10
|
+
<source>Hello World</source>
|
11
|
+
<target>Bonjour le monde</target>
|
12
|
+
</trans-unit>
|
13
|
+
EOF
|
14
|
+
end
|
15
|
+
it "is created with a nokogiri trans-unit node" do
|
16
|
+
trans_unit_node = Nokogiri::XML.parse(@minimal_trans_unit).xpath("//trans-unit").first
|
17
|
+
XLIFF::String.new(trans_unit_node).should be
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can't be created with a string" do
|
21
|
+
expect{XLIFF::String.new("<file></file>")}.to raise_error ArgumentError
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can't be created with a node that is not a file node" do
|
25
|
+
trans_unit_node = Nokogiri::XML.parse("<xliff></xliff>").xpath("/xliff").first
|
26
|
+
expect{XLIFF::String.new(trans_unit_node)}.to raise_error ArgumentError
|
27
|
+
end
|
28
|
+
|
29
|
+
it "have one source" do
|
30
|
+
xml = "<trans-unit><target></target></trans-unit>"
|
31
|
+
trans_unit_node = Nokogiri::XML.parse(xml).xpath("//trans-unit").first
|
32
|
+
expect{XLIFF::String.new(trans_unit_node)}.to raise_error NoElement
|
33
|
+
end
|
34
|
+
|
35
|
+
it "don't have multiple sources tag" do
|
36
|
+
xml = "<trans-unit>#{"<source></source>"*2}<target></target></trans-unit>"
|
37
|
+
trans_unit_node = Nokogiri::XML.parse(xml).xpath("//trans-unit").first
|
38
|
+
expect{XLIFF::String.new(trans_unit_node)}.to raise_error MultipleElement
|
39
|
+
end
|
40
|
+
|
41
|
+
it "don't have multiple targets tag" do
|
42
|
+
xml = "<trans-unit><source></source>#{"<target></target>"*2}</trans-unit>"
|
43
|
+
trans_unit_node = Nokogiri::XML.parse(xml).xpath("//trans-unit").first
|
44
|
+
expect{XLIFF::String.new(trans_unit_node)}.to raise_error MultipleElement
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "#id" do
|
49
|
+
it "is nil if not defined" do
|
50
|
+
xml = "<trans-unit><source></source><target></target></trans-unit>"
|
51
|
+
trans_unit_node = Nokogiri::XML.parse(xml).xpath("//trans-unit").first
|
52
|
+
XLIFF::String.new(trans_unit_node).id.should be nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "is the id attribute on trans-unit tag" do
|
56
|
+
xml = "<trans-unit id='my id'><source></source><target></target></trans-unit>"
|
57
|
+
trans_unit_node = Nokogiri::XML.parse(xml).xpath("//trans-unit").first
|
58
|
+
XLIFF::String.new(trans_unit_node).id.should eql("my id")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
#context "#strings" do
|
64
|
+
# before(:all) do
|
65
|
+
# @trans_unit = <<-EOF
|
66
|
+
# <trans-unit id="my id">
|
67
|
+
# <source>Hello World</source>
|
68
|
+
# <target>Bonjour le monde</target>
|
69
|
+
# </trans-unit>
|
70
|
+
# EOF
|
71
|
+
# end
|
72
|
+
# it "is an array " do
|
73
|
+
# trans_unit_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
74
|
+
# XLIFF::File.new(trans_unit_node).strings.should be_kind_of(Array)
|
75
|
+
# end
|
76
|
+
|
77
|
+
# it "can be empty" do
|
78
|
+
# trans_unit_node = Nokogiri::XML.parse("<xliff><file></file></xliff>").xpath("//file").first
|
79
|
+
# XLIFF::File.new(trans_unit_node).strings.should be_empty
|
80
|
+
# end
|
81
|
+
|
82
|
+
# it "should have a string" do
|
83
|
+
# trans_unit_node = Nokogiri::XML.parse("<xliff><file>#{@trans_unit}</file></xliff>").xpath("//file").first
|
84
|
+
# XLIFF::File.new(trans_unit_node).strings.size.should eql(1)
|
85
|
+
# end
|
86
|
+
|
87
|
+
# it "should have multiple strings" do
|
88
|
+
# trans_unit_node = Nokogiri::XML.parse("<xliff><file>#{@trans_unit * 10}</file></xliff>").xpath("//file").first
|
89
|
+
# XLIFF::File.new(trans_unit_node).strings.size.should eql(10)
|
90
|
+
# end
|
91
|
+
#end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module XLIFFer
|
4
|
+
describe XLIFF do
|
5
|
+
context "#new" do
|
6
|
+
it "accepts a xliff file" do
|
7
|
+
XLIFF.new(::File.open("spec/files/empty.xliff")).should be
|
8
|
+
end
|
9
|
+
|
10
|
+
it "accepts a xliff string" do
|
11
|
+
XLIFF.new(::File.open("spec/files/empty.xliff").read).should be
|
12
|
+
end
|
13
|
+
|
14
|
+
it "doesn't accept a number" do
|
15
|
+
expect{XLIFF.new(123)}.to raise_error ArgumentError
|
16
|
+
end
|
17
|
+
|
18
|
+
it "doesn't accept a random string" do
|
19
|
+
expect{XLIFF.new("foobar")}.to raise_error FormatError
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't accept a random file" do
|
23
|
+
expect{XLIFF.new(::File.new("spec/files/file.foobar"))}.to raise_error FormatError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#version" do
|
28
|
+
it "is the xliff version" do
|
29
|
+
XLIFF.new('<xliff version="9.8"></xliff>').version.should eql("9.8")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "is nil when it is not present" do
|
33
|
+
XLIFF.new('<xliff></xliff>').version.should be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "is a string when there is a xliff version" do
|
37
|
+
XLIFF.new('<xliff version="9.8"></xliff>').version.should be_kind_of(String)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#files" do
|
42
|
+
it "is an array " do
|
43
|
+
XLIFF.new('<xliff></xliff>').files.should be_kind_of(Array)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "can be empty" do
|
47
|
+
XLIFF.new('<xliff></xliff>').files.should be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a file" do
|
51
|
+
XLIFF.new('<xliff><file></file></xliff>').files.first.should be_kind_of(XLIFF::File)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have multiple files" do
|
55
|
+
XLIFF.new('<xliff><file></file><file></file></xliff>').files.size.should eql(2)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/xliffer.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'xliffer/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'xliffer'
|
6
|
+
s.version = XLIFFer::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.licenses = ["MIT"]
|
9
|
+
s.date = '2012-01-01'
|
10
|
+
s.summary = "A XLIFF parser"
|
11
|
+
s.description = "A parser for XLIFF files"
|
12
|
+
s.authors = ["Felipe Tanus"]
|
13
|
+
s.email = 'fotanus@gmail.com'
|
14
|
+
s.homepage = 'http://github.com/fotanus/xliff'
|
15
|
+
|
16
|
+
s.add_development_dependency "rspec", "~> 2"
|
17
|
+
s.rubyforge_project = "xliffer"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xliffer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Felipe Tanus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2012-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
description: A parser for XLIFF files
|
28
|
+
email: fotanus@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
34
|
+
- ".rspec"
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/xliffer.rb
|
40
|
+
- lib/xliffer/exceptions.rb
|
41
|
+
- lib/xliffer/version.rb
|
42
|
+
- lib/xliffer/xliff.rb
|
43
|
+
- lib/xliffer/xliff/file.rb
|
44
|
+
- lib/xliffer/xliff/string.rb
|
45
|
+
- spec/files/empty.xliff
|
46
|
+
- spec/files/file.foobar
|
47
|
+
- spec/files/wiki.xliff
|
48
|
+
- spec/files/xliffspec1.xliff
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
- spec/xliffer/file_spec.rb
|
51
|
+
- spec/xliffer/string_spec.rb
|
52
|
+
- spec/xliffer/xliff_spec.rb
|
53
|
+
- spec/xliffer_spec.rb
|
54
|
+
- xliffer.gemspec
|
55
|
+
homepage: http://github.com/fotanus/xliff
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project: xliffer
|
75
|
+
rubygems_version: 2.4.6
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: A XLIFF parser
|
79
|
+
test_files: []
|