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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a903044842b73b828911ed1f4834f63ad4e58b7cc2c32a0610380c44244503c6
4
- data.tar.gz: 300bba595145f9e55748b0fb9eb306ecea46d44998bd1ea6b903181a7bf82ac9
3
+ metadata.gz: e73d84463e51f762a16f3af689703839b546b43e9ce88245cf0d80d3b8c2501d
4
+ data.tar.gz: b8ef4a5aec5949a44905deaa0898e8e39b9e0d73220adc551de8a974b55791d1
5
5
  SHA512:
6
- metadata.gz: a9f186e0b65aa020ed0c2e5c8aff7e4af66898ebaa96eb004e26c887367219caa53cf27a7c095c5269c80098a4db013f0fc6532c1c018e4ac1c04cefd59e8a7c
7
- data.tar.gz: 285ea4a771adc5fdbeade8f2eaa154a2321ae8fa806da8dd30108ee5b9cee8f3cd0698bf31abd8f3f6dd6944987ab741787b77fe3a49502274e0da478b0ffe44
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
- description_field = locale.search(xpath_name).first
62
- if description_field.content != new_value[key]
63
- description_field.content = new_value[key]
64
- Helper.log.debug "Updated #{xpath_name} for locale #{locale}"
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"
@@ -1,3 +1,3 @@
1
1
  module Establish
2
- VERSION = "0.0.27"
2
+ VERSION = "0.0.28"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: establish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincenzo Fehring