establish 0.0.26 → 0.0.27
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 +57 -9
- 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: a903044842b73b828911ed1f4834f63ad4e58b7cc2c32a0610380c44244503c6
|
4
|
+
data.tar.gz: 300bba595145f9e55748b0fb9eb306ecea46d44998bd1ea6b903181a7bf82ac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f186e0b65aa020ed0c2e5c8aff7e4af66898ebaa96eb004e26c887367219caa53cf27a7c095c5269c80098a4db013f0fc6532c1c018e4ac1c04cefd59e8a7c
|
7
|
+
data.tar.gz: 285ea4a771adc5fdbeade8f2eaa154a2321ae8fa806da8dd30108ee5b9cee8f3cd0698bf31abd8f3f6dd6944987ab741787b77fe3a49502274e0da478b0ffe44
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
|
3
3
|
module Establish
|
4
|
+
class AppMetadataError < StandardError
|
5
|
+
|
6
|
+
end
|
7
|
+
|
4
8
|
class AppMetadata
|
5
|
-
|
9
|
+
ITUNES_NAMESPACE = "http://apple.com/itunes/importer"
|
6
10
|
|
7
11
|
attr_accessor :metadata_dir
|
8
12
|
|
@@ -28,9 +32,7 @@ module Establish
|
|
28
32
|
|
29
33
|
# Update the app description which is shown in the AppStore
|
30
34
|
def update_description(hash)
|
31
|
-
|
32
|
-
|
33
|
-
# TODO: Implement
|
35
|
+
update_localized_value('description', hash)
|
34
36
|
end
|
35
37
|
|
36
38
|
|
@@ -44,14 +46,60 @@ module Establish
|
|
44
46
|
end
|
45
47
|
|
46
48
|
private
|
47
|
-
def modify_value(xpath, new_value)
|
48
|
-
binding.pry
|
49
49
|
|
50
|
-
|
50
|
+
# Usage: '//x:keyword'
|
51
|
+
def fetch_value(xpath)
|
52
|
+
@data.xpath(xpath, "x" => ITUNES_NAMESPACE)
|
53
|
+
end
|
54
|
+
|
55
|
+
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
|
57
|
+
|
58
|
+
fetch_value("//x:locale").each do |locale|
|
59
|
+
key = locale['name']
|
60
|
+
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}"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
Helper.log.error "Could not find '#{xpath_name}' for #{key}. It was provided before. Not updating this value"
|
68
|
+
end
|
51
69
|
end
|
70
|
+
end
|
52
71
|
|
72
|
+
# Parses the metadata using nokogiri
|
53
73
|
def parse_package(path)
|
54
|
-
@data ||= Nokogiri::XML(File.read("#{
|
74
|
+
@data ||= Nokogiri::XML(File.read("#{path}/#{@app.apple_id}.itmsp/metadata.xml"))
|
75
|
+
verify_package
|
76
|
+
clean_package
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks if there is a non live version available
|
80
|
+
# (a new version, or a new app)
|
81
|
+
def verify_package
|
82
|
+
versions = fetch_value("//x:version")
|
83
|
+
|
84
|
+
# TODO: This does not work for new apps
|
85
|
+
raise AppMetadataError.new("You have to create a new version before modifying the app metadata") if versions.count == 1
|
86
|
+
|
87
|
+
raise AppMetadataError.new("metadata_token is missing") if fetch_value("//x:metadata_token").count != 1
|
88
|
+
end
|
89
|
+
|
90
|
+
# Cleans up the package of stuff we do not want to modify/upload
|
91
|
+
def clean_package
|
92
|
+
|
93
|
+
|
94
|
+
# Remove the live version (if it exists)
|
95
|
+
versions = fetch_value("//x:version")
|
96
|
+
while versions.count > 1
|
97
|
+
versions.last.remove
|
98
|
+
versions = fetch_value("//x:version")
|
99
|
+
end
|
100
|
+
Helper.log.info "Modifying version '#{versions.first.attr('string')}' of app #{@app.app_identifier}"
|
101
|
+
|
102
|
+
|
55
103
|
end
|
56
104
|
end
|
57
|
-
end
|
105
|
+
end
|
data/lib/establish/version.rb
CHANGED