i18n_yaml_sorter_2 0.3.1 → 0.3.2

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: '019fae05b5138063422c4d02b70bb5a8edcba76e'
4
- data.tar.gz: 90d5b1211d6e112b96552907676e569c9962a36c
3
+ metadata.gz: 5a0a54edc695b8e56d660aedabd8cb1de73ae762
4
+ data.tar.gz: 738ddde845a5317d85e76e7368714e8f92c817be
5
5
  SHA512:
6
- metadata.gz: 4050d253a20f8b2cb0260ff4f143251218b090e2241c12cbdf841c6347829569ce835fee5e6a2fb7bb63066e0d577efb56b12ff815206917cb8dd03eda5dc902
7
- data.tar.gz: 376e69e7010d5542ab3ef517e2854e6da8d91b8d7eb6349e65c0164f6d066735f8d3e0013c145c667e179f6953ca265aba7241d0184e1b598a77816f742ae28e
6
+ metadata.gz: 1bf9971d390c1f649c30df4f3014fd93ca3b957886f083ede993b75220420cdeb645dc65a317f11962c540a8e1ad94215445278f25ce540923a1c39bfbc772ef
7
+ data.tar.gz: 3ab295f0185e37fafa2070c2eb05f9000ce59b7288b4d61677fc54439d133a28627445fa76c0666266a08ba06bf61e3727aba013f30ef76a392e40c6bc1b401f
@@ -214,7 +214,7 @@ TODO: Add command line arguments parsing and options, so you can, for instance,
214
214
  == Development
215
215
 
216
216
  $rake spec # run tests
217
- $rake build
217
+ $rake release # build installable/publishable gem
218
218
 
219
219
  == Future improvements (Forks Welcome!)
220
220
 
@@ -5,18 +5,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
5
  require 'i18n_yaml_sorter'
6
6
 
7
7
  options = {}
8
- optparse = OptionParser.new do |opts|
9
- opts.banner = 'Usage: sort_yaml < INPUT > OUTPUT | sort_yaml --install_bundle'
8
+ optparse = OptionParser.new do|opts|
9
+ opts.banner = "Usage: sort_yaml < INPUT > OUTPUT | sort_yaml --install_bundle"
10
10
 
11
11
  # Define the options, and what they do
12
12
  options[:install_bundle] = false
13
- opts.on('-i', '--install_bundle', 'Installs TextMate for MAC OS X bundle (named "YAML Sort") in the current user home dir.') do
13
+ opts.on( '-i', '--install_bundle', 'Installs TextMate for MAC OS X bundle (named "YAML Sort") in the current user home dir.' ) do
14
14
  options[:install_bundle] = true
15
15
  end
16
16
 
17
17
  # This displays the help screen, all programs are
18
18
  # assumed to have this option.
19
- opts.on('-h', '--help', 'Display this screen') do
19
+ opts.on( '-h', '--help', 'Display this screen' ) do
20
20
  puts opts
21
21
  exit
22
22
  end
@@ -25,14 +25,14 @@ end
25
25
  optparse.parse!
26
26
 
27
27
  if options[:install_bundle]
28
- puts "Installing TextMate Bundle in your home dir (~/Library/Application\\ Support/TextMate/Bundles/)..."
28
+ puts "Installing TextMate Bundle in your home dir (~/Library/Application\\ Support/TextMate/Bundles/)..."
29
29
  puts
30
30
  system "mkdir -p ~/Library/Application\ Support/TextMate/Bundles"
31
31
  system "cp -Rfv #{File.join(File.dirname(__FILE__), '..', 'textmate', 'YAML\ Sort.tmbundle')} ~/Library/Application\\ Support/TextMate/Bundles/ "
32
32
  puts
33
- puts "Reloading TextMate bundles..."
33
+ puts "Reloading TextMate bundles..."
34
34
  system "osascript -e 'tell app \"TextMate\" to reload bundles'"
35
35
  else
36
36
  sorter = I18nYamlSorter::Sorter.new(STDIN)
37
37
  puts sorter.sort
38
- end
38
+ end
@@ -3,8 +3,8 @@ module I18nYamlSorter
3
3
  require 'rails'
4
4
  class Railtie < Rails::Railtie
5
5
  rake_tasks do
6
- load 'tasks/i18n_yaml_sorter.rake'
6
+ load "tasks/i18n_yaml_sorter.rake"
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -9,51 +9,51 @@ module I18nYamlSorter
9
9
  @current_array_index = 0
10
10
  sorted_yaml_from_blocks_array
11
11
  end
12
-
12
+
13
13
  private
14
-
14
+
15
15
  def break_blocks_into_array
16
16
  array = []
17
-
17
+
18
18
  loop do
19
-
19
+
20
20
  maybe_next_line = @read_line_again || @io_input.gets || break
21
21
  @read_line_again = nil
22
22
  maybe_next_line.chomp!
23
23
 
24
- # Is it blank? Discard!
24
+ #Is it blank? Discard!
25
25
  next if maybe_next_line.match(/^\s*$/)
26
26
 
27
- # Does it look like a key: value line?
27
+ #Does it look like a key: value line?
28
28
  key_value_parse = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(: )(\s*)(\S.*\S)(\s*)$/)
