bisu 1.2.4 → 1.3.0

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: 91a21fb208a5322f64116f20e4b82e6108085b8d
4
- data.tar.gz: 9a8b0eef2a85596da38cc1e51da31f699d5c6f94
3
+ metadata.gz: 6986c97d7458f01354dfea511217a6fe565e8623
4
+ data.tar.gz: 13ef8e986f57451ec5170612794ca098c285f0be
5
5
  SHA512:
6
- metadata.gz: cc959379b26785e7f50b44461908985ef491eb94d6e765390145ca3416c130305c3ba7877837f9fbafefa9d149bd9816e72bf6d82c92dbc97c0cc9fe5bde58b3
7
- data.tar.gz: faa8f17d79bf8579a6a5810e858f19e5adfff2635a213429e641ecbd1f8fe1e8373d27491f10182568b71859abe0349aa3a59c7ddb3c024e264fda38498b409b
6
+ metadata.gz: 91712afc1636778325e5119513a76173a4a8623fe7ec1b36e06bd97cafc8f180f3a311840e234d33f294c752ee243fe247a7d9ab708c38301607d4f475dd4348
7
+ data.tar.gz: 500e7bcc77107d003d032c71e53d5a79b6579a52ea3c1a0250e91e71f693edff0e0aecb2c9b8125ed52e5d536032e9e61acaef67122f6e94692bae899405d735
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gem 'xml-simple', '~> 1.1'
7
7
 
8
8
  gem 'webmock', '~> 1.20'
9
9
  gem 'rspec'
10
+ gem 'rspec-its'
data/Gemfile.lock CHANGED
@@ -16,6 +16,9 @@ GEM
16
16
  rspec-expectations (3.5.0)
17
17
  diff-lcs (>= 1.2.0, < 2.0)
18
18
  rspec-support (~> 3.5.0)
19
+ rspec-its (1.2.0)
20
+ rspec-core (>= 3.0.0)
21
+ rspec-expectations (>= 3.0.0)
19
22
  rspec-mocks (3.5.0)
20
23
  diff-lcs (>= 1.2.0, < 2.0)
21
24
  rspec-support (~> 3.5.0)
@@ -33,6 +36,7 @@ PLATFORMS
33
36
  DEPENDENCIES
34
37
  colorize (~> 0.7)
35
38
  rspec
39
+ rspec-its
36
40
  safe_yaml (~> 1.0)
37
41
  webmock (~> 1.20)
38
42
  xml-simple (~> 1.1)
data/lib/bisu/config.rb CHANGED
@@ -1,38 +1,54 @@
1
- require "yaml"
2
-
3
1
  module Bisu
4
- module Config
5
- extend self
2
+ class Config
3
+ def initialize(hash:)
4
+ @hash = hash.deep_symbolize
5
+ @hash.validate_structure!(EXPECTED_HASH)
6
+ end
6
7
 
7
- def parse(file_name)
8
- unless file_name
9
- Logger.error("Config file not provided")
10
- return nil
11
- end
8
+ def to_h
9
+ @hash
10
+ end
12
11
 
13
- unless File.exists?(file_name)
14
- Logger.error("Could not find config file #{file_name}")
15
- return nil
16
- end
12
+ def dictionary
13
+ @hash[:dictionary]
14
+ end
15
+
16
+ def type
17
+ @hash[:type]
18
+ end
17
19
 
18
- begin
19
- deep_sym(YAML::load_file(file_name))
20
- rescue Exception => e
21
- Logger.error("Could not parse config file #{file_name}: #{e}")
22
- return nil
20
+ def localize_files
21
+ @hash[:translate].each do |t|
22
+ @hash[:languages].each do |l|
23
+ downcase_locale = l[:locale].downcase.gsub("-", "_").gsub(" ", "_")
24
+ yield(t[:in], (t[:"out_#{downcase_locale}"] || t[:out]) % l, l[:language], l[:locale])
25
+ end
23
26
  end
