i18nliner 0.0.4 → 0.0.5

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.
@@ -11,12 +11,29 @@ module I18nliner
11
11
  scope.normalize_key(key.to_s)
12
12
  end
13
13
 
14
- def normalize_default(default, translate_options = {})
14
+ def normalize_default(default, translate_options = {}, options = {})
15
15
  default = infer_pluralization_hash(default, translate_options)
16
- default.strip! if default.is_a?(String)
16
+ normalize_whitespace!(default, options)
17
17
  default
18
18
  end
19
19
 
20
+ def normalize_whitespace!(default, options)
21
+ if default.is_a?(Hash)
22
+ default.each { |key, value| normalize_whitespace!(value, options) }
23
+ return
24
+ end
25
+
26
+ return unless default.is_a?(String)
27
+
28
+ if options[:remove_whitespace]
29
+ default.gsub!(/\s+/, ' ')
30
+ default.strip!
31
+ else
32
+ default.sub!(/\s*\n\z/, '')
33
+ default.lstrip!
34
+ end
35
+ end
36
+
20
37
  def infer_pluralization_hash(default, translate_options)
21
38
  return default unless default.is_a?(String) &&
22
39
  default =~ /\A[\w\-]+\z/ &&
@@ -27,7 +44,7 @@ module I18nliner
27
44
  def infer_key(default, translate_options = {})
28
45
  return unless default && (default.is_a?(String) || default.is_a?(Hash))
29
46
  default = default[:other].to_s if default.is_a?(Hash)
30
- keyify(normalize_default(default, translate_options))
47
+ keyify(normalize_default(default, translate_options, :remove_whitespace => true))
31
48
  end
32
49
 
33
50
  def keyify_underscored(string)
@@ -73,12 +90,13 @@ module I18nliner
73
90
  (hash.keys - ALLOWED_PLURALIZATION_KEYS).size == 0
74
91
  end
75
92
 
76
- def infer_arguments(args)
93
+ def infer_arguments(args, meta = {})
77
94
  if args.size == 2 && args[1].is_a?(Hash) && args[1][:default]
78
95
  return args
79
96
  end
80
97
 
81
98
  has_key = key_provided?(*args)
99
+ meta[:inferred_key] = !has_key
82
100
  args.unshift infer_key(args[0]) unless has_key
83
101
 
84
102
  default_or_options = args[1]
@@ -16,7 +16,7 @@ module I18nliner
16
16
  def run
17
17
  FileUtils.mkdir_p File.dirname(yml_file)
18
18
  File.open(yml_file, "w") do |file|
19
- file.write({I18n.default_locale.to_s => @translations.expand_keys}.ya2yaml(:syck_compatible => true))
19
+ file.write({I18n.default_locale.to_s => @translations}.ya2yaml(:syck_compatible => true))
20
20
  end
21
21
  puts "Wrote default translations to #{yml_file}" unless @options[:silent]
22
22
  end
@@ -0,0 +1,16 @@
1
+ require "i18nliner/scope"
2
+
3
+ module I18nliner
4
+ class ControllerScope < Scope
5
+ def scope
6
+ # best guess at current action, ymmv. we only add the action at this
7
+ # point because the scope already has the controller path
8
+ # see abstract_controller/translation.rb for reference
9
+ if context.current_defn
10
+ "#{super}.#{context.current_defn}"
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,4 +1,4 @@
1
- require 'action_view/template/handlers/erb'
1
+ require 'action_view/template'
2
2
  require 'i18nliner/pre_processors/erb_pre_processor'
3
3
 
4
4
  module I18nliner
@@ -7,12 +7,12 @@ module I18nliner
7
7
  module Controller
8
8
  include Inferpolation
9
9
 
10
- PATH = "app/controllers"
11
- ALLOW_RELATIVE = Rails.version >= '4'
10
+ def i18n_scope; end
12
11
 
13
12
  def translate(*args)
14
13
  key, options = CallHelpers.infer_arguments(args)
15
14
  options = inferpolate(options) if I18nliner.infer_interpolation_values
15
+ options[:i18n_scope] = i18n_scope
16
16
  super(key, options)
17
17
  end
18
18
  alias :t :translate
@@ -7,11 +7,20 @@ module I18nliner
7
7
  module Core
8
8
  def translate(*args)
9
9
  key, options = *CallHelpers.infer_arguments(args)
