easy_globalize3_accessors 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,4 +4,5 @@ pkg/*
4
4
  nbproject
5
5
  *.sqlite3
6
6
  test/debug.log
7
- test/db/database.yml
7
+ test/db/database.yml
8
+ Gemfile.lock
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source :gemcutter
2
2
 
3
3
  # Specify your gem's dependencies in global_boolean.gemspec
4
4
  gemspec
5
+
6
+ #gem 'globalize3', :git => 'git://github.com/galetahub/globalize3.git'
7
+ #gem 'globalize3', :git => 'git://github.com/svenfuchs/globalize3.git'
8
+ #gem 'globalize3', :git => 'git://github.com/galetahub/globalize3.git', :ref => '291ae54e0187'
9
+
10
+ #gem 'globalize3', '~> 0.2.0.beta1'
data/Rakefile CHANGED
@@ -1,11 +1,14 @@
1
- require 'bundler'
2
- #Bundler.require
3
- #require 'rake'
4
- Bundler::GemHelper.install_tasks
1
+ #!/usr/bin/env rake
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
5
7
 
6
- require 'rake'
8
+ Bundler::GemHelper.install_tasks
9
+ require 'rdoc/task'
7
10
  require 'rake/testtask'
8
- require 'rake/rdoctask'
11
+ require 'rake'
9
12
 
10
13
  desc 'Default: run unit tests.'
11
14
  task :default => :test
@@ -25,4 +28,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
25
28
  rdoc.options << '--line-numbers' << '--inline-source'
26
29
  rdoc.rdoc_files.include('README')
27
30
  rdoc.rdoc_files.include('lib/**/*.rb')
28
- end
31
+ end
@@ -14,9 +14,12 @@ Gem::Specification.new do |s|
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "easy_globalize3_accessors"
16
16
 
17
- s.add_dependency "globalize3", "~> 0.1.0.beta"
17
+ s.add_dependency "globalize3", "~> 0.2.0.beta1"
18
+
19
+ s.add_development_dependency "bundler", "~> 1.0.15"
20
+ s.add_development_dependency "rake", "~> 0.9.2"
21
+ s.add_development_dependency "sqlite3"
18
22
 
19
- s.add_development_dependency "bundler", "~> 1.0.7"
20
23
 
21
24
  s.files = `git ls-files`.split("\n")
22
25
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
@@ -1,13 +1,9 @@
1
- require 'active_record'
2
1
  require 'globalize3'
3
2
 
4
3
  module EasyGlobalize3Accessors
5
4
 
6
5
  def globalize_accessors(options = {})
7
- # Temporary workaround for bug: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5522-model-classes-are-loaded-before-i18n-is-set-when-running-tests
8
- default_locales = defined?(Rails) ? Rails.configuration.i18n.available_locales : I18n.available_locales
9
-
10
- options.reverse_merge!(:locales => default_locales, :attributes => translated_attribute_names)
6
+ options.reverse_merge!(:locales => I18n.available_locales, :attributes => translated_attribute_names)
11
7
 
12
8
  each_attribute_and_locale(options) do |attr_name, locale|
13
9
  define_accessors(attr_name, locale)
@@ -46,4 +42,4 @@ module EasyGlobalize3Accessors
46
42
 
47
43
  end
48
44
 
49
- ActiveRecord::Base.extend EasyGlobalize3Accessors
45
+ ActiveRecord::Base.extend EasyGlobalize3Accessors
@@ -1,3 +1,3 @@
1
1
  module EasyGlobalize3Accessors
2
- VERSION = '1.1.3'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -7,6 +7,12 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
7
7
  globalize_accessors
8
8
  end
9
9
 
10
+ class UnitTranslatedWithOptions < ActiveRecord::Base
11
+ set_table_name :units
12
+ translates :name
13
+ globalize_accessors :locales => [:pl], :attributes => [:name]
14
+ end
15
+
10
16
  setup do
11
17
  assert_equal :en, I18n.locale
12
18
  end
@@ -60,5 +66,21 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
60
66
 
61
67
  assert_nil u.title_en
62
68
  end
69
+
70
+ test "read and write on class with options" do
71
+ u = UnitTranslatedWithOptions.new()
72
+
73
+ assert u.respond_to?(:name_pl)
74
+ assert u.respond_to?(:name_pl=)
75
+
76
+ assert ! u.respond_to?(:name_en)
77
+ assert ! u.respond_to?(:name_en=)
78
+
79
+ u.name = "Name en"
80
+ u.name_pl = "Name pl"
81
+
82
+ assert_equal "Name en", u.name
83
+ assert_equal "Name pl", u.name_pl
84
+ end
63
85
 