24
27
  end
25
28
 
26
29
  private
27
30
 
28
- def deep_sym(obj)
29
- if obj.is_a?(Array)
30
- obj.map { |v| deep_sym(v) }
31
- elsif obj.is_a?(Hash)
32
- obj.inject({}) { |memo, (k,v)| memo[k.to_sym] = deep_sym(v); memo }
33
- else
34
- obj
35
- end
36
- end
31
+ EXPECTED_HASH = {
32
+ type: Hash,
33
+ elements: {
34
+ type: { type: String },
35
+ dictionary: { type: Hash, elements: {
36
+ sheet_id: { type: String },
37
+ keys_column: { type: String }
38
+ } },
39
+ translate: { type: Array, elements: {
40
+ type: Hash, elements: {
41
+ in: { type: String },
42
+ out: { type: String }
43
+ }
44
+ } },
45
+ languages: { type: Array, elements: {
46
+ type: Hash, elements: {
47
+ locale: { type: String },
48
+ language: { type: String }
49
+ }
50
+ } }
51
+ }
52
+ }
37
53
  end
38
54
  end
@@ -8,7 +8,7 @@ module Bisu
8
8
  @key_column = keys_column_title
9
9
  end
10
10
 
11
- def to_hash
11
+ def to_h
12
12
  raw = raw_data(@sheet_id)
13
13
 
14
14
  Logger.info("Parsing Google Sheet...")
@@ -2,7 +2,7 @@ module Bisu
2
2
  class Localizer
3
3
  def initialize(dictionary, type)
4
4
  @dict = dictionary
5
- @type = type.downcase.to_sym
5
+ @type = type.to_s.downcase.to_sym
6
6
 
7
7
  unless [:ios, :android, :ror].include?(@type)
8
8
  Logger.error("Unknown type #{@type}")
@@ -0,0 +1,41 @@
1
+ Object.class_eval do
2
+ def deep_symbolize
3
+ case self
4
+ when Array
5
+ self.map { |v| v.deep_symbolize }
6
+ when Hash
7
+ self.inject({}) { |memo, (k,v)| memo[k.to_sym] = v.deep_symbolize; memo }
8
+ else
9
+ self
10
+ end
11
+ end
12
+
13
+ def validate_structure!(structure, error_prefix=[])
14
+ return if self == nil && structure[:optional]
15
+
16
+ prepend_error = error_prefix.empty? ? "" : (["self"] + error_prefix + [": "]).join
17
+
18
+ unless self.is_a? structure[:type]
19
+ raise ArgumentError.new("#{prepend_error}Expected #{structure[:type]}, got #{self.class}")
20
+ end
21
+
22
+ return unless structure[:elements]
23
+
24
+ case self
25
+ when Array
26
+ self.each_with_index do |e, i|
27
+ e.validate_structure!(structure[:elements], error_prefix + ["[#{i}]"])
28
+ end
29
+ when Hash
30
+ mandatory_keys = structure[:elements].map { |k,s| k unless s[:optional] }.compact
31
+
32
+ unless (missing = mandatory_keys - self.keys).empty?
33
+ raise ArgumentError.new("#{prepend_error}Missing keys: #{missing.join(', ')}")
34
+ end
35
+
36
+ structure[:elements].each do |key, structure|
37
+ self[key].validate_structure!(structure, error_prefix + ["[:#{key}]"])
38
+ end
39
+ end
40
+ end
41
+ end
data/lib/bisu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bisu
2
- VERSION = '1.2.4'
3
- VERSION_UPDATED_AT = '2016-10-23'
2
+ VERSION = '1.3.0'
3
+ VERSION_UPDATED_AT = '2016-11-02'
4
4
  end
data/lib/bisu.rb CHANGED
@@ -1,10 +1,13 @@
1
+ require 'optparse'
2
+ require 'yaml'
3
+
1
4
  require 'bisu/logger'
