establish 0.0.21 → 0.0.22

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: 518e3050b1d74072f42d4f2adb101cb9ff32fef0e3c41953190b4d60db66d588
4
- data.tar.gz: d456334bc98a30925f2062304215320ba7ef970581c1c0a14ced65724a678dd7
3
+ metadata.gz: 56fb735050c9180935b7240f2dc5c9df0361dd4a401375050385c5907d44ab22
4
+ data.tar.gz: 84f69a19579d76a71cb17edf51721354d3535655df2691abbc62cfba56346485
5
5
  SHA512:
6
- metadata.gz: 1f9d58699e6c5944d305460f6059af18807e8b604eb1589a0d3b8ca92e716f4f3430e87697e2fc65049300b4819af12860965107df4deaabef5d9c14a3ad58bc
7
- data.tar.gz: 6cf6bb1f1ccd68c95f7d7fbc5f6c7c3542839bc64d691935e5dc13b7164373dd140e63ce7a5b2db961c20c185eda0227e1af8d46e99d01743d6223a6467e7e58
6
+ metadata.gz: b98147df552d896c5e3bf872136c1fa12f82afe7c3db4e05e04e6dfd22233b2f2b9619b0eb2dfff5bb49f2549593909f8d007496fb70915a7f3f17ea47643489
7
+ data.tar.gz: 220f3049b1792f88663f39c1974d3db7772df7464d716108ed65b833752e6a2fcf9a230e99ff15491ec664cb6411ab9881ef0f4f12a78e8dfa0793e92f1f1178
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ PATH
3
3
  specs:
4
4
  establish (0.0.1)
5
5
  capybara
6
+ highline
6
7
  poltergeist
7
8
  security
8
9
 
@@ -18,6 +19,7 @@ GEM
18
19
  cliver (0.3.2)
19
20
  coderay (1.1.0)
20
21
  diff-lcs (1.2.5)
22
+ highline (1.6.21)
21
23
  method_source (0.8.2)
22
24
  mime-types (2.3)
23
25
  mini_portile (0.6.0)
data/establish.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "capybara"
24
24
  spec.add_dependency "poltergeist"
25
25
  spec.add_dependency "security" # Mac OS Keychain manager
26
+ spec.add_dependency 'highline'
26
27
 
27
28
  spec.add_development_dependency "bundler", "~> 1.6"
28
29
  spec.add_development_dependency "rake"
@@ -0,0 +1,69 @@
1
+ require 'pty'
2
+
3
+ require 'establish/password_manager'
4
+
5
+
6
+ module Establish
7
+ class ItunesTransporter
8
+ ERROR_REGEX = />\s*ERROR:\s+(.+)/
9
+ WARNING_REGEX = />\s*WARN:\s+(.+)/
10
+ OUTPUT_REGEX = />\s+(.+)/
11
+
12
+ def initialize(user = nil, password = nil)
13
+ @user = (user || PasswordManager.new.username)
14
+ @password = (password || PasswordManager.new.password)
15
+ end
16
+
17
+ def download(app)
18
+ raise "No valid Establish::App given" unless app.kind_of?Establish::App
19
+
20
+ command = build_download_command(@user, @password, app.apple_id)
21
+ Helper.log.debug command
22
+
23
+ self.execute_transporter(command)
24
+ end
25
+
26
+ def execute_transporter(command)
27
+ # Taken from https://github.sshaw/itunes_store_transporter/blob/master/lib/itunes/store/transporter/output_parser.rb
28
+
29
+ errors = []
30
+ warnings = []
31
+
32
+ begin
33
+ PTY.spawn(command) do |stdin, stdout, pid|
34
+ stdin.each do |line|
35
+ if line =~ ERROR_REGEX
36
+ errors << $1
37
+ elsif line =~ WARNING_REGEX
38
+ warnings << $1
39
+ end
40
+
41
+ if line =~ OUTPUT_REGEX
42
+ # General logging for debug purposes
43
+ Helper.log.debug "[Transporter Output]: #{$1}"
44
+ end
45
+ end
46
+ end
47
+ rescue Exception => ex
48
+ Helper.log.fatal(ex.to_s)
49
+ errors << ex.to_s
50
+ end
51
+
52
+ raise errors.join("\n") if errors.count > 0
53
+ true
54
+ end
55
+
56
+ private
57
+ def build_download_command(username, password, apple_id, destination = "/tmp")
58
+ [
59
+ Helper.transporter_path,
60
+ "-m lookupMetadata",
61
+ "-u \"#{useername}\"",
62
+ "-p '#{password.gsub('$', '\\$')}'",
63
+ "-apple_id #{apple_id}",
64
+ "-destination '#{destination}'"
65
+ ].join(' ')
66
+ end
67
+
68
+ end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module Establish
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
data/lib/establish.rb CHANGED
@@ -3,6 +3,7 @@ require 'establish/helper'
3
3
  require 'establish/app'