10
- wrappers = options.delete(:wrappers)
10
+
11
+ scope = options.delete(:i18n_scope) || Scope.root
12
+ key = CallHelpers.normalize_key(key, scope)
13
+
14
+ if default = options[:default]
15
+ options[:default] = CallHelpers.normalize_default(default, options)
16
+ end
17
+
18
+ wrappers = options.delete(:wrappers) || options.delete(:wrapper)
11
19
  result = super(key, options)
12
20
  if wrappers
13
21
  result = apply_wrappers(result, wrappers)
14
22
  end
23
+
15
24
  result
16
25
  end
17
26
  alias :t :translate
@@ -42,7 +51,8 @@ module I18nliner
42
51
 
43
52
  def apply_wrappers(string, wrappers)
44
53
  string = string.html_safe? ? string.dup : ERB::Util.h(string)
45
- if wrappers.is_a?(Array)
54
+ unless wrappers.is_a?(Hash)
55
+ wrappers = Array(wrappers)
46
56
  wrappers = Hash[wrappers.each_with_index.map{ |w, i| ['*' * (1 + i), w]}]
47
57
  end
48
58
  wrappers.sort_by{ |k, v| -k.length }.each do |k, v|
@@ -7,13 +7,13 @@ module I18nliner
7
7
  module Model
8
8
  include Inferpolation
9
9
 
10
- PATH = "app/models"
11
- ALLOW_RELATIVE = false
10
+ def i18n_scope; end
12
11
 
13
12
  def translate(*args)
14
13
  key, options = CallHelpers.infer_arguments(args)
15
14
  options = inferpolate(options) if I18nliner.infer_interpolation_values
16
- I18n.t(key, options)
15
+ options[:i18n_scope] = i18n_scope
16
+ I18n.translate(key, options)
17
17
  end
18
18
  alias :t :translate
19
19
  alias :t! :translate
@@ -23,6 +23,10 @@ module I18nliner
23
23
  I18n.localize(*args)
24
24
  end
25
25
  alias :l :localize
26
+
27
+ def self.included(klass)
28
+ klass.extend(self)
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -7,8 +7,7 @@ module I18nliner
7
7
  module View
8
8
  include Inferpolation
9
9
 
10
- PATH = "app/views"
11
- ALLOW_RELATIVE = true
10
+ def i18n_scope; end
12
11
 
13
12
  def translate(*args)
14
13
  # if a block gets through to here, it either means:
@@ -18,6 +17,7 @@ module I18nliner
18
17
  raise ArgumentError.new("wrong number of arguments (0 for 1..3)") if args.empty? || args.size > 3
19
18
  key, options = CallHelpers.infer_arguments(args)
20
19
  options = inferpolate(options) if I18nliner.infer_interpolation_values
20
+ options[:i18n_scope] = i18n_scope
21
21
  super(key, options)
22
22
  end
23
23
  alias :t :translate
@@ -22,10 +22,23 @@ module I18nliner
22
22
  process(@sexps)
23
23
  end
24
24
 
25
+ attr_reader :current_defn
26
+ def process_defn(exp)
27
+ exp.shift
28
+ @current_defn = exp.shift
29
+ process exp.shift until exp.empty?
30
+ @current_defn = nil
31
+ s()
32
+ end
33
+
25
34
  def process_call(exp)
26
35
  exp.shift
27
- receiver = process(exp.shift)
28
- receiver = receiver.last if receiver
36
+ receiver_exp = exp.shift
37
+ receiver = nil
38
+ if receiver_exp
39
+ receiver = receiver_exp[0] == :const ? receiver_exp.last : UnsupportedExpression
40
+ process(receiver_exp)
41
+ end
29
42
  method = exp.shift
30
43
 
31
44
  if extractable_call?(receiver, method)
@@ -52,7 +65,7 @@ module I18nliner
52
65
 
53
66
  def process_translate_call(receiver, method, args)
54
67
  scope = receiver ? Scope.root : @scope
55
- call = TranslateCall.new(@scope, @current_line, method, args)
68
+ call = TranslateCall.new(scope, @current_line, method, args, :explicit_receiver => !receiver.nil?)
56
69
  call.translations.each &@block
57
70
  end
58
71
 
@@ -28,6 +28,7 @@ module I18nliner
28
28
  elsif stringish?(lhs)
29
29
  string_from(lhs) + rhs.last
30
30
  else
