zedlocales 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -3
- data/VERSION +1 -1
- data/bin/zedlocales +23 -0
- data/lib/cli/config.rb +20 -0
- data/lib/cli/projects.rb +33 -0
- data/lib/cli/runner.rb +37 -0
- data/lib/tasks/generate.rake +0 -6
- data/lib/zedlocales.rb +7 -4
- data/lib/zedlocales/content.rb +10 -28
- data/lib/zedlocales/content_scopes.rb +11 -28
- data/lib/zedlocales/content_sections.rb +11 -28
- data/lib/zedlocales/projects.rb +11 -28
- data/lib/zedlocales/simple.rb +2 -1
- data/lib/zedlocales/translations.rb +10 -22
- data/test/test_content.rb +5 -6
- data/test/test_content_scopes.rb +5 -6
- data/test/test_content_sections.rb +5 -5
- data/test/test_projects.rb +2 -4
- data/test/test_translations.rb +5 -6
- metadata +13 -9
data/Rakefile
CHANGED
@@ -25,11 +25,14 @@ begin
|
|
25
25
|
gem.summary = %Q{gem for localization support in Zedkit applications}
|
26
26
|
gem.description = %Q{gem for localization support in Zedkit applications to generate locale files and load translations via the Zedkit API}
|
27
27
|
|
28
|
-
gem.email = "
|
29
|
-
gem.homepage = "http://github.com/
|
30
|
-
gem.authors = ["
|
28
|
+
gem.email = "support@zedkit.com"
|
29
|
+
gem.homepage = "http://github.com/zedkit/zedlocales"
|
30
|
+
gem.authors = ["Zedkit"]
|
31
31
|
gem.rubyforge_project = "zedlocales"
|
32
|
+
|
32
33
|
gem.files = FileList['[A-Z]*', 'lib/**/*.rb', 'lib/tasks/*.rake', 'test/**/*.rb']
|
34
|
+
gem.executables = %w(zedlocales)
|
35
|
+
gem.default_executable = %q{zedlocales}
|
33
36
|
|
34
37
|
gem.add_dependency 'zedkit', '>= 1.1.0'
|
35
38
|
gem.add_dependency 'json', '>= 1.4.4'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/bin/zedlocales
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
##
|
3
|
+
# Copyright (c) Zedkit.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
6
|
+
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
7
|
+
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
# Software is furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
11
|
+
# Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
14
|
+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
15
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
16
|
+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
##
|
18
|
+
|
19
|
+
require 'zedlocales'
|
20
|
+
|
21
|
+
Dir["#{File.dirname(__FILE__)}/../lib/cli/*.rb"].each {|ci| require ci }
|
22
|
+
|
23
|
+
Zedlocales::CLI::Runner.new.go!
|
data/lib/cli/config.rb
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
Zedkit.configure do |zk|
|
19
|
+
zk.exceptions = true
|
20
|
+
end
|
data/lib/cli/projects.rb
ADDED
@@ -0,0 +1,33 @@
|
|
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
|
+
module CLI
|
20
|
+
class Projects < Zedkit::CLI::Bottom
|
21
|
+
class << self
|
22
|
+
def list(opts = {})
|
23
|
+
puts "\n Still TBD\n\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def codes(opts = {})
|
27
|
+
puts "\n Still TBD\n\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/lib/cli/runner.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
|
+
module Zedlocales
|
19
|
+
module CLI
|
20
|
+
class Runner < Zedkit::CLI::Runner
|
21
|
+
SECTIONS = ['sections','scopes','content']
|
22
|
+
|
23
|
+
protected
|
24
|
+
def just_do_it
|
25
|
+
klass = Object.const_get('Zedlocales').const_get('CLI').const_get(section.capitalize)
|
26
|
+
klass.send command.to_sym, :user_key => user_key, :items => items_to_key_value_hash, :argv => ARGV
|
27
|
+
end
|
28
|
+
def map
|
29
|
+
"\n" \
|
30
|
+
<< "== Project Commands\n\n" \
|
31
|
+
<< "list <uuid> # List project content structure\n" \
|
32
|
+
<< "codes # Outline applicable entity codes for ZedDB\n\n" \
|
33
|
+
<< "==\n\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/tasks/generate.rake
CHANGED
@@ -18,11 +18,5 @@
|
|
18
18
|
namespace :zedlocales do
|
19
19
|
desc "Generates the project's locale files with the latest content and translations"
|
20
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
21
|
end
|
28
22
|
end
|
data/lib/zedlocales.rb
CHANGED
@@ -20,10 +20,12 @@ require 'zedkit'
|
|
20
20
|
|
21
21
|
module Zedlocales
|
22
22
|
class << self
|
23
|
-
def entities
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def entities
|
24
|
+
rs = Zedkit::Client.get('entities/zedlocales')
|
25
|
+
if rs && block_given?
|
26
|
+
rs.is_a?(Array) ? rs.each {|i| yield(i) } : yield(rs)
|
27
|
+
end
|
28
|
+
rs
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -33,5 +35,6 @@ require 'zedlocales/content_sections'
|
|
33
35
|
require 'zedlocales/content_scopes'
|
34
36
|
require 'zedlocales/content'
|
35
37
|
require 'zedlocales/translations'
|
38
|
+
|
36
39
|
require 'zedlocales/simple'
|
37
40
|
require 'zedlocales/railtie' if defined?(Rails::Railtie)
|
data/lib/zedlocales/content.rb
CHANGED
@@ -19,12 +19,8 @@ module Zedlocales
|
|
19
19
|
class Content
|
20
20
|
class Translations
|
21
21
|
class << self
|
22
|
-
def get(
|
23
|
-
|
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
|
22
|
+
def get(zks = {}, &block)
|
23
|
+
Zedkit::Client.crud(:get, "content/translations", zks, [], &block)
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -67,34 +63,20 @@ module Zedlocales
|
|
67
63
|
# end
|
68
64
|
#
|
69
65
|
|
70
|
-
def get(
|
71
|
-
|
72
|
-
reshh = Zedkit::Client.get("content/content/#{zopts[:uuid]}", zopts[:user_key],
|
73
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
74
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
75
|
-
reshh
|
66
|
+
def get(zks = {}, &block)
|
67
|
+
Zedkit::Client.crud(:get, "content/content/#{zks[:uuid]}", zks, [], &block)
|
76
68
|
end
|
77
69
|
|
78
|
-
def create(
|
79
|
-
|
80
|
-
reshh = Zedkit::Client.create('content/content', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
81
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
82
|
-
reshh
|
70
|
+
def create(zks = {}, &block)
|
71
|
+
Zedkit::Client.crud(:create, 'content/content', zks, [], &block)
|
83
72
|
end
|
84
73
|
|
85
|
-
def update(
|
86
|
-
|
87
|
-
reshh = Zedkit::Client.update("content/content/#{zopts[:uuid]}", zopts[:user_key],
|
88
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
89
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
90
|
-
reshh
|
74
|
+
def update(zks = {}, &block)
|
75
|
+
Zedkit::Client.crud(:update, "content/content/#{zks[:uuid]}", zks, [], &block)
|
91
76
|
end
|
92
77
|
|
93
|
-
def delete(
|
94
|
-
|
95
|
-
reshh = Zedkit::Client.delete("content/content/#{zopts[:uuid]}", zopts[:user_key])
|
96
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
97
|
-
reshh
|
78
|
+
def delete(zks = {}, &block)
|
79
|
+
Zedkit::Client.crud(:delete, "content/content/#{zks[:uuid]}", zks, [], &block)
|
98
80
|
end
|
99
81
|
end
|
100
82
|
end
|
@@ -19,15 +19,12 @@ module Zedlocales
|
|
19
19
|
class ContentScopes
|
20
20
|
class Content
|
21
21
|
class << self
|
22
|
-
def get(
|
23
|
-
|
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
|
22
|
+
def get(zks = {}, &block)
|
23
|
+
Zedkit::Client.crud(:get, "content/content", zks, [], &block)
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
30
|
-
|
27
|
+
|
31
28
|
class << self
|
32
29
|
#
|
33
30
|
# = Zedlocales Content Scopes
|
@@ -66,34 +63,20 @@ module Zedlocales
|
|
66
63
|
# end
|
67
64
|
#
|
68
65
|
|
69
|
-
def get(
|
70
|
-
|
71
|
-
reshh = Zedkit::Client.get("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
|
72
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
73
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
74
|
-
reshh
|
66
|
+
def get(zks = {}, &block)
|
67
|
+
Zedkit::Client.crud(:get, "content/scopes/#{zks[:uuid]}", zks, [], &block)
|
75
68
|
end
|
76
69
|
|
77
|
-
def create(
|
78
|
-
|
79
|
-
reshh = Zedkit::Client.create('content/scopes', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
80
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
81
|
-
reshh
|
70
|
+
def create(zks = {}, &block)
|
71
|
+
Zedkit::Client.crud(:create, 'content/scopes', zks, [], &block)
|
82
72
|
end
|
83
73
|
|
84
|
-
def update(
|
85
|
-
|
86
|
-
reshh = Zedkit::Client.update("content/scopes/#{zopts[:uuid]}", zopts[:user_key],
|
87
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
88
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
89
|
-
reshh
|
74
|
+
def update(zks = {}, &block)
|
75
|
+
Zedkit::Client.crud(:update, "content/scopes/#{zks[:uuid]}", zks, [], &block)
|
90
76
|
end
|
91
77
|
|
92
|
-
def delete(
|
93
|
-
|
94
|
-
reshh = Zedkit::Client.delete("content/scopes/#{zopts[:uuid]}", zopts[:user_key])
|
95
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
96
|
-
reshh
|
78
|
+
def delete(zks = {}, &block)
|
79
|
+
Zedkit::Client.crud(:delete, "content/scopes/#{zks[:uuid]}", zks, [], &block)
|
97
80
|
end
|
98
81
|
end
|
99
82
|
end
|
@@ -19,15 +19,12 @@ module Zedlocales
|
|
19
19
|
class ContentSections
|
20
20
|
class ContentScopes
|
21
21
|
class << self
|
22
|
-
def get(
|
23
|
-
|
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
|
22
|
+
def get(zks = {}, &block)
|
23
|
+
Zedkit::Client.crud(:get, "content/scopes", zks, [], &block)
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
30
|
-
|
27
|
+
|
31
28
|
class << self
|
32
29
|
#
|
33
30
|
# = Zedlocales Content Sections
|
@@ -66,34 +63,20 @@ module Zedlocales
|
|
66
63
|
# end
|
67
64
|
#
|
68
65
|
|
69
|
-
def get(
|
70
|
-
|
71
|
-
reshh = Zedkit::Client.get("content/sections/#{zopts[:uuid]}", zopts[:user_key],
|
72
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
73
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
74
|
-
reshh
|
66
|
+
def get(zks = {}, &block)
|
67
|
+
Zedkit::Client.crud(:get, "content/sections/#{zks[:uuid]}", zks, [], &block)
|
75
68
|
end
|
76
69
|
|
77
|
-
def create(
|
78
|
-
|
79
|
-
reshh = Zedkit::Client.create('content/sections', zopts[:user_key], zopts.zdelete_keys!(%w(user_key)))
|
80
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
81
|
-
reshh
|
70
|
+
def create(zks = {}, &block)
|
71
|
+
Zedkit::Client.crud(:create, 'content/sections', zks, [], &block)
|
82
72
|
end
|
83
73
|
|
84
|
-
def update(
|
85
|
-
|
86
|
-
reshh = Zedkit::Client.update("content/sections/#{zopts[:uuid]}", zopts[:user_key],
|
87
|
-
zopts.zdelete_keys!(%w(uuid user_key)))
|
88
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
89
|
-
reshh
|
74
|
+
def update(zks = {}, &block)
|
75
|
+
Zedkit::Client.crud(:update, "content/sections/#{zks[:uuid]}", zks, [], &block)
|
90
76
|
end
|
91
77
|
|
92
|
-
def delete(
|
93
|
-
|
94
|
-
reshh = Zedkit::Client.delete("content/sections/#{zopts[:uuid]}", zopts[:user_key])
|
95
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
96
|
-
reshh
|
78
|
+
def delete(zks = {}, &block)
|
79
|
+
Zedkit::Client.crud(:delete, "content/sections/#{zks[:uuid]}", zks, [], &block)
|
97
80
|
end
|
98
81
|
end
|
99
82
|
end
|
data/lib/zedlocales/projects.rb
CHANGED
@@ -19,46 +19,29 @@ module Zedkit
|
|
19
19
|
class Projects
|
20
20
|
class ContentSections
|
21
21
|
class << self
|
22
|
-
def get(
|
23
|
-
|
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
|
22
|
+
def get(zks = {}, &block)
|
23
|
+
Zedkit::Client.crud(:get, "content/sections", zks, [], &block)
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
31
28
|
class Locales
|
32
29
|
class << self
|
33
|
-
def get(
|
34
|
-
|
35
|
-
reshh = Zedkit::Client.get("projects/#{zopts[:project][:uuid]}/locales", zopts[:user_key])
|
36
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
37
|
-
reshh
|
30
|
+
def get(zks = {}, &block)
|
31
|
+
Zedkit::Client.crud(:get, "projects/#{zks[:project][:uuid]}/locales", zks, %w(project), &block)
|
38
32
|
end
|
39
33
|
|
40
|
-
def create(
|
41
|
-
|
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
|
34
|
+
def create(zks = {}, &block)
|
35
|
+
Zedkit::Client.crud(:create, "projects/#{zks[:project][:uuid]}/locales", zks, %w(project), &block)
|
46
36
|
end
|
47
37
|
|
48
|
-
def update(
|
49
|
-
|
50
|
-
|
51
|
-
zopts[:user_key], zopts.zdelete_keys!(%w(user_key project)))
|
52
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
53
|
-
reshh
|
38
|
+
def update(zks = {}, &block)
|
39
|
+
Zedkit::Client.crud(:update,
|
40
|
+
"projects/#{zks[:project][:uuid]}/locales/#{zks[:locale][:code]}", zks, %w(project), &block)
|
54
41
|
end
|
55
42
|
|
56
|
-
def delete(
|
57
|
-
|
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
|
43
|
+
def delete(zks = {}, &block)
|
44
|
+
Zedkit::Client.crud(:delete, "projects/#{zks[:project][:uuid]}/locales/#{zks[:locale][:code]}", zks, [], &block)
|
62
45
|
end
|
63
46
|
end
|
64
47
|
end
|
data/lib/zedlocales/simple.rb
CHANGED
@@ -40,7 +40,8 @@ module Zedlocales
|
|
40
40
|
|
41
41
|
private
|
42
42
|
def locale_head
|
43
|
-
tmps = "
|
43
|
+
tmps = "# encoding: UTF-8\n"
|
44
|
+
tmps << "##\n"
|
44
45
|
tmps << "# DO NOT EDIT THIS FILE.\n"
|
45
46
|
tmps << "# This locale file is auto-generated from the ZedAPI by the ZedLocales Ruby gem. Any manual updates to an rb\n"
|
46
47
|
tmps << "# file will be lost when this file is regenerated, with this current file only versioned once, or discarded.\n"
|
@@ -18,35 +18,23 @@
|
|
18
18
|
module Zedlocales
|
19
19
|
class Translations
|
20
20
|
class << self
|
21
|
-
def get(
|
22
|
-
|
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
|
21
|
+
def get(zks = {}, &block)
|
22
|
+
Zedkit::Client.crud(:get, "content/translations/#{zks[:uuid]}", zks, [], &block)
|
27
23
|
end
|
28
24
|
|
29
|
-
def create(
|
30
|
-
|
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
|
25
|
+
def create(zks = {}, &block)
|
26
|
+
Zedkit::Client.crud(:create, 'content/translations', zks, [], &block)
|
34
27
|
end
|
35
28
|
|
36
|
-
def update(
|
37
|
-
|
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
|
29
|
+
def update(zks = {}, &block)
|
30
|
+
Zedkit::Client.crud(:update, "content/translations/#{zks[:uuid]}", zks, [], &block)
|
42
31
|
end
|
43
32
|
|
44
|
-
def delete(
|
45
|
-
|
46
|
-
reshh = Zedkit::Client.delete("content/translations/#{zopts[:uuid]}", zopts[:user_key])
|
47
|
-
yield(reshh) if (not reshh.nil?) && block_given?
|
48
|
-
reshh
|
33
|
+
def delete(zks = {}, &block)
|
34
|
+
Zedkit::Client.crud(:delete, "content/translations/#{zks[:uuid]}", zks, [], &block)
|
49
35
|
end
|
50
36
|
end
|
51
37
|
end
|
52
38
|
end
|
39
|
+
|
40
|
+
|
data/test/test_content.rb
CHANGED
@@ -24,14 +24,14 @@ class TestContent < Test::Unit::TestCase
|
|
24
24
|
assert_equal 2, tt.length
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_get
|
28
28
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
29
29
|
cc = Zedlocales::Content.get(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'])
|
30
30
|
assert_equal 'whatever', cc['key']
|
31
31
|
assert_equal cs[0]['uuid'], cc['uuid']
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def test_create
|
35
35
|
cc = Zedlocales::Content.create(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] },
|
36
36
|
:content => { :key => 'yo', :content => 'yo yo' })
|
37
37
|
assert_equal 32, cc['uuid'].length
|
@@ -39,7 +39,7 @@ class TestContent < Test::Unit::TestCase
|
|
39
39
|
assert_equal 'yo yo', cc['content']
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def test_update
|
43
43
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
44
44
|
cc = Zedlocales::Content.update(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'], :content => { :content => 'yo' })
|
45
45
|
assert_equal cs[0]['uuid'], cc['uuid']
|
@@ -47,9 +47,8 @@ class TestContent < Test::Unit::TestCase
|
|
47
47
|
assert_equal 'yo', cc['content']
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def test_destroy
|
51
51
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
52
|
-
|
53
|
-
assert_equal cc, {}
|
52
|
+
assert_nil Zedlocales::Content.delete(:user_key => @uu['user_key'], :uuid => cs[0]['uuid'])
|
54
53
|
end
|
55
54
|
end
|
data/test/test_content_scopes.rb
CHANGED
@@ -24,26 +24,25 @@ class TestContentScopes < Test::Unit::TestCase
|
|
24
24
|
assert_equal 'whatever', cs[0]['key']
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_get
|
28
28
|
cs = Zedlocales::ContentScopes.get(:user_key => @uu['user_key'], :uuid => con_scopes[0]['uuid'])
|
29
29
|
assert_equal 'whatever', cs['key']
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def test_create
|
33
33
|
cs = Zedlocales::ContentScopes.create(:user_key => @uu['user_key'],
|
34
34
|
:section => { :uuid => con_sections[0]['uuid'] }, :scope => { :key => 'neww' })
|
35
35
|
assert_equal 'neww', cs['key']
|
36
36
|
assert_equal 32, cs['uuid'].length
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def test_update
|
40
40
|
cs = Zedlocales::ContentScopes.update(:user_key => @uu['user_key'],
|
41
41
|
:uuid => con_scopes[0]['uuid'], :scope => { :key => "updated" })
|
42
42
|
assert_equal 'updated', cs['key']
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
47
|
-
assert_equal cs, {}
|
45
|
+
def test_delete
|
46
|
+
assert_nil Zedlocales::ContentScopes.delete(:user_key => @uu['user_key'], :uuid => con_scopes[0]['uuid'])
|
48
47
|
end
|
49
48
|
end
|
@@ -25,26 +25,26 @@ class TestContentSections < Test::Unit::TestCase
|
|
25
25
|
assert_equal 'whatever', ss[0]['key']
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def test_get
|
29
29
|
ss = Zedlocales::ContentSections.get(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid'])
|
30
30
|
assert_equal 'whatever', ss['key']
|
31
31
|
assert_equal 32, ss['uuid'].length
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def test_create
|
35
35
|
ss = Zedlocales::ContentSections.create(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
36
36
|
:section => { :key => 'newsection' })
|
37
37
|
assert_equal 32, ss['uuid'].length
|
38
38
|
assert_equal 'newsection', ss['key']
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def test_update
|
42
42
|
ss = Zedlocales::ContentSections.update(:user_key => @uu['user_key'],
|
43
43
|
:uuid => con_sections[0]['uuid'], :section => { :key => 'updatedsection' })
|
44
44
|
assert_equal 'updatedsection', ss['key']
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
|
47
|
+
def test_delete
|
48
|
+
assert_nil Zedlocales::ContentSections.delete(:user_key => @uu['user_key'], :uuid => con_sections[0]['uuid'])
|
49
49
|
end
|
50
50
|
end
|
data/test/test_projects.rb
CHANGED
@@ -50,9 +50,7 @@ class TestProjects < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_delete_locale_connection
|
53
|
-
|
54
|
-
|
55
|
-
assert pl.is_a? Hash
|
56
|
-
assert_equal pl, {}
|
53
|
+
assert_nil Zedkit::Projects::Locales.delete(:user_key => @uu['user_key'], :project => { :uuid => @uu['projects'][0] },
|
54
|
+
:locale => { :code => 'fr'})
|
57
55
|
end
|
58
56
|
end
|
data/test/test_translations.rb
CHANGED
@@ -18,14 +18,14 @@
|
|
18
18
|
require 'helper'
|
19
19
|
|
20
20
|
class TestContent < Test::Unit::TestCase
|
21
|
-
def
|
21
|
+
def test_get
|
22
22
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
23
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
|
-
def
|
28
|
+
def test_create
|
29
29
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
30
30
|
tt = Zedlocales::Translations.create(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] },
|
31
31
|
:translation => { :locale => 'de', :source => 'ZEDKIT', :translation => 'yo' })
|
@@ -33,7 +33,7 @@ class TestContent < Test::Unit::TestCase
|
|
33
33
|
assert_equal 'yo', tt['translation']
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def test_update
|
37
37
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
38
38
|
cc = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
39
39
|
tt = Zedlocales::Translations.update(:user_key => @uu['user_key'],
|
@@ -43,10 +43,9 @@ class TestContent < Test::Unit::TestCase
|
|
43
43
|
assert_equal 'yo', tt['translation']
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def test_destroy
|
47
47
|
cs = Zedlocales::ContentScopes::Content.get(:user_key => @uu['user_key'], :scope => { :uuid => con_scopes[0]['uuid'] })
|
48
48
|
cc = Zedlocales::Content::Translations.get(:user_key => @uu['user_key'], :content => { :uuid => cs[0]['uuid'] })
|
49
|
-
|
50
|
-
assert_equal tt['content']['uuid'], cs[0]['uuid']
|
49
|
+
assert_nil Zedlocales::Translations.delete(:user_key => @uu['user_key'], :uuid => cc[0]['uuid'])
|
51
50
|
end
|
52
51
|
end
|
metadata
CHANGED
@@ -5,17 +5,17 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 3
|
9
|
+
version: 1.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
-
|
12
|
+
- Zedkit
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
17
|
+
date: 2011-01-06 00:00:00 -08:00
|
18
|
+
default_executable: zedlocales
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: zedkit
|
@@ -61,9 +61,9 @@ dependencies:
|
|
61
61
|
type: :runtime
|
62
62
|
version_requirements: *id003
|
63
63
|
description: gem for localization support in Zedkit applications to generate locale files and load translations via the Zedkit API
|
64
|
-
email:
|
65
|
-
executables:
|
66
|
-
|
64
|
+
email: support@zedkit.com
|
65
|
+
executables:
|
66
|
+
- zedlocales
|
67
67
|
extensions: []
|
68
68
|
|
69
69
|
extra_rdoc_files:
|
@@ -74,6 +74,9 @@ files:
|
|
74
74
|
- README.rdoc
|
75
75
|
- Rakefile
|
76
76
|
- VERSION
|
77
|
+
- lib/cli/config.rb
|
78
|
+
- lib/cli/projects.rb
|
79
|
+
- lib/cli/runner.rb
|
77
80
|
- lib/tasks/generate.rake
|
78
81
|
- lib/zedlocales.rb
|
79
82
|
- lib/zedlocales/content.rb
|
@@ -91,8 +94,9 @@ files:
|
|
91
94
|
- test/test_projects.rb
|
92
95
|
- test/test_simple_backend.rb
|
93
96
|
- test/test_translations.rb
|
97
|
+
- bin/zedlocales
|
94
98
|
has_rdoc: true
|
95
|
-
homepage: http://github.com/
|
99
|
+
homepage: http://github.com/zedkit/zedlocales
|
96
100
|
licenses: []
|
97
101
|
|
98
102
|
post_install_message:
|