4
4
  require 'establish/itunes_connect'
5
5
  require 'establish/itunes_search_api'
6
+ require 'establish/itunes_transporter'
6
7
 
7
8
  module Establish
8
9
  # Your code goes here...
@@ -3,7 +3,7 @@ describe Establish do
3
3
  it "returns nil when it could not be found" do
4
4
  Establish::ItunesSearchApi.fetch("invalid").should eq(nil)
5
5
  Establish::ItunesSearchApi.fetch("").should eq(nil)
6
- Establish::ItunesSearchApi.fetch(123).should eq(nil)
6
+ Establish::ItunesSearchApi.fetch(0).should eq(nil)
7
7
  end
8
8
 
9
9
  it "returns the actual object if it could be found" do
@@ -0,0 +1,26 @@
1
+ describe Establish do
2
+ describe Establish::ItunesTransporter, new: true do
3
+ before do
4
+ @app = Establish::App.new(284882215, 'com.facebook.Facebook')
5
+ end
6
+
7
+ describe "#download" do
8
+ it "throws an exception when invalid parameter is given" do
9
+ except {
10
+ Establish::ItunesTransporter.new.download(123)
11
+ }.to raise_error "No valid Establish::App given"
12
+ end
13
+
14
+ it "downloads the package" do
15
+ exception {
16
+ Establish::ItunesTransporter.new("email@email.com", "login").download(@app).should eq(true)
17
+ }.to raise_error(/.*This Apple ID has been locked for security reasons.*/)
18
+ end
19
+
20
+ it "works with correct inputs" do
21
+ @app.apple_id = 794902327
22
+ Establish::ItunesTransporter.new.download(@app).should eq(true)
23
+ end
24
+ end
25
+ end
26
+ 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.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincenzo Fehring
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: highline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -129,12 +143,14 @@ files:
129
143
  - lib/establish/helper.rb
130
144
  - lib/establish/itunes_connect.rb
131
145
  - lib/establish/itunes_search_api.rb
146
+ - lib/establish/itunes_transporter.rb
132
147
  - lib/establish/password_manager.rb
133
148
  - lib/establish/version.rb
134
149
  - spec/app_spec.rb
135
150
  - spec/helper_spec.rb
136
151
  - spec/itunes_connect_spec.rb
137
152
  - spec/itunes_search_api_spec.rb
153
+ - spec/itunes_transporter_spec.rb
138
154
  - spec/password_manager_spec.rb
139
155
  - spec/spec_helper.rb
140
156
  - tasks/rspec.rake
@@ -166,5 +182,6 @@ test_files:
166
182
  - spec/helper_spec.rb
167
183
  - spec/itunes_connect_spec.rb
168
184
  - spec/itunes_search_api_spec.rb
185
+ - spec/itunes_transporter_spec.rb
169
186
  - spec/password_manager_spec.rb
170
187
  - spec/spec_helper.rb