31
+ process(lhs)
31
32
  UnsupportedExpression
32
33
  end
33
34
  end
@@ -10,10 +10,11 @@ module I18nliner
10
10
 
11
11
  attr_reader :key, :default
12
12
 
13
- def initialize(scope, line, method, args)
13
+ def initialize(scope, line, method, args, meta = {})
14
14
  @scope = scope
15
15
  @line = line
16
16
  @method = method
17
+ @meta = meta
17
18
 
18
19
  normalize_arguments(args)
19
20
 
@@ -28,8 +29,8 @@ module I18nliner
28
29
  end
29
30
 
30
31
  def normalize
31
- @key = normalize_key(@key, @scope)
32
- @default = normalize_default(@default, @options || {})
32
+ @key = normalize_key(@key, @scope) unless @meta[:inferred_key]
33
+ @default = normalize_default(@default, @options || {}, {:remove_whitespace => @scope.remove_whitespace?})
33
34
  end
34
35
 
35
36
  def translations
@@ -78,7 +79,7 @@ module I18nliner
78
79
  def normalize_arguments(args)
79
80
  raise InvalidSignatureError.new(@line, args) if args.empty?
80
81
 
81
- @key, @options, *others = infer_arguments(args)
82
+ @key, @options, *others = infer_arguments(args, @meta)
82
83
 
83
84
  raise InvalidSignatureError.new(@line, args) if !others.empty?
84
85
  raise InvalidSignatureError.new(@line, args) unless @key.is_a?(Symbol) || @key.is_a?(String)
@@ -4,18 +4,10 @@ module I18nliner
4
4
  attr_accessor :line
5
5
 
6
6
  def self.new(hash = {})
7
- hash.is_a?(self) ? hash : super().replace(flatten(hash))
8
- end
9
-
10
- def self.flatten(hash, result = {}, prefix = "")
11
- hash.each do |key, value|
12
- if value.is_a?(Hash)
13
- flatten(value, result, "#{prefix}#{key}.")
14
- else
15
- result["#{prefix}#{key}"] = value
16
- end
7
+ hash.inject(super()) do |result, (key, value)|
8
+ result.store(key.to_s, value.is_a?(Hash) ? new(value) : value)
9
+ result
17
10
  end
18
- result
19
11
  end
20
12
 
21
13
  def initialize(*args)
@@ -51,16 +43,6 @@ module I18nliner
51
43
  hash.store(leaf, value)
52
44
  end
53
45
  end
54
-
55
- def expand_keys
56
- result = {}
57
- each do |key, value|
58
- parts = key.split(".")
59
- last = parts.pop
60
- parts.inject(result){ |h, k2| h[k2] ||= {}}[last] = value
61
- end
62
- result
63
- end
64
46
  end
65
47
  end
66
48
  end
@@ -22,10 +22,15 @@ module I18nliner
22
22
  end
23
23
  end
24
24
 
25
+ VIEW_PATH = %r{\A(.*/)?app/views/(.*?)\.(erb|html\.erb)\z}
25
26
  def scope_for(path)
26
- scope = path.gsub(/(\A|.*\/)app\/views\/|\.html\z|(\.html)?\.erb\z/, '')
27
- scope = scope.gsub(/\/_?/, '.')
28
- Scope.new(scope, :allow_relative => true)
27
+ scope = path.dup
28
+ if scope.sub!(VIEW_PATH, '\2')
29
+ scope = scope.gsub(/\/_?/, '.')
30
+ Scope.new(scope, :allow_relative => true, :remove_whitespace => true, :context => self)
31
+ else
32
+ Scope.root
33
+ end
29
34
  end
30
35
  end
31
36
  end
@@ -1,6 +1,7 @@
1
1
  require 'i18nliner/processors/abstract_processor'
2
2
  require 'i18nliner/extractors/ruby_extractor'
3
3
  require 'i18nliner/scope'
4
+ require 'i18nliner/controller_scope'
4
5
 
5
6
  module I18nliner
6
7
  module Processors
@@ -21,8 +22,21 @@ module I18nliner
21
22
  File.read(file)
22
23
  end
23
24
 
