phrase_assembler 1.2.7 → 1.2.8

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.
@@ -9,30 +9,30 @@ module PACsvProxy
9
9
 
10
10
  def to_csv(file_name, options = {})
11
11
  self.current_replace_token = "AAA"
12
- substituted_values = substitute_default_tokens(data, options)
12
+ substituted_values = substitute_default_tokens(data, options, "")
13
13
  File.open(file_name, 'w') {|f| f.write(substituted_values) }
14
14
  return substituted_values
15
15
  end
16
16
 
17
- def get_csv_safe_string_line(s)
18
- return "\"#{s.gsub('"', '""')}\"\n"
17
+ def get_csv_safe_string_line(backtrace_string, s)
18
+ return "#{backtrace_string},\"#{s.gsub('"', '""')}\"\n"
19
19
  end
20
20
 
21
- def substitute_default_tokens(p_data, p_options)
21
+ def substitute_default_tokens(p_data, p_options, backtrace_string)
22
22
  if p_data.is_a? Hash
23
23
  t_text = ""
24
- p_data.keys.sort{|a, b| a.to_s <=> b.to_s}.each{|k| t_text << substitute_default_tokens(p_data[k], p_options)}
24
+ p_data.keys.sort{|a, b| a.to_s <=> b.to_s}.each{|k| t_text << substitute_default_tokens(p_data[k], p_options, "#{backtrace_string}:#{k.to_s}")}
25
25
  return t_text
26
26
  elsif p_data.is_a? Array
27
27
  t_text = ""
28
- p_data.each{|v| t_text << substitute_default_tokens(v, p_options)}
28
+ p_data.each_index{|index| v=p_data[index];t_text << substitute_default_tokens(v, p_options, "#{backtrace_string}[#{index}]")}
29
29
  return t_text
30
30
  elsif p_data.is_a? String
31
- return substitute_default_token(String.new(p_data), p_options)
31
+ return substitute_default_token(String.new(p_data), p_options, backtrace_string)
32
32
  end
33
33
  end
34
34
 
35
- def substitute_default_token(p_data, p_options)
35
+ def substitute_default_token(p_data, p_options, backtrace_string)
36
36
  add_options = {}
37
37
  result = ""
38
38
 
@@ -98,10 +98,10 @@ module PACsvProxy
98
98
  for i in 0...max_length
99
99
  temp_lang_options = {}
100
100
  add_lang_options.keys.each{|k| v=add_lang_options[k]; temp_lang_options[k] = v[((i > v.length - 1) ? (v.length - 1) : i)]}
101
- result << get_csv_safe_string_line(substitute_token(String.new(p_data), p_options, PATokenProxyOptions.new_if_needed(temp_lang_options.merge(add_options))))
101
+ result << get_csv_safe_string_line(substitute_token(backtrace_string, String.new(p_data), p_options, PATokenProxyOptions.new_if_needed(temp_lang_options.merge(add_options))))
102
102
  end
103
103
  else
104
- result << get_csv_safe_string_line(substitute_token(p_data, p_options, PATokenProxyOptions.new_if_needed(add_options)))
104
+ result << get_csv_safe_string_line(backtrace_string, substitute_token(p_data, p_options, PATokenProxyOptions.new_if_needed(add_options)))
105
105
  end
106
106
 
107
107
  return result
@@ -2,6 +2,7 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
2
2
  require 'pa_proxies/pa_composite_proxy'
3
3
  require 'pa_proxies/pa_user_proxy'
4
4
  require 'pa_proxies/pa_error_proxy'
5
+ require 'railtie.rb'
5
6
  module PhraseAssembler
6
7
  @@supress_errors = true
7
8
  def supress_errors
data/lib/railtie.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Paperclip
2
+ if defined? Rails::Railtie
3
+ require 'rails'
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ load "tasks/phrase_assembler.rake"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,6 @@
1
1
  require 'pa_proxies/pa_composite_proxy'
2
2
  namespace :phrase_assembler do
3
+ desc "Outputs whole yml to csv file"
3
4
  task(:get_csv_file) do
4
5
  if ENV['out'].nil?
5
6
  raise 'Must specify output file out='
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phrase_assembler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 7
10
- version: 1.2.7
9
+ - 8
10
+ version: 1.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Lovro \xC5\xBDmak, Radan Skori\xC4\x87, Drap"
@@ -57,6 +57,7 @@ files:
57
57
  - lib/pa_proxies/pa_token_proxy_options.rb
58
58
  - lib/pa_proxies/pa_user_proxy.rb
59
59
  - lib/phrase_assembler.rb
60
+ - lib/railtie.rb
60
61
  - lib/tasks/phrase_assembler.rake
61
62
  - lib/utils/hash_add_on.rb
62
63
  - lib/utils/r_array.rb