r18n-rails 1.1.11 → 2.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b28a469d1a2dea1c66e6ae2463f76766f7b98c27
4
- data.tar.gz: 2a3667b2a627c871d5e9f8c9d7e1496fb0d01fde
3
+ metadata.gz: 19b4862889c33630c6afe6f3889527eebc349c83
4
+ data.tar.gz: c70239c24e688f0df03e9bb3e0dcfc0db897dd0d
5
5
  SHA512:
6
- metadata.gz: 26d4b4523a8de3d1cc7f80925146caa48d2aa6a69c1749af614ce010520f0b1df880142c3335f5cd8cd36f7b01af040073a329ff558788bff95305ab54e70dc7
7
- data.tar.gz: 994bc1253b941331deec13e8d074887d19031e39d208b2bf73c67e3dd15b94bd87362884b8e862d1e93d98f044419de6f0a94868ab4193775e6864a808b331de
6
+ metadata.gz: 701eec0d8c117df40209f856f6f81b1c64ec66bf3bd5f8e92c9d159b8e623e3c5fcc21d0697ae681e6e48c29214a87a10ccfca3f8925c096913852f094e0dbb7
7
+ data.tar.gz: d4b2340e6b4feee15fab4765c4fefda4a839715a725461c6ed3d68698406dcfd92aae3dba98409097bff6f45aa5e56337aad21e7207c83b57ee742777755cf24
data/README.md CHANGED
@@ -71,14 +71,14 @@ See full features in [main README](https://github.com/ai/r18n/blob/master/README
71
71
  5. Use translated messages in views. You can use Rails I18n syntax:
72
72
 
73
73
  ```ruby
74
- t 'user.name', :name => 'John'
75
- t 'user.count', :count => 5
74
+ t 'user.name', name: 'John'
75
+ t 'user.count', count: 5
76
76
  ```
77
77
  or R18n syntax:
78
78
 
79
79
  ```ruby
80
- t.user.name(:name => 'John') # for Rails I18n named variables
81
- t.user.name('John') # for R18n variables
80
+ t.user.name(name: 'John') # for Rails I18n named variables
81
+ t.user.name('John') # for R18n variables
82
82
  t.user.count(5)
83
83
  ```
84
84
 
@@ -39,7 +39,7 @@ module R18n
39
39
  end
40
40
 
41
41
  i18n = R18n::I18n.new(locales, R18n.default_places,
42
- :off_filters => :untranslated, :on_filters => :untranslated_html)
42
+ off_filters: :untranslated, on_filters: :untranslated_html)
43
43
  ::I18n.locale = i18n.locale.code.to_sym
44
44
  i18n
45
45
  end
@@ -46,9 +46,9 @@ module R18n
46
46
 
47
47
  # Extend +l+ helper to use also R18n syntax.
48
48
  #
49
- # l Time.now # Rails I18n default format
50
- # l Time.now, :format => :short # Rails I18n style
51
- # l Time.now, :human # R18n style
49
+ # l Time.now # Rails I18n default format
50
+ # l Time.now, format: :short # Rails I18n style
51
+ # l Time.now, :human # R18n style
52
52
  def l(obj, *params)
53
53
  if params.empty? or params.first.is_a? Hash
54
54
  super(obj, *params)
data/lib/r18n-rails.rb CHANGED
@@ -44,8 +44,8 @@ ActiveSupport.on_load(:after_initialize) do
44
44
  locale = env || I18n.default_locale.to_s
45
45
  if defined? Rails::Console and not defined? Wirble
46
46
  i18n = R18n::I18n.new(locale, R18n.default_places,
47
- :off_filters => :untranslated,
48
- :on_filters => :untranslated_bash)
47
+ off_filters: :untranslated,
48
+ on_filters: :untranslated_bash)
49
49
  R18n.set(i18n)
50
50
  else
51
51
  R18n.set(locale)
