globalize2_sugar 0.1.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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +33 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/active_record/globalize_accessors.rb +27 -0
- data/my_easy_globalize2_accessors.gemspec +51 -0
- data/pkg/my_easy_globalize2_accessors-0.0.0.gem +0 -0
- data/pkg/my_easy_globalize2_accessors-0.1.0.gem +0 -0
- data/test/easy_globalize_accessors_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= EasyGlobalizeAccessors
|
2
|
+
|
3
|
+
== Introduction
|
4
|
+
|
5
|
+
Generator of easy accessor methods for models using Globalize2.
|
6
|
+
|
7
|
+
Use globalize_accessors with list of translated fields you want easy 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
|
+
script/plugin install git://github.com/astropanic/easy_globalize2_accessors.git
|
15
|
+
|
16
|
+
== Example
|
17
|
+
|
18
|
+
Definition like this:
|
19
|
+
|
20
|
+
class Product
|
21
|
+
translates :title, :description
|
22
|
+
globalize_accessors :pl, :en, :de
|
23
|
+
end
|
24
|
+
|
25
|
+
Gives you access to methods: title_pl, title_en, title_de, title_pl=, title_en=, title_de= (and similar set of description_* methods). And they work seamlessly with Globalize2 (not even touching the "core" title, title= methods used by Globalize2 itself).
|
26
|
+
|
27
|
+
== TODO
|
28
|
+
|
29
|
+
* Make it work with full-blown locales including dash character (minus sign) like en-US, en-GB, pl-PL etc.
|
30
|
+
|
31
|
+
== blah blah
|
32
|
+
|
33
|
+
Copyright (c) 2009 Tomek "Tomash" Stachewicz (http://tomash.wrug.eu), released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Generate documentation for the easy_globalize_accessors plugin.'
|
9
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'EasyGlobalizeAccessors'
|
12
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
13
|
+
rdoc.rdoc_files.include('README')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'jeweler'
|
19
|
+
Jeweler::Tasks.new do |gemspec|
|
20
|
+
gemspec.name = "globalize2_sugar"
|
21
|
+
gemspec.summary = "Provide helper methods for globalize2 model translations"
|
22
|
+
gemspec.description = "Updated from the original"
|
23
|
+
gemspec.email = "dcarper@thorleyindustries.com"
|
24
|
+
gemspec.homepage = "http://github.com/DCarper/easy_globalize2_accessors"
|
25
|
+
gemspec.authors = ["Dan Carper"]
|
26
|
+
end
|
27
|
+
Jeweler::GemcutterTasks.new
|
28
|
+
rescue LoadError
|
29
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
30
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Base.send :include, ActiveRecord::GlobalizeAccessors
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module GlobalizeAccessors
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ActMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ActMethods
|
8
|
+
def globalize_accessors(*attr_names)
|
9
|
+
languages = attr_names
|
10
|
+
attribs = translated_attribute_names
|
11
|
+
attribs.each do |attr_name|
|
12
|
+
languages.each do |with_locale|
|
13
|
+
safe_locale = with_locale.to_s.gsub("-", "_")
|
14
|
+
define_method :"#{attr_name}_#{safe_locale}" do
|
15
|
+
globalize.fetch with_locale, attr_name
|
16
|
+
end
|
17
|
+
|
18
|
+
define_method :"#{attr_name}_#{safe_locale}=" do |val|
|
19
|
+
globalize.stash with_locale, attr_name, val
|
20
|
+
self[attr_name] = val
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{my_easy_globalize2_accessors}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dan Carper"]
|
12
|
+
s.date = %q{2010-07-02}
|
13
|
+
s.description = %q{Updated from the original}
|
14
|
+
s.email = %q{dcarper@thorleyindustries.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"init.rb",
|
24
|
+
"lib/active_record/globalize_accessors.rb",
|
25
|
+
"my_easy_globalize2_accessors.gemspec",
|
26
|
+
"pkg/my_easy_globalize2_accessors-0.0.0.gem",
|
27
|
+
"pkg/my_easy_globalize2_accessors-0.1.0.gem",
|
28
|
+
"test/easy_globalize_accessors_test.rb",
|
29
|
+
"test/test_helper.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/DCarper/easy_globalize2_accessors}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.6}
|
35
|
+
s.summary = %q{Provide helper methods for globalize2 model translations}
|
36
|
+
s.test_files = [
|
37
|
+
"test/easy_globalize_accessors_test.rb",
|
38
|
+
"test/test_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
else
|
47
|
+
end
|
48
|
+
else
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
Binary file
|
Binary file
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: globalize2_sugar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dan Carper
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-07-02 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Updated from the original
|
22
|
+
email: dcarper@thorleyindustries.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
files:
|
30
|
+
- MIT-LICENSE
|
31
|
+
- README.rdoc
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- init.rb
|
35
|
+
- lib/active_record/globalize_accessors.rb
|
36
|
+
- my_easy_globalize2_accessors.gemspec
|
37
|
+
- pkg/my_easy_globalize2_accessors-0.0.0.gem
|
38
|
+
- pkg/my_easy_globalize2_accessors-0.1.0.gem
|
39
|
+
- test/easy_globalize_accessors_test.rb
|
40
|
+
- test/test_helper.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/DCarper/easy_globalize2_accessors
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.6
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Provide helper methods for globalize2 model translations
|
71
|
+
test_files:
|
72
|
+
- test/easy_globalize_accessors_test.rb
|
73
|
+
- test/test_helper.rb
|