establish 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/establish/app_metadata.rb +32 -7
- data/lib/establish/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e73d84463e51f762a16f3af689703839b546b43e9ce88245cf0d80d3b8c2501d
|
4
|
+
data.tar.gz: b8ef4a5aec5949a44905deaa0898e8e39b9e0d73220adc551de8a974b55791d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4068c39e807b38aec16a018f5894a7f969879535c579c16de2aca1eeeaa035ba118567d0883010241533c7ee7b11dca4d1103bf8f7745569d1beff3a1cba4a24
|
7
|
+
data.tar.gz: e730669e5898ef9e4a45a63cbf74fbdd90a638e025d876fd2197a7ac50a42f1f682d7f4d31fd331fa5574ff295ecd68a5bb29cf328168db103c5fbef5076941a
|
@@ -2,7 +2,8 @@ require 'nokogiri'
|
|
2
2
|
|
3
3
|
module Establish
|
4
4
|
class AppMetadataError < StandardError
|
5
|
-
|
5
|
+
end
|
6
|
+
class AppMetadataParameterError < StandardError
|
6
7
|
end
|
7
8
|
|
8
9
|
class AppMetadata
|
@@ -32,7 +33,28 @@ module Establish
|
|
32
33
|
|
33
34
|
# Update the app description which is shown in the AppStore
|
34
35
|
def update_description(hash)
|
35
|
-
update_localized_value('description', hash)
|
36
|
+
update_localized_value('description', hash) do |field, new_val|
|
37
|
+
raise AppMetadataParameterError.new("Parameter needs to be as hash, containing strings with the new description") unless new_val.kind_of?String
|
38
|
+
|
39
|
+
field.content = new_val
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Update the app keywords
|
44
|
+
def update_keywords(hash)
|
45
|
+
update_localized_value('keywords', hash) do |field, keywords|
|
46
|
+
raise AppMetadataParameterError.new("Parameter needs to be a hash (each language) with an array of keywords in it") unless keywords.kind_of?Array
|
47
|
+
|
48
|
+
field.children.remove # remove old keywords
|
49
|
+
|
50
|
+
node_set = Nokogiri::XML::NodeSet.new(@data)
|
51
|
+
keywords.each do |word|
|
52
|
+
keyword = Nokogiri::XML::Node.new('Keyord', @data)
|
53
|
+
node_set << keywrod
|
54
|
+
end
|
55
|
+
|
56
|
+
field.children = node_set
|
57
|
+
end
|
36
58
|
end
|
37
59
|
|
38
60
|
|
@@ -53,15 +75,18 @@ module Establish
|
|
53
75
|
end
|
54
76
|
|
55
77
|
def update_localized_value(xpath_name, new_value)
|
56
|
-
raise "Please pass a hash of languages to this method" unless new_value.kind_of?Hash
|
78
|
+
raise AppMetadataParameterError.new("Please pass a hash of languages to this method") unless new_value.kind_of?Hash
|
79
|
+
raise AppMetadataParameterError.new("Please pass a block, which updates the resulting node") unless block_given?
|
57
80
|
|
58
81
|
fetch_value("//x:locale").each do |locale|
|
59
82
|
key = locale['name']
|
60
83
|
if new_value[key]
|
61
|
-
|
62
|
-
if
|
63
|
-
|
64
|
-
Helper.log.
|
84
|
+
field = locale.search(xpath_name).first
|
85
|
+
if field.content != new_value[key]
|
86
|
+
yield(field, new_value[key])
|
87
|
+
Helper.log.info "Updated #{xpath_name} for locale #{key}"
|
88
|
+
else
|
89
|
+
Helper.log.info "Did not update #{xpath_name} for locale #{locale}, since it hasn't changed"
|
65
90
|
end
|
66
91
|
else
|
67
92
|
Helper.log.error "Could not find '#{xpath_name}' for #{key}. It was provided before. Not updating this value"
|
data/lib/establish/version.rb
CHANGED