tolk 1.3.5 → 1.3.6

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.
@@ -55,7 +55,7 @@ module Tolk
55
55
  secondary_locales.each do |locale|
56
56
  File.open("#{to}/#{locale.name}.yml", "w+") do |file|
57
57
  data = locale.to_hash
58
- data.respond_to?(:ya2yaml) ? file.write(data.ya2yaml(:syck_compatible => true)) : YAML.dump(locale.to_hash, file)
58
+ data.respond_to?(:ya2yaml) ? file.write(data.ya2yaml(:syck_compatible => true)) : file.write(YAML.dump(data).force_encoding file.external_encoding.name)
59
59
  end
60
60
  end
61
61
  end
@@ -17,7 +17,6 @@ module Tolk
17
17
 
18
18
  attr_accessible :phrase_id, :locale_id, :text, :primary_updated, :previous_text, :locale, :phrase
19
19
 
20
- attr_accessor :force_set_primary_update
21
20
  before_save :set_primary_updated
22
21
 
23
22
  before_save :set_previous_text
@@ -114,7 +113,7 @@ module Tolk
114
113
  if primary_translation.present?
115
114
  if self.text.is_a?(String) && !primary_translation.text.is_a?(String)
116
115
  self.text = begin
117
- YAML.load(self.text.strip)
116
+ YAML.safe_load(self.text.strip)
118
117
  rescue ArgumentError
119
118
  nil
120
119
  end
@@ -138,7 +137,7 @@ module Tolk
138
137
  end
139
138
 
140
139
  def set_primary_updated
141
- self.primary_updated = self.force_set_primary_update ? true : false
140
+ self.primary_updated = false
142
141
  true
143
142
  end
144
143
 
data/lib/tolk.rb CHANGED
@@ -5,6 +5,8 @@ require 'tolk/engine'
5
5
  require 'tolk/sync'
6
6
  require 'tolk/import'
7
7
 
8
+ SafeYAML::OPTIONS[:suppress_warnings] = true
9
+
8
10
  module Tolk
9
11
  # Setup Tolk
10
12
  def self.config(&block)
data/lib/tolk/import.rb CHANGED
@@ -53,7 +53,7 @@ module Tolk
53
53
 
54
54
  puts "[INFO] Reading #{locale_file} for locale #{self.name}"
55
55
  begin
56
- self.class.flat_hash(YAML::load(IO.read(locale_file))[self.name])
56
+ self.class.flat_hash(YAML::safe_load(IO.read(locale_file))[self.name])
57
57
  rescue
58
58
  puts "[ERROR] File #{locale_file} expected to declare #{self.name} locale, but it does not. Skipping this file."
59
59
  nil
data/lib/tolk/sync.rb CHANGED
@@ -38,7 +38,6 @@ module Tolk
38
38
 
39
39
  def sync_phrases(translations)
40
40
  primary_locale = self.primary_locale
41
- secondary_locales = self.secondary_locales
42
41
 
43
42
  # Handle deleted phrases
44
43
  translations.present? ? Tolk::Phrase.destroy_all(["tolk_phrases.key NOT IN (?)", translations.keys]) : Tolk::Phrase.destroy_all
@@ -54,12 +53,7 @@ module Tolk
54
53
 
55
54
  if translation.changed? && !translation.new_record?
56
55
  # Set the primary updated flag if the primary translation has changed and it is not a new record.
57
- secondary_locales.each do |locale|
58
- if existing_translation = existing_phrase.translations.detect {|t| t.locale_id == locale.id }
59
- existing_translation.force_set_primary_update = true
60
- existing_translation.save!
61
- end
62
- end
56
+ existing_phrase.translations.update_all({ :primary_updated => true }, Tolk::Translation.arel_table[:locale_id].not_eq(primary_locale.id))
63
57
  end
64
58
 
65
59
  translation.primary = true
data/lib/tolk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tolk
2
- VERSION = "1.3.5"
2
+ VERSION = "1.3.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tolk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-02-08 00:00:00.000000000 Z
15
+ date: 2013-03-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: will_paginate
@@ -35,17 +35,17 @@ dependencies:
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  none: false
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.7'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  none: false
45
45
  requirements:
46
- - - ! '>='
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '0.7'
49
49
  description: Tolk is a web interface for doing i18n translations packaged as an engine
50
50
  for Rails applications.
51
51
  email: [email protected]
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 1.8.23
112
+ rubygems_version: 1.8.25
113
113
  signing_key:
114
114
  specification_version: 3
115
115
  summary: Rails engine providing web interface for managing i18n yaml files
OSZAR »