t_t 1.3.0 → 1.3.1

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: db067791facedb6247eff1b9fed82785f6bd325a
4
- data.tar.gz: ced2994ee972a2956c9799e4b1ba8c0e79ff3dc2
3
+ metadata.gz: e1778d63797bef7e82a460b8db4120d651651cfd
4
+ data.tar.gz: 6ec1bc34106914cf96f5d05609153f61329d0e2d
5
5
  SHA512:
6
- metadata.gz: cfe464540b1e363083f4bd74e5a647379e7f86f627b3d665f2eeab8f8a1cb90258a1a4ba42fb764707b7edb35b5ad44b4ed2717781e053a716863ac06f4e550b
7
- data.tar.gz: 407fc17c5b26f170fbc58235d070e9e4483a63fa65502b4b44d5d39b2cf03658e2e64551cee614ea5dadab34d57cec95387e3b372749d11414340870098162a0
6
+ metadata.gz: 05623243e817f16aa945b7c7b01fd56b244c41b0d1d0f8b0958918bdd978fa78e5352039672bbde0e03a2a9fc7ba8b33a6680df534b398745e81e3642a857a72
7
+ data.tar.gz: c2acf9ffb897a9ec497c1f02a24a0e11b60912dd156661a9ce1d195aa3aeb98471986d4d35fc75db387f6f7fdb82a2fdf2f0916d32ad1de50dce0a7946017535
data/Dockerfile ADDED
@@ -0,0 +1,6 @@
1
+ FROM ruby:2.4
2
+ VOLUME /opt/tt
3
+ VOLUME /root/.ssh
4
+ WORKDIR /opt/tt
5
+ RUN gem install bundler
6
+ CMD bash
@@ -0,0 +1,37 @@
1
+ module TT
2
+ module Formaters
3
+ extend self
4
+
5
+ def print(groups, format)
6
+ case format
7
+ when 'csv' then csv(groups)
8
+ else stdout(groups)
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def stdout(groups)
15
+ groups.each do |group, list|
16
+ puts "# #{ group }"
17
+
18
+ list.each do |line|
19
+ puts line.inject("") { |r, (k, v)| r + "#{ k.upcase }: #{ v.to_s.encode('utf-8') }\n" }
20
+ end
21
+
22
+ puts '---'
23
+ end
24
+ end
25
+
26
+ def csv(groups)
27
+ return if groups.empty?
28
+
29
+ require 'csv'
30
+ CSV.open('tmp/tt-missed.csv', 'w') do |io|
31
+ locales = groups.first.last.first.keys.sort
32
+ io << locales.map(&:upcase)
33
+ groups.each_value { |list| list.each { |line| io << line.values_at(*locales) } }
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/t_t/tasks.rb CHANGED
@@ -9,17 +9,10 @@ namespace :tt do
9
9
  end
10
10
 
11
11
  desc "Shows a missed keys in the translation file groups"
12
- task :m => [:s] do
12
+ task :m, [:format] => [:s] do |t, args|
13
13
  if sync = TT::Rails.sync
14
- sync.missed.each do |group, list|
15
- puts "# #{ group }"
16
-
17
- list.each do |line|
18
- puts line.inject("") { |r, (k, v)| r + "#{ k.upcase }: #{ v.to_s.encode('utf-8') }\n" }
19
- end
20
-
21
- puts '---'
22
- end
14
+ require_relative './formaters'
15
+ TT::Formaters.print(sync.missed, args[:format])
23
16
  else
24
17
  puts "t_t: Please, setup the synchronisation first"
25
18
  end
data/readme.md CHANGED
@@ -102,6 +102,8 @@ Just add `gem "t_t"` into your Gemfile and run `bundle`.
102
102
  Dos-T is tested against Ruby 1.9.3+ & JRuby(1.9+ compatible). If your application uses Ruby on Rails the framework version should be 3.2+
103
103
 
104
104
  ## Changelog
105
+ - 1.3.1
106
+ - Add csv export in tt:m task
105
107
  - 1.3.0
106
108
  - Allow specify a custom mark for locale file synchonization
107
109
  - 1.2.2
data/t_t.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "t_t"
5
- spec.version = "1.3.0"
5
+ spec.version = "1.3.1"
6
6
  spec.authors = ["Sergey Pchelintsev"]
7
7
  spec.email = ["mail@sergeyp.me"]
8
8
  spec.summary = %q{An opinioned I18n helper}
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+ require 't_t/formaters'
3
+
4
+ describe "Formaters" do
5
+ it 'prints csv output' do
6
+ groups = { 'deserts.yml' => [{ 'en' => 'Apple', 'es' => 'Manzana' }, { 'es' => 'Dulce', 'en' => 'Candy' }] }
7
+ begin
8
+ TT::Formaters::CSV = Struct.new(:example) {
9
+ def open(*args, &block)
10
+ io = []
11
+ block.call(io)
12
+ example.assert_equal io.length, 3
13
+ example.assert_equal io[0], ['EN', 'ES']
14
+ example.assert_equal io[1], ['Apple', 'Manzana']
15
+ example.assert_equal io[2], ['Candy', 'Dulce']
16
+ end
17
+ }.new(self)
18
+ TT::Formaters.print(groups, 'csv')
19
+ ensure
20
+ TT::Formaters.send(:remove_const, :CSV)
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t_t
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pchelintsev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-03 00:00:00.000000000 Z
11
+ date: 2017-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
119
  - ".travis.yml"
120
+ - Dockerfile
120
121
  - Gemfile
121
122
  - Rakefile
122
123
  - cheatsheet.md
@@ -133,6 +134,7 @@ files:
133
134
  - lib/t_t/action_factory.rb
134
135
  - lib/t_t/base.rb
135
136
  - lib/t_t/builtin_rules.rb
137
+ - lib/t_t/formaters.rb
136
138
  - lib/t_t/i18n_sync.rb
137
139
  - lib/t_t/rails.rb
138
140
  - lib/t_t/tasks.rb
@@ -141,6 +143,7 @@ files:
141
143
  - tests/lib/action_factory_test.rb
142
144
  - tests/lib/action_pack_test.rb
143
145
  - tests/lib/builtin_rules_test.rb
146
+ - tests/lib/formaters_test.rb
144
147
  - tests/lib/i18n_sync_test.rb
145
148
  - tests/lib/model_module_test.rb
146
149
  - tests/lib/model_test.rb
@@ -166,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
169
  version: '0'
167
170
  requirements: []
168
171
  rubyforge_project:
169
- rubygems_version: 2.6.11
172
+ rubygems_version: 2.6.14
170
173
  signing_key:
171
174
  specification_version: 4
172
175
  summary: An opinioned I18n helper