24
- def scope_for(path)
25
- Scope.root
25
+ if defined?(::Rails) && ::Rails.version > '4'
26
+ CONTROLLER_PATH = %r{\A(.*/)?app/controllers/(.*)_controller\.rb\z}
27
+ def scope_for(path)
28
+ scope = path.dup
29
+ if scope.sub!(CONTROLLER_PATH, '\2')
30
+ scope = scope.gsub(/\/_?/, '.')
31
+ ControllerScope.new(scope, :allow_relative => true, :context => self)
32
+ else
33
+ Scope.root
34
+ end
35
+ end
36
+ else
37
+ def scope_for(path)
38
+ Scope.root
39
+ end
26
40
  end
27
41
 
28
42
  def pre_process(source)
@@ -1,16 +1,17 @@
1
1
  module I18nliner
2
2
  class Scope
3
3
  attr_reader :scope
4
+ attr_reader :allow_relative
5
+ attr_reader :context
6
+ alias :allow_relative? :allow_relative
7
+ attr_accessor :remove_whitespace
8
+ alias :remove_whitespace? :remove_whitespace
4
9
 
5
10
  def initialize(scope = nil, options = {})
6
11
  @scope = scope ? "#{scope}." : scope
7
- @options = {
8
- :allow_relative => false
9
- }.merge(options)
10
- end
11
-
12
- def allow_relative?
13
- @options[:allow_relative]
12
+ @allow_relative = options.fetch(:allow_relative, false)
13
+ @remove_whitespace = options.fetch(:remove_whitespace, false)
14
+ @context = options.fetch(:context, nil)
14
15
  end
15
16
 
16
17
  def normalize_key(key)
@@ -24,5 +25,9 @@ module I18nliner
24
25
  def self.root
25
26
  @root ||= new
26
27
  end
28
+
29
+ def root?
30
+ scope.blank?
31
+ end
27
32
  end
28
33
  end
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+ require 'i18nliner/extensions/controller'
3
+ require 'i18nliner/call_helpers'
4
+
5
+ describe I18nliner::Extensions::Controller do
6
+ let(:i18n) do
7
+ Module.new do
8
+ extend(Module.new do
9
+ def translate(*args)
10
+ I18n.translate(*args)
11
+ end
12
+
13
+ def controller_name
14
+ "foo"
15
+ end
16
+ end)
17
+ extend I18nliner::Extensions::Controller
18
+ end
19
+ end
20
+
21
+
22
+ describe "#translate" do
23
+ it "should inferpolate" do
24
+ i18n.stub(:foo).and_return("FOO")
25
+ I18nliner::CallHelpers.stub(:infer_key).and_return(:key)
26
+
27
+ expect(I18n).to receive(:translate).with(:key, :default => "hello %{foo}", :foo => "FOO", :i18n_scope => i18n.i18n_scope)
28
+ i18n.translate("hello %{foo}")
29
+ end
30
+
31
+ it "should pass along its scope to I18n.t" do
32
+ expect(I18n).to receive(:translate).with(:key, :default => "foo", :i18n_scope => i18n.i18n_scope)
33
+ i18n.translate(:key, "foo")
34
+ end
35
+ end
36
+ end
37
+
38
+
@@ -28,15 +28,36 @@ describe I18nliner::Extensions::Core do
28
28
  i18n.translate("Hello %{name}", :name => "bob")
29
29
  end
30
30
 
31
- it "should apply wrappers" do
32
- result = i18n.translate("Hello *bob*. Click **here**", :wrappers => ['<b>\1</b>', '<a href="/">\1</a>'])
33
- result.should == "Hello <b>bob</b>. Click <a href=\"/\">here</a>"
34
- result.should be_html_safe
31
+ it "should infer pluralization hashes" do
32
+ expect(i18n).to receive(:simple_translate).with("light_6feedaaa", :default => {:one => "1 light", :other => "%{count} lights"}, count: 1)
33
+ i18n.translate("light", :count => 1)
35
34
  end
36
35
 
