Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
add rails 4.0 testing support and overall cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry committed Jul 31, 2013
1 parent be7fbe1 commit d6f8376
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
pkg/*
.idea
test.log
test/has_translations_plugin.sqlite3.db
test/debug.log

1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
rvm:
- 1.8.7
- 1.9.2
- ree
- 1.9.3
env:
- "RAILS_VERSION=3.0.0"
- "RAILS_VERSION=3.1.0"
- "RAILS_VERSION=3.2.0"
- 2.0.0

before_install:
- "gem install bundler -v=1.3.0"
before_script:
- "bundle install"

script: "bundle exec rake test"

gemfile:
- gemfiles/Gemfile.rails-3.0
- gemfiles/Gemfile.rails-3.1
- gemfiles/Gemfile.rails-3.2
- gemfiles/3.1.gemfile
- gemfiles/3.2.gemfile
- gemfiles/4.0.gemfile

matrix:
exclude:
- rvm: ree
gemfile: gemfiles/4.0.gemfile
11 changes: 11 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
appraise '3.1' do
gem 'rails', '~> 3.1.6'
end

appraise '3.2' do
gem 'rails', '~> 3.2.6'
end

appraise '4.0' do
gem 'rails', '4.0.0'
end
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
source 'https://rubygems.org'

gemspec

gem 'rake'
gem 'rdoc'
gem 'sqlite3'
56 changes: 32 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
PATH
remote: .
specs:
has_translations (1.0.0.alpha.1)
activerecord (>= 3.2)
activesupport (>= 3.2)
has_translations (1.0.0)
activerecord (>= 3.1.0)
activesupport (>= 3.1.0)

GEM
remote: https://rubygems.org/
specs:
activemodel (3.2.12)
activesupport (= 3.2.12)
builder (~> 3.0.0)
activerecord (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
i18n (0.6.2)
json (1.7.7)
multi_json (1.6.1)
rake (10.0.3)
rdoc (4.0.0)
json (~> 1.4)
activemodel (4.0.0)
activesupport (= 4.0.0)
builder (~> 3.1.0)
activerecord (4.0.0)
activemodel (= 4.0.0)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.0)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
arel (4.0.0)
atomic (1.1.10)
builder (3.1.4)
i18n (0.6.4)
minitest (4.7.5)
multi_json (1.7.7)
rake (10.1.0)
sqlite3 (1.3.7)
tzinfo (0.3.35)
thread_safe (0.1.2)
atomic
tzinfo (0.3.37)

PLATFORMS
ruby

DEPENDENCIES
appraisal
has_translations!
rake
rdoc
sqlite3
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
HasTranslations v1.0.0.alpha.1
==============================

[![Build Status](https://secure.travis-ci.org/dmitry/has_translations.png?branch=master)](http://travis-ci.org/dmitry/has_translations) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/dmitry/has_translations/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

This simple plugin creates translations for your model.
Uses delegation pattern: http://en.wikipedia.org/wiki/Delegation_pattern

Tested with ActiveRecord versions: 3.0.0, 3.1.0, 3.2.0 (to test with Rails 3.1 run `rake RAILS_VERSION=3.1`)
And tested with ruby 1.8.7, 1.9.2, 1.9.3
Tested with ActiveRecord versions: 3.1.x, 3.2.x, 4.0.x
And tested with ruby 1.8.7 (ree), 1.9.3, 2.0.0

Compatibility
=============

This version only support Rails 3.x.x. For Rails 2.3.x support please get the 0.3.5 version of this gem.
This version only support Rails 4.0.x and 3.x.x. For Rails 2.3.x support please get the 0.3.5 version of this gem.
Plugin support is deprecated in Rails and will be removed soon so this version drop plugin support.
To prevent method shadowing between "translations" class method and "translations" relation in models the class
method has been renamed has_translations.
Expand Down
25 changes: 13 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
require 'rake'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rdoc/task'
require 'appraisal'

require 'bundler'
Bundler::GemHelper.install_tasks
Rake::TestTask.new do |t|
t.libs = %w(lib test)
t.test_files = Dir.glob('test/**/*_test.rb').sort
t.verbose = true
end

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the has_translations plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Setup Appraisal.'
task 'appraisal:setup' do
Rake::Task['appraisal:cleanup'].invoke
Rake::Task['appraisal:gemfiles'].invoke
Rake::Task['appraisal:install'].invoke
end
7 changes: 7 additions & 0 deletions gemfiles/3.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 3.1.6"

