zedlocales 1.1.1 → 1.1.2
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/VERSION +1 -1
- data/lib/zedlocales/content.rb +21 -17
- data/lib/zedlocales/content_scopes.rb +13 -9
- data/lib/zedlocales/content_sections.rb +12 -8
- data/lib/zedlocales/projects.rb +66 -0
- data/lib/zedlocales.rb +1 -1
- data/test/helper.rb +2 -2
- data/test/test_content.rb +11 -15
- data/test/test_content_scopes.rb +6 -10
- data/test/test_content_sections.rb +7 -10
- data/test/test_projects.rb +58 -0
- data/test/test_translations.rb +7 -10
- metadata +6 -4
- data/lib/zedkit/projects.rb +0 -29
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.2
|
data/lib/zedlocales/content.rb
CHANGED
|
@@ -17,30 +17,42 @@
|
|
|
17
17
|
|
|
18
18
|
module Zedlocales
|
|
19
19
|
class Content
|
|
20
|
+
class Translations
|
|
21
|
+
class << self
|
|
22
|
+
def get(*args)
|
|
23
|
+
zopts = args.extract_zedkit_options!
|
|
24
|
+
reshh = Zedkit::Client.get("content/translations/#{zopts[:uuid]}", zopts[:user_key],
|
|
25
|
+
zopts.zdelete_keys!(%w(user_key)))
|
|
26
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
27
|
+
reshh
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
20
32
|
class << self
|
|
21
33
|
#
|
|
22
34
|
# = Zedlocales Content
|
|
23
35
|
#
|
|
24
|
-
# All Zedkit applications have optional content
|
|
25
|
-
#
|
|
26
|
-
# method.
|
|
36
|
+
# All Zedkit applications have optional content that can be maintained with the Zedkit management interface. You can
|
|
37
|
+
# create, read, update, or delete content within content scopes. To perform an operation on a specific content scope
|
|
38
|
+
# you need its UUID, as available from the Zedlocales::ContentScopes::Content.get method.
|
|
27
39
|
#
|
|
28
|
-
# To get a Content:
|
|
40
|
+
# To get a Content item:
|
|
29
41
|
#
|
|
30
42
|
# Zedlocales::Content.get(:user_key => user['user_key'], :uuid => content['uuid'])
|
|
31
43
|
#
|
|
32
|
-
# To update a Content:
|
|
44
|
+
# To update a Content item:
|
|
33
45
|
#
|
|
34
46
|
# Zedlocales::Content.update(:user_key => user['user_key'],
|
|
35
47
|
# :uuid => content['uuid'], :content => { :content => 'whatever' })
|
|
36
48
|
#
|
|
37
|
-
# To delete a Content:
|
|
49
|
+
# To delete a Content item:
|
|
38
50
|
#
|
|
39
51
|
# Zedlocales::Content.delete(:user_key => user['user_key'], :uuid => scope['uuid'])
|
|
40
52
|
#
|
|
41
|
-
# To create a new Content you submit the required parameters with the scope UUID that you are creating the content
|
|
42
|
-
# Whatever items you send within the :content Hash are passed through to the ZedAPI untouched. There is no client
|
|
43
|
-
# validation within this gem.
|
|
53
|
+
# To create a new Content item you submit the required parameters with the scope UUID that you are creating the content
|
|
54
|
+
# for. Whatever items you send within the :content Hash are passed through to the ZedAPI untouched. There is no client
|
|
55
|
+
# side validation within this gem.
|
|
44
56
|
#
|
|
45
57
|
# Zedlocales::Content.create(:user_key => user['user_key'], :scope => { :uuid => scope['uuid'] },
|
|
46
58
|
# :content => { :key => 'whatever', :content => 'yo this the api' })
|
|
@@ -84,14 +96,6 @@ module Zedlocales
|
|
|
84
96
|
yield(reshh) if (not reshh.nil?) && block_given?
|
|
85
97
|
reshh
|
|
86
98
|
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
99
|
end
|
|
96
100
|
end
|
|
97
101
|
end
|
|
@@ -17,13 +17,24 @@
|
|
|
17
17
|
|
|
18
18
|
module Zedlocales
|
|
19
19
|
class ContentScopes
|
|
20
|
+
class Content
|
|
21
|
+
class << self
|
|
22
|
+
def get(*args)
|
|
23
|
+
zopts = args.extract_zedkit_options!
|
|
24
|
+
reshh = Zedkit::Client.get('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
|
25
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
26
|
+
reshh
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
20
31
|
class << self
|
|
21
32
|
#
|
|
22
33
|
# = Zedlocales Content Scopes
|
|
23
34
|
#
|
|
24
35
|
# All Zedkit applications have optional content. You can create, read, update, or delete content scopes within sections
|
|
25
36
|
# to organize it. To perform an operation on a specific content scope you need its UUID, as available from the
|
|
26
|
-
# ContentSections.
|
|
37
|
+
# Zedlocales::ContentSections::ContentScopes.get method.
|
|
27
38
|
#
|
|
28
39
|
# To get a Content Scope:
|
|
29
40
|
#
|
|
@@ -51,7 +62,7 @@ module Zedlocales
|
|
|
51
62
|
#
|
|
52
63
|
# For each request you can also pass a block to process the response directly:
|
|
53
64
|
#
|
|
54
|
-
# Zedlocales::
|
|
65
|
+
# Zedlocales::ContentScopes.get(:user_key => user['user_key'], :uuid => scope['uuid']) do |result|
|
|
55
66
|
# end
|
|
56
67
|
#
|
|
57
68
|
|
|
@@ -84,13 +95,6 @@ module Zedlocales
|
|
|
84
95
|
yield(reshh) if (not reshh.nil?) && block_given?
|
|
85
96
|
reshh
|
|
86
97
|
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
98
|
end
|
|
95
99
|
end
|
|
96
100
|
end
|
|
@@ -17,13 +17,24 @@
|
|
|
17
17
|
|
|
18
18
|
module Zedlocales
|
|
19
19
|
class ContentSections
|
|
20
|
+
class ContentScopes
|
|
21
|
+
class << self
|
|
22
|
+
def get(*args)
|
|
23
|
+
zopts = args.extract_zedkit_options!
|
|
24
|
+
reshh = Zedkit::Client.get('content/scopes', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
|
25
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
26
|
+
reshh
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
20
31
|
class << self
|
|
21
32
|
#
|
|
22
33
|
# = Zedlocales Content Sections
|
|
23
34
|
#
|
|
24
35
|
# All Zedkit applications have optional content. You can create, read, update, or delete content sections to organize
|
|
25
36
|
# it. To perform an operation on a specific content section you need its UUID, as available from the
|
|
26
|
-
#
|
|
37
|
+
# Zedkit::Projects::ContentSections.get method.
|
|
27
38
|
#
|
|
28
39
|
# To get a Content Section:
|
|
29
40
|
#
|
|
@@ -84,13 +95,6 @@ module Zedlocales
|
|
|
84
95
|
yield(reshh) if (not reshh.nil?) && block_given?
|
|
85
96
|
reshh
|
|
86
97
|
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
98
|
end
|
|
95
99
|
end
|
|
96
100
|
end
|
|
@@ -0,0 +1,66 @@
|
|
|
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 ContentSections
|
|
21
|
+
class << self
|
|
22
|
+
def get(*args)
|
|
23
|
+
zopts = args.extract_zedkit_options!
|
|
24
|
+
reshh = Zedkit::Client.get('content/sections', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
|
25
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
26
|
+
reshh
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class Locales
|
|
32
|
+
class << self
|
|
33
|
+
def get(*args)
|
|
34
|
+
zopts = args.extract_zedkit_options!
|
|
35
|
+
reshh = Zedkit::Client.get("projects/#{zopts[:project][:uuid]}/locales", zopts[:user_key])
|
|
36
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
37
|
+
reshh
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create(*args)
|
|
41
|
+
zopts = args.extract_zedkit_options!
|
|
42
|
+
reshh = Zedkit::Client.create("projects/#{zopts[:project][:uuid]}/locales", zopts[:user_key],
|
|
43
|
+
zopts.zdelete_keys!(%w(user_key project)))
|
|
44
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
45
|
+
reshh
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update(*args)
|
|
49
|
+
zopts = args.extract_zedkit_options!
|
|
50
|
+
reshh = Zedkit::Client.update("projects/#{zopts[:project][:uuid]}/locales/#{zopts[:locale][:code]}",
|
|
51
|
+
zopts[:user_key], zopts.zdelete_keys!(%w(user_key project)))
|
|
52
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
53
|
+
reshh
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def delete(*args)
|
|
57
|
+
zopts = args.extract_zedkit_options!
|
|
58
|
+
reshh = Zedkit::Client.delete("projects/#{zopts[:project][:uuid]}/locales/#{zopts[:locale][:code]}",
|
|
59
|
+
zopts[:user_key])
|
|
60
|
+
yield(reshh) if (not reshh.nil?) && block_given?
|
|
61
|
+
reshh
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
data/lib/zedlocales.rb
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
require 'rubygems'
|
|
19
19
|
require 'zedkit'
|
|
20
|
-
require 'zedkit/projects'
|
|
21
20
|
|
|
22
21
|
module Zedlocales
|
|
23
22
|
class << self
|
|
@@ -29,6 +28,7 @@ module Zedlocales
|
|
|
29
28
|
end
|
|
30
29
|
end
|
|
31
30
|
|
|
31
|
+
require 'zedlocales/projects'
|
|
32
32
|
require 'zedlocales/content_sections'
|
|
33
33
|
require 'zedlocales/content_scopes'
|
|
34
34
|
require 'zedlocales/content'
|
data/test/helper.rb
CHANGED
|
@@ -39,9 +39,9 @@ class Test::Unit::TestCase
|
|
|
39
39
|
|
|
40
40
|
protected
|
|
41
41
|
def con_sections
|
|
42
|
-
Zedkit::Projects.
|
|
42
|
+
Zedkit::Projects::ContentSections.get(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] })
|
|
43
43
|
end
|
|
44
44
|
def con_scopes
|
|
45
|
-
Zedlocales::ContentSections
|
|
45
|
+
Zedlocales::ContentSections::ContentScopes::get(:user_key => @uu['user_key'], :section => { :uuid => con_sections[0]['uuid'] })
|
|
46
46
|
end
|
|
47
47
|
end
|
data/test/test_content.rb
CHANGED
|
@@ -17,15 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
require 'helper'
|
|
19
19
|
|
|
20
|
-
class TestContent < Test::Unit::TestCase
|
|
20
|
+
class TestContent < Test::Unit::TestCase
|
|
21
|
+
def test_get_translations
|
|
22
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
23
|
+
tt = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
|
24
|
+
assert_equal 2, tt.length
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
def test_get_content
|
|
22
|
-
cs = Zedlocales::ContentScopes.
|
|
28
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
23
29
|
cc = Zedlocales::Content.get(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'])
|
|
24
30
|
assert_equal 'whatever', cc['key']
|
|
25
31
|
assert_equal cs[0]['uuid'], cc['uuid']
|
|
26
32
|
end
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
|
|
29
34
|
def test_create_content
|
|
30
35
|
cc = Zedlocales::Content.create(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] },
|
|
31
36
|
:content => { :key => 'yo', :content => 'yo yo' })
|
|
@@ -34,26 +39,17 @@ class TestContent < Test::Unit::TestCase
|
|
|
34
39
|
assert_equal 'yo yo', cc['content']
|
|
35
40
|
end
|
|
36
41
|
|
|
37
|
-
|
|
38
42
|
def test_update_content
|
|
39
|
-
cs = Zedlocales::ContentScopes.
|
|
43
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
40
44
|
cc = Zedlocales::Content.update(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'], :content => { :content => 'yo' })
|
|
41
45
|
assert_equal cs[0]['uuid'], cc['uuid']
|
|
42
46
|
assert_equal 'whatever', cc['key']
|
|
43
47
|
assert_equal 'yo', cc['content']
|
|
44
48
|
end
|
|
45
49
|
|
|
46
|
-
|
|
47
50
|
def test_destroy_content
|
|
48
|
-
cs = Zedlocales::ContentScopes.
|
|
51
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
49
52
|
cc = Zedlocales::Content.delete(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'])
|
|
50
53
|
assert_equal cc, {}
|
|
51
54
|
end
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def test_get_translations
|
|
55
|
-
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
56
|
-
tt = Zedlocales::Content.translations(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
|
57
|
-
assert_equal 2, tt.length
|
|
58
|
-
end
|
|
59
55
|
end
|
data/test/test_content_scopes.rb
CHANGED
|
@@ -18,12 +18,17 @@
|
|
|
18
18
|
require 'helper'
|
|
19
19
|
|
|
20
20
|
class TestContentScopes < Test::Unit::TestCase
|
|
21
|
+
def test_get_content
|
|
22
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
23
|
+
assert_equal 32, cs[0]['uuid'].length
|
|
24
|
+
assert_equal 'whatever', cs[0]['key']
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
def test_get_content_scope
|
|
22
28
|
cs = Zedlocales::ContentScopes.get(:user_key => @uu['user_key'], :uuid => con_scopes[0]['uuid'])
|
|
23
29
|
assert_equal 'whatever', cs['key']
|
|
24
30
|
end
|
|
25
31
|
|
|
26
|
-
|
|
27
32
|
def test_create_content_scope
|
|
28
33
|
cs = Zedlocales::ContentScopes.create(:user_key => @uu['user_key'],
|
|
29
34
|
:section => { :uuid => con_sections[0]['uuid'] }, :scope => { :key => 'neww' })
|
|
@@ -31,23 +36,14 @@ class TestContentScopes < Test::Unit::TestCase
|
|
|
31
36
|
assert_equal 32, cs['uuid'].length
|
|
32
37
|
end
|
|
33
38
|
|
|
34
|
-
|
|
35
39
|
def test_update_content_scope
|
|
36
40
|
cs = Zedlocales::ContentScopes.update(:user_key => @uu['user_key'],
|
|
37
41
|
:uuid => con_scopes[0]['uuid'], :scope => { :key => "updated" })
|
|
38
42
|
assert_equal 'updated', cs['key']
|
|
39
43
|
end
|
|
40
44
|
|
|
41
|
-
|
|
42
45
|
def test_delete_content_scope
|
|
43
46
|
cs = Zedlocales::ContentScopes.delete(:user_key => @uu['user_key'], :uuid => con_scopes[0]['uuid'])
|
|
44
47
|
assert_equal cs, {}
|
|
45
48
|
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_get_content
|
|
49
|
-
cs = Zedlocales::ContentScopes.content(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
50
|
-
assert_equal 32, cs[0]['uuid'].length
|
|
51
|
-
assert_equal 'whatever', cs[0]['key']
|
|
52
|
-
end
|
|
53
49
|
end
|
|
@@ -18,13 +18,19 @@
|
|
|
18
18
|
require 'helper'
|
|
19
19
|
|
|
20
20
|
class TestContentSections < Test::Unit::TestCase
|
|
21
|
+
def test_get_content_section_scopes
|
|
22
|
+
ss = Zedlocales::ContentSections::ContentScopes.get(:user_key => @uu['user_key'],
|
|
23
|
+
:section => { :uuid => con_sections[0]['uuid'] })
|
|
24
|
+
assert_equal 32, ss[0]['uuid'].length
|
|
25
|
+
assert_equal 'whatever', ss[0]['key']
|
|
26
|
+
end
|
|
27
|
+
|
|
21
28
|
def test_get_content_section
|
|
22
29
|
ss = Zedlocales::ContentSections.get(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid'])
|
|
23
30
|
assert_equal 'whatever', ss['key']
|
|
24
31
|
assert_equal 32, ss['uuid'].length
|
|
25
32
|
end
|
|
26
33
|
|
|
27
|
-
|
|
28
34
|
def test_create_content_section
|
|
29
35
|
ss = Zedlocales::ContentSections.create(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
|
30
36
|
:section => { :key => 'newsection' })
|
|
@@ -32,22 +38,13 @@ class TestContentSections < Test::Unit::TestCase
|
|
|
32
38
|
assert_equal 'newsection', ss['key']
|
|
33
39
|
end
|
|
34
40
|
|
|
35
|
-
|
|
36
41
|
def test_update_content_section
|
|
37
42
|
ss = Zedlocales::ContentSections.update(:user_key => @uu['user_key'],
|
|
38
43
|
:uuid => con_sections[0]['uuid'], :section => { :key => 'updatedsection' })
|
|
39
44
|
assert_equal 'updatedsection', ss['key']
|
|
40
45
|
end
|
|
41
46
|
|
|
42
|
-
|
|
43
47
|
def test_delete_content_section
|
|
44
48
|
assert_equal Zedlocales::ContentSections.delete(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid']), {}
|
|
45
49
|
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[0]['uuid'].length
|
|
51
|
-
assert_equal 'whatever', ss[0]['key']
|
|
52
|
-
end
|
|
53
50
|
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
|
|
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 TestProjects < Test::Unit::TestCase
|
|
21
|
+
def test_get_content_sections
|
|
22
|
+
pl = Zedkit::Projects::ContentSections.get(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] })
|
|
23
|
+
assert pl.is_a? Array
|
|
24
|
+
assert_equal 1, pl.length
|
|
25
|
+
assert_not_nil pl[0]['uuid']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_get_locale_connections
|
|
29
|
+
pl = Zedkit::Projects::Locales.get(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] })
|
|
30
|
+
assert pl.is_a? Array
|
|
31
|
+
assert_equal 2, pl.length
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_create_locale_connection
|
|
35
|
+
pl = Zedkit::Projects::Locales.create(:user_key => @uu['user_key'],
|
|
36
|
+
:project => { :uuid => @uu['projects'][0] }, :locale => { :code => 'sk' })
|
|
37
|
+
assert pl.is_a? Hash
|
|
38
|
+
assert_equal @uu['projects'][0], pl['project']['uuid']
|
|
39
|
+
assert_equal 'sk', pl['locale']['code']
|
|
40
|
+
assert_equal 'DEVELOPMENT', pl['stage']
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_update_locale_connection
|
|
44
|
+
pl = Zedkit::Projects::Locales.update(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
|
45
|
+
:locale => { :code => 'fr', :stage => 'development' })
|
|
46
|
+
assert pl.is_a? Hash
|
|
47
|
+
assert_equal @uu['projects'][0], pl['project']['uuid']
|
|
48
|
+
assert_equal 'fr', pl['locale']['code']
|
|
49
|
+
assert_equal 'DEVELOPMENT', pl['stage']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_delete_locale_connection
|
|
53
|
+
pl = Zedkit::Projects::Locales.delete(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
|
54
|
+
:locale => { :code => 'fr'})
|
|
55
|
+
assert pl.is_a? Hash
|
|
56
|
+
assert_equal pl, {}
|
|
57
|
+
end
|
|
58
|
+
end
|
data/test/test_translations.rb
CHANGED
|
@@ -19,25 +19,23 @@ require 'helper'
|
|
|
19
19
|
|
|
20
20
|
class TestContent < Test::Unit::TestCase
|
|
21
21
|
def test_get_translation
|
|
22
|
-
cs = Zedlocales::ContentScopes.
|
|
23
|
-
cc = Zedlocales::Content.
|
|
22
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
23
|
+
cc = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
|
24
24
|
tt = Zedlocales::Translations.get(:user_key => @uu['user_key'], :uuid => cc[0]['uuid'])
|
|
25
25
|
assert_equal tt['content']['uuid'], cs[0]['uuid']
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
def test_create_translation
|
|
30
|
-
cs = Zedlocales::ContentScopes.
|
|
29
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
31
30
|
tt = Zedlocales::Translations.create(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] },
|
|
32
31
|
:translation => { :locale => 'de', :source => 'ZEDKIT', :translation => 'yo' })
|
|
33
32
|
assert_equal cs[0]['uuid'], tt['content']['uuid']
|
|
34
33
|
assert_equal 'yo', tt['translation']
|
|
35
34
|
end
|
|
36
35
|
|
|
37
|
-
|
|
38
36
|
def test_update_translation
|
|
39
|
-
cs = Zedlocales::ContentScopes.
|
|
40
|
-
cc = Zedlocales::Content.
|
|
37
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
38
|
+
cc = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
|
41
39
|
tt = Zedlocales::Translations.update(:user_key => @uu['user_key'],
|
|
42
40
|
:uuid => cc[0]['uuid'], :translation => { :translation => 'yo' })
|
|
43
41
|
assert_equal cs[0]['uuid'], tt['content']['uuid']
|
|
@@ -45,10 +43,9 @@ class TestContent < Test::Unit::TestCase
|
|
|
45
43
|
assert_equal 'yo', tt['translation']
|
|
46
44
|
end
|
|
47
45
|
|
|
48
|
-
|
|
49
46
|
def test_destroy_translation
|
|
50
|
-
cs = Zedlocales::ContentScopes.
|
|
51
|
-
cc = Zedlocales::Content.
|
|
47
|
+
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
|
48
|
+
cc = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
|
52
49
|
tt = Zedlocales::Translations.get(:user_key => @uu['user_key'], :uuid => cc[0]['uuid'])
|
|
53
50
|
assert_equal tt['content']['uuid'], cs[0]['uuid']
|
|
54
51
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 1
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
version: 1.1.
|
|
8
|
+
- 2
|
|
9
|
+
version: 1.1.2
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Eric Woodward
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-11-
|
|
17
|
+
date: 2010-11-19 00:00:00 -08:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -75,11 +75,11 @@ files:
|
|
|
75
75
|
- Rakefile
|
|
76
76
|
- VERSION
|
|
77
77
|
- lib/tasks/generate.rake
|
|
78
|
-
- lib/zedkit/projects.rb
|
|
79
78
|
- lib/zedlocales.rb
|
|
80
79
|
- lib/zedlocales/content.rb
|
|
81
80
|
- lib/zedlocales/content_scopes.rb
|
|
82
81
|
- lib/zedlocales/content_sections.rb
|
|
82
|
+
- lib/zedlocales/projects.rb
|
|
83
83
|
- lib/zedlocales/railtie.rb
|
|
84
84
|
- lib/zedlocales/simple.rb
|
|
85
85
|
- lib/zedlocales/translations.rb
|
|
@@ -88,6 +88,7 @@ files:
|
|
|
88
88
|
- test/test_content_scopes.rb
|
|
89
89
|
- test/test_content_sections.rb
|
|
90
90
|
- test/test_locales.rb
|
|
91
|
+
- test/test_projects.rb
|
|
91
92
|
- test/test_simple_backend.rb
|
|
92
93
|
- test/test_translations.rb
|
|
93
94
|
has_rdoc: true
|
|
@@ -128,5 +129,6 @@ test_files:
|
|
|
128
129
|
- test/test_content_scopes.rb
|
|
129
130
|
- test/test_content_sections.rb
|
|
130
131
|
- test/test_locales.rb
|
|
132
|
+
- test/test_projects.rb
|
|
131
133
|
- test/test_simple_backend.rb
|
|
132
134
|
- test/test_translations.rb
|
data/lib/zedkit/projects.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|