5
+ require 'bisu/object_extension'
2
6
  require 'bisu/config'
3
7
  require 'bisu/google_sheet'
4
8
  require 'bisu/dictionary'
5
9
  require 'bisu/localizer'
6
10
  require 'bisu/version'
7
- require 'optparse'
8
11
 
9
12
  module Bisu
10
13
  extend self
@@ -12,20 +15,19 @@ module Bisu
12
15
  def run(options)
13
16
  options = command_line_options(options)
14
17
 
15
- if config = Bisu::Config.parse("translatable.yml")
16
- google_sheet = Bisu::GoogleSheet.new(config[:sheet_id], config[:keys_column])
17
- dictionary = Bisu::Dictionary.new(google_sheet.to_hash)
18
- localizer = Bisu::Localizer.new(dictionary, config[:type])
18
+ if config_file = open_file("translatable.yml", "r", true)
19
+ config = Bisu::Config.new(hash: YAML::load(config_file))
20
+ google_sheet = Bisu::GoogleSheet.new(config.dictionary[:sheet_id], config.dictionary[:keys_column])
21
+ dictionary = Bisu::Dictionary.new(google_sheet.to_h)
22
+ localizer = Bisu::Localizer.new(dictionary, config.type)
19
23
 
20
- config[:in].each do |in_path|
21
- config[:out].each do |out|
22
- unless dictionary.has_language?(out[:kb_language])
23
- Logger.error("Unknown language #{out[:kb_language]}")
24
- return false
25
- end
26
-
27
- localize_file(localizer, out[:locale], out[:kb_language], options[:default_language], in_path, out[:path] || config[:out_path])
24
+ config.localize_files do |in_path, out_path, language, locale|
25
+ unless dictionary.has_language?(language)
26
+ Logger.error("Unknown language #{language}")
27
+ return false
28
28
  end
29
+
30
+ localize_file(localizer, locale, language, options[:default_language], in_path, out_path)
29
31
  end
30
32
  end
31
33
 
@@ -57,22 +59,25 @@ module Bisu
57
59
  opts_hash
58
60
  end
59
61
 
60
- def localize_file(localizer, locale, language, default_language, in_path, out_path)
61
- in_name = File.basename(in_path)
62
- out_name = in_name.gsub(/\.translatable$/, "")
63
-
64
- unless in_name.match /\.translatable$/
65
- Logger.error("Expected .translatable file. Got '#{in_name}'")
66
- return false
62
+ def open_file(file_name, method, should_exist)
63
+ if !File.file?(File.expand_path(file_name))
64
+ if should_exist
65
+ Logger.error("File #{file_name} not found!")
66
+ return nil
67
+ else
68
+ FileUtils.mkdir_p(File.dirname(file_name))
69
+ end
67
70
  end
68
71
 
69
- out_path = out_path % { locale: locale, android_locale: locale.gsub("-", "-r"), out_name: out_name }
72
+ File.open(File.expand_path(file_name), method)
73
+ end
74
+
75
+ def localize_file(localizer, locale, language, default_language, in_path, out_path)
76
+ Logger.info("Translating #{in_path} to #{language} > #{out_path}...")
70
77
 
71
78
  return false unless in_file = open_file(in_path, "r", true)
72
79
  return false unless out_file = open_file(out_path, "w", false)
73
80
 
74
- Logger.info("Translating #{in_path} to #{language} > #{out_path}...")
75
-
76
81
  in_file.each_line do |line|
77
82
  out_file.write(localizer.localize(line, language, locale, default_language))
78
83
  end
@@ -83,17 +88,4 @@ module Bisu
83
88
 
84
89
  true
85
90
  end