gemspec :path=>"../"
7 changes: 7 additions & 0 deletions gemfiles/3.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 3.2.6"

gemspec :path=>"../"
7 changes: 7 additions & 0 deletions gemfiles/4.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "4.0.0"

gemspec :path=>"../"
1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-3.0

This file was deleted.

1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-3.1

This file was deleted.

1 change: 0 additions & 1 deletion gemfiles/Gemfile.rails-3.2

This file was deleted.

21 changes: 12 additions & 9 deletions has_translations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ $:.push File.expand_path("../lib", __FILE__)
require "has_translations/version"

Gem::Specification.new do |s|
s.name = "has_translations"
s.name = 'has_translations'
s.version = HasTranslations::VERSION
s.authors = ["Dmitry Polushkin"]
s.email = ["[email protected]"]
s.homepage = "http://github.com/dmitry/has_translations"
s.authors = ['Dmitry Polushkin']
s.email = %w([email protected])
s.homepage = 'http://github.com/dmitry/has_translations'
s.summary = %q{Create translations for your ActiveRecord models.}
s.description = %q{Create translations for your ActiveRecord models. Uses delegate pattern. Fully tested and used in a several production sites.}

s.rubyforge_project = "has_translations"
s.rubyforge_project = 'has_translations'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.require_paths = %w(lib)

s.license = 'MIT'
s.add_dependency 'activesupport', ">= #{ENV['RAILS_VERSION'] || '3.2'}"
s.add_dependency 'activerecord', ">= #{ENV['RAILS_VERSION'] || '3.2'}"
#s.add_development_dependency "ruby-debug"

s.add_dependency 'activesupport', '>= 3.1.0'
s.add_dependency 'activerecord', '>= 3.1.0'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'rake'
end
1 change: 0 additions & 1 deletion install.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/has_translations/model_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def find_or_create_translation(locale)
locale = locale.to_s
(find_translation(locale) || self.has_translations_options[:translation_class].new).tap do |t|
t.locale = locale
t.send(:"#{self.class.model_name.demodulize.underscore.to_sym}_id=", self.id)
t.send(:"#{self.class.model_name.to_s.demodulize.underscore.to_sym}_id=", self.id)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/has_translations/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module HasTranslations
VERSION = "1.0.0.alpha.1"
VERSION = '1.0.0'
end
4 changes: 0 additions & 4 deletions tasks/has_translations_tasks.rake

This file was deleted.

2 changes: 0 additions & 2 deletions test/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion test/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
end

class ArticleTranslation < ActiveRecord::Base
attr_accessible :description, :text
#attr_accessible :description, :text
end
class Article < ActiveRecord::Base
include HasTranslations::ModelAdditions
Expand Down
11 changes: 3 additions & 8 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
require 'rubygems'
require 'test/unit'

rails_version = "~> #{ENV['RAILS_VERSION'] || '3.2'}"

gem 'activerecord', rails_version
gem 'activesupport', rails_version

require 'active_record'
require 'logger'

Expand All @@ -14,18 +9,18 @@
begin
I18n.available_locales = :ru, :en, :es
rescue
p "[WARNING]: This test should have the I18n.available_locales= method, which were included in versions ~> 0.3.0"
p '[WARNING]: This test should have the I18n.available_locales= method, which were included in versions ~> 0.3.0'
end

puts "Using Rails version: #{ActiveRecord::VERSION::STRING}"

ActiveRecord::Base.logger = Logger.new('test.log')
#ActiveRecord::Base.logger = nil
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')

def setup_db
ActiveRecord::Migration.verbose = false
load "schema.rb"
load 'schema.rb'
end

def teardown_db
Expand Down
1 change: 0 additions & 1 deletion uninstall.rb

This file was deleted.

0 comments on commit d6f8376

Please sign in to comment.