dm-is-localizable 0.10.1
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/.document +5 -0
- data/.gitignore +23 -0
- data/CHANGELOG +423 -0
- data/LICENSE +20 -0
- data/README.textile +260 -0
- data/Rakefile +86 -0
- data/TODO +2 -0
- data/VERSION +1 -0
- data/dm-is-localizable.gemspec +88 -0
- data/lib/dm-is-localizable/is/localizable.rb +135 -0
- data/lib/dm-is-localizable/storage/language.rb +21 -0
- data/lib/dm-is-localizable/storage/translation.rb +18 -0
- data/lib/dm-is-localizable.rb +6 -0
- data/spec/fixtures/item.rb +12 -0
- data/spec/lib/rspec_tmbundle_support.rb +35 -0
- data/spec/shared/shared_examples_spec.rb +72 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/unit/auto_migrate_spec.rb +13 -0
- data/spec/unit/class_level_api_spec.rb +169 -0
- data/spec/unit/instance_level_api_spec.rb +328 -0
- data/spec/unit/is_localizable_spec.rb +28 -0
- data/spec/unit/language_spec.rb +97 -0
- data/spec/unit/translation_spec.rb +27 -0
- data/tasks/changelog.rb +18 -0
- data/tasks/install.rb +9 -0
- data/tasks/whitespace.rb +4 -0
- metadata +131 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Language" do
|
4
|
+
|
5
|
+
describe "with valid attributes" do
|
6
|
+
|
7
|
+
it "should be valid" do
|
8
|
+
Language.new(:code => "en-US", :name => "English").should be_valid
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should store unique locale string codes" do
|
12
|
+
Language.create(:code => "en-US", :name => "English").should_not be_new
|
13
|
+
Language.create(:code => "en-US", :name => "English").should be_new
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "with incomplete attributes" do
|
19
|
+
|
20
|
+
before :each do
|
21
|
+
@l = Language.new
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should require a code" do
|
25
|
+
@l.name = "English"
|
26
|
+
@l.should_not be_valid
|
27
|
+
@l.errors.size.should == 1
|
28
|
+
@l.errors.on(:code).should_not be_empty
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should require a name" do
|
32
|
+
@l.code = "en-US"
|
33
|
+
@l.should_not be_valid
|
34
|
+
@l.errors.size.should == 1
|
35
|
+
@l.errors.on(:name).should_not be_empty
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "with invalid attributes" do
|
41
|
+
|
42
|
+
it "should not accept invalid locale strings" do
|
43
|
+
Language.new(:code => 'foo', :name => "English").should_not be_valid
|
44
|
+
Language.new(:code => 'foo-bar', :name => "English").should_not be_valid
|
45
|
+
Language.new(:code => 'foo-BAR', :name => "English").should_not be_valid
|
46
|
+
Language.new(:code => 'FOO-bar', :name => "English").should_not be_valid
|
47
|
+
Language.new(:code => 'FOO-BAR', :name => "English").should_not be_valid
|
48
|
+
Language.new(:code => 'en-us', :name => "English").should_not be_valid
|
49
|
+
Language.new(:code => 'EN-us', :name => "English").should_not be_valid
|
50
|
+
Language.new(:code => 'EN-US', :name => "English").should_not be_valid
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should only allow unique locale string codes" do
|
54
|
+
l1 = Language.create(:code => 'en-US', :name => "English")
|
55
|
+
l1.should_not be_new
|
56
|
+
l2 = Language.create(:code => 'en-US', :name => "English")
|
57
|
+
l2.should be_new
|
58
|
+
l2.errors.on(:code).should_not be_empty
|
59
|
+
l2.errors.size.should == 1
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "the [](value) class method" do
|
65
|
+
|
66
|
+
before :each do
|
67
|
+
Language.create :code => 'en-US', :name => 'English'
|
68
|
+
Language.create :code => 'de-AT', :name => 'Deutsch'
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "with nil as paramter" do
|
72
|
+
|
73
|
+
it "should return nil" do
|
74
|
+
Language[nil].should be_nil
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "with an invalid (not present) language symbol as parameter" do
|
80
|
+
|
81
|
+
it "should return nil" do
|
82
|
+
Language[:it].should be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "with a valid (present) language symbol as parameter" do
|
88
|
+
|
89
|
+
it "should return the correct language instance" do
|
90
|
+
Language[:en_US].should == Language.first(:code => 'en-US')
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "the remixed translation resource" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@l = Language.create :code => 'en-US', :name => 'English'
|
7
|
+
@i = Item.create
|
8
|
+
@t1 = ItemTranslation.create(:item => @i, :language => @l)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should belong to a localizable resource" do
|
12
|
+
@t1.item.should == @i
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should belong to a language" do
|
16
|
+
@t1.language.should == @l
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should store unique languages for every resource to translate" do
|
20
|
+
@t2 = ItemTranslation.create(:item => @i, :language => @l)
|
21
|
+
@t1.should_not be_new
|
22
|
+
@t2.should be_new
|
23
|
+
@t2.errors.should_not be_empty
|
24
|
+
@t2.errors.size.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/tasks/changelog.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
desc 'update changelog'
|
2
|
+
task :changelog do
|
3
|
+
File.open('CHANGELOG', 'w+') do |changelog|
|
4
|
+
`git log -z --abbrev-commit`.split("\0").each do |commit|
|
5
|
+
next if commit =~ /^Merge: \d*/
|
6
|
+
ref, author, time, _, title, _, message = commit.split("\n", 7)
|
7
|
+
ref = ref[/commit ([0-9a-f]+)/, 1]
|
8
|
+
author = author[/Author: (.*)/, 1].strip
|
9
|
+
time = Time.parse(time[/Date: (.*)/, 1]).utc
|
10
|
+
title.strip!
|
11
|
+
|
12
|
+
changelog.puts "[#{ref} | #{time}] #{author}"
|
13
|
+
changelog.puts '', " * #{title}"
|
14
|
+
changelog.puts '', message.rstrip if message
|
15
|
+
changelog.puts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/tasks/install.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
desc "Install gem using sudo"
|
2
|
+
task :install => :build do
|
3
|
+
puts '-' * 65
|
4
|
+
puts ' Put the following model definition in a file called language.rb'
|
5
|
+
puts '-' * 65
|
6
|
+
File.open(ROOT.join('lib/dm-is-localizable/storage/language.rb')).each do |line|
|
7
|
+
puts line
|
8
|
+
end
|
9
|
+
end
|
data/tasks/whitespace.rb
ADDED
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dm-is-localizable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Gamsjaeger (snusnu)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-04 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: dm-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.10.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: dm-is-remixable
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: dm-validations
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.10.2
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "1.3"
|
54
|
+
version:
|
55
|
+
description:
|
56
|
+
email: gamsnjaga@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- LICENSE
|
63
|
+
- README.textile
|
64
|
+
- TODO
|
65
|
+
files:
|
66
|
+
- .document
|
67
|
+
- .gitignore
|
68
|
+
- CHANGELOG
|
69
|
+
- LICENSE
|
70
|
+
- README.textile
|
71
|
+
- Rakefile
|
72
|
+
- TODO
|
73
|
+
- VERSION
|
74
|
+
- dm-is-localizable.gemspec
|
75
|
+
- lib/dm-is-localizable.rb
|
76
|
+
- lib/dm-is-localizable/is/localizable.rb
|
77
|
+
- lib/dm-is-localizable/storage/language.rb
|
78
|
+
- lib/dm-is-localizable/storage/translation.rb
|
79
|
+
- spec/fixtures/item.rb
|
80
|
+
- spec/lib/rspec_tmbundle_support.rb
|
81
|
+
- spec/shared/shared_examples_spec.rb
|
82
|
+
- spec/spec.opts
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
- spec/unit/auto_migrate_spec.rb
|
85
|
+
- spec/unit/class_level_api_spec.rb
|
86
|
+
- spec/unit/instance_level_api_spec.rb
|
87
|
+
- spec/unit/is_localizable_spec.rb
|
88
|
+
- spec/unit/language_spec.rb
|
89
|
+
- spec/unit/translation_spec.rb
|
90
|
+
- tasks/changelog.rb
|
91
|
+
- tasks/install.rb
|
92
|
+
- tasks/whitespace.rb
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/snusnu/dm-is-localizable
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- --charset=UTF-8
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.3.5
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Datamapper support for localization of content in multilanguage applications
|
121
|
+
test_files:
|
122
|
+
- spec/fixtures/item.rb
|
123
|
+
- spec/lib/rspec_tmbundle_support.rb
|
124
|
+
- spec/shared/shared_examples_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/unit/auto_migrate_spec.rb
|
127
|
+
- spec/unit/class_level_api_spec.rb
|
128
|
+
- spec/unit/instance_level_api_spec.rb
|
129
|
+
- spec/unit/is_localizable_spec.rb
|
130
|
+
- spec/unit/language_spec.rb
|
131
|
+
- spec/unit/translation_spec.rb
|