86
-
87
- def open_file(file_name, method, should_exist)
88
- if !File.file?(File.expand_path(file_name))
89
- if should_exist
90
- Logger.error("File #{file_name} not found!")
91
- return nil
92
- else
93
- FileUtils.mkdir_p(File.dirname(file_name))
94
- end
95
- end
96
-
97
- File.open(File.expand_path(file_name), method)
98
- end
99
91
  end
@@ -0,0 +1,17 @@
1
+ type: iOS
2
+
3
+ dictionary:
4
+ sheet_id: sheet-id
5
+ keys_column: keys-column
6
+
7
+ translate:
8
+ - in: hole19/Localizable.strings.translatable
9
+ out: hole19/%{locale}.lproj/Localizable.strings
10
+ - in: hole19/Countries.strings.translatable
11
+ out: hole19/%{locale}.lproj/Countries.strings
12
+
13
+ languages:
14
+ - locale: en
15
+ language: english
16
+ - locale: en-US
17
+ language: english
@@ -0,0 +1,53 @@
1
+ describe Bisu::Config do
2
+ subject(:config) { Bisu::Config.new(hash: hash) }
3
+
4
+ let(:hash) { {
5
+ type: "BisuOS",
6
+ dictionary: {
7
+ sheet_id: "abc1234567890",
8
+ keys_column: "key_name"
9
+ },
10
+ translate: [
11
+ { in: "path/to/file/to/1.ext.translatable",
12
+ out: "path/to/final-%{locale}/1.ext",
13
+ out_en_us: "path/to/default/1.ext"
14
+ },
15
+ { in: "path/to/file/to/2.ext.translatable",
16
+ out: "path/to/final-%{locale}/2.ext",
17
+ out_en_us: "path/to/default/2.ext"
18
+ },
19
+ ],
20
+ languages: [
21
+ { locale: "en-US", language: "english" },
22
+ { locale: "pt", language: "portuguese" },
23
+ { locale: "pt-PT", language: "portuguese" },
24
+ { locale: "pt-Batatas", language: "portuguese" }
25
+ ]
26
+ } }
27
+
28
+ context "when hash is missing params" do
29
+ before { hash.delete(:type) }
30
+ it { expect { config }.to raise_error /missing keys/i }
31
+ end
32
+
33
+ its(:to_h) { should eq(hash) }
34
+ its(:type) { should eq("BisuOS") }
35
+ its(:dictionary) { should eq({ sheet_id: "abc1234567890", keys_column: "key_name" }) }
36
+
37
+ describe "#localize_files" do
38
+ it "yields 5 times with the expected arguments" do
39
+ expect { |b|
40
+ config.localize_files(&b)
41
+ }.to yield_successive_args(
42
+ ["path/to/file/to/1.ext.translatable", "path/to/default/1.ext", "english", "en-US" ],
43
+ ["path/to/file/to/1.ext.translatable", "path/to/final-pt/1.ext", "portuguese", "pt" ],
44
+ ["path/to/file/to/1.ext.translatable", "path/to/final-pt-PT/1.ext", "portuguese", "pt-PT" ],
45
+ ["path/to/file/to/1.ext.translatable", "path/to/final-pt-Batatas/1.ext", "portuguese", "pt-Batatas"],
46
+ ["path/to/file/to/2.ext.translatable", "path/to/default/2.ext", "english", "en-US" ],
47
+ ["path/to/file/to/2.ext.translatable", "path/to/final-pt/2.ext", "portuguese", "pt" ],
48
+ ["path/to/file/to/2.ext.translatable", "path/to/final-pt-PT/2.ext", "portuguese", "pt-PT" ],
49
+ ["path/to/file/to/2.ext.translatable", "path/to/final-pt-Batatas/2.ext", "portuguese", "pt-Batatas"]
50
+ )
51
+ end
52
+ end
53
+ end
File without changes
@@ -1,5 +1,5 @@
1
1
  describe Bisu::GoogleSheet do
