easy_globalize3_accessors 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b49ff457d87efa7ad5b7ea6969fb7b1b4f97f405
4
- data.tar.gz: eacab7e85cda683a24606a64d3d6c77e75e7f353
3
+ metadata.gz: 9c12194f0b3eb82788a0234c4f4e4575c135ef0e
4
+ data.tar.gz: d8b583385b70eb41942432565e17e57fda424ecc
5
5
  SHA512:
6
- metadata.gz: c3a54024a939bf01302cbd4fd54f7fb05b9803224ae2b2d97c39ddef0a2d6df515778cd2f64e43dd2e5097877f52fbf9b795a96c19e0fa96e287abeb41fde79d
7
- data.tar.gz: 04f0cbf82a79972fa220dc3a6264f905985bb1ce21bb10163d0ed5f9dc241a27360751c5103ce42f11d5447ea3bb67dab775ab90f1bc245d076a6800291e6dbf
6
+ metadata.gz: 65369848859553dd2ebad17994645549b1da596f777d904c5b4ccb70fd6245a596e8da79c201c929337b937627ddbdcbd906def8c55bfb6f77db7845c6498c1d
7
+ data.tar.gz: 43f0f6ab65ef0c464db46a4ae642423b5028cf3423a3dc6af726d76cfe51c54b67d10a371efb22a3e1e7005779ca8fab1a4c518eb5dce72403f861f8c733342e
@@ -1,54 +1 @@
1
- = EasyGlobalize3Accessors
2
-
3
- == Introduction
4
-
5
- Generator of easy accessor methods for models using Globalize3.
6
-
7
- Use globalize_accessors with list of translated fields you want easily access to and extra :locales array listing locales for which you want the accessors to be generated.
8
-
9
- This way a single form can be used to edit given model fields with all anticipated translations.
10
-
11
-
12
- == Installation
13
-
14
- gem install easy_globalize3_accessors
15
-
16
- == Example
17
-
18
- Definition like this:
19
-
20
- class Product
21
- translates :title, :description
22
- globalize_accessors :locales => [:en, :pl], :attributes => [:title]
23
- end
24
-
25
- Gives you access to methods: title_pl, title_en, title_pl=, title_en= (and similar set of description_* methods). And they work seamlessly with Globalize3 (not even touching the "core" title, title= methods used by Globalize3 itself).
26
-
27
- :locales and :attributes are optional. Default values are:
28
- :locales => I18n.available_locales
29
- :attributes => translated_attribute_names
30
-
31
- which means that skipping all options will generate you accessor method for all translated fields and available languages.
32
-
33
- You can also get locales for class with "globalize_locales" method:
34
- Product.globalize_locales # => [:en, :pl]
35
-
36
- == Always define accessors
37
-
38
- If you wish to always define accessors and don't want to call globalize_accessors method in every class, you can extend ActiveRecord::Base with such module:
39
-
40
- module TranslatesWithAccessors
41
-
42
- def translates(*params)
43
- options = params.extract_options!
44
- options.reverse_merge!(:globalize_accessors => true)
45
- accessors = options.delete(:globalize_accessors)
46
- super
47
- globalize_accessors if accessors
48
- end
49
-
50
- end
51
-
52
- == Licence
53
-
54
- Copyright (c) 2009-2010 Tomek "Tomash" Stachewicz (http://tomash.wrug.eu), Robert Pankowecki (http://robert.pankowecki.pl) released under the MIT license
1
+ Development moved to https://github.com//globalize/globalize-accessors
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
24
24
  s.files = `git ls-files`.split("\n")
25
25
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
26
  s.require_path = 'lib'
27
+ s.post_install_message = "Development of easy_globalize3_accessors moved to https://github.com/globalize/globalize-accessors . Please upgrade."
27
28
  end
@@ -23,17 +23,17 @@ module EasyGlobalize3Accessors
23
23
 
24
24
 
25
25
  def define_getter(attr_name, locale)
26
- define_method :"#{attr_name}_#{locale}" do
26
+ define_method :"#{attr_name}_#{locale.to_s.underscore}" do
27
27
  read_attribute(attr_name, :locale => locale)
28
28
  end
29
29
  end
30
30
 
31
31
  def define_setter(attr_name, locale)
32
- define_method :"#{attr_name}_#{locale}=" do |value|
32
+ define_method :"#{attr_name}_#{locale.to_s.underscore}=" do |value|
33
33
  write_attribute(attr_name, value, :locale => locale)
34
34
  end
35
35
  if respond_to?(:accessible_attributes) && accessible_attributes.include?(attr_name)
36
- attr_accessible :"#{attr_name}_#{locale}"
36
+ attr_accessible :"#{attr_name}_#{locale.to_s.underscore}"
37
37
  end
38
38
  end
39
39
 
@@ -1,3 +1,3 @@
1
1
  module EasyGlobalize3Accessors
2
- VERSION = '1.3.2'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -20,6 +20,12 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
20
20
  globalize_accessors
21
21
  end
22
22
 
23
+ class UnitWithDashedLocales < ActiveRecord::Base
24
+ self.table_name = :units
25
+ translates :name
26
+ globalize_accessors :locales => [:"pt-BR", :"en-AU"], :attributes => [:name]
27
+ end
28
+
23
29
  setup do
24
30
  assert_equal :en, I18n.locale
25
31
  end
@@ -107,4 +113,22 @@ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
107
113
  test "globalize locales on class with locales specified in options" do
108
114
  assert_equal [:pl], UnitTranslatedWithOptions.globalize_locales
109
115
  end
116
+
117
+ test "read and write on class with dashed locales" do
118
+ u = UnitWithDashedLocales.new()
119
+
120
+ assert u.respond_to?(:name_pt_br)
121
+ assert u.respond_to?(:name_pt_br=)
122
+
123
+ assert u.respond_to?(:name_en_au)
124
+ assert u.respond_to?(:name_en_au=)
125
+
126
+ u.name = "Name en"
127
+ u.name_pt_br = "Name pt-BR"
128
+ u.name_en_au = "Name en-AU"
129
+
130
+ assert_equal "Name en", u.name
131
+ assert_equal "Name pt-BR", u.name_pt_br
132
+ assert_equal "Name en-AU", u.name_en_au
133
+ end
110
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_globalize3_accessors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Stachewicz
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-21 00:00:00.000000000 Z
14
+ date: 2013-12-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: globalize3
@@ -94,7 +94,8 @@ files:
94
94
  homepage: http://rubygems.org/gems/easy_globalize3_accessors
95
95
  licenses: []
96
96
  metadata: {}
97
- post_install_message:
97
+ post_install_message: Development of easy_globalize3_accessors moved to https://github.com/globalize/globalize-accessors
98
+ . Please upgrade.
98
99
  rdoc_options: []
99
100
  require_paths:
100
101
  - lib
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  version: 1.3.6
111
112
  requirements: []
112
113
  rubyforge_project: easy_globalize3_accessors
113
- rubygems_version: 2.0.5
114
+ rubygems_version: 2.1.11
114
115
  signing_key:
115
116
  specification_version: 4
116
117
  summary: Define methods for accessing translated attributes