i18n_screwdriver 8.0 → 8.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: 985f287225f7ed2e2ca841b194933300f765507e
4
- data.tar.gz: 8f4a5a9b52d1e4d816185a245f7ca7eb68273b74
3
+ metadata.gz: 3bcf4a98f37390d173a9fa6a82f3c595c17c98b4
4
+ data.tar.gz: 74c3c6b1abf2d63d27c1a081033f782c15af896d
5
5
  SHA512:
6
- metadata.gz: 066ea43385e0fb9b4a6dbfb837fdc332da787fce9e44f8f5d9d933ec7f521c2fa09d2f8687dcdee6044a2b42e630c733bbe376876ec5189b0c7dfbcddfed7e38
7
- data.tar.gz: 72661a41c29c395445c8728c424a0d98c3cf8d5193fb44b4dd57f0b8fe27895a2351c6d81f3dc55dede5fb3a994ce827b88509b3a8a690c4f6a7bbc7244e155a
6
+ metadata.gz: d92d15d612024f28392ebd6bf74f8951826a53842cb70ff0e2d5aeff5f6cbf5354c7893cb2ee8112179fe0d164fab85428a40299cb59a4cd4c7266963448a31d
7
+ data.tar.gz: d56782ac7f4b2b693b3cd741dfa9acb4f9a7a13d824159390668dc4186137419bb9768d00dea432c4dee2d7178b73591a51b32918377b788baca9d379350bd5b
@@ -1,4 +1,3 @@
1
1
  require 'rails'
2
2
  require 'i18n_screwdriver/rails/engine'
3
3
  require "i18n_screwdriver/translation"
4
-
@@ -1,5 +1,7 @@
1
1
  module I18nScrewdriver
2
2
  class Translation < String
3
+ Error = Class.new(StandardError)
4
+
3
5
  attr_accessor :text, :options
4
6
 
5
7
  def self.new(text, options = {}, &block)
@@ -10,17 +12,22 @@ module I18nScrewdriver
10
12
  if block
11
13
  urls = Array(block.call)
12
14
  urls_to_interpolate_count = translation.scan(/<<.+?>>/).count
13
- raise ArgumentError, "too few urls specified" if urls.count < urls_to_interpolate_count
14
- if urls.count > urls_to_interpolate_count
15
- raise ArgumentError, "too many urls specified (#{urls.count} <> #{urls_to_interpolate_count})" unless urls.last.is_a?(Hash)
16
- translation = new(translation % urls.last, :raw => true)
17
- end
15
+ emit_warning("invalid number of urls specified (#{urls.count} <> #{urls_to_interpolate_count})") unless urls.count == urls_to_interpolate_count
18
16
  translation.linkify(block.binding, urls)
19
17
  end
20
18
 
21
19
  translation
22
20
  end
23
21
 
22
+ def self.emit_warning(message)
23
+ raise Error, message unless ::Rails.env.production?
24
+ ::Rails.logger.warn(%|I18nScrewdriver: #{message}\n#{application_frames(caller).join("\n")}|)
25
+ end
26
+
27
+ def self.application_frames(backtrace)
28
+ backtrace.select{ |path| path.starts_with?(::Rails.root.to_s) }
29
+ end
30
+
24
31
  def linkify(binding, urls)
25
32
  context = binding ? eval('self', binding) : self
26
33
  keep_html_safety do
@@ -42,4 +49,3 @@ module I18nScrewdriver
42
49
  end
43
50
  end
44
51
  end
45
-
@@ -1,3 +1,3 @@
1
1
  module I18nScrewdriver
2
- VERSION = "8.0"
2
+ VERSION = "8.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_screwdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: '8.0'
4
+ version: '8.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Miesel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-01 00:00:00.000000000 Z
12
+ date: 2016-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project: i18n_screwdriver
84
- rubygems_version: 2.4.5
84
+ rubygems_version: 2.4.5.1
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: make translating with rails i18n fun again