2
- subject(:to_hash) { Bisu::GoogleSheet.new(sheet_id, key_column).to_hash }
2
+ subject(:to_h) { Bisu::GoogleSheet.new(sheet_id, key_column).to_h }
3
3
 
4
4
  let(:sheet_id) { "abc1234567890" }
5
5
  let(:url_info) { "https://spreadsheets.google.com/feeds/worksheets/#{sheet_id}/public/full" }
@@ -17,20 +17,20 @@ describe Bisu::GoogleSheet do
17
17
  end
18
18
 
19
19
  it do
20
- expect { to_hash }.not_to raise_error
20
+ expect { to_h }.not_to raise_error
21
21
  end
22
22
 
23
23
  it "returns an hash" do
24
- expect(to_hash).to include("kConnectEmail")
25
- expect(to_hash["kConnectEmail"]).to include("korean")
26
- expect(to_hash["kConnectEmail"]).to include("spanish" => "Conéctate con Email")
24
+ expect(to_h).to include("kConnectEmail")
25
+ expect(to_h["kConnectEmail"]).to include("korean")
26
+ expect(to_h["kConnectEmail"]).to include("spanish" => "Conéctate con Email")
27
27
  end
28
28
 
29
29
  context "but the key column is not present in the first sheet" do
30
30
  let(:key_column) { "expecting_another_key_column" }
31
31
 
32
32
  it do
33
- expect { to_hash }.to raise_error /Cannot find key column/
33
+ expect { to_h }.to raise_error /Cannot find key column/
34
34
  end
35
35
  end
36
36
  end
@@ -39,7 +39,7 @@ describe Bisu::GoogleSheet do
39
39
  before { stub_request(:get, url_info).to_return(:status => 400, :body => "Not Found", :headers => {}) }
40
40
 
41
41
  it do
42
- expect { to_hash }.to raise_error /Cannot access sheet/
42
+ expect { to_h }.to raise_error /Cannot access sheet/
43
43
  end
44
44
  end
45
45
 
@@ -47,7 +47,7 @@ describe Bisu::GoogleSheet do
47
47
  before { stub_request(:get, url_info).to_return(:status => 302, :body => "<HTML></HTML>", :headers => {}) }
48
48
 
49
49
  it do
50
- expect { to_hash }.to raise_error /Cannot access sheet/
50
+ expect { to_h }.to raise_error /Cannot access sheet/
51
51
  end
52
52
  end
53
53
 
@@ -55,7 +55,7 @@ describe Bisu::GoogleSheet do
55
55
  before { stub_request(:get, url_info).to_return(:status => 200, :body => "This is not XML; { this: \"is json\" }", :headers => {}) }
56
56
 
57
57
  it do
58
- expect { to_hash }.to raise_error /Cannot parse. Expected XML/
58
+ expect { to_h }.to raise_error /Cannot parse. Expected XML/
59
59
  end
60
60
  end
61
61
  end
@@ -85,8 +85,6 @@ describe Bisu::Localizer do
85
85
  end
86
86
 
87
87
  it "does not throw an error when key parameters where given" do
88
- Bisu::Logger.silent_mode = false
89
-
90
88
  expect {
91
89
  localizer.localize("$k1ParameterKey{name:%1$s}$", language, locale)
92
90
  }.to not_change { Bisu::Logger.summary[:warn] }