64
86
  end
data/test/test_helper.rb CHANGED
@@ -1,9 +1,12 @@
1
+ require 'i18n'
2
+ I18n.available_locales = [:en, :pl]
3
+
1
4
  require 'test/unit'
2
5
  require 'active_support'
3
6
  require 'active_support/test_case'
4
- require 'active_record'
5
7
  require 'logger'
6
8
 
9
+ require 'easy_globalize3_accessors' # => globalize3 => active_record
7
10
 
8
11
  plugin_test_dir = File.dirname(__FILE__)
9
12
 
@@ -12,6 +15,3 @@ ActiveRecord::Base.configurations = YAML::load( IO.read( File.join(plugin_test_
12
15
  ActiveRecord::Base.establish_connection("sqlite3mem")
13
16
  ActiveRecord::Migration.verbose = false
14
17
  load(File.join(plugin_test_dir, "db", "schema.rb"))
15
-
16
- require 'easy_globalize3_accessors'
17
- I18n.available_locales = [:en, :pl]
metadata CHANGED
@@ -1,14 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: easy_globalize3_accessors
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 1
8
- - 3
9
- version: 1.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Tomasz Stachewicz
13
9
  - Wojciech Pietrzak
14
10
  - Steve Verlinden
@@ -16,54 +12,63 @@ authors:
16
12
  autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
-
20
- date: 2011-02-28 00:00:00 +01:00
15
+ date: 2011-10-09 00:00:00.000000000 +02:00
21
16
  default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
24
19
  name: globalize3
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
20
+ requirement: &72475720 !ruby/object:Gem::Requirement
27
21
  none: false
28
- requirements:
22
+ requirements:
29
23
  - - ~>
30
- - !ruby/object:Gem::Version
31
- segments:
32
- - 0
33
- - 1
34
- - 0
35
- - beta
36
- version: 0.1.0.beta
24
+ - !ruby/object:Gem::Version
25
+ version: 0.2.0.beta1
37
26
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
27
+ prerelease: false
28
+ version_requirements: *72475720
29
+ - !ruby/object:Gem::Dependency
40
30
  name: bundler
31
+ requirement: &72475120 !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ~>
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.15
37
+ type: :development
41
38
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ version_requirements: *72475120
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ requirement: &72474410 !ruby/object:Gem::Requirement
43
43
  none: false
44
- requirements:
44
+ requirements:
45
45
  - - ~>
46
- - !ruby/object:Gem::Version
47
- segments:
48
- - 1
49
- - 0
50
- - 7
51
- version: 1.0.7
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.2
52
48
  type: :development
53
- version_requirements: *id002
49
+ prerelease: false
50
+ version_requirements: *72474410
51
+ - !ruby/object:Gem::Dependency
52
+ name: sqlite3
53
+ requirement: &72474090 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ type: :development
60
+ prerelease: false
61
+ version_requirements: *72474090
54
62
  description: Define methods for accessing translated attributes
55
- email:
63
+ email:
56
64
  - tomekrs@o2.pl
57
65
  - steve.verlinden@gmail.com
58
66
  - robert.pankowecki@gmail.com
59
67
  - rpa@gavdi.com
60
68
  executables: []
61
-
62
69
  extensions: []
63
-
64
70
  extra_rdoc_files: []
65
-
66
- files:
71
+ files:
67
72
  - .gitignore
68
73
  - Gemfile
69
74
  - MIT-LICENSE
@@ -79,36 +84,29 @@ files:
79
84
  has_rdoc: true
80
85
  homepage: http://rubygems.org/gems/easy_globalize3_accessors
81
86
  licenses: []
82
-
83
87
  post_install_message:
84
88
  rdoc_options: []
85
-
86
- require_paths:
89
+ require_paths:
87
90
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
91
+ required_ruby_version: !ruby/object:Gem::Requirement
89
92
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- segments:
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ segments:
94
98
  - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ hash: -939160079
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
101
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- segments:
102
- - 1
103
- - 3
104
- - 6
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
105
  version: 1.3.6
106
106
  requirements: []
107
-
108
107
  rubyforge_project: easy_globalize3_accessors
109
- rubygems_version: 1.3.7
108
+ rubygems_version: 1.6.2
110
109
  signing_key:
111
110
  specification_version: 3
112
111
  summary: Define methods for accessing translated attributes
113
112
  test_files: []
114
-