establish 0.0.25 → 0.0.26
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.rb +32 -2
- data/lib/establish/app_metadata.rb +57 -0
- data/lib/establish/itunes_transporter.rb +34 -5
- data/lib/establish/version.rb +1 -1
- data/lib/establish.rb +1 -0
- data/spec/app_metadata_spec.rb +26 -0
- data/spec/app_spec.rb +37 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1565c65a2866c66db980533a1fd6e1487f53a6407aff769130f72c724997dc0
|
4
|
+
data.tar.gz: 3375023d4ec987c1d2ee6c87cbd39191674a5b2fcfb390d3cd7c0a6dc9b67d7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf04845085479a3aae363a1be6b6b32106d9a3ebf18dd373df2db3e802eb8efeff983a0e35848ce934eabba8b21998e2653298590ff713ea22a4a35468070c5d
|
7
|
+
data.tar.gz: f24bd4dc68af13149226ead11f61bacc7c1af43b2aff1f5bf5093c198d75815583993877b7c03ea586c27e47763a619f216ba6166fd86b11f7dd12f156569aac
|
data/lib/establish/app.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Establish
|
2
2
|
class App
|
3
|
-
attr_accessor :apple_id, :app_identifier
|
3
|
+
attr_accessor :apple_id, :app_identifier, :metadata, :metadata_dir
|
4
|
+
|
5
|
+
|
4
6
|
|
5
7
|
module AppStatus
|
6
8
|
# As specified by Apple: https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/ChanginAppStatus.html
|
@@ -28,6 +30,7 @@ module Establish
|
|
28
30
|
self.app_identifier = app_identifier
|
29
31
|
|
30
32
|
if apple_id and not app_identifier
|
33
|
+
# Fetch the app identifier based on the given Apple ID
|
31
34
|
self.app_identifier = Establish::ItunesSearchApi.fetch_bundle_identifier(apple_id)
|
32
35
|
Helper.log.debug "Created app with ID #{apple_id} and app_identifier #{self.app_identifier}"
|
33
36
|
end
|
@@ -49,10 +52,37 @@ module Establish
|
|
49
52
|
"#{apple_id} - #{app_identifier}"
|
50
53
|
end
|
51
54
|
|
52
|
-
#
|
55
|
+
# Use this method to change the default download location for the metadata packages
|
56
|
+
def set_metadata_directory(dir)
|
57
|
+
raise "Can not change metadata directory after accessing metdata of an app" if @metadata
|
58
|
+
self.metadata_dir = dir
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_metadata_directory
|
62
|
+
metdata_dir || './'
|
63
|
+
end
|
64
|
+
|
65
|
+
def metadata
|
66
|
+
@metadata ||= Establish::AppMetadata.new(self, get_metadata_directory)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
#####################################################
|
71
|
+
# Destructive/Constructive methods
|
72
|
+
#####################################################
|
53
73
|
|
54
74
|
def create_new_version!(version_number)
|
55
75
|
itc.create_new_version!(self, version_number)
|
56
76
|
end
|
77
|
+
|
78
|
+
# This method has to be called, after modifying the values of .metadata
|
79
|
+
# It will take care of uploading all changes to Apple
|
80
|
+
def upload_metadata!
|
81
|
+
raise "You first have to modify the metadata using app.metadata.setDescription" unless @metadata
|
82
|
+
|
83
|
+
self.metadata.upload!
|
84
|
+
end
|
85
|
+
|
86
|
+
|
57
87
|
end
|
58
88
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Establish
|
4
|
+
class AppMetadata
|
5
|
+
APPLE_ITUNES_NAMESPACE = "http://apple.com/itunes/importer"
|
6
|
+
|
7
|
+
attr_accessor :metadata_dir
|
8
|
+
|
9
|
+
def transporter
|
10
|
+
@transporter ||= ItunesTransporter.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(app, dir)
|
14
|
+
self.metadata_dir = dir
|
15
|
+
@app = app
|
16
|
+
|
17
|
+
# we want to update the metadata, so first we have to download the existing one
|
18
|
+
transporter.download(app, dir)
|
19
|
+
|
20
|
+
# Parse the downloaded package
|
21
|
+
parse_package(dir)
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
#####################################################
|
26
|
+
# Updating metadata information
|
27
|
+
#####################################################
|
28
|
+
|
29
|
+
# Update the app description which is shown in the AppStore
|
30
|
+
def update_description(hash)
|
31
|
+
raise "Please pass a hash of languages to this method" unless hash.kind_of?Hash
|
32
|
+
|
33
|
+
# TODO: Implement
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
#####################################################
|
38
|
+
# Uploading the updated metadata
|
39
|
+
#####################################################
|
40
|
+
|
41
|
+
# Actually upload the updated metadata to Apple
|
42
|
+
def upload!
|
43
|
+
transporter.upload(@app, @app.get_metadata_directory)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def modify_value(xpath, new_value)
|
48
|
+
binding.pry
|
49
|
+
|
50
|
+
@data.xpath("//x:#{xpath}", "x" => APPLE_ITUNES_NAMESPACE)
|
51
|
+
end
|
52
|
+
|
53
|
+
def parse_package(path)
|
54
|
+
@data ||= Nokogiri::XML(File.read("#{self.metadata_dir}/#{@app.apple_id}.itmsp/metadata.xml"))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -14,11 +14,22 @@ module Establish
|
|
14
14
|
@password = (password || PasswordManager.new.password)
|
15
15
|
end
|
16
16
|
|
17
|
-
def download(app)
|
17
|
+
def download(app, dir = nil)
|
18
18
|
raise "No valid Establish::App given" unless app.kind_of?Establish::App
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
dir ||= app.get_metadata_directory
|
21
|
+
command = build_download_command(@user, @password, app.apple_id, dir)
|
22
|
+
|
23
|
+
self.execute_transporter(command)
|
24
|
+
end
|
25
|
+
|
26
|
+
def upload(app, dir)
|
27
|
+
raise "No valid Establish::App given" unless app.kind_of?Establish::App
|
28
|
+
|
29
|
+
dir ||= app.get_metadata_directory
|
30
|
+
dir += "/#{app.apple_id}.itmsp"
|
31
|
+
|
32
|
+
command = build_upload_command(@user, @password, app.apple_id, dir)
|
22
33
|
|
23
34
|
self.execute_transporter(command)
|
24
35
|
end
|
@@ -49,7 +60,11 @@ module Establish
|
|
49
60
|
errors << ex.to_s
|
50
61
|
end
|
51
62
|
|
52
|
-
|
63
|
+
if errors.count > 0
|
64
|
+
Helper.log.debug(caller)
|
65
|
+
raise errors.join("\n")
|
66
|
+
end
|
67
|
+
|
53
68
|
true
|
54
69
|
end
|
55
70
|
|
@@ -59,11 +74,25 @@ module Establish
|
|
59
74
|
Helper.transporter_path,
|
60
75
|
"-m lookupMetadata",
|
61
76
|
"-u \"#{useername}\"",
|
62
|
-
"-p '#{password
|
77
|
+
"-p '#{escaped_password(password)}'",
|
63
78
|
"-apple_id #{apple_id}",
|
64
79
|
"-destination '#{destination}'"
|
65
80
|
].join(' ')
|
66
81
|
end
|
67
82
|
|
83
|
+
def build_upload_command(username, password, apple_id, source = "/tmp")
|
84
|
+
[
|
85
|
+
Helper.transporter_path,
|
86
|
+
"-m upload",
|
87
|
+
"-u \"#{username}\"",
|
88
|
+
"-p '#{escaped_password(password)}'",
|
89
|
+
"-f '#{source}'"
|
90
|
+
].join(' ')
|
91
|
+
end
|
92
|
+
|
93
|
+
def escaped_password(password)
|
94
|
+
password.gsub('$', '\\$')
|
95
|
+
end
|
96
|
+
|
68
97
|
end
|
69
98
|
end
|
data/lib/establish/version.rb
CHANGED
data/lib/establish.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
describe Establish do
|
2
|
+
describe Establish::AppMetadata do
|
3
|
+
let (:apple_id) { 794902327 }
|
4
|
+
let (:app_identifier) { 'net.sunapps.1' }
|
5
|
+
|
6
|
+
describe "#update_description" do
|
7
|
+
before do
|
8
|
+
@app = Establish::App.new(apple_id, app_identifier)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "throws an exception when a string is given instead of a string" do
|
12
|
+
except {
|
13
|
+
@app.metadata.update_description("something")
|
14
|
+
}.to raise_error("Please pass a hash of languages to this method")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "updates the description when a hash is given", now: true do
|
18
|
+
@app.metadata.update_description({
|
19
|
+
'de' => "new"
|
20
|
+
})
|
21
|
+
# TODO
|
22
|
+
# @app.upload_metadata!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/app_spec.rb
CHANGED
@@ -2,6 +2,7 @@ describe Establish do
|
|
2
2
|
describe Establish::App do
|
3
3
|
let (:apple_id) { 284882215 }
|
4
4
|
let (:app_identifier) { 'com.facebook.Facebook' }
|
5
|
+
|
5
6
|
describe "#initialize" do
|
6
7
|
it "automatically fetches the app identifier, if only Apple ID is given" do
|
7
8
|
app = Establish::App.new(apple_id)
|
@@ -11,7 +12,7 @@ describe Establish do
|
|
11
12
|
end
|
12
13
|
|
13
14
|
it "lets me create an app using an Apple ID and app identifier" do
|
14
|
-
app = Establish::App.new(apple_id,
|
15
|
+
app = Establish::App.new(apple_id, app_identifier)
|
15
16
|
|
16
17
|
app.app_identifier.should eq(app_identifier)
|
17
18
|
app.apple_id.should eq(apple_id)
|
@@ -21,5 +22,40 @@ describe Establish do
|
|
21
22
|
Establish::App.new.app_identifier.should eq(nil)
|
22
23
|
end
|
23
24
|
end
|
25
|
+
|
26
|
+
|
27
|
+
describe "Accessing App Metadata", felix: true do
|
28
|
+
before do
|
29
|
+
@app = Establish::App.new(794902327, 'net.sunapps.1')
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#set_metadata_directory" do
|
33
|
+
|
34
|
+
it "throws an exception when updating the location after accessing metadata" do
|
35
|
+
@app.metadata
|
36
|
+
except {
|
37
|
+
@app.set_metadata_directory("something")
|
38
|
+
}.to raise_error("Can not change metadata directory after accessing metadata of an app")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "let's the user modify the download directory" do
|
42
|
+
@app.get_metadata_directory.should eq('./')
|
43
|
+
|
44
|
+
alternative = '/tmp/something'
|
45
|
+
@app.set_metadata_directory(alternative)
|
46
|
+
|
47
|
+
@app.get_metadata_directory.should eq(alternative)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#upload_metadata!" do
|
53
|
+
it "throws an exception when metadata was not yet downloaded" do
|
54
|
+
except {
|
55
|
+
@app.upload_metadata!
|
56
|
+
}.to raise_error("You first have to modify the metadata using app.metadata.setDescription")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
24
60
|
end
|
25
61
|
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.
|
4
|
+
version: 0.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincenzo Fehring
|
@@ -154,12 +154,14 @@ files:
|
|
154
154
|
- establish.gemspec
|
155
155
|
- lib/establish.rb
|
156
156
|
- lib/establish/app.rb
|
157
|
+
- lib/establish/app_metadata.rb
|
157
158
|
- lib/establish/helper.rb
|
158
159
|
- lib/establish/itunes_connect.rb
|
159
160
|
- lib/establish/itunes_search_api.rb
|
160
161
|
- lib/establish/itunes_transporter.rb
|
161
162
|
- lib/establish/password_manager.rb
|
162
163
|
- lib/establish/version.rb
|
164
|
+
- spec/app_metadata_spec.rb
|
163
165
|
- spec/app_spec.rb
|
164
166
|
- spec/helper_spec.rb
|
165
167
|
- spec/itunes_connect_spec.rb
|
@@ -192,6 +194,7 @@ signing_key:
|
|
192
194
|
specification_version: 4
|
193
195
|
summary: Updating your iOS app should not be painful and time consuming.
|
194
196
|
test_files:
|
197
|
+
- spec/app_metadata_spec.rb
|
195
198
|
- spec/app_spec.rb
|
196
199
|
- spec/helper_spec.rb
|
197
200
|
- spec/itunes_connect_spec.rb
|