exvo_globalize 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/README.md +42 -1
- data/Rakefile +8 -0
- data/app/controllers/globalize_translations_controller.rb +22 -2
- data/app/views/globalize_translations/index.html +0 -0
- data/config/routes.rb +3 -1
- data/exvo_globalize.gemspec +8 -0
- data/lib/exvo_globalize.rb +4 -1
- data/lib/exvo_globalize/backend/chain.rb +30 -0
- data/lib/exvo_globalize/{globalize_store.rb → backend/globalize_store.rb} +9 -2
- data/lib/exvo_globalize/backend/simple.rb +16 -0
- data/lib/exvo_globalize/engine.rb +2 -2
- data/lib/exvo_globalize/version.rb +1 -1
- data/lib/generators/exvo_globalize/exvo_globalize_generator.rb +23 -0
- data/lib/generators/exvo_globalize/templates/migration.rb +16 -0
- data/spec/app.rb +41 -0
- data/spec/controllers/globalize_translations_controller_spec.rb +59 -0
- data/spec/factories.rb +23 -0
- data/spec/fixtures/locales/en.yml +6 -0
- data/spec/integration/caching_spec.rb +18 -0
- data/spec/integration/exvo_globalize_spec.rb +52 -0
- data/spec/integration/locale_fallback_spec.rb +30 -0
- data/spec/models/globalize_translation_spec.rb +24 -0
- data/spec/spec_helper.rb +27 -0
- metadata +147 -5
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/README.md
CHANGED
@@ -1,7 +1,48 @@
|
|
1
1
|
# Exvo Globalize
|
2
2
|
|
3
|
-
This plugin lets you make use of the Globalize app (http://
|
3
|
+
This plugin lets you make use of the Globalize app (http://globalize.exvo.com/)
|
4
4
|
to handle the translation of your Rails app into multiple languages.
|
5
5
|
|
6
6
|
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ gem install exvo_globalize
|
13
|
+
```
|
14
|
+
|
15
|
+
add it to the Gemfile
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'exvo_globalize'
|
19
|
+
```
|
20
|
+
|
21
|
+
bundle
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
and generate the database migration
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ rails generate exvo_globalize
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
Is is advised to have your `/globalize/` actions behind an authorization barrier (besides `/globalize/translations.json`, which is by default publicly accessible).
|
35
|
+
Create a `config/initializers/exvo_globalize.rb` file with similar contents:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
I18n::Backend::GlobalizeStore.authenticator = proc {
|
39
|
+
authenticate_user!
|
40
|
+
require_admin!
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
`authenticate_user!` and `require_admin!` are just exemplary authorization actions.
|
45
|
+
|
46
|
+
|
47
|
+
|
7
48
|
Copyright © 2011 Exvo.com Development BV, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
class GlobalizeTranslationsController < ApplicationController
|
2
|
-
|
2
|
+
|
3
|
+
before_filter :globalize_translations_authenticator, :except => [:index]
|
4
|
+
|
5
|
+
# get :index as JSON should not require authentication
|
6
|
+
before_filter(:only => :index) do |controller|
|
7
|
+
globalize_translations_authenticator unless controller.request.format.json?
|
8
|
+
end
|
9
|
+
|
10
|
+
layout false
|
11
|
+
|
12
|
+
respond_to :html, :json
|
3
13
|
|
4
14
|
def index
|
5
15
|
# returns {"default_locale":"en","pl":{"hello.world":"Witaj \u015bwiecie","hello.earth":"Witaj ziemio"},"en":{"hello.world":"Hello world","hello.earth":"Hello Earth"}}
|
6
|
-
|
16
|
+
@translations = I18n.backend.available_translations.merge({ :default_locale => I18n.default_locale })
|
17
|
+
respond_with @translations
|
7
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def globalize_translations_authenticator
|
23
|
+
if I18n::Backend::GlobalizeStore.authenticator && I18n::Backend::GlobalizeStore.authenticator.respond_to?(:call)
|
24
|
+
I18n::Backend::GlobalizeStore.authenticator.bind(self).call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
8
28
|
end
|
File without changes
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
scope '/globalize' do
|
3
|
-
resources :translations, :only => [:index], :as => 'globalize_translations', :controller => 'globalize_translations'
|
3
|
+
resources :translations, :only => [:index], :as => 'globalize_translations', :controller => 'globalize_translations' do
|
4
|
+
put :update_many, :on => :collection
|
5
|
+
end
|
4
6
|
end
|
5
7
|
end
|
data/exvo_globalize.gemspec
CHANGED
@@ -21,4 +21,12 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency 'rails', ['>= 3.0.0']
|
23
23
|
s.add_dependency 'i18n', ['>= 0.5.0']
|
24
|
+
s.add_development_dependency 'guard', ['>= 0.5.0']
|
25
|
+
s.add_development_dependency 'guard-rspec', ['>= 0.4.0']
|
26
|
+
s.add_development_dependency 'sqlite3', ['>= 1.3']
|
27
|
+
s.add_development_dependency 'rspec', ['>= 2.6']
|
28
|
+
s.add_development_dependency 'rspec-rails', ['>= 2.6']
|
29
|
+
s.add_development_dependency 'factory_girl_rails', ['>= 1.1.0']
|
30
|
+
s.add_development_dependency 'shoulda-matchers', ['>= 1.0.0.beta3']
|
31
|
+
s.add_development_dependency 'json', ['>= 1.5.1']
|
24
32
|
end
|
data/lib/exvo_globalize.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "exvo_globalize/version"
|
2
|
-
require "exvo_globalize/
|
2
|
+
require "exvo_globalize/backend/chain"
|
3
|
+
require "exvo_globalize/backend/globalize_store"
|
4
|
+
require "exvo_globalize/backend/simple"
|
3
5
|
|
6
|
+
# Make it a Rails engine
|
4
7
|
module ExvoGlobalize
|
5
8
|
require 'exvo_globalize/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
6
9
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module I18n
|
2
|
+
module Backend
|
3
|
+
class Chain
|
4
|
+
module Implementation
|
5
|
+
|
6
|
+
# Extend the Chain backend with a custom `available_translations` method
|
7
|
+
# returning a combined hash with translations from all chained backends
|
8
|
+
def available_translations
|
9
|
+
# reverse, so that the translations from the first backend (GlobalizeStore) overwrite/overshadow others
|
10
|
+
backends.map { |backend| backend.available_translations }.reverse.inject(&:merge)
|
11
|
+
end
|
12
|
+
|
13
|
+
# add the simplest possible fallback to the I18n.default_locale for missing translations
|
14
|
+
def translate_with_fallback(locale, key, default_options = {})
|
15
|
+
begin
|
16
|
+
# will look for a translation in all backends (using requested locale)
|
17
|
+
translate_without_fallback(locale, key, default_options)
|
18
|
+
rescue I18n::MissingTranslationData
|
19
|
+
# if it does not find a translation it will look again in all backends, but using I18n.default_locale as a locale
|
20
|
+
translate_without_fallback(I18n.default_locale, key, default_options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method_chain :translate, :fallback
|
25
|
+
end
|
26
|
+
|
27
|
+
include Implementation
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -3,6 +3,9 @@ module I18n
|
|
3
3
|
class GlobalizeStore
|
4
4
|
# based on https://github.com/svenfuchs/i18n-active_record/blob/master/lib/i18n/backend/active_record.rb
|
5
5
|
|
6
|
+
# Authentication proc
|
7
|
+
cattr_accessor :authenticator
|
8
|
+
|
6
9
|
module Implementation
|
7
10
|
include Base, Flatten
|
8
11
|
|
@@ -24,11 +27,15 @@ module I18n
|
|
24
27
|
def store_translations(locale, data, options = {})
|
25
28
|
escape = options.fetch(:escape, true)
|
26
29
|
flatten_translations(locale, data, escape, false).each do |key, value|
|
27
|
-
|
28
|
-
GlobalizeTranslation.create(:locale => locale.to_s, :key => key.to_s, :value => value)
|
30
|
+
store_flatten_translation(locale, key, value)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
def store_flatten_translation(locale, key, value)
|
35
|
+
GlobalizeTranslation.locale(locale).lookup(expand_keys(key)).delete_all
|
36
|
+
GlobalizeTranslation.create(:locale => locale.to_s, :key => key.to_s, :value => value)
|
37
|
+
end
|
38
|
+
|
32
39
|
protected
|
33
40
|
|
34
41
|
def lookup(locale, key, scope = [], options = {})
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module I18n
|
2
|
+
module Backend
|
3
|
+
class Simple
|
4
|
+
module Implementation
|
5
|
+
|
6
|
+
# Extend the Simple backend with a custom `available_translations` method
|
7
|
+
# returning a combined hash with all translations from this backend
|
8
|
+
def available_translations
|
9
|
+
send(:translations)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
include Implementation
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -5,8 +5,8 @@ require "i18n"
|
|
5
5
|
module ExvoGlobalize
|
6
6
|
class Engine < Rails::Engine
|
7
7
|
initializer "exvo_globalize.configure_i18n" do |app|
|
8
|
-
# database backed
|
9
|
-
I18n.backend = I18n::Backend::GlobalizeStore.new
|
8
|
+
# chained backends; GlobalizeStore (database backed) first, then YAML files (fallback)
|
9
|
+
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::GlobalizeStore.new, I18n.backend)
|
10
10
|
|
11
11
|
# caching layer
|
12
12
|
I18n::Backend::GlobalizeStore.send(:include, I18n::Backend::Cache)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class ExvoGlobalizeGenerator < Rails::Generators::Base
|
4
|
+
desc "Add a 'create_globalize_translations' migration"
|
5
|
+
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.next_migration_number(dirname)
|
13
|
+
if ActiveRecord::Base.timestamped_migrations
|
14
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
15
|
+
else
|
16
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_migration_file
|
21
|
+
migration_template 'migration.rb', 'db/migrate/create_globalize_translations.rb'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateGlobalizeTranslations < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :globalize_translations do |t|
|
4
|
+
t.string :locale
|
5
|
+
t.string :key
|
6
|
+
t.text :value
|
7
|
+
t.text :interpolations
|
8
|
+
t.boolean :is_proc, :default => false
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :globalize_translations
|
15
|
+
end
|
16
|
+
end
|
data/spec/app.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'action_controller/railtie'
|
3
|
+
require 'action_view/railtie'
|
4
|
+
|
5
|
+
# database
|
6
|
+
ActiveRecord::Base.configurations = { 'test' => { :adapter => 'sqlite3', :database => ':memory:' } }
|
7
|
+
ActiveRecord::Base.establish_connection 'test'
|
8
|
+
|
9
|
+
# config
|
10
|
+
app = Class.new(Rails::Application)
|
11
|
+
app.config.secret_token = "aoijg543oi2u88923j4fnvfjt529hg92"
|
12
|
+
app.config.session_store :cookie_store, :key => "_exvo_globalize_session"
|
13
|
+
app.config.active_support.deprecation = :log
|
14
|
+
app.config.i18n.default_locale = :en
|
15
|
+
app.initialize!
|
16
|
+
|
17
|
+
# application controller
|
18
|
+
class ApplicationController < ActionController::Base
|
19
|
+
def require_admin
|
20
|
+
redirect_to '/403.html', :status => 403 unless @current_user && @current_user.admin?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# custom authentication
|
25
|
+
I18n::Backend::GlobalizeStore.authenticator = proc {
|
26
|
+
require_admin
|
27
|
+
}
|
28
|
+
|
29
|
+
# migration
|
30
|
+
class CreateGlobalizeTranslations < ActiveRecord::Migration
|
31
|
+
def self.up
|
32
|
+
create_table :globalize_translations do |t|
|
33
|
+
t.string :locale
|
34
|
+
t.string :key
|
35
|
+
t.text :value
|
36
|
+
t.text :interpolations
|
37
|
+
t.boolean :is_proc, :default => false
|
38
|
+
t.timestamps
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe GlobalizeTranslationsController do
|
5
|
+
|
6
|
+
let(:i18n_title) { Factory(:i18n_title) }
|
7
|
+
|
8
|
+
context "JSON" do
|
9
|
+
|
10
|
+
describe "GET :index" do
|
11
|
+
|
12
|
+
let(:translations) do
|
13
|
+
i18n_title # needed so there is some data in the database before a call to get :index
|
14
|
+
get :index, :format => :json
|
15
|
+
JSON.parse(response.body)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a non-empty JSON" do
|
19
|
+
translations.present?.should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a JSON with default_locale" do
|
23
|
+
translations["default_locale"].should eq(I18n.default_locale.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns a JSON with translations" do
|
27
|
+
i18n_title.value.should eq(translations["en"]["title"])
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context "HTML" do
|
35
|
+
|
36
|
+
describe "GET :index" do
|
37
|
+
|
38
|
+
context "without being logged in" do
|
39
|
+
before do
|
40
|
+
get :index, :format => :html
|
41
|
+
end
|
42
|
+
|
43
|
+
it { should respond_with(:forbidden) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when being logged in as admin" do
|
47
|
+
before do
|
48
|
+
controller.stub!(:require_admin).and_return(true)
|
49
|
+
get :index, :format => :html
|
50
|
+
end
|
51
|
+
|
52
|
+
it { should respond_with(:success) }
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/spec/factories.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Factory.define :i18n_example, :class => GlobalizeTranslation do |u|
|
2
|
+
u.locale 'en'
|
3
|
+
u.key 'example'
|
4
|
+
u.value 'This is an example'
|
5
|
+
end
|
6
|
+
|
7
|
+
Factory.define :i18n_nested_example, :class => GlobalizeTranslation do |u|
|
8
|
+
u.locale 'en'
|
9
|
+
u.key 'nested.example'
|
10
|
+
u.value 'This is a nested example'
|
11
|
+
end
|
12
|
+
|
13
|
+
Factory.define :i18n_title, :class => GlobalizeTranslation do |u|
|
14
|
+
u.locale 'en'
|
15
|
+
u.key 'title'
|
16
|
+
u.value 'This is a title'
|
17
|
+
end
|
18
|
+
|
19
|
+
Factory.define :i18n_title_pl, :class => GlobalizeTranslation do |u|
|
20
|
+
u.locale 'pl'
|
21
|
+
u.key 'title'
|
22
|
+
u.value 'To jest tytuł'
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ExvoGlobalize do
|
4
|
+
|
5
|
+
let(:i18n_example) { Factory(:i18n_example) }
|
6
|
+
|
7
|
+
it "caches translations in memory" do
|
8
|
+
old = I18n.translate(:example)
|
9
|
+
new = 'New example'
|
10
|
+
|
11
|
+
i18n_example.update_attributes(:value => new)
|
12
|
+
i18n_example.reload
|
13
|
+
i18n_example.value.should eq(new)
|
14
|
+
|
15
|
+
I18n.translate(:example).should eq(old)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ExvoGlobalize do
|
4
|
+
|
5
|
+
I18n.load_path = ['spec/fixtures/locales/en.yml']
|
6
|
+
|
7
|
+
let(:i18n_example) { Factory(:i18n_example) }
|
8
|
+
let(:i18n_nested_example) { Factory(:i18n_nested_example) }
|
9
|
+
let(:i18n_title) { Factory(:i18n_title) }
|
10
|
+
|
11
|
+
it "respects the default_locale setting" do
|
12
|
+
I18n.default_locale.should eq(:en)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "provides a valid translation for a given key" do
|
16
|
+
i18n_example.value.should eq(I18n.t(:example))
|
17
|
+
end
|
18
|
+
|
19
|
+
it "provides a valid translation for a scoped key" do
|
20
|
+
i18n_nested_example.value.should eq(I18n.t(:example, :scope => [:nested]))
|
21
|
+
end
|
22
|
+
|
23
|
+
context "translation storage" do
|
24
|
+
let(:hello_world) { 'Hello world' }
|
25
|
+
let(:hello_earth) { 'Hello Earth' }
|
26
|
+
let(:globalize_store_backend) { I18n.backend.backends.detect { |backend| backend.is_a?(I18n::Backend::GlobalizeStore) } }
|
27
|
+
|
28
|
+
it "stores nested translations in the GlobalizeStore backend" do
|
29
|
+
globalize_store_backend.store_translations(I18n.locale, { :hello => { :world => hello_world} })
|
30
|
+
I18n.translate('hello.world').should eql(hello_world)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "stores flatten translation in the GlobalizeStore backend" do
|
34
|
+
globalize_store_backend.store_flatten_translation(I18n.locale, 'hello.earth', hello_earth)
|
35
|
+
I18n.translate(:earth, :scope => [:hello]).should eql(hello_earth)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "falls back to the YAML file if the translation is missing in the GlobalizeStore backend (db)" do
|
40
|
+
I18n.translate('yaml.title').should eq('YAML Title')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "prioritizes the translations from GlobalizeStore backend (db) over others" do
|
44
|
+
i18n_title.value.should eq(I18n.translate(:title))
|
45
|
+
end
|
46
|
+
|
47
|
+
it "lists available_translations from the Simple backend (YAML files)" do
|
48
|
+
simple_backend = I18n.backend.backends.detect { |backend| backend.is_a?(I18n::Backend::Simple) }
|
49
|
+
simple_backend.available_translations[:en][:title].should eq('YAML Title')
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ExvoGlobalize do
|
4
|
+
|
5
|
+
I18n.load_path = ['spec/fixtures/locales/en.yml']
|
6
|
+
|
7
|
+
let(:i18n_example) { Factory(:i18n_example) }
|
8
|
+
|
9
|
+
context "locale fallbacks" do
|
10
|
+
|
11
|
+
before { I18n.locale = :pt }
|
12
|
+
|
13
|
+
it "has set a different locale than the default one" do
|
14
|
+
I18n.locale.should_not be_eql(I18n.default_locale)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "uses translation from the GlobalizeStore backend" do
|
18
|
+
i18n_example.value.should eql(I18n.translate(:example))
|
19
|
+
end
|
20
|
+
|
21
|
+
it "uses translation from the Simple backend if it is not found in the GlobalizeTranslation backend" do
|
22
|
+
simple_backend = I18n.backend.backends.detect { |backend| backend.is_a?(I18n::Backend::Simple) }
|
23
|
+
simple_backend.translate(I18n.default_locale, :name).should eql(I18n.translate(:name))
|
24
|
+
end
|
25
|
+
|
26
|
+
after { I18n.locale = I18n.default_locale }
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GlobalizeTranslation do
|
4
|
+
|
5
|
+
let(:i18n_title) { Factory(:i18n_title) }
|
6
|
+
let(:i18n_title_pl) { Factory(:i18n_title_pl) }
|
7
|
+
|
8
|
+
it "has a :title key" do
|
9
|
+
i18n_title.key.should eql('title')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns all translations for all locales" do
|
13
|
+
[i18n_title, i18n_title_pl].map(&:value).should =~ GlobalizeTranslation.lookup(:title).map(&:value)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns a translation for scoped locale" do
|
17
|
+
i18n_title.value.should eq(GlobalizeTranslation.locale('en').lookup(:title).first.value)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "lists available locales" do
|
21
|
+
[i18n_title, i18n_title_pl].map(&:locale).map(&:to_sym).should =~ GlobalizeTranslation.available_locales
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$:.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require 'exvo_globalize'
|
6
|
+
|
7
|
+
require File.join(File.dirname(__FILE__), 'app')
|
8
|
+
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'factory_girl_rails'
|
11
|
+
require 'shoulda-matchers'
|
12
|
+
|
13
|
+
# Requires supporting ruby files with custom matchers and macros, etc.
|
14
|
+
# in spec/support/ and its subdirectories.
|
15
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.mock_with :rspec
|
19
|
+
|
20
|
+
# run migrations
|
21
|
+
config.before :all do
|
22
|
+
CreateGlobalizeTranslations.up unless ActiveRecord::Base.connection.table_exists? 'globalize_translations'
|
23
|
+
end
|
24
|
+
|
25
|
+
# run each spec within a transactions
|
26
|
+
config.use_transactional_fixtures = true
|
27
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exvo_globalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Pawe\xC5\x82 Go\xC5\x9Bcicki"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-04 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,133 @@ dependencies:
|
|
50
50
|
version: 0.5.0
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: guard
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 11
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 5
|
65
|
+
- 0
|
66
|
+
version: 0.5.0
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 15
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 4
|
81
|
+
- 0
|
82
|
+
version: 0.4.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: sqlite3
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 9
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 3
|
97
|
+
version: "1.3"
|
98
|
+
type: :development
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: rspec
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 15
|
109
|
+
segments:
|
110
|
+
- 2
|
111
|
+
- 6
|
112
|
+
version: "2.6"
|
113
|
+
type: :development
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rspec-rails
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 15
|
124
|
+
segments:
|
125
|
+
- 2
|
126
|
+
- 6
|
127
|
+
version: "2.6"
|
128
|
+
type: :development
|
129
|
+
version_requirements: *id007
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: factory_girl_rails
|
132
|
+
prerelease: false
|
133
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 19
|
139
|
+
segments:
|
140
|
+
- 1
|
141
|
+
- 1
|
142
|
+
- 0
|
143
|
+
version: 1.1.0
|
144
|
+
type: :development
|
145
|
+
version_requirements: *id008
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: shoulda-matchers
|
148
|
+
prerelease: false
|
149
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 62196357
|
155
|
+
segments:
|
156
|
+
- 1
|
157
|
+
- 0
|
158
|
+
- 0
|
159
|
+
- beta
|
160
|
+
- 3
|
161
|
+
version: 1.0.0.beta3
|
162
|
+
type: :development
|
163
|
+
version_requirements: *id009
|
164
|
+
- !ruby/object:Gem::Dependency
|
165
|
+
name: json
|
166
|
+
prerelease: false
|
167
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
hash: 1
|
173
|
+
segments:
|
174
|
+
- 1
|
175
|
+
- 5
|
176
|
+
- 1
|
177
|
+
version: 1.5.1
|
178
|
+
type: :development
|
179
|
+
version_requirements: *id010
|
53
180
|
description: It exposes `/globalize/translations.json` with JSON of all translations in the app
|
54
181
|
email:
|
55
182
|
- pawel.goscicki@gmail.com
|
@@ -61,18 +188,33 @@ extra_rdoc_files: []
|
|
61
188
|
|
62
189
|
files:
|
63
190
|
- .gitignore
|
191
|
+
- .rspec
|
64
192
|
- Gemfile
|
65
193
|
- MIT-LICENSE
|
66
194
|
- README.md
|
67
195
|
- Rakefile
|
68
196
|
- app/controllers/globalize_translations_controller.rb
|
69
197
|
- app/models/globalize_translation.rb
|
198
|
+
- app/views/globalize_translations/index.html
|
70
199
|
- config/routes.rb
|
71
200
|
- exvo_globalize.gemspec
|
72
201
|
- lib/exvo_globalize.rb
|
202
|
+
- lib/exvo_globalize/backend/chain.rb
|
203
|
+
- lib/exvo_globalize/backend/globalize_store.rb
|
204
|
+
- lib/exvo_globalize/backend/simple.rb
|
73
205
|
- lib/exvo_globalize/engine.rb
|
74
|
-
- lib/exvo_globalize/globalize_store.rb
|
75
206
|
- lib/exvo_globalize/version.rb
|
207
|
+
- lib/generators/exvo_globalize/exvo_globalize_generator.rb
|
208
|
+
- lib/generators/exvo_globalize/templates/migration.rb
|
209
|
+
- spec/app.rb
|
210
|
+
- spec/controllers/globalize_translations_controller_spec.rb
|
211
|
+
- spec/factories.rb
|
212
|
+
- spec/fixtures/locales/en.yml
|
213
|
+
- spec/integration/caching_spec.rb
|
214
|
+
- spec/integration/exvo_globalize_spec.rb
|
215
|
+
- spec/integration/locale_fallback_spec.rb
|
216
|
+
- spec/models/globalize_translation_spec.rb
|
217
|
+
- spec/spec_helper.rb
|
76
218
|
has_rdoc: true
|
77
219
|
homepage: https://github.com/Exvo/exvo_globalize
|
78
220
|
licenses:
|