zedlocales 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +15 -0
- data/README.rdoc +8 -0
- data/Rakefile +74 -0
- data/VERSION +1 -0
- data/lib/tasks/generate.rake +28 -0
- data/lib/zedkit/projects.rb +29 -0
- data/lib/zedlocales/content.rb +97 -0
- data/lib/zedlocales/content_scopes.rb +96 -0
- data/lib/zedlocales/content_sections.rb +96 -0
- data/lib/zedlocales/railtie.rb +26 -0
- data/lib/zedlocales/simple.rb +58 -0
- data/lib/zedlocales/translations.rb +52 -0
- data/lib/zedlocales.rb +37 -0
- data/test/helper.rb +47 -0
- data/test/test_content.rb +64 -0
- data/test/test_content_scopes.rb +54 -0
- data/test/test_content_sections.rb +53 -0
- data/test/test_locales.rb +21 -0
- data/test/test_simple_backend.rb +36 -0
- data/test/test_translations.rb +55 -0
- metadata +132 -0
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
Copyright (c) Zedkit.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
Software is furnished to do so, subject to the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
require 'rake'
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'jeweler'
|
23
|
+
Jeweler::Tasks.new do |gem|
|
24
|
+
gem.name = "zedlocales"
|
25
|
+
gem.summary = %Q{gem for localization support in Zedkit applications}
|
26
|
+
gem.description = %Q{gem for localization support in Zedkit applications to generate locale files and load translations via the Zedkit API}
|
27
|
+
|
28
|
+
gem.email = "ejw@zedkit.com"
|
29
|
+
gem.homepage = "http://github.com/ejw/zedlocales"
|
30
|
+
gem.authors = ["Eric Woodward"]
|
31
|
+
gem.rubyforge_project = "zedlocales"
|
32
|
+
gem.files = FileList['[A-Z]*', 'lib/**/*.rb', 'lib/tasks/*.rake', 'test/**/*.rb']
|
33
|
+
|
34
|
+
gem.add_dependency 'zedkit', '>= 1.1.0'
|
35
|
+
gem.add_dependency 'json', '>= 1.4.4'
|
36
|
+
gem.add_dependency 'human_hash'
|
37
|
+
end
|
38
|
+
Jeweler::GemcutterTasks.new
|
39
|
+
rescue LoadError
|
40
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
41
|
+
end
|
42
|
+
|
43
|
+
require 'rake/testtask'
|
44
|
+
Rake::TestTask.new(:test) do |test|
|
45
|
+
test.libs << 'lib' << 'test'
|
46
|
+
test.pattern = 'test/**/test_*.rb'
|
47
|
+
test.verbose = true
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'rcov/rcovtask'
|
52
|
+
Rcov::RcovTask.new do |test|
|
53
|
+
test.libs << 'test'
|
54
|
+
test.pattern = 'test/**/test_*.rb'
|
55
|
+
test.verbose = true
|
56
|
+
end
|
57
|
+
rescue LoadError
|
58
|
+
task :rcov do
|
59
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
task :test => :check_dependencies
|
64
|
+
task :default => :test
|
65
|
+
|
66
|
+
require 'rake/rdoctask'
|
67
|
+
Rake::RDocTask.new do |rdoc|
|
68
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
69
|
+
|
70
|
+
rdoc.rdoc_dir = 'rdoc'
|
71
|
+
rdoc.title = "zedlocales #{version}"
|
72
|
+
rdoc.rdoc_files.include('README*')
|
73
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
74
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
@@ -0,0 +1,28 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
namespace :zedlocales do
|
19
|
+
desc "Generates the project's locale files with the latest content and translations"
|
20
|
+
task :generate => :environment do
|
21
|
+
|
22
|
+
# puts "Acquiring Locale for Simple Backend [#{locale}]..."
|
23
|
+
# puts "DONE"
|
24
|
+
|
25
|
+
Zedlocales::Client.get_locales
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module Zedkit
|
19
|
+
class Projects
|
20
|
+
class << self
|
21
|
+
def content_sections(*args)
|
22
|
+
zopts = args.extract_zedkit_options!
|
23
|
+
reshh = Zedkit::Client.get('content/sections', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
24
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
25
|
+
reshh
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module Zedlocales
|
19
|
+
class Content
|
20
|
+
class << self
|
21
|
+
#
|
22
|
+
# = Zedlocales Content
|
23
|
+
#
|
24
|
+
# All Zedkit applications have optional content. You can create, read, update, or delete content within content scopes
|
25
|
+
# To perform an operation on a specific content scope you need its UUID, as available from the ContentScopes.content
|
26
|
+
# method.
|
27
|
+
#
|
28
|
+
# To get a Content:
|
29
|
+
#
|
30
|
+
# Zedlocales::Content.get(:user_key => user['user_key'], :uuid => content['uuid'])
|
31
|
+
#
|
32
|
+
# To update a Content:
|
33
|
+
#
|
34
|
+
# Zedlocales::Content.update(:user_key => user['user_key'],
|
35
|
+
# :uuid => content['uuid'], :content => { :content => 'whatever' })
|
36
|
+
#
|
37
|
+
# To delete a Content:
|
38
|
+
#
|
39
|
+
# Zedlocales::Content.delete(:user_key => user['user_key'], :uuid => scope['uuid'])
|
40
|
+
#
|
41
|
+
# To create a new Content you submit the required parameters with the scope UUID that you are creating the content for.
|
42
|
+
# Whatever items you send within the :content Hash are passed through to the ZedAPI untouched. There is no client side
|
43
|
+
# validation within this gem.
|
44
|
+
#
|
45
|
+
# Zedlocales::Content.create(:user_key => user['user_key'], :scope => { :uuid => scope['uuid'] },
|
46
|
+
# :content => { :key => 'whatever', :content => 'yo this the api' })
|
47
|
+
#
|
48
|
+
# From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed,
|
49
|
+
# or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a
|
50
|
+
# security failure or that an UUID is incorrect, not attached the user's account, or non-existent.
|
51
|
+
#
|
52
|
+
# For each request you can also pass a block to process the response directly:
|
53
|
+
#
|
54
|
+
# Zedlocales::Content.get(:user_key => user['user_key'], :uuid => content['uuid']) do |result|
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
|
58
|
+
def get(*args)
|
59
|
+
zopts = args.extract_zedkit_options!
|
60
|
+
reshh = Zedkit::Client.get("content/content/#{zopts[:uuid]}", zopts[:user_key],
|
61
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
62
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
63
|
+
reshh
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(*args)
|
67
|
+
zopts = args.extract_zedkit_options!
|
68
|
+
reshh = Zedkit::Client.create('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
69
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
70
|
+
reshh
|
71
|
+
end
|
72
|
+
|
73
|
+
def update(*args)
|
74
|
+
zopts = args.extract_zedkit_options!
|
75
|
+
reshh = Zedkit::Client.update("content/content/#{zopts[:uuid]}", zopts[:user_key],
|
76
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
77
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
78
|
+
reshh
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete(*args)
|
82
|
+
zopts = args.extract_zedkit_options!
|
83
|
+
reshh = Zedkit::Client.delete("content/content/#{zopts[:uuid]}", zopts[:user_key])
|
84
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
85
|
+
reshh
|
86
|
+
end
|
87
|
+
|
88
|
+
def translations(*args)
|
89
|
+
zopts = args.extract_zedkit_options!
|
90
|
+
reshh = Zedkit::Client.get("content/translations/#{zopts[:uuid]}", zopts[:user_key],
|
91
|
+
zopts.zdelete_keys!(%w(user_key)))
|
92
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
93
|
+
reshh
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module Zedlocales
|
19
|
+
class ContentScopes
|
20
|
+
class << self
|
21
|
+
#
|
22
|
+
# = Zedlocales Content Scopes
|
23
|
+
#
|
24
|
+
# All Zedkit applications have optional content. You can create, read, update, or delete content scopes within sections
|
25
|
+
# to organize it. To perform an operation on a specific content scope you need its UUID, as available from the
|
26
|
+
# ContentSections.scopes method.
|
27
|
+
#
|
28
|
+
# To get a Content Scope:
|
29
|
+
#
|
30
|
+
# Zedlocales::ContentScopes.get(:user_key => user['user_key'], :uuid => scope['uuid'])
|
31
|
+
#
|
32
|
+
# To update a Content Scope:
|
33
|
+
#
|
34
|
+
# Zedlocales::ContentScopes.update(:user_key => user['user_key'],
|
35
|
+
# :uuid => scope['uuid'], :scope => { :key => 'whatever' })
|
36
|
+
#
|
37
|
+
# To delete a Content Scope:
|
38
|
+
#
|
39
|
+
# Zedlocales::ContentScopes.delete(:user_key => user['user_key'], :uuid => scope['uuid'])
|
40
|
+
#
|
41
|
+
# To create a new Content Scope you submit the required parameters with the section UUID that you are creating the
|
42
|
+
# content scope for. Whatever items you send within the :scope Hash are passed through to the ZedAPI untouched.
|
43
|
+
# There is no client side validation within this gem.
|
44
|
+
#
|
45
|
+
# Zedlocales::ContentScopes.create(:user_key => user['user_key'],
|
46
|
+
# :section => { :uuid => section['uuid'] }, :scope => { :key => 'whatever' })
|
47
|
+
#
|
48
|
+
# From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed,
|
49
|
+
# or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a
|
50
|
+
# security failure or that an UUID is incorrect, not attached the user's account, or non-existent.
|
51
|
+
#
|
52
|
+
# For each request you can also pass a block to process the response directly:
|
53
|
+
#
|
54
|
+
# Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => scope['uuid']) do |result|
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
|
58
|
+
def get(*args)
|
59
|
+
zopts = args.extract_zedkit_options!
|
60
|
+
reshh = Zedkit::Client.get("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
|
61
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
62
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
63
|
+
reshh
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(*args)
|
67
|
+
zopts = args.extract_zedkit_options!
|
68
|
+
reshh = Zedkit::Client.create('content/scopes', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
69
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
70
|
+
reshh
|
71
|
+
end
|
72
|
+
|
73
|
+
def update(*args)
|
74
|
+
zopts = args.extract_zedkit_options!
|
75
|
+
reshh = Zedkit::Client.update("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
|
76
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
77
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
78
|
+
reshh
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete(*args)
|
82
|
+
zopts = args.extract_zedkit_options!
|
83
|
+
reshh = Zedkit::Client.delete("content/scopes/#{zopts[:uuid]}", zopts[:user_key])
|
84
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
85
|
+
reshh
|
86
|
+
end
|
87
|
+
|
88
|
+
def content(*args)
|
89
|
+
zopts = args.extract_zedkit_options!
|
90
|
+
reshh = Zedkit::Client.get('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
91
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
92
|
+
reshh
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module Zedlocales
|
19
|
+
class ContentSections
|
20
|
+
class << self
|
21
|
+
#
|
22
|
+
# = Zedlocales Content Sections
|
23
|
+
#
|
24
|
+
# All Zedkit applications have optional content. You can create, read, update, or delete content sections to organize
|
25
|
+
# it. To perform an operation on a specific content section you need its UUID, as available from the
|
26
|
+
# Websites.content_sections method.
|
27
|
+
#
|
28
|
+
# To get a Content Section:
|
29
|
+
#
|
30
|
+
# Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => section['uuid'])
|
31
|
+
#
|
32
|
+
# To update a Content Section:
|
33
|
+
#
|
34
|
+
# Zedlocales::ContentSections.update(:user_key => user['user_key'],
|
35
|
+
# :uuid => section['uuid'], :section => { :key => 'whatever' })
|
36
|
+
#
|
37
|
+
# To delete a Content Section:
|
38
|
+
#
|
39
|
+
# Zedlocales::ContentSections.delete(:user_key => user['user_key'], :uuid => section['uuid'])
|
40
|
+
#
|
41
|
+
# To create a new Content Section you submit the required parameters with the project UUID that you are creating the
|
42
|
+
# content section for. Whatever items you send within the :section Hash are passed through to the ZedAPI untouched.
|
43
|
+
# There is no client side validation within this gem.
|
44
|
+
#
|
45
|
+
# Zedlocales::ContentSections.create(:user_key => user['user_key'],
|
46
|
+
# :project => { :uuid => project['uuid'] }, :section => { :key => 'whatever' })
|
47
|
+
#
|
48
|
+
# From each of these requests the Zedkit::Client class will return a response hash for your reference, if needed,
|
49
|
+
# or as applicable to the request. If there was a HTTP 401 or 404 you will get a nil response. This indicates a
|
50
|
+
# security failure or that an UUID is incorrect, not attached the user's account, or non-existent.
|
51
|
+
#
|
52
|
+
# For each request you can also pass a block to process the response directly:
|
53
|
+
#
|
54
|
+
# Zedlocales::ContentSections.get(:user_key => user['user_key'], :uuid => section['uuid']) do |result|
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
|
58
|
+
def get(*args)
|
59
|
+
zopts = args.extract_zedkit_options!
|
60
|
+
reshh = Zedkit::Client.get("content/sections/#{zopts[:uuid]}", zopts[:user_key],
|
61
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
62
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
63
|
+
reshh
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(*args)
|
67
|
+
zopts = args.extract_zedkit_options!
|
68
|
+
reshh = Zedkit::Client.create('content/sections', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
69
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
70
|
+
reshh
|
71
|
+
end
|
72
|
+
|
73
|
+
def update(*args)
|
74
|
+
zopts = args.extract_zedkit_options!
|
75
|
+
reshh = Zedkit::Client.update("content/sections/#{zopts[:uuid]}", zopts[:user_key],
|
76
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
77
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
78
|
+
reshh
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete(*args)
|
82
|
+
zopts = args.extract_zedkit_options!
|
83
|
+
reshh = Zedkit::Client.delete("content/sections/#{zopts[:uuid]}", zopts[:user_key])
|
84
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
85
|
+
reshh
|
86
|
+
end
|
87
|
+
|
88
|
+
def scopes(*args)
|
89
|
+
zopts = args.extract_zedkit_options!
|
90
|
+
reshh = Zedkit::Client.get('content/scopes', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
91
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
92
|
+
reshh
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'rails'
|
19
|
+
|
20
|
+
module Zedlocales
|
21
|
+
class Railtie < Rails::Railtie
|
22
|
+
rake_tasks do
|
23
|
+
load "tasks/generate.rake"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
7
|
+
# is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
10
|
+
#
|
11
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
12
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
13
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
14
|
+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
15
|
+
##
|
16
|
+
|
17
|
+
module Zedlocales
|
18
|
+
class Simple
|
19
|
+
class << self
|
20
|
+
def get(locale)
|
21
|
+
reshh = Zedkit::Client.get("locales/#{locale}/content", nil)
|
22
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
23
|
+
reshh
|
24
|
+
end
|
25
|
+
|
26
|
+
def set(locale, content)
|
27
|
+
set_locale_in_simple_backend(locale, content)
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
def set_locale_in_simple_backend(locale, content)
|
32
|
+
pp = ["#{Rails.root}",'config','locales',"#{locale}.rb"].join('/')
|
33
|
+
File.open(pp, 'w') do |fd|
|
34
|
+
fd.write locale_head
|
35
|
+
fd.write locale_code(locale)
|
36
|
+
fd.write content.human_inspect
|
37
|
+
fd.write locale_end(fd)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def locale_head
|
43
|
+
tmps = "##\n"
|
44
|
+
tmps << "# DO NOT EDIT THIS FILE.\n"
|
45
|
+
tmps << "# This locale file is auto-generated from the ZedAPI by the ZedLocales Ruby gem. Any manual updates to an rb\n"
|
46
|
+
tmps << "# file will be lost when this file is regenerated, with this current file only versioned once, or discarded.\n"
|
47
|
+
tmps << "# http://zedkit.com\n"
|
48
|
+
tmps << "##\n\n"
|
49
|
+
end
|
50
|
+
def locale_code(locale)
|
51
|
+
"{\n :'#{locale}' =>\n\n"
|
52
|
+
end
|
53
|
+
def locale_end
|
54
|
+
"\n\n}\n\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
module Zedlocales
|
19
|
+
class Translations
|
20
|
+
class << self
|
21
|
+
def get(*args)
|
22
|
+
zopts = args.extract_zedkit_options!
|
23
|
+
reshh = Zedkit::Client.get("content/translations/#{zopts[:uuid]}", zopts[:user_key],
|
24
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
25
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
26
|
+
reshh
|
27
|
+
end
|
28
|
+
|
29
|
+
def create(*args)
|
30
|
+
zopts = args.extract_zedkit_options!
|
31
|
+
reshh = Zedkit::Client.create('content/translations', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
32
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
33
|
+
reshh
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(*args)
|
37
|
+
zopts = args.extract_zedkit_options!
|
38
|
+
reshh = Zedkit::Client.update("content/translations/#{zopts[:uuid]}", zopts[:user_key],
|
39
|
+
zopts.zdelete_keys!(%w(uuid user_key)))
|
40
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
41
|
+
reshh
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete(*args)
|
45
|
+
zopts = args.extract_zedkit_options!
|
46
|
+
reshh = Zedkit::Client.delete("content/translations/#{zopts[:uuid]}", zopts[:user_key])
|
47
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
48
|
+
reshh
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/zedlocales.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
require 'zedkit'
|
20
|
+
require 'zedkit/projects'
|
21
|
+
|
22
|
+
module Zedlocales
|
23
|
+
class << self
|
24
|
+
def entities(user_key)
|
25
|
+
reshh = Zedkit::Client.get('v1/entities/zedlocales', user_key)
|
26
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
27
|
+
reshh
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'zedlocales/content_sections'
|
33
|
+
require 'zedlocales/content_scopes'
|
34
|
+
require 'zedlocales/content'
|
35
|
+
require 'zedlocales/translations'
|
36
|
+
require 'zedlocales/simple'
|
37
|
+
require 'zedlocales/railtie' if defined?(Rails::Railtie)
|
data/test/helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
7
|
+
# is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
10
|
+
#
|
11
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
12
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
13
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
14
|
+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
15
|
+
##
|
16
|
+
|
17
|
+
require 'test/unit'
|
18
|
+
require 'rubygems'
|
19
|
+
require 'zedlocales'
|
20
|
+
|
21
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
22
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
23
|
+
|
24
|
+
class Test::Unit::TestCase
|
25
|
+
TEST_GEMS_PROJECT_KEY = 'BE1OZog8gJogtQTosh'
|
26
|
+
TEST_GEMS_LOCALES_KEY = '6yca7DsnBvaDVupKEZ'
|
27
|
+
TEST_GEMS_LOGIN = 'gems@zedkit.com'
|
28
|
+
TEST_GEMS_PASSWORD = 'NGIaDhr5vDlXo1tDs6bW3Gd'
|
29
|
+
|
30
|
+
def setup
|
31
|
+
Zedkit.configure do |zb|
|
32
|
+
zb.project_key = TEST_GEMS_PROJECT_KEY
|
33
|
+
zb.locales_key = TEST_GEMS_LOCALES_KEY
|
34
|
+
# zb.api_host = '0.0.0.0'
|
35
|
+
# zb.api_port = 5010
|
36
|
+
end
|
37
|
+
@uu = Zedkit::Users.verify(:username => TEST_GEMS_LOGIN, :password => TEST_GEMS_PASSWORD)
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def con_sections
|
42
|
+
Zedkit::Projects.content_sections(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] })['sections']
|
43
|
+
end
|
44
|
+
def con_scopes
|
45
|
+
Zedlocales::ContentSections.scopes(:user_key => @uu['user_key'], :section => { :uuid => con_sections[0]['uuid'] })
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestContent < Test::Unit::TestCase
|
21
|
+
def test_get_content
|
22
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'],
|
23
|
+
:scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
24
|
+
cc = Zedlocales::Content.get(:user_key => @uu['user_key'], :uuid => cs['content'][0]['uuid'])
|
25
|
+
assert_equal 'whatever', cc['key']
|
26
|
+
assert_equal cs['content'][0]['uuid'], cc['uuid']
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def test_create_content
|
31
|
+
cc = Zedlocales::Content.create(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes['scopes'][0]['uuid'] },
|
32
|
+
:content => { :key => 'yo', :content => 'yo yo' })
|
33
|
+
assert_equal 32, cc['uuid'].length
|
34
|
+
assert_equal 'yo', cc['key']
|
35
|
+
assert_equal 'yo yo', cc['content']
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def test_update_content
|
40
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'],
|
41
|
+
:scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
42
|
+
cc = Zedlocales::Content.update(:user_key => @uu['user_key'],
|
43
|
+
:uuid => cs['content'][0]['uuid'], :content => { :content => 'yo' })
|
44
|
+
assert_equal cs['content'][0]['uuid'], cc['uuid']
|
45
|
+
assert_equal 'whatever', cc['key']
|
46
|
+
assert_equal 'yo', cc['content']
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def test_destroy_content
|
51
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'],
|
52
|
+
:scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
53
|
+
cc = Zedlocales::Content.delete(:user_key => @uu['user_key'], :uuid => cs['content'][0]['uuid'])
|
54
|
+
assert_equal cc, {}
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def test_get_translations
|
59
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'],
|
60
|
+
:scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
61
|
+
tt = Zedlocales::Content.translations(:user_key => @uu['user_key'], :content => { :uuid => cs['content'][0]['uuid'] })
|
62
|
+
assert_equal 2, tt['translations'].length
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestContentScopes < Test::Unit::TestCase
|
21
|
+
def test_get_content_scope
|
22
|
+
cs = Zedlocales::ContentScopes.get(:user_key => @uu['user_key'], :uuid => con_scopes['scopes'][0]['uuid'])
|
23
|
+
assert_equal 'whatever', cs['key']
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_create_content_scope
|
28
|
+
cs = Zedlocales::ContentScopes.create(:user_key => @uu['user_key'],
|
29
|
+
:section => { :uuid => con_sections[0]['uuid'] }, :scope => { :key => 'neww' })
|
30
|
+
assert_equal 'neww', cs['key']
|
31
|
+
assert_equal 32, cs['uuid'].length
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_update_content_scope
|
36
|
+
cs = Zedlocales::ContentScopes.update(:user_key => @uu['user_key'],
|
37
|
+
:uuid => con_scopes['scopes'][0]['uuid'], :scope => { :key => "updated" })
|
38
|
+
assert_equal 'updated', cs['key']
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def test_delete_content_scope
|
43
|
+
cs = Zedlocales::ContentScopes.delete(:user_key => @uu['user_key'], :uuid => con_scopes['scopes'][0]['uuid'])
|
44
|
+
assert_equal cs, {}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def test_get_content
|
49
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'],
|
50
|
+
:scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
51
|
+
assert_equal 32, cs['content'][0]['uuid'].length
|
52
|
+
assert_equal 'whatever', cs['content'][0]['key']
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestContentSections < Test::Unit::TestCase
|
21
|
+
def test_get_content_section
|
22
|
+
ss = Zedlocales::ContentSections.get(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid'])
|
23
|
+
assert_equal 'whatever', ss['key']
|
24
|
+
assert_equal 32, ss['uuid'].length
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def test_create_content_section
|
29
|
+
ss = Zedlocales::ContentSections.create(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
30
|
+
:section => { :key => 'newsection' })
|
31
|
+
assert_equal 32, ss['uuid'].length
|
32
|
+
assert_equal 'newsection', ss['key']
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def test_update_content_section
|
37
|
+
ss = Zedlocales::ContentSections.update(:user_key => @uu['user_key'],
|
38
|
+
:uuid => con_sections[0]['uuid'], :section => { :key => 'updatedsection' })
|
39
|
+
assert_equal 'updatedsection', ss['key']
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def test_delete_content_section
|
44
|
+
assert_equal Zedlocales::ContentSections.delete(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid']), {}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def test_get_content_section_scopes
|
49
|
+
ss = Zedlocales::ContentSections.scopes(:user_key => @uu['user_key'], :section => { :uuid => con_sections[0]['uuid'] })
|
50
|
+
assert_equal 32, ss['scopes'][0]['uuid'].length
|
51
|
+
assert_equal 'whatever', ss['scopes'][0]['key']
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestLocales < Test::Unit::TestCase
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestSimpleBackend < Test::Unit::TestCase
|
21
|
+
def test_get_english_locale
|
22
|
+
en = Zedlocales::Simple.get(:en)['content']
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_french_locale
|
26
|
+
fr = Zedlocales::Simple.get(:fr)['content']
|
27
|
+
assert_not_nil fr
|
28
|
+
assert_equal ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"], fr['fr']['date']['abbr_day_names']
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_spanish_locale
|
32
|
+
es = Zedlocales::Simple.get(:es)['content']
|
33
|
+
assert_not_nil es
|
34
|
+
assert_equal ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab"], es['es']['date']['abbr_day_names']
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
##
|
2
|
+
# Copyright (c) Zedkit.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
7
|
+
# Software is furnished to do so, subject to the following conditions:
|
8
|
+
#
|
9
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
10
|
+
# Software.
|
11
|
+
#
|
12
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
13
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
14
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
15
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
16
|
+
##
|
17
|
+
|
18
|
+
require 'helper'
|
19
|
+
|
20
|
+
class TestContent < Test::Unit::TestCase
|
21
|
+
def test_get_translation
|
22
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
23
|
+
cc = Zedlocales::Content.translations(:user_key => @uu['user_key'], :content => { :uuid => cs['content'][0]['uuid'] })
|
24
|
+
tt = Zedlocales::Translations.get(:user_key => @uu['user_key'], :uuid => cc['translations'][0]['uuid'])
|
25
|
+
assert_equal tt['content']['uuid'], cs['content'][0]['uuid']
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def test_create_translation
|
30
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
31
|
+
tt = Zedlocales::Translations.create(:user_key => @uu['user_key'], :content => { :uuid => cs['content'][0]['uuid'] },
|
32
|
+
:translation => { :locale => 'de', :source => 'ZEDKIT', :translation => 'yo' })
|
33
|
+
assert_equal cs['content'][0]['uuid'], tt['content']['uuid']
|
34
|
+
assert_equal 'yo', tt['translation']
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def test_update_translation
|
39
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
40
|
+
cc = Zedlocales::Content.translations(:user_key => @uu['user_key'], :content => { :uuid => cs['content'][0]['uuid'] })
|
41
|
+
tt = Zedlocales::Translations.update(:user_key => @uu['user_key'],
|
42
|
+
:uuid => cc['translations'][0]['uuid'], :translation => { :translation => 'yo' })
|
43
|
+
assert_equal cs['content'][0]['uuid'], tt['content']['uuid']
|
44
|
+
assert_equal cc['translations'][0]['uuid'], tt['uuid']
|
45
|
+
assert_equal 'yo', tt['translation']
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def test_destroy_translation
|
50
|
+
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes['scopes'][0]['uuid'] })
|
51
|
+
cc = Zedlocales::Content.translations(:user_key => @uu['user_key'], :content => { :uuid => cs['content'][0]['uuid'] })
|
52
|
+
tt = Zedlocales::Translations.get(:user_key => @uu['user_key'], :uuid => cc['translations'][0]['uuid'])
|
53
|
+
assert_equal tt['content']['uuid'], cs['content'][0]['uuid']
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zedlocales
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 1.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Eric Woodward
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-15 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: zedkit
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 1.1.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 4
|
46
|
+
- 4
|
47
|
+
version: 1.4.4
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: human_hash
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
description: gem for localization support in Zedkit applications to generate locale files and load translations via the Zedkit API
|
64
|
+
email: ejw@zedkit.com
|
65
|
+
executables: []
|
66
|
+
|
67
|
+
extensions: []
|
68
|
+
|
69
|
+
extra_rdoc_files:
|
70
|
+
- LICENSE
|
71
|
+
- README.rdoc
|
72
|
+
files:
|
73
|
+
- LICENSE
|
74
|
+
- README.rdoc
|
75
|
+
- Rakefile
|
76
|
+
- VERSION
|
77
|
+
- lib/tasks/generate.rake
|
78
|
+
- lib/zedkit/projects.rb
|
79
|
+
- lib/zedlocales.rb
|
80
|
+
- lib/zedlocales/content.rb
|
81
|
+
- lib/zedlocales/content_scopes.rb
|
82
|
+
- lib/zedlocales/content_sections.rb
|
83
|
+
- lib/zedlocales/railtie.rb
|
84
|
+
- lib/zedlocales/simple.rb
|
85
|
+
- lib/zedlocales/translations.rb
|
86
|
+
- test/helper.rb
|
87
|
+
- test/test_content.rb
|
88
|
+
- test/test_content_scopes.rb
|
89
|
+
- test/test_content_sections.rb
|
90
|
+
- test/test_locales.rb
|
91
|
+
- test/test_simple_backend.rb
|
92
|
+
- test/test_translations.rb
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/ejw/zedlocales
|
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
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
requirements: []
|
119
|
+
|
120
|
+
rubyforge_project: zedlocales
|
121
|
+
rubygems_version: 1.3.7
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: gem for localization support in Zedkit applications
|
125
|
+
test_files:
|
126
|
+
- test/helper.rb
|
127
|
+
- test/test_content.rb
|
128
|
+
- test/test_content_scopes.rb
|
129
|
+
- test/test_content_sections.rb
|
130
|
+
- test/test_locales.rb
|
131
|
+
- test/test_simple_backend.rb
|
132
|
+
- test/test_translations.rb
|