data/r18n-rails.gemspec CHANGED
@@ -2,9 +2,10 @@ require File.expand_path('../../r18n-core/lib/r18n-core/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
- s.name = 'r18n-rails'
6
- s.version = R18n::VERSION.dup
7
- s.date = Time.now.strftime('%Y-%m-%d')
5
+ s.name = 'r18n-rails'
6
+ s.version = R18n::VERSION.dup
7
+ s.date = Time.now.strftime('%Y-%m-%d')
8
+
8
9
  s.summary = 'R18n for Rails'
9
10
  s.description = <<-EOF
10
11
  Out-of-box R18n support for Ruby on Rails.
@@ -1,19 +1,19 @@
1
1
  class TestController < ApplicationController
2
2
  layout false
3
3
 
4
- before_filter :reload_r18n, :only => :filter
4
+ before_filter :reload_r18n, only: :filter
5
5
 
6
6
  def locales
7
- render :text => R18n.get.locales.map { |i| i.code }.join(', ')
7
+ render text: R18n.get.locales.map { |i| i.code }.join(', ')
8
8
  end
9
9
 
10
10
  def translations
11
- render :text => "R18n: #{R18n.get.r18n.translations}. " +
11
+ render text: "R18n: #{R18n.get.r18n.translations}. " +
12
12
  "Rails I18n: #{R18n.get.i18n.translations}"
13
13
  end
14
14
 
15
15
  def available
16
- render :text => R18n.get.available_locales.map { |i| i.code }.sort.join(' ')
16
+ render text: R18n.get.available_locales.map { |i| i.code }.sort.join(' ')
17
17
  end
18
18
 
19
19
  def helpers
@@ -22,24 +22,24 @@ class TestController < ApplicationController
22
22
  end
23
23
 
24
24
  def untranslated
25
- render :text => "#{R18n.get.user.not.exists}"
25
+ render text: "#{R18n.get.user.not.exists}"
26
26
  end
27
27
 
28
28
  def controller
29
- render :text => "#{t.user.name} #{r18n.t.user.name} #{t('user.name')}"
29
+ render text: "#{t.user.name} #{r18n.t.user.name} #{t('user.name')}"
30
30
  end
31
31
 
32
32
  def time
33
- render :text => l(Time.at(0).utc) + "\n" +
34
- l(Time.at(0).utc, :format => :short)
33
+ render text: l(Time.at(0).utc) + "\n" +
34
+ l(Time.at(0).utc, format: :short)
35
35
  end
36
36
 
37
37
  def human_time
38
- render :text => l(Time.now, :human)
38
+ render text: l(Time.now, :human)
39
39
  end
40
40
 
41
41
  def filter
42
- render :text => t.ruby
42
+ render text: t.ruby
43
43
  end
44
44
 
45
45
  def format
@@ -1,7 +1,7 @@
1
1
  class TestMailer < ActionMailer::Base
2
- default :from => 'from@example.com'
2
+ default from: 'from@example.com'
3
3
 
4
4
  def test
5
- mail(:to => 'to@example.com')
5
+ mail(to: 'to@example.com')
6
6
  end
7
7
  end
@@ -1 +1 @@
1
- <%= number_to_currency(1000.12345, :precision => 1) %>
1
+ <%= number_to_currency(1000.12345, precision: 1) %>
@@ -6,7 +6,7 @@ require "action_mailer/railtie"
6
6
  require "rails/test_unit/railtie"
7
7
 
8
8
  if defined?(Bundler)
9
- Bundler.require(*Rails.groups(:assets => %w(development test)))
9
+ Bundler.require(*Rails.groups(assets: %w(development test)))
10
10
  end
11
11
 
12
12
  module App
@@ -1,6 +1,6 @@
1
1
  App::Application.routes.draw do
2
2
  controller :test do
3
- match '/:action', :via => 'get'
4
- match '/:locale/:action', :via => 'get'
3
+ match '/:action', via: 'get'
4
+ match '/:locale/:action', via: 'get'
5
5
  end
6
6
  end
@@ -10,9 +10,9 @@
10
10
  #
11
11
  # It's strongly recommended to check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(:version => 20091218123631) do
13
+ ActiveRecord::Schema.define(version: 20091218123631) do
14
14
 
15
- create_table "posts", :force => true do |t|
15
+ create_table "posts", force: true do |t|
16
16
  t.string "title_en"
17
17
  t.string "title_ru"
18
18
  end
data/spec/rails_spec.rb CHANGED
@@ -1,160 +1,164 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
- describe TestController, :type => :controller do
3
+ describe TestController, type: :controller do
5
4
  render_views
6
5
 
7
6
  it "uses default locale" do
8
7
  get :locales
9
- response.should be_success
10
- response.body.should == 'ru'
8
+ expect(response).to be_success
9
+ expect(response.body).to eq 'ru'
11
10
  end
12
11
 
13
12
  it "gets locale from param" do
14
- get :locales, :locale => 'ru'
15
- response.should be_success
16
- response.body.should == 'ru, en'
13
+ get :locales, locale: 'ru'
14
+ expect(response).to be_success
15
+ expect(response.body).to eq 'ru, en'
17
16
  end
18
17
 
19
18
  it "gets locale from session" do
20
- get :locales, {}, { :locale => 'ru' }
21
- response.should be_success
22
- response.body.should == 'ru, en'
19
+ get :locales, {}, { locale: 'ru' }
20
+ expect(response).to be_success
21
+ expect(response.body).to eq 'ru, en'
23
22
  end
24
23
 
25
24
  it "gets locales from http" do
26
25
  request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru,fr;q=0.9'
27
26
  get :locales
28
- response.should be_success
29
- response.body.should == 'ru, fr, en'
27
+ expect(response).to be_success
28
+ expect(response.body).to eq 'ru, fr, en'
30
29
  end
31
30
 
32
31
  it "loads translations" do
33
- get :translations, :locale => 'en'
34
- response.should be_success
35
- response.body.should == 'R18n: supported. Rails I18n: supported'
32
+ get :translations, locale: 'en'
33
+ expect(response).to be_success
34
+ expect(response.body).to eq 'R18n: supported. Rails I18n: supported'
36
35
  end
37
36
 
38
37
  it "returns available translations" do
39
38
  get :available
40
- response.should be_success
41
- response.body.should == 'en ru'
39
+ expect(response).to be_success
40
+ expect(response.body).to eq 'en ru'
42
41
  end
43
42
 
44
43
  it "adds helpers" do
45
- get :helpers, :locale => 'en'
46
- response.should be_success
47
- response.body.should == "Name\nName\nName\nName\n"
44
+ get :helpers, locale: 'en'
45
+ expect(response).to be_success
46
+ expect(response.body).to eq "Name\nName\nName\nName\n"
48
47
  end
49
48
 
50
49
  it "formats untranslated" do
51
50
  get :untranslated
52
- response.should be_success
53
- response.body.should == 'user.<span style="color: red">[not.exists]</span>'
51
+ expect(response).to be_success
52
+ expect(response.body).to eq(
53
+ 'user.<span style="color: red">[not.exists]</span>')
54
54
  end
55
55
 
56
56
  it "adds methods to controller" do
57
- get :controller, :locale => 'en'
58
- response.should be_success
59
- response.body.should == "Name Name Name"
57
+ get :controller, locale: 'en'
58
+ expect(response).to be_success
59
+ expect(response.body).to eq "Name Name Name"
60
60
  end
61
61
 
62
62
  it "localizes time by Rails I18n" do
63
- get :time, :locale => 'en'
64
- response.should be_success
65
- response.body.should == "Thu, 01 Jan 1970 00:00:00 +0000\n01 Jan 00:00"
63
+ get :time, locale: 'en'
64
+ expect(response).to be_success
65
+ expect(response.body).to eq "Thu, 01 Jan 1970 00:00:00 +0000\n01 Jan 00:00"
66
66
  end
67
67
 
68
68
  it "localizes time by R18n" do
69
- get :human_time, :locale => 'en'
70
- response.should be_success
71
- response.body.should == "now"
69
+ get :human_time, locale: 'en'
70
+ expect(response).to be_success
71
+ expect(response.body).to eq 'now'
72
72
  end
73
73
 
74
74
  it "translates models" do
75
75
  ActiveRecord::Schema.verbose = false
76
- ActiveRecord::Schema.define(:version => 20091218130034) do
77
- create_table "posts", :force => true do |t|
76
+ ActiveRecord::Schema.define(version: 20091218130034) do
77
+ create_table "posts", force: true do |t|
78
78
  t.string "title_en"
79
79
  t.string "title_ru"
80
80
  end
81
81
  end
82
82
 
83
- Post.unlocalized_getters(:title).should == { 'ru' => 'title_ru',
84
- 'en' => 'title_en' }
85
- Post.unlocalized_setters(:title).should == { 'ru' => 'title_ru=',
86
- 'en' => 'title_en=' }
83
+ expect(Post.unlocalized_getters(:title)).to eq({
84
+ 'ru' => 'title_ru',
85
+ 'en' => 'title_en'
86
+ })
87
+ expect(Post.unlocalized_setters(:title)).to eq({
88
+ 'ru' => 'title_ru=',
89
+ 'en' => 'title_en='
90
+ })
87
91
 
88
92
  @post = Post.new
89
93
  @post.title_en = 'Record'
90
94
 
91
95
  R18n.set('ru')
92
- @post.title.should == 'Record'
96
+ expect(@post.title).to eq 'Record'
93
97
 
94
98
  @post.title = 'Запись'
95
- @post.title_ru.should == 'Запись'
96
- @post.title_en.should == 'Record'
97
- @post.title.should == 'Запись'
99
+ expect(@post.title_ru).to eq 'Запись'
100
+ expect(@post.title_en).to eq 'Record'
101
+ expect(@post.title).to eq 'Запись'
98
102
  end
99
103
 
100
104
  it "sets default places" do
101
- R18n.default_places.should == [Rails.root.join('app/i18n'),
102
- R18n::Loader::Rails.new]
105
+ expect(R18n.default_places).to eq([
106
+ Rails.root.join('app/i18n'), R18n::Loader::Rails.new])
107
+
103
108
  R18n.set('en')
104
- R18n.get.user.name.should == 'Name'
109
+ expect(R18n.get.user.name).to eq 'Name'
105
110
  end
106
111
 
107
112
  it "translates mails" do
108
113
  R18n.set('en')
109
114
  email = TestMailer.test.deliver
110
- email.body.to_s.should == "Name\nName\nName\n"
115
+ expect(email.body.to_s).to eq "Name\nName\nName\n"
111
116
  end
112
117
 
113
118
  it "reloads filters from app directory" do
114
- get :filter, :locale => 'en'
115
- response.should be_success
116
- response.body.should == 'Rails'
117
- R18n::Rails::Filters.loaded.should == [:rails_custom_filter]
119
+ get :filter, locale: 'en'
120
+ expect(response).to be_success
121
+ expect(response.body).to eq 'Rails'
122
+ expect(R18n::Rails::Filters.loaded).to eq [:rails_custom_filter]
118
123
 
119
124
  R18n::Filters.defined[:rails_custom_filter].block = proc { 'No' }
120
- get :filter, :locale => 'en'
125
+ get :filter, locale: 'en'
121
126
 
122
- response.should be_success
123
- response.body.should == 'Rails'
127
+ expect(response).to be_success
128
+ expect(response.body).to eq 'Rails'
124
129
  end
125
130
 
126
131
  it "escapes html inside R18n" do
127
- get :safe, :locale => 'en'
128
- response.should be_success
129
- response.body.should ==
130
- "<b> user.<span style=\"color: red\">[no_tr]</span>\n"
132
+ get :safe, locale: 'en'
133
+ expect(response).to be_success
134
+ expect(response.body).to eq(
135
+ "<b> user.<span style=\"color: red\">[no_tr]</span>\n")
131
136
  end
132
137
 
133
138
  it "works with Rails build-in herlpers" do
134
139
  get :format
135
- response.should be_success
136
- response.body.should == "1 000,1 руб.\n"
140
+ expect(response).to be_success
141
+ expect(response.body).to eq "1 000,1 руб.\n"
137
142
  end
138
143
 
139
144
  it "caches I18n object" do
140
145
  R18n.clear_cache!
141
146
 
142
147
  get :translations
143
- R18n.cache.keys.length.should == 1
148
+ expect(R18n.cache.keys.length).to eq 1
144
149
 
145
150
  get :translations
146
- R18n.cache.keys.length.should == 1
151
+ expect(R18n.cache.keys.length).to eq 1
147
152
 
148
153
  get :translations
149
154
  request.env['HTTP_ACCEPT_LANGUAGE'] = 'ru,fr;q=0.9'
150
- R18n.cache.keys.length.should == 1
155
+ expect(R18n.cache.keys.length).to eq 1
151
156
 
152
- get :translations, :locale => 'en'
153
- R18n.cache.keys.length.should == 2
157
+ get :translations, locale: 'en'
158
+ expect(R18n.cache.keys.length).to eq 2
154
159
  end
155
160
 
156
161
  it "parameterizes strigns" do
157
- 'One two три'.parameterize.should == 'one-two'
162
+ expect('One two три'.parameterize).to eq 'one-two'
158
163
  end
159
-
160
164
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r18n-rails-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.11
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.11
26
+ version: 2.0.0
27
27
  description: |2
28
28
  Out-of-box R18n support for Ruby on Rails.
29
29
  It is just a wrapper for R18n Rails API and R18n core libraries.
@@ -50,7 +50,6 @@ files:
50
50
  - r18n-rails.gemspec
51
51
  - spec/app/app/controllers/application_controller.rb
52
52
  - spec/app/app/controllers/test_controller.rb
53
- - spec/app/app/helpers/application_helper.rb
54
53
  - spec/app/app/i18n/en.yml
55
54
  - spec/app/app/i18n/filters.rb
56
55
  - spec/app/app/i18n/ru.yml
@@ -72,7 +71,6 @@ files:
72
71
  - spec/app/config/routes.rb
73
72
  - spec/app/db/migrate/20091218123631_create_posts.rb
74
73
  - spec/app/db/schema.rb
75
- - spec/app/script/rails
76
74
  - spec/rails_spec.rb
77
75
  - spec/spec_helper.rb
78
76
  homepage: https://github.com/ai/r18n/tree/master/r18n-rails
@@ -102,7 +100,6 @@ summary: R18n for Rails
102
100
  test_files:
103
101
  - spec/app/app/controllers/application_controller.rb
104
102
  - spec/app/app/controllers/test_controller.rb
105
- - spec/app/app/helpers/application_helper.rb
106
103
  - spec/app/app/i18n/en.yml
107
104
  - spec/app/app/i18n/filters.rb
108
105
  - spec/app/app/i18n/ru.yml
@@ -124,6 +121,5 @@ test_files:
124
121
  - spec/app/config/routes.rb
125
122
  - spec/app/db/migrate/20091218123631_create_posts.rb
126
123
  - spec/app/db/schema.rb
127
- - spec/app/script/rails
128
124
  - spec/rails_spec.rb
129
125
  - spec/spec_helper.rb
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'