37
- it "should html-escape the default when applying wrappers" do
38
- i18n.translate("*bacon* > narwhals", :wrappers => ['<b>\1</b>']).
39
- should == "<b>bacon</b> &gt; narwhals"
36
+ context "with wrappers" do
37
+ it "should apply a single wrapper" do
38
+ result = i18n.translate("Hello *bob*.", :wrapper => '<b>\1</b>')
39
+ result.should == "Hello <b>bob</b>."
40
+ end
41
+
42
+ it "should be html-safe" do
43
+ result = i18n.translate("Hello *bob*.", :wrapper => '<b>\1</b>')
44
+ result.should be_html_safe
45
+ end
46
+
47
+ it "should apply multiple wrappers" do
48
+ result = i18n.translate("Hello *bob*. Click **here**", :wrappers => ['<b>\1</b>', '<a href="/">\1</a>'])
49
+ result.should == "Hello <b>bob</b>. Click <a href=\"/\">here</a>"
50
+ end
51
+
52
+ it "should apply multiple wrappers with arbitrary delimiters" do
53
+ result = i18n.translate("Hello !!!bob!!!. Click ???here???", :wrappers => {'!!!' => '<b>\1</b>', '???' => '<a href="/">\1</a>'})
54
+ result.should == "Hello <b>bob</b>. Click <a href=\"/\">here</a>"
55
+ end
56
+
57
+ it "should html-escape the default when applying wrappers" do
58
+ i18n.translate("*bacon* > narwhals", :wrappers => ['<b>\1</b>']).
59
+ should == "<b>bacon</b> &gt; narwhals"
60
+ end
40
61
  end
41
62
  end
42
63
 
@@ -0,0 +1,35 @@
1
+ # encoding: UTF-8
2
+ require 'i18nliner/extensions/model'
3
+ require 'i18nliner/call_helpers'
4
+
5
+ describe I18nliner::Extensions::Model do
6
+ let(:i18n) do
7
+ Module.new do
8
+ extend(Module.new do
9
+ def translate(*args)
10
+ I18n.translate(*args)
11
+ end
12
+ end)
13
+ extend I18nliner::Extensions::Model
14
+ end
15
+ end
16
+
17
+
18
+ describe "#translate" do
19
+ it "should inferpolate" do
20
+ i18n.stub(:foo).and_return("FOO")
21
+ I18nliner::CallHelpers.stub(:infer_key).and_return(:key)
22
+
23
+ expect(I18n).to receive(:translate).with(:key, :default => "hello %{foo}", :foo => "FOO", :i18n_scope => i18n.i18n_scope)
24
+ i18n.translate("hello %{foo}")
25
+ end
26
+
27
+ it "should pass along its scope to I18n.t" do
28
+ expect(I18n).to receive(:translate).with(:key, :default => "foo", :i18n_scope => i18n.i18n_scope)
29
+ i18n.translate(:key, "foo")
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+
@@ -20,7 +20,7 @@ describe I18nliner::Extensions::View do
20
20
  i18n.stub(:foo).and_return("FOO")
21
21
  I18nliner::CallHelpers.stub(:infer_key).and_return(:key)
22
22
 
23
- expect(I18n).to receive(:translate).with(:key, :default => "hello %{foo}", :foo => "FOO")
23
+ expect(I18n).to receive(:translate).with(:key, :default => "hello %{foo}", :foo => "FOO", :i18n_scope => i18n.i18n_scope)
24
24
  i18n.translate("hello %{foo}")
25
25
  end
26
26
 
@@ -37,6 +37,11 @@ describe I18nliner::Extensions::View do
37
37
  i18n.translate
38
38
  }.to raise_error /wrong number of arguments/
39
39
  end
40
+
41
+ it "should pass along its scope to I18n.t" do
42
+ expect(I18n).to receive(:translate).with(:key, :default => "foo", :i18n_scope => i18n.i18n_scope)
43
+ i18n.translate(:key, "foo")
44
+ end
40
45
  end
41
46
  end
42
47
 
@@ -1,5 +1,6 @@
1
1
  require 'i18nliner/processors/erb_processor'
2
2
  require 'i18nliner/extractors/translation_hash'
3
+ require 'i18nliner/scope'
3
4
 
4
5
  describe I18nliner::Processors::ErbProcessor do
5
6
  before do
@@ -7,6 +8,22 @@ describe I18nliner::Processors::ErbProcessor do
7
8
  @processor = I18nliner::Processors::ErbProcessor.new(@translations)
8
9
  end
9
10
 
11
+ describe "#scope_for" do
12
+ context "with an erb template" do
13
+ subject { @processor.scope_for("app/views/foos/show.html.erb") }
14
+
15
+ specify { expect(subject).to be_allow_relative }
16
+ specify { expect(subject).to be_remove_whitespace }
17
+ specify { expect(subject.scope).to eq "foos.show." }
18
+ end
19
+
20
+ context "with anything else" do
21
+ subject { @processor.scope_for("foo.erb") }
22
+
23
+ specify { expect(subject).to be I18nliner::Scope.root }
24
+ end
25
+ end
26
+
10
27
  describe "#check_contents" do
