multilang-hstore 0.3 → 0.4

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.
@@ -2,6 +2,7 @@ require 'multilang-hstore/version'
2
2
  require 'multilang-hstore/translation_proxy'
3
3
  require 'multilang-hstore/translation_keeper'
4
4
  require 'multilang-hstore/active_record_extensions'
5
+ require 'activerecord-postgres-hstore'
5
6
 
6
7
  module Multilang
7
8
  end
@@ -1,3 +1,3 @@
1
1
  module Multilang
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,34 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multilang-hstore
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Arthur Meinart
9
- - Firebase.co
9
+ - Heapsource
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-12 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2013-07-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pg
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.0.1
31
+ - !ruby/object:Gem::Dependency
32
+ name: activerecord-postgres-hstore
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 0.7.5
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.7.5
15
47
  description: Model translations for Rails 3 backed by PostgreSQL and Hstore
16
- email: hello@firebase.co
48
+ email: hello@heapsource.com
17
49
  executables: []
18
50
  extensions: []
19
- extra_rdoc_files:
20
- - README.rdoc
51
+ extra_rdoc_files: []
21
52
  files:
22
53
  - lib/multilang-hstore.rb
23
54
  - lib/multilang-hstore/active_record_extensions.rb
24
55
  - lib/multilang-hstore/translation_keeper.rb
25
56
  - lib/multilang-hstore/translation_proxy.rb
26
57
  - lib/multilang-hstore/version.rb
27
- - README.rdoc
28
58
  - spec/multilang_spec.rb
29
59
  - spec/schema.rb
30
60
  - spec/spec_helper.rb
31
- homepage: http://github.com/firebaseco/multilang-hstore
61
+ homepage: http://github.com/heapsource/multilang-hstore
32
62
  licenses: []
33
63
  post_install_message:
34
64
  rdoc_options: []
data/README.rdoc DELETED
@@ -1,134 +0,0 @@
1
- == Multilang-hstore
2
-
3
- Multilang is a small translation library for translating database values for Rails 3 using the [Hstore datatype](http://www.postgresql.org/docs/9.0/static/hstore.html).
4
-
5
- This project is a fork of [artworklv/multilang](https://github.com/artworklv/multilang) with some remarkable differences:
6
-
7
- * Replaced YAML text fields in favor of Hstore fields.
8
- * The translation hash is no longer limited to locales in `I18n.available_locales`.
9
-
10
- It uses [engageis/activerecord-postgres-hstore](https://github.com/engageis/activerecord-postgres-hstore)
11
-
12
- == Installation
13
-
14
- You need configure the multilang gem inside your gemfile:
15
-
16
- gem 'multilang-hstore'
17
-
18
- Do not forget to run
19
-
20
- bundle install
21
-
22
-
23
- == Basic Usage
24
-
25
- This is a walkthrough with all steps you need to setup multilang translated attributes, including model and migration.
26
-
27
- We're assuming here you want a Post model with some multilang attributes, as outlined below:
28
-
29
- class Post < ActiveRecord::Base
30
- multilang :title, :accessible => true
31
- end
32
-
33
- or
34
-
35
- class Post < ActiveRecord::Base
36
- multilang :title, :description, :required => true, :length => 100, :accessible => true
37
- end
38
-
39
- The multilang translations are stored in the same model attributes (eg. title):
40
-
41
- You may need to create migration for Post as usual, but multilang attributes should be in hstore type:
42
-
43
- create_table(:posts) do |t|
44
- t.hstore :title
45
- t.timestamps
46
- end
47
-
48
- Thats it!
49
-
50
- Now you are able to translate values for the attributes :title and :description per locale:
51
-
52
- I18n.locale = :en
53
- post.title = 'Multilang rocks!'
54
- I18n.locale = :lv
55
- post.title = 'Multilang rulle!'
56
-
57
- I18n.locale = :en
58
- post.title #=> Multilang rocks!
59
- I18n.locale = :lv
60
- post.title #=> Multilang rulle!
61
-
62
-
63
- You may assign attributes through auto generated methods (this methods depend from I18n.available_locales):
64
-
65
- I18n.available_locales #=> [:en. :lv]
66
-
67
- post.title_en = 'Multilang rocks!'
68
- post.title_lv = 'Multilang rulle!'
69
-
70
- post.title_en #=> 'Multilang rocks!'
71
- post.title_lv #=> 'Multilang rulle!'
72
-
73
- You may use mass assignment on model creation (if :accessible param is defined):
74
-
75
- Post.new(:title => {:en => 'Multilang rocks!', :lv => 'Multilang rulle!'})
76
-
77
- or
78
-
79
- Post.new(:title_en => 'Multilang rocks!', :title_lv => 'Multilang rulle!')
80
-
81
- Also, you may ise same hashes with setters:
82
-
83
- post.title = {:en => 'Multilang rocks!', :lv => 'Multilang rulle!'}
84
-
85
- == Attribute methods
86
-
87
- You may get other translations via attribute translation method:
88
-
89
- post.title.translation[:lv] #=> 'Multilang rocks!'
90
- post.title.translation[:en] #=> 'Multilang rulle!'
91
- post.title.translation.locales #=> [:en, :lv]
92
-
93
- If you have incomplete translations, you can get translation from other locale:
94
-
95
- post.title = {:en => 'Multilang rocks!', :lv => ''}
96
- I18n.locale = :lv
97
- post.title.any #=> 'Multilang rocks!'
98
-
99
- The value from "any" method returns value for I18n.current_locale or, if value is empty, it searches through all locales. It takes searching order from I18n.available_locales array.
100
-
101
- == Validations
102
- Multilang has some validation features:
103
-
104
- multilang :title, :length => 100 #define maximal length validator
105
- multilang :title, :required => true #define requirement validator
106
- multilang :title, :format => /regexp/ #define validates_format_of validator
107
-
108
- == Tests
109
-
110
- Test runs using a temporary database in your local PostgreSQL server:
111
-
112
- Create a test database:
113
-
114
- $ createdb multilang-hstore-test
115
-
116
- Create the [hstore extension](http://www.postgresql.org/docs/9.1/static/sql-createextension.html):
117
- psql -d multilang-hstore-test -c "CREATE EXTENSION IF NOT EXISTS hstore"
118
-
119
- Create the role *postgres* if necessary:
120
-
121
- $ createuser -s -r postgres
122
-
123
- Finally, you can run your tests:
124
-
125
- rspec
126
-
127
- == Bugs and Feedback
128
-
129
- Use [http://github.com/artworklv/multilang/issues](http://github.com/artworklv/multilang/issues)
130
-
131
- == License(MIT)
132
-
133
- Copyright (c) 2010 Arthur Meinart
134
- Copyright (c) 2012 Firebase.co