translatable_ar 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/templates/setup.rb +1 -1
- data/test/template_test.rb +88 -0
- metadata +47 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eec03fcd82e16ce2da34f286ebd27550efbf151
|
4
|
+
data.tar.gz: b157d493625d17e9536cf6948fcab3e085d56c8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e02b0e531d7e37d54cc1bcea6ce91eff24828eed7b9f1f1749e5843fa60b8805cf25148bc81233e352b7046ab9d159338a7593a3ac8eca1bdd7d476d71cd77
|
7
|
+
data.tar.gz: 82fcbe2c36ff25a9fced672723da4a9e3afab9ce405f6a86d0acbedc866e77b405511c9664cc3685342181fc5c433c1d1fcde4ad9f568e23c0ee620a2accf189
|
data/lib/templates/setup.rb
CHANGED
@@ -8,7 +8,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration
|
|
8
8
|
add_column :<%= attribute.model.table_name %>, :<%= attribute.name %>_i18n, :hstore
|
9
9
|
<% end -%>
|
10
10
|
|
11
|
-
attributes.each do |attribute| -%>
|
11
|
+
<% attributes.each do |attribute| -%>
|
12
12
|
add_hstore_index :<%= attribute.model.table_name %>, :<%= attribute.name %>_i18n
|
13
13
|
<% end -%>
|
14
14
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "minitest/reporters"
|
4
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
5
|
+
|
6
|
+
|
7
|
+
class FakeRailtie
|
8
|
+
def migration_class_name
|
9
|
+
"FakeMigrationClassName"
|
10
|
+
end
|
11
|
+
def attributes
|
12
|
+
[FakeAttribute.new(1), FakeAttribute.new(2)]
|
13
|
+
end
|
14
|
+
def models
|
15
|
+
[FakeModel.new(1), FakeModel.new(2)]
|
16
|
+
end
|
17
|
+
def get_binding
|
18
|
+
binding
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class FakeAttribute
|
23
|
+
def initialize(n)
|
24
|
+
@n = n
|
25
|
+
end
|
26
|
+
def model
|
27
|
+
FakeModel.new(@n)
|
28
|
+
end
|
29
|
+
def name
|
30
|
+
"fake_attribute#{@n}_name"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class FakeModel
|
35
|
+
def initialize(n)
|
36
|
+
@n = n
|
37
|
+
end
|
38
|
+
def table_name
|
39
|
+
"fake_models_#{@n}"
|
40
|
+
end
|
41
|
+
def to_s
|
42
|
+
"fake_model#{@n}_to_s"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class TestTranslatableAR < Minitest::Unit::TestCase
|
47
|
+
|
48
|
+
def test_template
|
49
|
+
railtie = FakeRailtie.new
|
50
|
+
text = ERB.new(File.read(File.dirname(__FILE__) + '/../lib/templates/setup.rb'), nil, '-').result(railtie.get_binding)
|
51
|
+
assert_equal text, <<-EOF
|
52
|
+
class FakeMigrationClassName < ActiveRecord::Migration
|
53
|
+
|
54
|
+
def up
|
55
|
+
|
56
|
+
execute "CREATE EXTENSION IF NOT EXISTS hstore"
|
57
|
+
|
58
|
+
add_column :fake_models_1, :fake_attribute1_name_i18n, :hstore
|
59
|
+
add_column :fake_models_2, :fake_attribute2_name_i18n, :hstore
|
60
|
+
|
61
|
+
add_hstore_index :fake_models_1, :fake_attribute1_name_i18n
|
62
|
+
add_hstore_index :fake_models_2, :fake_attribute2_name_i18n
|
63
|
+
|
64
|
+
puts "Preparing existing fake_model1_to_s objects ..."
|
65
|
+
fake_model1_to_s.reset_column_information
|
66
|
+
fake_model1_to_s.all.each do |object|
|
67
|
+
object.save
|
68
|
+
end
|
69
|
+
puts "Preparing existing fake_model2_to_s objects ..."
|
70
|
+
fake_model2_to_s.reset_column_information
|
71
|
+
fake_model2_to_s.all.each do |object|
|
72
|
+
object.save
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def down
|
77
|
+
remove_column :fake_models_1, :fake_attribute1_name_i18n
|
78
|
+
remove_column :fake_models_2, :fake_attribute2_name_i18n
|
79
|
+
|
80
|
+
remove_hstore_index :fake_models_1, :fake_attribute1_name_i18n
|
81
|
+
remove_hstore_index :fake_models_2, :fake_attribute2_name_i18n
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
EOF
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translatable_ar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Bjørn Nielsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest-reporters
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: activerecord
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -35,6 +77,7 @@ files:
|
|
35
77
|
- lib/templates/setup.rb
|
36
78
|
- lib/translatable_ar.rb
|
37
79
|
- lib/translatable_ar_class.rb
|
80
|
+
- test/template_test.rb
|
38
81
|
homepage: http://github.com/kasperbn/translatable_ar
|
39
82
|
licenses: []
|
40
83
|
metadata: {}
|
@@ -59,4 +102,5 @@ rubygems_version: 2.2.2
|
|
59
102
|
signing_key:
|
60
103
|
specification_version: 4
|
61
104
|
summary: i18n for your active record models with HStore attribute
|
62
|
-
test_files:
|
105
|
+
test_files:
|
106
|
+
- test/template_test.rb
|