activerecord_globalize 1.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.
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.2.4
5
+ - 2.1.8
6
+ - 2.0.0
7
+ addons:
8
+ code_climate:
9
+ repo_token: $CODECLIMATE_REPO_TOKEN
10
+ before_install:
11
+ - gem install bundler -v '~> 1.11'
12
+ gemfile:
13
+ - gemfiles/40.gemfile
14
+ - gemfiles/41.gemfile
15
+ - gemfiles/42.gemfile
16
+ - gemfiles/50.gemfile
17
+ matrix:
18
+ exclude:
19
+ - rvm: 2.0.0
20
+ gemfile: gemfiles/50.gemfile
21
+ - rvm: 2.1.8
22
+ gemfile: gemfiles/50.gemfile
23
+ after_success:
24
+ - bundle exec codeclimate-test-reporter
25
+ cache:
26
+ - bundler
@@ -0,0 +1,15 @@
1
+ appraise '40' do
2
+ gem 'rails', '~> 4.0.0'
3
+ end
4
+
5
+ appraise '41' do
6
+ gem 'rails', '~> 4.1.0'
7
+ end
8
+
9
+ appraise '42' do
10
+ gem 'rails', '~> 4.2.0'
11
+ end
12
+
13
+ appraise '50' do
14
+ gem 'rails', '5.0'
15
+ end
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activerecord_globalize.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 mohamedelfiky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # ActiveRecord Globalize [![Build Status](https://travis-ci.org/mohamedelfiky/activerecord_globalize.svg?branch=master)](https://travis-ci.org/mohamedelfiky/activerecord_globalize) [![Code Climate](https://codeclimate.com/github/mohamedelfiky/activerecord_globalize/badges/gpa.svg)](https://codeclimate.com/github/mohamedelfiky/activerecord_globalize) [![Test Coverage](https://codeclimate.com/github/mohamedelfiky/activerecord_globalize/badges/coverage.svg)](https://codeclimate.com/github/mohamedelfiky/activerecord_globalize/coverage) [![Inline docs](http://inch-ci.org/github/mohamedelfiky/activerecord_globalize.svg?branch=master)](http://inch-ci.org/github/mohamedelfiky/activerecord_globalize)
2
+
3
+ Rails I18n library for ActiveRecord model/data translation using PostgreSQL's hstore datatype. It provides an interface inspired by hstore_translate but without the need for data migrations (zero down time solution for large set of data).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'activerecord_globalize'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install activerecord_globalize
20
+
21
+ ## Usage
22
+
23
+ You'll need to define an hstore column for each of your translated attributes, using the suffix "_translations":
24
+
25
+ ```ruby
26
+ class CreatePosts < ActiveRecord::Migration
27
+ def up
28
+ create_table :posts do |t|
29
+ t.column :title_translations, 'hstore'
30
+ t.column :body_translations, 'hstore'
31
+ t.timestamps
32
+ end
33
+ end
34
+ def down
35
+ drop_table :posts
36
+ end
37
+ end
38
+ ```
39
+
40
+ Model translations allow you to translate your models' attribute values.
41
+
42
+ ```ruby
43
+ class Post < ActiveRecord::Base
44
+ translates :title, :body
45
+ end
46
+ ```
47
+
48
+ Allows you to translate the attributes :title and :body per locale:
49
+
50
+ ```ruby
51
+ I18n.locale = :en
52
+ post.title # => This database rocks!
53
+
54
+ I18n.locale = :he
55
+ post.title # => אתר זה טוב
56
+ ```
57
+
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
62
+
63
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/mohamedelfiky/activerecord_globalize/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task test: :spec
7
+ task default: :spec
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'activerecord_globalize/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'activerecord_globalize'
8
+ spec.version = ActiverecordGlobalize::VERSION
9
+ spec.authors = ['mohamedelfiky']
10
+ spec.email = ['mohamed.elfikyy@gmail.com']
11
+
12
+ spec.summary = "Adds model translations allow you to translate your models' attributes"
13
+ spec.homepage = 'https://github.com/mohamedelfiky/activerecord_globalize'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.8'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'byebug'
25
+ spec.add_development_dependency 'simplecov'
26
+ spec.add_development_dependency 'codeclimate-test-reporter'
27
+ spec.add_development_dependency 'pg'
28
+ spec.add_development_dependency 'database_cleaner'
29
+ spec.add_development_dependency 'appraisal'
30
+
31
+ spec.add_dependency 'activerecord', '>= 4.0.0'
32
+ spec.add_dependency 'railties', '>= 4.0.0'
33
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activerecord_globalize"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ activerecord_globalize (0.1.0)
5
+ activerecord (>= 4.0.0)
6
+ railties (>= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.0.13)
12
+ actionpack (= 4.0.13)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.0.13)
15
+ activesupport (= 4.0.13)
16
+ builder (~> 3.1.0)
17
+ erubis (~> 2.7.0)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ activemodel (4.0.13)
21
+ activesupport (= 4.0.13)
22
+ builder (~> 3.1.0)
23
+ activerecord (4.0.13)
24
+ activemodel (= 4.0.13)
25
+ activerecord-deprecated_finders (~> 1.0.2)
26
+ activesupport (= 4.0.13)
27
+ arel (~> 4.0.0)
28
+ activerecord-deprecated_finders (1.0.4)
29
+ activesupport (4.0.13)
30
+ i18n (~> 0.6, >= 0.6.9)
31
+ minitest (~> 4.2)
32
+ multi_json (~> 1.3)
33
+ thread_safe (~> 0.1)
34
+ tzinfo (~> 0.3.37)
35
+ appraisal (2.1.0)
36
+ bundler
37
+ rake
38
+ thor (>= 0.14.0)
39
+ arel (4.0.2)
40
+ builder (3.1.4)
41
+ byebug (9.0.6)
42
+ codeclimate-test-reporter (1.0.3)
43
+ simplecov
44
+ concurrent-ruby (1.0.2)
45
+ database_cleaner (1.5.3)
46
+ diff-lcs (1.2.5)
47
+ docile (1.1.5)
48
+ erubis (2.7.0)
49
+ i18n (0.7.0)
50
+ json (1.8.3)
51
+ mail (2.6.4)
52
+ mime-types (>= 1.16, < 4)
53
+ mime-types (3.1)
54
+ mime-types-data (~> 3.2015)
55
+ mime-types-data (3.2016.0521)
56
+ minitest (4.7.5)
57
+ multi_json (1.12.1)
58
+ pg (0.18.4)
59
+ rack (1.5.5)
60
+ rack-test (0.6.3)
61
+ rack (>= 1.0)
62
+ rails (4.0.13)
63
+ actionmailer (= 4.0.13)
64
+ actionpack (= 4.0.13)
65
+ activerecord (= 4.0.13)
66
+ activesupport (= 4.0.13)
67
+ bundler (>= 1.3.0, < 2.0)
68
+ railties (= 4.0.13)
69
+ sprockets-rails (~> 2.0)
70
+ railties (4.0.13)
71
+ actionpack (= 4.0.13)
72
+ activesupport (= 4.0.13)
73
+ rake (>= 0.8.7)
74
+ thor (>= 0.18.1, < 2.0)
75
+ rake (10.5.0)
76
+ rspec (3.5.0)
77
+ rspec-core (~> 3.5.0)
78
+ rspec-expectations (~> 3.5.0)
79
+ rspec-mocks (~> 3.5.0)
80
+ rspec-core (3.5.4)
81
+ rspec-support (~> 3.5.0)
82
+ rspec-expectations (3.5.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.5.0)
85
+ rspec-mocks (3.5.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.5.0)
88
+ rspec-support (3.5.0)
89
+ simplecov (0.12.0)
90
+ docile (~> 1.1.0)
91
+ json (>= 1.8, < 3)
92
+ simplecov-html (~> 0.10.0)
93
+ simplecov-html (0.10.0)
94
+ sprockets (3.7.0)
95
+ concurrent-ruby (~> 1.0)
96
+ rack (> 1, < 3)
97
+ sprockets-rails (2.3.3)
98
+ actionpack (>= 3.0)
99
+ activesupport (>= 3.0)
100
+ sprockets (>= 2.8, < 4.0)
101
+ thor (0.19.1)
102
+ thread_safe (0.3.5)
103
+ tzinfo (0.3.52)
104
+
105
+ PLATFORMS
106
+ ruby
107
+
108
+ DEPENDENCIES
109
+ activerecord_globalize!
110
+ appraisal
111
+ bundler (~> 1.8)
112
+ byebug
113
+ codeclimate-test-reporter
114
+ database_cleaner
115
+ pg
116
+ rails (~> 4.0.0)
117
+ rake (~> 10.0)
118
+ rspec
119
+ simplecov
120
+
121
+ BUNDLED WITH
122
+ 1.12.5
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.1.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,129 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ activerecord_globalize (0.1.0)
5
+ activerecord (>= 4.0.0)
6
+ railties (>= 4.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.1)
12
+ actionpack (= 4.1.1)
13
+ actionview (= 4.1.1)
14
+ mail (~> 2.5.4)
15
+ actionpack (4.1.1)
16
+ actionview (= 4.1.1)
17
+ activesupport (= 4.1.1)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.1)
21
+ activesupport (= 4.1.1)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activemodel (4.1.1)
25
+ activesupport (= 4.1.1)
26
+ builder (~> 3.1)
27
+ activerecord (4.1.1)
28
+ activemodel (= 4.1.1)
29
+ activesupport (= 4.1.1)
30
+ arel (~> 5.0.0)
31
+ activesupport (4.1.1)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 1.1)
37
+ appraisal (2.1.0)
38
+ bundler
39
+ rake
40
+ thor (>= 0.14.0)
41
+ arel (5.0.1.20140414130214)
42
+ builder (3.2.2)
43
+ byebug (9.0.6)
44
+ codeclimate-test-reporter (1.0.3)
45
+ simplecov
46
+ concurrent-ruby (1.0.2)
47
+ database_cleaner (1.5.3)
48
+ diff-lcs (1.2.5)
49
+ docile (1.1.5)
50
+ erubis (2.7.0)
51
+ i18n (0.7.0)
52
+ json (1.8.3)
53
+ mail (2.5.4)
54
+ mime-types (~> 1.16)
55
+ treetop (~> 1.4.8)
56
+ mime-types (1.25.1)
57
+ minitest (5.9.0)
58
+ pg (0.18.4)
59
+ polyglot (0.3.4)
60
+ rack (1.5.5)
61
+ rack-test (0.6.3)
62
+ rack (>= 1.0)
63
+ rails (4.1.1)
64
+ actionmailer (= 4.1.1)
65
+ actionpack (= 4.1.1)
66
+ actionview (= 4.1.1)
67
+ activemodel (= 4.1.1)
68
+ activerecord (= 4.1.1)
69
+ activesupport (= 4.1.1)
70
+ bundler (>= 1.3.0, < 2.0)
71
+ railties (= 4.1.1)
72
+ sprockets-rails (~> 2.0)
73
+ railties (4.1.1)
74
+ actionpack (= 4.1.1)
75
+ activesupport (= 4.1.1)
76
+ rake (>= 0.8.7)
77
+ thor (>= 0.18.1, < 2.0)
78
+ rake (10.5.0)
79
+ rspec (3.5.0)
80
+ rspec-core (~> 3.5.0)
81
+ rspec-expectations (~> 3.5.0)
82
+ rspec-mocks (~> 3.5.0)
83
+ rspec-core (3.5.4)
84
+ rspec-support (~> 3.5.0)
85
+ rspec-expectations (3.5.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.5.0)
88
+ rspec-mocks (3.5.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.5.0)
91
+ rspec-support (3.5.0)
92
+ simplecov (0.12.0)
93
+ docile (~> 1.1.0)
94
+ json (>= 1.8, < 3)
95
+ simplecov-html (~> 0.10.0)
96
+ simplecov-html (0.10.0)
97
+ sprockets (3.7.0)
98
+ concurrent-ruby (~> 1.0)
99
+ rack (> 1, < 3)
100
+ sprockets-rails (2.3.3)
101
+ actionpack (>= 3.0)
102
+ activesupport (>= 3.0)
103
+ sprockets (>= 2.8, < 4.0)
104
+ thor (0.19.1)
105
+ thread_safe (0.3.5)
106
+ treetop (1.4.15)
107
+ polyglot
108
+ polyglot (>= 0.3.1)
109
+ tzinfo (1.2.2)
110
+ thread_safe (~> 0.1)
111
+
112
+ PLATFORMS
113
+ ruby
114
+
115
+ DEPENDENCIES
116
+ activerecord_globalize!
117
+ appraisal
118
+ bundler (~> 1.8)
119
+ byebug
120
+ codeclimate-test-reporter
121
+ database_cleaner
122
+ pg
123
+ rails (~> 4.1.0)
124
+ rake (~> 10.0)
125
+ rspec
126
+ simplecov
127
+
128
+ BUNDLED WITH
129
+ 1.12.5