11
28
  it "should extract valid translation calls" do
12
29
  @processor.check_contents(<<-SOURCE)
@@ -0,0 +1,28 @@
1
+ require 'i18nliner/processors/ruby_processor'
2
+ require 'i18nliner/extractors/translation_hash'
3
+ require 'i18nliner/scope'
4
+
5
+ describe I18nliner::Processors::RubyProcessor do
6
+ before do
7
+ @translations = I18nliner::Extractors::TranslationHash.new
8
+ @processor = I18nliner::Processors::RubyProcessor.new(@translations)
9
+ end
10
+
11
+ describe "#scope_for" do
12
+ if defined?(::Rails) && ::Rails.version > '4'
13
+ context "with a controller" do
14
+ subject { @processor.scope_for("app/controllers/foos/bars_controller.rb") }
15
+
16
+ specify { expect(subject).to be_allow_relative }
17
+ specify { expect(subject.scope).to eq "foos.bars." }
18
+ end
19
+ end
20
+
21
+ context "with any old ruby file" do
22
+ subject { @processor.scope_for("foo.rb") }
23
+
24
+ specify { expect(subject).to be I18nliner::Scope.root }
25
+ end
26
+ end
27
+ end
28
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18nliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-21 00:00:00.000000000 Z
12
+ date: 2014-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 2.0.6
69
+ version: '2.0'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 2.0.6
77
+ version: '2.0'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: globby
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +206,7 @@ files:
206
206
  - lib/i18nliner/commands/dump.rb
207
207
  - lib/i18nliner/commands/generic_command.rb
208
208
  - lib/i18nliner/commands/import.rb
209
+ - lib/i18nliner/controller_scope.rb
209
210
  - lib/i18nliner/errors.rb
210
211
  - lib/i18nliner/erubis.rb
211
212
  - lib/i18nliner/extensions/controller.rb
@@ -213,7 +214,6 @@ files:
213
214
  - lib/i18nliner/extensions/inferpolation.rb
214
215
  - lib/i18nliner/extensions/model.rb
215
216
  - lib/i18nliner/extensions/view.rb
216
- - lib/i18nliner/extractors/abstract_extractor.rb
217
217
  - lib/i18nliner/extractors/ruby_extractor.rb
218
218
  - lib/i18nliner/extractors/sexp_helper.rb
219
219
  - lib/i18nliner/extractors/translate_call.rb
@@ -229,8 +229,10 @@ files:
229
229
  - lib/tasks/i18nliner.rake
230
230
  - spec/commands/check_spec.rb
231
231
  - spec/commands/dump_spec.rb
232
+ - spec/extensions/controller_spec.rb
232
233
  - spec/extensions/core_spec.rb
233
234
  - spec/extensions/inferpolation_spec.rb
235
+ - spec/extensions/model_spec.rb
234
236
  - spec/extensions/view_spec.rb
235
237
  - spec/extractors/ruby_extractor_spec.rb
236
238
  - spec/extractors/translate_call_spec.rb
@@ -239,6 +241,7 @@ files:
239
241
  - spec/fixtures/app/models/valid.rb
240
242
  - spec/pre_processors/erb_pre_processor_spec.rb
241
243
  - spec/processors/erb_processor_spec.rb
244
+ - spec/processors/ruby_processor_spec.rb
242
245
  homepage: http://github.com/jenseng/i18nliner
243
246
  licenses: []
244
247
  post_install_message:
@@ -1,33 +0,0 @@
1
- module I18nliner
2
- module Extractors
3
- module AbstractExtractor
4
- def initialize(options = {})
5
- @scope = options[:scope] || ''
6
- @translations = TranslationHash.new(options[:translations] || {})
7
- @total = 0
8
- super()
9
- end
10
-
11
- def look_up(key)
12
- @translations[key]
13
- end
14
-
15
- def add_translation(full_key, default)
16
- @total += 1
17
- @translations[full_key] = default
18
- end
19
-
20
- def total_unique
21
- @translations.total_size
22
- end
23
-
24
- def self.included(base)
25
- base.instance_eval do
26
- attr_reader :total
27
- attr_accessor :translations, :scope
28
- end
29
- end
30
- end
31
- end
32
- end
33
-