File without changes
@@ -0,0 +1,100 @@
1
+ describe Object do
2
+
3
+ describe "#deep_symbolize" do
4
+ subject { obj.deep_symbolize }
5
+
6
+ context "when object is an Hash" do
7
+ let(:obj) { { "key1" => "value1", key2: "value2" } }
8
+ it { should eq({ key1: "value1", key2: "value2" }) }
9
+
10
+ context "with inner Hashes" do
11
+ before { obj["key2"] = { "key3" => { "key4" => "value4" } } }
12
+ it { should eq({ key1: "value1", key2: { key3: { key4: "value4" } }}) }
13
+ end
14
+ end
15
+
16
+ context "when object is an Array" do
17
+ let(:obj) { ["value1"] }
18
+ it { should eq obj }
19
+
20
+ context "with inner Hashes" do
21
+ let(:obj) { [{ "key1" => "value1" }, { "key2" => "value2" }] }
22
+ it { should eq([{ key1: "value1" }, { key2: "value2" }]) }
23
+ end
24
+ end
25
+
26
+ context "when object is something else" do
27
+ let(:obj) { "value1" }
28
+ it { should eq obj }
29
+ end
30
+ end
31
+
32
+ describe "#validate_structure!" do
33
+ subject { obj.validate_structure!(structure) }
34
+
35
+ context "when object type differs of the structure type" do
36
+ let(:obj) { "a string" }
37
+ let(:structure) { { type: Integer } }
38
+ it { expect { subject }.to raise_error /expected Integer, got String/i }
39
+ end
40
+
41
+ context "when object is a Nil" do
42
+ let(:obj) { nil }
43
+ let(:structure) { { type: Integer } }
44
+ it { expect { subject }.to raise_error /expected Integer, got NilClass/i }
45
+
46
+ context "but is also optional" do
47
+ before { structure[:optional] = true }
48
+ it { expect { subject }.not_to raise_error }
49
+ end
50
+ end
51
+
52
+ context "when object is an Array" do
53
+ let(:obj) { ["elem1", "elem2"] }
54
+ let(:structure) { { type: Array } }
55
+ it { expect { subject }.not_to raise_error }
56
+
57
+ context "given an element structure" do
58
+ before { structure[:elements] = { type: String } }
59
+ it { expect { subject }.not_to raise_error }
60
+
61
+ context "which is not respected" do
62
+ before { structure[:elements] = { type: Integer } }
63
+ it { expect { subject }.to raise_error /expected Integer, got String/i }
64
+ end
65
+ end
66
+ end
67
+
68
+ context "when object is an Hash" do
69
+ let(:obj) { { key1: "value1", key2: "value2", key3: "value3" } }
70
+ let(:structure) { { type: Hash } }
71
+ it { expect { subject }.not_to raise_error }
72
+
73
+ context "when given an element structure" do
74
+ let(:structure) { { type: Hash, elements: { key1: { type: String }, key2: { type: String }, key3: { type: String } } } }
75
+ it { expect { subject }.not_to raise_error }
76
+
77
+ context "which is not respected" do
78
+ before { obj[:key2] = {} }
79
+ it { expect { subject }.to raise_error /expected String, got Hash/i }
80
+ end
81
+
82
+ context "when missing keys" do
83
+ before do
84
+ obj.delete(:key1)
85
+ obj.delete(:key3)
86
+ end
87
+ it { expect { subject }.to raise_error /missing keys: key1, key3/i }
88
+
89
+ context "which are optional" do
90
+ before do
91
+ structure[:elements][:key1][:optional] = true
92
+ structure[:elements][:key3][:optional] = true
93
+ end
94
+ it { expect { subject }.not_to raise_error }
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,35 @@
1
+ describe Bisu do
2
+ subject(:run) { Bisu.run([]) }
3
+
4
+ context "when there is a translatable.yml" do
5
+ let(:file) { File.open("spec/fixtures/sample.translatable.yml") }
6
+
7
+ before do
8
+ allow(Bisu).to receive(:open_file).and_return(file)
9
+ allow_any_instance_of(Bisu::GoogleSheet).to receive(:to_h).and_return({
10
+ "kKey" => { "english" => "Value" }
11
+ })
12
+ allow(Bisu).to receive(:localize_file)
13
+ end
14
+
15
+ it { expect { run }.not_to raise_error }
16
+
17
+ it "logs an error" do
18
+ expect {
19
+ run
20
+ }.to not_change { Bisu::Logger.summary[:warn] }
21
+ .and not_change { Bisu::Logger.summary[:error] }
22
+ end
23
+ end
24
+
25
+ context "when translatable.yml does not exist locally" do
26
+ it { expect { run }.not_to raise_error }
27
+
28
+ it "logs an error" do
29
+ expect {
30
+ run
31
+ }.to not_change { Bisu::Logger.summary[:warn] }
32
+ .and change { Bisu::Logger.summary[:error] }.by(1)
33
+ end
34
+ end
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bisu'
2
2
  require 'webmock/rspec'
