my_easy_globalize2_accessors 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
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 = "my_easy_globalize2_accessors"
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.0.0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ ActiveRecord::Base.send :include, ActiveRecord::GlobalizeAccessors
@@ -0,0 +1,26 @@
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 = globalize_options[:translated_attributes]
11
+ attribs.each do |attr_name|
12
+ languages.each do |with_locale|
13
+ define_method :"#{attr_name}_#{with_locale}" do
14
+ globalize.fetch with_locale, attr_name
15
+ end
16
+
17
+ define_method :"#{attr_name}_#{with_locale}=" do |val|
18
+ globalize.stash with_locale, attr_name, val
19
+ self[attr_name] = val
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,50 @@
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.0.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
+ "test/easy_globalize_accessors_test.rb",
28
+ "test/test_helper.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/DCarper/easy_globalize2_accessors}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.6}
34
+ s.summary = %q{Provide helper methods for globalize2 model translations}
35
+ s.test_files = [
36
+ "test/easy_globalize_accessors_test.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ else
46
+ end
47
+ else
48
+ end
49
+ end
50
+
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class EasyGlobalizeAccessorsTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: my_easy_globalize2_accessors
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 0
9
+ version: 0.0.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
+ - test/easy_globalize_accessors_test.rb
39
+ - test/test_helper.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/DCarper/easy_globalize2_accessors
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Provide helper methods for globalize2 model translations
70
+ test_files:
71
+ - test/easy_globalize_accessors_test.rb
72
+ - test/test_helper.rb