29
- if key_value_parse
30
- array << maybe_next_line.concat("\n") #yes, it is the beginning of a key:value block
31
-
32
- # Special cases when it should add extra lines to the array element (multi line quoted strings)
33
-
34
- # Is the value surrounded by quotes?
29
+ if key_value_parse
30
+ array << maybe_next_line.concat("\n") #yes, it is the beginning of a key:value block
31
+
32
+ #Special cases when it should add extra lines to the array element (multi line quoted strings)
33
+
34
+ #Is the value surrounded by quotes?
35
35
  starts_with_quote = key_value_parse[5].match(/^["']/)[0] rescue nil
36
36
  ends_with_quote = key_value_parse[5].match(/[^\\](["'])$/)[1] rescue nil
37
- if starts_with_quote and !(starts_with_quote == ends_with_quote)
38
-
37
+ if starts_with_quote and !(starts_with_quote == ends_with_quote)
38
+
39
39
  loop do #Append next lines until we find the closing quote
40
40
  content_line = @io_input.gets || break
41
41
  content_line.chomp!
42
42
  array.last << content_line.concat("\n")
43
43
  break if content_line.match(/[^\\][#{starts_with_quote}]\s*$/)
44
44
  end
45
-
46
- end
47
-
45
+
46
+ end # if starts_with_quote
47
+
48
48
  next
49
- end
50
-
51
- # Is it a | or > string value?
49
+ end # if key_value_parse
50
+
51
+ # Is it a | or > string alue?
52
52
  is_special_string = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(: )(\s*)([|>])(\s*)$/)
53
53
  if is_special_string
54
- array << maybe_next_line.concat("\n") #yes, it is the beginning of a key block
54
+ array << maybe_next_line.concat("\n") #yes, it is the beginning of a key block
55
55
  indentation = is_special_string[1]
56
- # Append the next lines until we find one that is not indented
56
+ #Append the next lines until we find one that is not indented
57
57
  loop do
58
58
  content_line = @io_input.gets || break
59
59
  processed_line = content_line.chomp
@@ -65,48 +65,53 @@ module I18nYamlSorter
65
65
  break
66
66
  end
67
67
  end
68
-
68
+
69
69
  next
70
- end
71
-
72
- # Is it the beginning of a multi level hash?
70
+ end #if is_special_string
71
+
72
+ # Is it the begining of a multi level hash?
73
73
  is_start_of_hash = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(:)(\s*)$/)
74
74
  if is_start_of_hash
75
75
  array << maybe_next_line.concat("\n")
76
76
  next
77
- end
78
-
79
- # If we got here and nothing was done, this line
77
+ end
78
+
79
+ #If we got here and nothing was done, this line
80
80
  # should probably be merged with the previous one.
81
81
  if array.last
82
82
  array.last << maybe_next_line.concat("\n")
83
83
  else
84
84
  array << maybe_next_line.concat("\n")
85
85
  end
86
- end
86
+ end #loop
87
+
88
+ #debug:
89
+ #puts array.join("$$$$$$$$$$$$$$$$$$$$$$\n")
90
+
87
91
  array
88
92
  end
89
93
 
90
94
  def sorted_yaml_from_blocks_array(current_block = nil)
95
+
91
96
  unless current_block
92
97
  current_block = @array[@current_array_index]
93
98
  @current_array_index += 1
94
99
  end
95
-
100
+
96
101
  out_array = []
97
102
  current_match = current_block.match(/^(\s*)(["']?[\w\-]+["']?)(:)/)
98
103
  current_level = current_match[1] rescue ''
99
104
  current_key = current_match[2].downcase.tr(%q{"'}, "") rescue ''
100
105
  out_array << [current_key, current_block]
101
-
106
+
102
107
  loop do
103
108
  next_block = @array[@current_array_index] || break
104
109
  @current_array_index += 1
105
-
110
+
106
111
  current_match = next_block.match(/^(\s*)(["']?[\w\-]+["']?)(:)/) || next
107
112
  current_key = current_match[2].downcase.tr(%q{"'}, "")
108
113
  next_level = current_match[1]
109
-
114
+
110
115
  if current_level.size < next_level.size
111
116
  out_array.last.last << sorted_yaml_from_blocks_array(next_block)
112
117
  elsif current_level.size == next_level.size
@@ -116,8 +121,8 @@ module I18nYamlSorter
116
121
  break
117
122
  end
118
123
  end
119
-
120
- out_array.sort.map(&:last).join
124
+
125
+ return out_array.sort.map(&:last).join
121
126
  end
122
127
  end
123
- end
128
+ end
@@ -0,0 +1,3 @@
1
+ module I18nYamlSorter
2
+ VERSION = '0.3.2'
3
+ end
@@ -2,15 +2,15 @@ require 'i18n_yaml_sorter'
2
2
 
3
3
  namespace :i18n do
4
4
 
5
- desc 'Sort locales keys in alphabetic order. Sort all locales if no path parameter given'
6
-
7
- task :sort, [:path_to_file] => :environment do |t, args|
5
+ desc "Sort locales keys in alphabetic order. Sort all locales if no path parameter given"
6
+
7
+ task :sort, [:path_to_file] => :environment do |t , args|
8
8
  locales = args[:path_to_file] || Dir.glob("#{Rails.root}/config/locales/**/*.yml")
9
9
 
10
10
  locales.each do |locale_path|
11
11
  sorted_contents = File.open(locale_path) { |f| I18nYamlSorter::Sorter.new(f).sort }
12
- File.open(locale_path, 'w') { |f| f << sorted_contents }
12
+ File.open(locale_path, 'w') { |f| f << sorted_contents}
13
13
  end
14
14
  end
15
-
16
- end
15
+
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'yaml'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'i18n_yaml_sorter'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe I18nYamlSorter do
4
+ it 'test_should_sort_complex_sample_file' do
5
+ open(File.dirname(__FILE__) + '/in.yml') do |file|
6
+ sorter = I18nYamlSorter::Sorter.new(file)
7
+ open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
8
+ expect(expected_out.read).to eq(sorter.sort)
9
+ end
10
+ end
11
+ end
12
+
13
+ it 'test_should_rails_i18n_default_file' do
14
+ open(File.dirname(__FILE__) + '/in_rails.yml') do |file|
15
+ sorter = I18nYamlSorter::Sorter.new(file)
16
+ open(File.dirname(__FILE__) + '/out_rails.yml') do |expected_out|
17
+ expect(expected_out.read).to eq(sorter.sort)
18
+ end
19
+ end
20
+ end
21
+
22
+ it 'test_should_sort_simple_text_file' do
23
+ open(File.dirname(__FILE__) + '/in_simple.yml') do |file|
24
+ sorter = I18nYamlSorter::Sorter.new(file)
25
+ open(File.dirname(__FILE__) + '/out_simple.yml') do |expected_out|
26
+ expect(expected_out.read).to eq(sorter.sort)
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'test_should_not_alter_the_serialized_yaml' do
32
+ #ordering should'n t change a thing, since hashes don't have order in Ruby
33
+ open(File.dirname(__FILE__) + '/in.yml') do |file|
34
+ sorter = I18nYamlSorter::Sorter.new(file)
35
+ present = YAML::load(file.read)
36
+ file.rewind
37
+ future = YAML::load(sorter.sort)
38
+ expect(present).to eq(future)
39
+ end
40
+ end
41
+
42
+ it 'test_command_line_should_work_in_stdin' do
43
+ output = `#{File.dirname(__FILE__)}/../bin/sort_yaml < #{File.dirname(__FILE__)}/in.yml`
44
+ open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
45
+ expect(expected_out.read).to eq(output)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: UTF-8
2
+
3
+ m_13: >
4
+ Não deve dar problema aqui!
5
+ Não deve dar problema aqui!
6
+ Não deve dar problema aqui!
7
+ Pois às vezes dá.
8
+
9
+ o_15: |
10
+ Não deve dar problema aqui!
11
+ Pois às vezes dá.
12
+
13
+ b_two:
14
+ a_1: Joãozinho
15
+ b_two: |
16
+ Nos somos legais, como
17
+ por exemplo: João,
18
+ que: gosta de nos dar milhões
19
+ em dinheiro todos os dias.
20
+
21
+ Linhas em Branco com tabulação
22
+ nos strings devem ser preservadas.
23
+
24
+ d_four: "Somos chatos
25
+ gostamos de várias linhas\"
26
+ e ainda usamos escaping
27
+ para fuder"
28
+ e_five: Prefirimos strings sem
29
+ nenhum tipo de especificação.
30
+ c_three:
31
+ a: "Marcelo"
32
+ d_4: Rafael
33
+ # Comentário de muitas
34
+ # linhas (goes with d_4)
35
+ "b": Bernardo
36
+ c_3:
37
+ unify: Luiz
38
+ klass: Lucas
39
+ f_six: Dalton
40
+ a_one: José # Comentado
41
+ c_three: Gustavo
42
+ # Comentário (goes with c_three)
43
+ f_six: Thiago
44
+ e_five:
45
+ b_two: Catarina
46
+ a_one: Rodrigo
47
+ # Comentário (goes with a_one)
48
+ "g-seven": Marcelo
49
+ d_four: Oliveira
50
+ k_eleven: Ronaldo
51
+ "l_other123123": Emilio
52
+
53
+ i_nine: Prestes
54
+
55
+ j_ten: >
56
+ Pior quando resolvemos escrever
57
+ assim, impossível aturar!
58
+ n_14: >
59
+ Não deve dar problema aqui!
60
+ Pois às vezes dá.
61
+ o_15: |
62
+ Não deve dar problema aqui!
63
+ Pois às vezes dá.
64
+ p_16: Não deve dar problema aqui!
65
+ Pois às vezes dá.
66
+ h_eight: "Jonivildo"
@@ -0,0 +1,239 @@
1
+ # encoding: UTF-8
2
+ # pt-BR translations for Ruby on Rails
3
+ "pt-BR":
4
+ date:
5
+ # formatos de data e hora
6
+ formats:
7
+ default: "%d/%m/%Y"
8
+ short: "%d de %B"
9
+ long: "%d de %B de %Y"
10
+
11
+ day_names:
12
+ - Domingo
13
+ - Segunda
14
+ - Terça
15
+ - Quarta
16
+ - Quinta
17
+ - Sexta
18
+ - Sábado
19
+ abbr_day_names:
20
+ - Dom
21
+ - Seg
22
+ - Ter
23
+ - Qua
24
+ - Qui
25
+ - Sex
26
+ - Sáb
27
+
28
+ month_names:
29
+ - ~
30
+ - Janeiro
31
+ - Fevereiro
32
+ - Março
33
+ - Abril
34
+ - Maio
35
+ - Junho
36
+ - Julho
37
+ - Agosto
38
+ - Setembro
39
+ - Outubro
40
+ - Novembro
41
+ - Dezembro
42
+ abbr_month_names:
43
+ - ~
44
+ - Jan
45
+ - Fev
46
+ - Mar
47
+ - Abr
48
+ - Mai
49
+ - Jun
50
+ - Jul
51
+ - Ago
52
+ - Set
53
+ - Out
54
+ - Nov
55
+ - Dez
56
+ order:
57
+ - :day
58
+ - :month
59
+ - :year
60
+
61
+ time:
62
+ formats:
63
+ default: "%A, %d de %B de %Y, %H:%M h"
64
+ short: "%d/%m, %H:%M h"
65
+ long: "%A, %d de %B de %Y, %H:%M h"
66
+ am: ''
67
+ pm: ''
68
+
69
+ support:
70
+ array:
71
+ # Usado no Array.to_sentence
72
+ words_connector: ", "
73
+ two_words_connector: " e "
74
+ last_word_connector: " e "
75
+
76
+ select:
77
+ prompt: "Por favor selecione"
78
+
79
+ number:
80
+ format:
81
+ separator: ','
82
+ delimiter: '.'
83
+ precision: 3
84
+ significant: false
85
+ strip_insignificant_zeros: false
86
+
87
+ currency:
88
+ format:
89
+ format: '%u %n'
90
+ unit: 'R$'
91
+ separator: ','
92
+ delimiter: '.'
93
+ precision: 2
94
+ significant: false
95
+ strip_insignificant_zeros: false
96
+
97
+ percentage:
98
+ format:
99
+ delimiter: '.'
100
+
101
+ precision:
102
+ format:
103
+ delimiter: '.'
104
+
105
+ human:
106
+ format:
107
+ delimiter: '.'
108
+ precision: 2
109
+ significant: true
110
+ strip_insignificant_zeros: true
111
+ storage_units:
112
+ format: "%n %u"
113
+ units:
114
+ byte:
115
+ one: "Byte"
116
+ other: "Bytes"
117
+ kb: "KB"
118
+ mb: "MB"
119
+ gb: "GB"
120
+ tb: "TB"
121
+ decimal_units:
122
+ # number_to_human()
123
+ # new in rails 3: please add to other locales
124
+ format: "%n %u"
125
+ units:
126
+ unit: ""
127
+ thousand: "mil"
128
+ million:
129
+ one: milhão
130
+ other: milhões
131
+ billion:
132
+ one: bilhão
133
+ other: bilhões
134
+ trillion:
135
+ one: trilhão
136
+ other: trilhões
137
+ quadrillion:
138
+ one: quatrilhão
139
+ other: quatrilhões
140
+
141
+ datetime:
142
+ distance_in_words:
143
+ # distancia do tempo em palavras
144
+ half_a_minute: 'meio minuto'
145
+ less_than_x_seconds:
146
+ one: 'menos de 1 segundo'
147
+ other: 'menos de %{count} segundos'
148
+ x_seconds:
149
+ one: '1 segundo'
150
+ other: '%{count} segundos'
151
+ less_than_x_minutes:
152
+ one: 'menos de um minuto'
153
+ other: 'menos de %{count} minutos'
154
+ x_minutes:
155
+ one: '1 minuto'
156
+ other: '%{count} minutos'
157
+ about_x_hours:
158
+ one: 'aproximadamente 1 hora'
159
+ other: 'aproximadamente %{count} horas'
160
+ x_days:
161
+ one: '1 dia'
162
+ other: '%{count} dias'
163
+ about_x_months:
164
+ one: 'aproximadamente 1 mês'
165
+ other: 'aproximadamente %{count} meses'
166
+ x_months:
167
+ one: '1 mês'
168
+ other: '%{count} meses'
169
+ about_x_years:
170
+ one: 'aproximadamente 1 ano'
171
+ other: 'aproximadamente %{count} anos'
172
+ over_x_years:
173
+ one: 'mais de 1 ano'
174
+ other: 'mais de %{count} anos'
175
+ almost_x_years:
176
+ one: 'quase 1 ano'
177
+ other: 'quase %{count} anos'
178
+ prompts:
179
+ year: "Ano"
180
+ month: "Mês"
181
+ day: "Dia"
182
+ hour: "Hora"
183
+ minute: "Minuto"
184
+ second: "Segundo"
185
+
186
+ helpers:
187
+ select:
188
+ prompt: "Por favor selecione"
189
+
190
+ submit:
191
+ create: 'Criar %{model}'
192
+ update: 'Atualizar %{model}'
193
+ submit: 'Salvar %{model}'
194
+
195
+ errors:
196
+ format: "%{attribute} %{message}"
197
+
198
+ template:
199
+ header:
200
+ one: "Não foi possível gravar %{model}: 1 erro"
201
+ other: "Não foi possível gravar %{model}: %{count} erros."
202
+ body: "Por favor, verifique o(s) seguinte(s) campo(s):"
203
+
204
+ messages: &errors_messages
205
+ inclusion: "não está incluído na lista"
206
+ exclusion: "não está disponível"
207
+ invalid: "não é válido"
208
+ confirmation: "não está de acordo com a confirmação"
209
+ accepted: "deve ser aceito"
210
+ empty: "não pode ficar vazio"
211
+ blank: "não pode ficar em branco"
212
+ too_long: "é muito longo (máximo: %{count} caracteres)"
213
+ too_short: "é muito curto (mínimo: %{count} caracteres)"
214
+ wrong_length: "não possui o tamanho esperado (%{count} caracteres)"
215
+ not_a_number: "não é um número"
216
+ not_an_integer: "não é um número inteiro"
217
+ greater_than: "deve ser maior que %{count}"
218
+ greater_than_or_equal_to: "deve ser maior ou igual a %{count}"
219
+ equal_to: "deve ser igual a %{count}"
220
+ less_than: "deve ser menor que %{count}"
221
+ less_than_or_equal_to: "deve ser menor ou igual a %{count}"
222
+ odd: "deve ser ímpar"
223
+ even: "deve ser par"
224
+
225
+ activerecord:
226
+ errors:
227
+ template:
228
+ header:
229
+ one: "Não foi possível gravar %{model}: 1 erro"
230
+ other: "Não foi possível gravar %{model}: %{count} erros."
231
+ body: "Por favor, verifique o(s) seguinte(s) campo(s):"
232
+
233
+ messages:
234
+ taken: "já está em uso"
235
+ record_invalid: "A validação falhou: %{errors}"
236
+ <<: *errors_messages
237
+
238
+ full_messages:
239
+ format: "%{attribute} %{message}"
@@ -0,0 +1,28 @@
1
+ pt-BR:
2
+ # Note how this is a nice way of inputing
3
+ # paragraphs of text in YAML.
4
+ apples: >
5
+ Maçãs são boas,
6
+ só não coma
7
+ seus iPods!
8
+ grapes: Não comemos elas.
9
+ bananas: |
10
+ Bananas são "legais":
11
+ - Elas são <b> doces </b>.
12
+ isto: não é chave
13
+
14
+ Por isto todos gostam de bananas!
15
+ en-US:
16
+ # Note that our comments are important:
17
+ # Don't let your yaml sorter delete them!
18
+ grapes: We dont' eat them.
19
+ bananas: |
20
+ Bananas are "nice":
21
+ - They are <b> sweet </b>.
22
+ this: not a key
23
+
24
+ That is why everyone like bananas!
25
+ apples: >
26
+ Apples are fine,
27
+ just don't eat your
28
+ iPods!
@@ -0,0 +1,61 @@
1
+ # encoding: UTF-8
2
+ a_one: José # Comentado
3
+ b_two:
4
+ a_1: Joãozinho
5
+ b_two: |
6
+ Nos somos legais, como
7
+ por exemplo: João,
8
+ que: gosta de nos dar milhões
9
+ em dinheiro todos os dias.
10
+
11
+ Linhas em Branco com tabulação
12
+ nos strings devem ser preservadas.
13
+
14
+ c_three:
15
+ a: "Marcelo"
16
+ "b": Bernardo
17
+ c_3:
18
+ klass: Lucas
19
+ unify: Luiz
20
+ d_4: Rafael
21
+ # Comentário de muitas
22
+ # linhas (goes with d_4)
23
+ d_four: "Somos chatos
24
+ gostamos de várias linhas\"
25
+ e ainda usamos escaping
26
+ para fuder"
27
+ e_five: Prefirimos strings sem
28
+ nenhum tipo de especificação.
29
+ f_six: Dalton
30
+ c_three: Gustavo
31
+ # Comentário (goes with c_three)
32
+ d_four: Oliveira
33
+ e_five:
34
+ a_one: Rodrigo
35
+ # Comentário (goes with a_one)
36
+ b_two: Catarina
37
+ f_six: Thiago
38
+ "g-seven": Marcelo
39
+ h_eight: "Jonivildo"
40
+ i_nine: Prestes
41
+ j_ten: >
42
+ Pior quando resolvemos escrever
43
+ assim, impossível aturar!
44
+ k_eleven: Ronaldo
45
+ "l_other123123": Emilio
46
+ m_13: >
47
+ Não deve dar problema aqui!
48
+ Não deve dar problema aqui!
49
+ Não deve dar problema aqui!
50
+ Pois às vezes dá.
51
+ n_14: >
52
+ Não deve dar problema aqui!
53
+ Pois às vezes dá.
54
+ o_15: |
55
+ Não deve dar problema aqui!
56
+ Pois às vezes dá.
57
+ o_15: |
58
+ Não deve dar problema aqui!
59
+ Pois às vezes dá.
60
+ p_16: Não deve dar problema aqui!
61
+ Pois às vezes dá.
@@ -0,0 +1,220 @@
1
+ # encoding: UTF-8
2
+ # pt-BR translations for Ruby on Rails
3
+ "pt-BR":
4
+ activerecord:
5
+ errors:
6
+ full_messages:
7
+ format: "%{attribute} %{message}"
8
+ messages:
9
+ record_invalid: "A validação falhou: %{errors}"
10
+ <<: *errors_messages
11
+ taken: "já está em uso"
12
+ template:
13
+ body: "Por favor, verifique o(s) seguinte(s) campo(s):"
14
+ header:
15
+ one: "Não foi possível gravar %{model}: 1 erro"
16
+ other: "Não foi possível gravar %{model}: %{count} erros."
17
+ date:
18
+ # formatos de data e hora
19
+ abbr_day_names:
20
+ - Dom
21
+ - Seg
22
+ - Ter
23
+ - Qua
24
+ - Qui
25
+ - Sex
26
+ - Sáb
27
+ abbr_month_names:
28
+ - ~
29
+ - Jan
30
+ - Fev
31
+ - Mar
32
+ - Abr
33
+ - Mai
34
+ - Jun
35
+ - Jul
36
+ - Ago
37
+ - Set
38
+ - Out
39
+ - Nov
40
+ - Dez
41
+ day_names:
42
+ - Domingo
43
+ - Segunda
44
+ - Terça
45
+ - Quarta
46
+ - Quinta
47
+ - Sexta
48
+ - Sábado
49
+ formats:
50
+ default: "%d/%m/%Y"
51
+ long: "%d de %B de %Y"
52
+ short: "%d de %B"
53
+ month_names:
54
+ - ~
55
+ - Janeiro
56
+ - Fevereiro
57
+ - Março
58
+ - Abril
59
+ - Maio
60
+ - Junho
61
+ - Julho
62
+ - Agosto
63
+ - Setembro
64
+ - Outubro
65
+ - Novembro
66
+ - Dezembro
67
+ order:
68
+ - :day
69
+ - :month
70
+ - :year
71
+ datetime:
72
+ distance_in_words:
73
+ # distancia do tempo em palavras
74
+ about_x_hours:
75
+ one: 'aproximadamente 1 hora'
76
+ other: 'aproximadamente %{count} horas'
77
+ about_x_months:
78
+ one: 'aproximadamente 1 mês'
79
+ other: 'aproximadamente %{count} meses'
80
+ about_x_years:
81
+ one: 'aproximadamente 1 ano'
82
+ other: 'aproximadamente %{count} anos'
83
+ almost_x_years:
84
+ one: 'quase 1 ano'
85
+ other: 'quase %{count} anos'
86
+ half_a_minute: 'meio minuto'
87
+ less_than_x_minutes:
88
+ one: 'menos de um minuto'
89
+ other: 'menos de %{count} minutos'
90
+ less_than_x_seconds:
91
+ one: 'menos de 1 segundo'
92
+ other: 'menos de %{count} segundos'
93
+ over_x_years:
94
+ one: 'mais de 1 ano'
95
+ other: 'mais de %{count} anos'
96
+ x_days:
97
+ one: '1 dia'
98
+ other: '%{count} dias'
99
+ x_minutes:
100
+ one: '1 minuto'
101
+ other: '%{count} minutos'
102
+ x_months:
103
+ one: '1 mês'
104
+ other: '%{count} meses'
105
+ x_seconds:
106
+ one: '1 segundo'
107
+ other: '%{count} segundos'
108
+ prompts:
109
+ day: "Dia"
110
+ hour: "Hora"
111
+ minute: "Minuto"
112
+ month: "Mês"
113
+ second: "Segundo"
114
+ year: "Ano"
115
+ errors:
116
+ format: "%{attribute} %{message}"
117
+ messages: &errors_messages
118
+ accepted: "deve ser aceito"
119
+ blank: "não pode ficar em branco"
120
+ confirmation: "não está de acordo com a confirmação"
121
+ empty: "não pode ficar vazio"
122
+ equal_to: "deve ser igual a %{count}"
123
+ even: "deve ser par"
124
+ exclusion: "não está disponível"
125
+ greater_than: "deve ser maior que %{count}"
126
+ greater_than_or_equal_to: "deve ser maior ou igual a %{count}"
127
+ inclusion: "não está incluído na lista"
128
+ invalid: "não é válido"
129
+ less_than: "deve ser menor que %{count}"
130
+ less_than_or_equal_to: "deve ser menor ou igual a %{count}"
131
+ not_a_number: "não é um número"
132
+ not_an_integer: "não é um número inteiro"
133
+ odd: "deve ser ímpar"
134
+ too_long: "é muito longo (máximo: %{count} caracteres)"
135
+ too_short: "é muito curto (mínimo: %{count} caracteres)"
136
+ wrong_length: "não possui o tamanho esperado (%{count} caracteres)"
137
+ template:
138
+ body: "Por favor, verifique o(s) seguinte(s) campo(s):"
139
+ header:
140
+ one: "Não foi possível gravar %{model}: 1 erro"
141
+ other: "Não foi possível gravar %{model}: %{count} erros."
142
+ helpers:
143
+ select:
144
+ prompt: "Por favor selecione"
145
+ submit:
146
+ create: 'Criar %{model}'
147
+ submit: 'Salvar %{model}'
148
+ update: 'Atualizar %{model}'
149
+ number:
150
+ currency:
151
+ format:
152
+ delimiter: '.'
153
+ precision: 2
154
+ format: '%u %n'
155
+ separator: ','
156
+ significant: false
157
+ strip_insignificant_zeros: false
158
+ unit: 'R$'
159
+ format:
160
+ delimiter: '.'
161
+ precision: 3
162
+ separator: ','
163
+ significant: false
164
+ strip_insignificant_zeros: false
165
+ human:
166
+ decimal_units:
167
+ # number_to_human()
168
+ # new in rails 3: please add to other locales
169
+ format: "%n %u"
170
+ units:
171
+ billion:
172
+ one: bilhão
173
+ other: bilhões
174
+ million:
175
+ one: milhão
176
+ other: milhões
177
+ quadrillion:
178
+ one: quatrilhão
179
+ other: quatrilhões
180
+ thousand: "mil"
181
+ trillion:
182
+ one: trilhão
183
+ other: trilhões
184
+ unit: ""
185
+ format:
186
+ delimiter: '.'
187
+ precision: 2
188
+ significant: true
189
+ strip_insignificant_zeros: true
190
+ storage_units:
191
+ format: "%n %u"
192
+ units:
193
+ byte:
194
+ one: "Byte"
195
+ other: "Bytes"
196
+ gb: "GB"
197
+ kb: "KB"
198
+ mb: "MB"
199
+ tb: "TB"
200
+ percentage:
201
+ format:
202
+ delimiter: '.'
203
+ precision:
204
+ format:
205
+ delimiter: '.'
206
+ support:
207
+ array:
208
+ # Usado no Array.to_sentence
209
+ last_word_connector: " e "
210
+ two_words_connector: " e "
211
+ words_connector: ", "
212
+ select:
213
+ prompt: "Por favor selecione"
214
+ time:
215
+ am: ''
216
+ formats:
217
+ default: "%A, %d de %B de %Y, %H:%M h"
218
+ long: "%A, %d de %B de %Y, %H:%M h"
219
+ short: "%d/%m, %H:%M h"
220
+ pm: ''
@@ -0,0 +1,28 @@
1
+ en-US:
2
+ # Note that our comments are important:
3
+ # Don't let your yaml sorter delete them!
4
+ apples: >
5
+ Apples are fine,
6
+ just don't eat your
7
+ iPods!
8
+ bananas: |
9
+ Bananas are "nice":
10
+ - They are <b> sweet </b>.
11
+ this: not a key
12
+
13
+ That is why everyone like bananas!
14
+ grapes: We dont' eat them.
15
+ pt-BR:
16
+ # Note how this is a nice way of inputing
17
+ # paragraphs of text in YAML.
18
+ apples: >
19
+ Maçãs são boas,
20
+ só não coma
21
+ seus iPods!
22
+ bananas: |
23
+ Bananas são "legais":
24
+ - Elas são <b> doces </b>.
25
+ isto: não é chave
26
+
27
+ Por isto todos gostam de bananas!
28
+ grapes: Não comemos elas.
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require File.expand_path('../../lib/i18n_yaml_sorter.rb', __FILE__)
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestI18nYamlSorter < Test::Unit::TestCase
4
+ def test_should_sort_complex_sample_file
5
+ open(File.dirname(__FILE__) + '/in.yml') do |file|
6
+ sorter = I18nYamlSorter::Sorter.new(file)
7
+ open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
8
+ assert_equal expected_out.read, sorter.sort
9
+ end
10
+ end
11
+ end
12
+
13
+ def test_should_rails_i18n_default_file
14
+ open(File.dirname(__FILE__) + '/in_rails.yml') do |file|
15
+ sorter = I18nYamlSorter::Sorter.new(file)
16
+ open(File.dirname(__FILE__) + '/out_rails.yml') do |expected_out|
17
+ assert_equal expected_out.read, sorter.sort
18
+ end
19
+ end
20
+ end
21
+
22
+ def test_should_sort_simple_text_file
23
+ open(File.dirname(__FILE__) + '/in_simple.yml') do |file|
24
+ sorter = I18nYamlSorter::Sorter.new(file)
25
+ open(File.dirname(__FILE__) + '/out_simple.yml') do |expected_out|
26
+ assert_equal expected_out.read, sorter.sort
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_should_not_alter_the_serialized_yaml
32
+ #ordering should'n t change a thing, since hashes don't have order in Ruby
33
+ open(File.dirname(__FILE__) + '/in.yml') do |file|
34
+ sorter = I18nYamlSorter::Sorter.new(file)
35
+ present = YAML::load(file.read)
36
+ file.rewind
37
+ future = YAML::load(sorter.sort)
38
+ assert_equal present, future
39
+ end
40
+ end
41
+
42
+ def test_command_line_should_work_in_stdin
43
+ output = `#{File.dirname(__FILE__)}/../bin/sort_yaml < #{File.dirname(__FILE__)}/in.yml`
44
+ open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
45
+ assert_equal expected_out.read, output
46
+ end
47
+ end
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_yaml_sorter_2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo de Pádua
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2081-04-06 00:00:00.000000000 Z
12
+ date: 2018-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -53,36 +53,38 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- description: " Allows you to deep sort YAML files that are mainly composed of \n nested
57
- hashes and string values. Great to sort your rails I18n YAML files. You can easily\n
58
- \ add it to a textmate bundle, rake task, or just use the included regular comand
59
- line tool. \n "
56
+ description: Allows you to deep sort YAML files that are mainly composed of nested
57
+ hashes and string values. Great to sort your rails I18n YAML files. You can easily
58
+ add it to a textmate bundle, rake task, or just use the included regular comand
59
+ line tool.
60
60
  email:
61
61
  - berpasan@gmail.com
62
62
  - compiledwrong+i18n_yaml_sorter@gmail.com
63
63
  executables:
64
64
  - sort_yaml
65
65
  extensions: []
66
- extra_rdoc_files:
67
- - LICENSE
68
- - README.rdoc
66
+ extra_rdoc_files: []
69
67
  files:
70
- - ".document"
71
- - Gemfile
72
- - Gemfile.lock
73
68
  - LICENSE
74
69
  - README.rdoc
75
70
  - Rakefile
76
- - VERSION
77
71
  - bin/sort_yaml
78
- - i18n_yaml_sorter.gemspec
79
72
  - lib/i18n_yaml_sorter.rb
80
73
  - lib/i18n_yaml_sorter/railtie.rb
81
74
  - lib/i18n_yaml_sorter/sorter.rb
75
+ - lib/i18n_yaml_sorter/version.rb
82
76
  - lib/tasks/i18n_yaml_sorter.rake
83
- - textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand
84
- - textmate/YAML Sort.tmbundle/info.plist
85
- homepage: http://github.com/redealumni/i18n_yaml_sorter
77
+ - spec/helper.rb
78
+ - spec/i18n_yaml_sorter_spec.rb
79
+ - spec/in.yml
80
+ - spec/in_rails.yml
81
+ - spec/in_simple.yml
82
+ - spec/out.yml
83
+ - spec/out_rails.yml
84
+ - spec/out_simple.yml
85
+ - spec/spec_helper.rb
86
+ - spec/test_i18n_yaml_sorter.rb
87
+ homepage: https://github.com/compwron/i18n_yaml_sorter
86
88
  licenses:
87
89
  - MIT
88
90
  metadata: {}
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in i18n_yaml_sorter.gemspec
4
- gemspec
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- i18n_yaml_sorter_2 (0.3.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.3)
10
- rake (12.3.1)
11
- rspec (3.7.0)
12
- rspec-core (~> 3.7.0)
13
- rspec-expectations (~> 3.7.0)
14
- rspec-mocks (~> 3.7.0)
15
- rspec-core (3.7.1)
16
- rspec-support (~> 3.7.0)
17
- rspec-expectations (3.7.0)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.7.0)
20
- rspec-mocks (3.7.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.7.0)
23
- rspec-support (3.7.1)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- bundler
30
- i18n_yaml_sorter_2!
31
- rake
32
- rspec
33
-
34
- BUNDLED WITH
35
- 1.16.1
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.1
@@ -1,45 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'i18n_yaml_sorter/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "i18n_yaml_sorter_2"
7
- s.version = I18nYamlSorter::VERSION
8
-
9
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
- s.authors = ["Bernardo de P\u{e1}dua", 'compiledwrong']
11
- s.date = "2081-04-06"
12
- s.description = " Allows you to deep sort YAML files that are mainly composed of \n nested hashes and string values. Great to sort your rails I18n YAML files. You can easily\n add it to a textmate bundle, rake task, or just use the included regular comand line tool. \n "
13
- s.email = ["berpasan@gmail.com", 'compiledwrong+i18n_yaml_sorter@gmail.com']
14
- s.executables = ["sort_yaml"]
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/sort_yaml",
28
- "i18n_yaml_sorter.gemspec",
29
- "lib/i18n_yaml_sorter.rb",
30
- "lib/i18n_yaml_sorter/railtie.rb",
31
- "lib/i18n_yaml_sorter/sorter.rb",
32
- "lib/tasks/i18n_yaml_sorter.rake",
33
- "textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand",
34
- "textmate/YAML Sort.tmbundle/info.plist"
35
- ]
36
- s.homepage = "http://github.com/redealumni/i18n_yaml_sorter"
37
- s.licenses = ["MIT"]
38
- s.require_paths = ["lib"]
39
- s.summary = "A I18n YAML deep sorter that will keep your locales organized and not screw up your text formating"
40
-
41
- s.add_development_dependency 'bundler'
42
- s.add_development_dependency 'rake'
43
- s.add_development_dependency 'rspec'
44
- end
45
-
@@ -1,22 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>beforeRunningCommand</key>
6
- <string>nop</string>
7
- <key>command</key>
8
- <string>sort_yaml</string>
9
- <key>input</key>
10
- <string>selection</string>
11
- <key>keyEquivalent</key>
12
- <string>@S</string>
13
- <key>name</key>
14
- <string>Sort YAML</string>
15
- <key>output</key>
16
- <string>replaceSelectedText</string>
17
- <key>scope</key>
18
- <string>source.yaml</string>
19
- <key>uuid</key>
20
- <string>190B37B2-9070-4F27-97DA-10ABC11EEF2D</string>
21
- </dict>
22
- </plist>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>name</key>
6
- <string>YAML Sort</string>
7
- <key>uuid</key>
8
- <string>9C66740A-912D-4940-92C7-60B6D5984871</string>
9
- </dict>
10
- </plist>