3
+ require 'rspec/its'
3
4
 
4
5
  # This file was generated by the `rspec --init` command. Conventionally, all
5
6
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaoffcosta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-23 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -89,15 +89,18 @@ files:
89
89
  - lib/bisu/google_sheet.rb
90
90
  - lib/bisu/localizer.rb
91
91
  - lib/bisu/logger.rb
92
+ - lib/bisu/object_extension.rb
92
93
  - lib/bisu/version.rb
93
- - spec/bisu/config_spec.rb
94
- - spec/bisu/dictionary_spec.rb
95
- - spec/bisu/google_sheet_spec.rb
96
- - spec/bisu/localizer_spec.rb
97
- - spec/bisu/logger_spec.rb
94
+ - spec/fixtures/sample.translatable.yml
98
95
  - spec/fixtures/sample_kb_public_info.html
99
96
  - spec/fixtures/sample_kb_public_sheet.html
100
- - spec/fixtures/sample_translatable.yml
97
+ - spec/lib/bisu/config_spec.rb
98
+ - spec/lib/bisu/dictionary_spec.rb
99
+ - spec/lib/bisu/google_sheet_spec.rb
100
+ - spec/lib/bisu/localizer_spec.rb
101
+ - spec/lib/bisu/logger_spec.rb
102
+ - spec/lib/bisu/object_extension_spec.rb
103
+ - spec/lib/bisu_spec.rb
101
104
  - spec/spec_helper.rb
102
105
  homepage: https://github.com/hole19/bisu
103
106
  licenses:
@@ -1,35 +0,0 @@
1
- describe Bisu::Config do
2
- subject { Bisu::Config.parse(file_path) }
3
-
4
- context "given a yml file" do
5
- let(:file_path) { "spec/fixtures/sample_translatable.yml" }
6
-
7
- it "should parse the yml with deep key symbolization" do
8
- expect(subject).to eq({
9
- type: "BisuOS",
10
- sheet_id: "abc1234567890",
11
- keys_column: "key_name",
12
- in: [
13
- "path/to/file/to/1.ext.translatable",
14
- "path/to/file/to/2.ext.translatable"
15
- ],
16
- out_path: "path/to/final-%{locale}/%{out_name}",
17
- out: [
18
- { locale: "en", kb_language: "english", path: "path/to/default/%{out_name}" },
19
- { locale: "pt", kb_language: "portuguese" },
20
- { locale: "pt-PT", kb_language: "portuguese" }
21
- ]
22
- })
23
- end
24
- end
25
-
26
- context "given an inexistent file" do
27
- let(:file_path) { "does_not_exist" }
28
- it { should be nil }
29
- end
30
-
31
- context "given no file path" do
32
- let(:file_path) { nil }
33
- it { should be nil }
34
- end
35
- end
@@ -1,18 +0,0 @@
1
- type: BisuOS
2
-
3
- sheet_id: abc1234567890
4
- keys_column: key_name
5
-
6
- in:
7
- - path/to/file/to/1.ext.translatable
8
- - path/to/file/to/2.ext.translatable
9
-
10
- out_path: path/to/final-%{locale}/%{out_name}
11
- out:
12
- - locale: en
13
- kb_language: english
14
- path: path/to/default/%{out_name}
15
- - locale: pt
16
- kb_language: portuguese
17
- - locale: pt-PT
18
- kb_language: portuguese