devise-track_locale 0.1.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 +7 -0
- data/LICENSE +20 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/lib/devise/models/track_locale.rb +11 -0
- data/lib/devise/track_locale/version.rb +5 -0
- data/lib/devise/track_locale.rb +7 -0
- data/lib/devise-track_locale.rb +1 -0
- data/spec/models/track_locale_spec.rb +31 -0
- data/spec/spec_helper.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b5f0156cfda2b66dd1a7be1c214e987d81f0806
|
4
|
+
data.tar.gz: 59d7359cf5298fcace6df213197546a9bf0496d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f424d7aa6a404e081ef019160cc83743c9ba3e7e71bd013acf0da92373edde6896f8ae82cc7757a6a7e58297b2e8b6116c5c5d0aac3b3fe10ce880f5744274ec
|
7
|
+
data.tar.gz: 9129ec557abce16875fc5617c5da518cff2cbbe1b9b651bc1b4052d06a267ee844a9726b9a3836a6438d52b8ec183642a18bc1d15353444ddc2188af101012db
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 Sunny Ripert
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
devise-track_locale
|
2
|
+
===================
|
3
|
+
|
4
|
+
Adds support to [Devise](http://github.com/plataformatec/devise) for
|
5
|
+
remembering a user's last locale.
|
6
|
+
|
7
|
+
Installation
|
8
|
+
-----------
|
9
|
+
|
10
|
+
Add the gem to your Gemfile:
|
11
|
+
|
12
|
+
```rb
|
13
|
+
gem "devise"
|
14
|
+
gem "devise-track_locale"
|
15
|
+
```
|
16
|
+
|
17
|
+
Usage
|
18
|
+
-----
|
19
|
+
|
20
|
+
In your model, add `:track_locale` as a devise module:
|
21
|
+
|
22
|
+
```rb
|
23
|
+
class User < ActiveRecord::Base
|
24
|
+
devise …, :track_locale
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Add a `locale` attribute to your users:
|
29
|
+
|
30
|
+
```sh
|
31
|
+
$ rails g migration AddLocaleToUsers locale
|
32
|
+
$ rake db:migrate
|
33
|
+
```
|
34
|
+
|
35
|
+
Copyright
|
36
|
+
---------
|
37
|
+
|
38
|
+
By Sunny Ripert, under the MIT License. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Bundler
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
# Rspec
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
RSpec::Core::RakeTask.new(:spec)
|
12
|
+
task default: :spec
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'devise/track_locale'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Devise::Models::TrackLocale do
|
4
|
+
class MockModel
|
5
|
+
include Devise::Models::TrackLocale
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#set_locale!" do
|
9
|
+
let(:model) { MockModel.new }
|
10
|
+
before do
|
11
|
+
allow(model).to receive(:update_attribute)
|
12
|
+
allow(model).to receive(:locale) { "en" }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "saves the new locale on the model" do
|
16
|
+
I18n.with_locale(:fr) do
|
17
|
+
model.set_locale!
|
18
|
+
end
|
19
|
+
|
20
|
+
expect(model).to have_received(:update_attribute).with(:locale, "fr")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "does not change the model if the locale is the same" do
|
24
|
+
I18n.with_locale(:en) do
|
25
|
+
model.set_locale!
|
26
|
+
end
|
27
|
+
|
28
|
+
expect(model).not_to have_received(:update_attribute)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise-track_locale
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sunny Ripert
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: devise
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- sunny@sunfox.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/devise-track_locale.rb
|
52
|
+
- lib/devise/models/track_locale.rb
|
53
|
+
- lib/devise/track_locale.rb
|
54
|
+
- lib/devise/track_locale/version.rb
|
55
|
+
- spec/models/track_locale_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: http://github.com/sunny/devise-track_locale
|
58
|
+
licenses: []
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Track a user's last locale with Devise.
|
80
|
+
test_files:
|
81
|
+
- spec/models/track_locale_spec.rb
|
82
|
+
- spec/spec_helper.rb
|