yaml-twine-formatter 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.
- checksums.yaml +7 -0
- data/lib/yaml-twine-formatter.rb +47 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f603033bab38953c5dffafdcad2e047d6819e5e
|
4
|
+
data.tar.gz: 4bd2cfec5ca465549ca2a8e7d556a3965549aa14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c33d91a046a8ad4764144a2846ca129e77eb28ba5c4387a02cc6cbb6f91c60a75921ae591d445977cabe2e1686e119145842e3c6a1f7671bda503b4fe7e70fe9
|
7
|
+
data.tar.gz: dd05ceb77c112a0993a60785aace47be7a387fc8519b28fd19162f432fd5fe5715b5e169248af8e653dc6c07f9f2f95dc5dd508c820d5fbd292638e4720b11c9
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Twine
|
4
|
+
module Formatters
|
5
|
+
class Yaml < Abstract
|
6
|
+
def format_name
|
7
|
+
'yaml'
|
8
|
+
end
|
9
|
+
|
10
|
+
def extension
|
11
|
+
'.yml'
|
12
|
+
end
|
13
|
+
|
14
|
+
def can_handle_directory?(path)
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_file_name
|
19
|
+
'strings.yml'
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_header(lang)
|
23
|
+
"# YAML\n# Generated by Twine #{Twine::VERSION}\n# Language: #{lang}\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_sections(twine_file, lang)
|
27
|
+
sections = get_key_value_table(twine_file.sections, lang)
|
28
|
+
YAML.dump(sections)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_key_value_table(sections, lang)
|
32
|
+
table = {}
|
33
|
+
|
34
|
+
sections.each do |section|
|
35
|
+
section.definitions.each do |definition|
|
36
|
+
next unless definition.translations.include? lang
|
37
|
+
table["[[#{section.name}]].[#{definition.key}]"] = definition.translations[lang]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
table
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Twine::Formatters.formatters << Twine::Formatters::Yaml.new
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yaml-twine-formatter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Šimon Kručinin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: twine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
27
|
+
description: A Twine formatter to YAML
|
28
|
+
email: simon.krucinin@qest.cz
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/yaml-twine-formatter.rb
|
34
|
+
homepage: http://rubygems.org/gems/yaml-twine-formatter
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
source_code_uri: https://github.com/skjorn/yaml-twine-formatter
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.5.2
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: A Twine formatter to YAML
|
59
|
+
test_files: []
|