itunes_store_transporter 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +21 -1
- data/README.rdoc +6 -5
- data/lib/itunes/store/transporter.rb +1 -0
- data/lib/itunes/store/transporter/command.rb +4 -2
- data/lib/itunes/store/transporter/command/providers.rb +2 -1
- data/lib/itunes/store/transporter/command/schema.rb +3 -2
- data/lib/itunes/store/transporter/command/status.rb +18 -25
- data/lib/itunes/store/transporter/command/status_all.rb +21 -0
- data/lib/itunes/store/transporter/command/upload.rb +6 -0
- data/lib/itunes/store/transporter/command/verify.rb +1 -0
- data/lib/itunes/store/transporter/errors.rb +9 -8
- data/lib/itunes/store/transporter/itms_transporter.rb +9 -2
- data/lib/itunes/store/transporter/output_parser.rb +1 -0
- data/lib/itunes/store/transporter/shell.rb +17 -3
- data/lib/itunes/store/transporter/version.rb +1 -1
- data/lib/itunes/store/transporter/xml/status.rb +145 -0
- data/spec/command_spec.rb +156 -62
- data/spec/fixtures/status.yml +55 -23
- data/spec/output_parser_spec.rb +25 -9
- data/spec/shell_spec.rb +17 -12
- data/spec/spec_helper.rb +12 -1
- data/spec/transporter_spec.rb +19 -0
- data/spec/xml_status_spec.rb +60 -0
- data/spec/xml_status_spec.rb~ +22 -0
- metadata +9 -3
data/spec/output_parser_spec.rb
CHANGED
@@ -7,20 +7,36 @@ describe ITunes::Store::Transporter::OutputParser do
|
|
7
7
|
context "without an error code" do
|
8
8
|
before(:all) { @parser = described_class.new(fixture("errors_and_warnings.no_error_number")) }
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it "has no warnings" do
|
11
|
+
expect(@parser.warnings).to be_empty
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has two errors" do
|
15
|
+
expect(@parser.errors.size).to eq 2
|
16
|
+
end
|
13
17
|
|
14
18
|
describe "the first error" do
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
before { @error = @parser.errors[0] }
|
20
|
+
|
21
|
+
it "has a nil code" do
|
22
|
+
expect(@error.code).to be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has the right error message" do
|
26
|
+
expect(@error.message).to eq "An error occurred while doing fun stuff"
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
describe "the second error" do
|
21
|
-
|
22
|
-
|
23
|
-
|
31
|
+
before { @error = @parser.errors[1] }
|
32
|
+
|
33
|
+
it "has a nil code" do
|
34
|
+
expect(@error.code).to be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has the right error message" do
|
38
|
+
expect(@error.message).to eq "An exception has occurred: network timeout"
|
39
|
+
end
|
24
40
|
end
|
25
41
|
end
|
26
42
|
|
data/spec/shell_spec.rb
CHANGED
@@ -32,12 +32,12 @@ describe ITunes::Store::Transporter::Shell do
|
|
32
32
|
output << [ stream, line.chomp! ]
|
33
33
|
end
|
34
34
|
|
35
|
-
output.
|
35
|
+
expect(output).to eq expect
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "#exec" do
|
39
39
|
it "requires a block" do
|
40
|
-
|
40
|
+
expect { described_class.new.exec([]) }.to raise_exception(ArgumentError, "block required")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,32 +45,37 @@ describe ITunes::Store::Transporter::Shell do
|
|
45
45
|
before(:all) { ENV["PROGRAMFILES"] = "C:\\" }
|
46
46
|
|
47
47
|
it "selects the Windows executable" do
|
48
|
-
described_class.
|
49
|
-
described_class.
|
48
|
+
allow(described_class).to receive(:windows?).and_return(true)
|
49
|
+
allow(described_class).to receive(:osx?).and_return(false)
|
50
|
+
expect(described_class.new.path).to match /#{described_class::WINDOWS_EXE}\z/
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
context "when on OS X" do
|
54
|
-
before
|
55
|
+
before do
|
56
|
+
allow(described_class).to receive(:windows?).and_return(false)
|
57
|
+
allow(described_class).to receive(:osx?).and_return(true)
|
58
|
+
end
|
55
59
|
|
56
60
|
it "selects the right executable" do
|
57
|
-
exe = described_class::
|
58
|
-
File.
|
59
|
-
described_class.new.path.
|
61
|
+
exe = described_class::OSX_APPLICATION_LOADER_PATHS.first
|
62
|
+
allow(File).to receive(:exist?).and_return(true)
|
63
|
+
expect(described_class.new.path).to eq exe
|
60
64
|
end
|
61
65
|
|
62
66
|
context "and no OS X specific executable is found" do
|
63
67
|
it "defaults to the *nix executable" do
|
64
|
-
File.
|
65
|
-
described_class.new.path.
|
68
|
+
allow(File).to receive(:exist?).and_return(false)
|
69
|
+
expect(described_class.new.path).to eq described_class::DEFAULT_UNIX_PATH
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
74
|
context "when not on Windows or OS X" do
|
71
75
|
it "selects the right executable" do
|
72
|
-
described_class.
|
73
|
-
described_class.
|
76
|
+
allow(described_class).to receive(:windows?).and_return(false)
|
77
|
+
allow(described_class).to receive(:osx?).and_return(false)
|
78
|
+
expect(described_class.new.path).to match /#{described_class::EXE_NAME}\z/
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,17 @@ module SpecHelper
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def expect_shell_args(*expected)
|
19
|
-
|
19
|
+
output = expected.last.is_a?(Hash) ? expected.pop : {}
|
20
|
+
ITunes::Store::Transporter::Shell.any_instance.should_receive(:exec) do |*args, &block|
|
21
|
+
expect(args.first).to include(*expected)
|
22
|
+
|
23
|
+
[:stdout, :stderr].each do |fd|
|
24
|
+
next unless output[fd]
|
25
|
+
output[fd].each { |line| block.call(line, fd) }
|
26
|
+
end
|
27
|
+
|
28
|
+
0
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
def fixture(path)
|
@@ -32,6 +42,7 @@ module SpecHelper
|
|
32
42
|
[:stderr, :stdout].each do |fd|
|
33
43
|
fixture = options[fd]
|
34
44
|
next unless fixture
|
45
|
+
|
35
46
|
lines = Array === fixture ? fixture : Fixture.for(fixture)
|
36
47
|
outputs << [ lines, fd ]
|
37
48
|
end
|
data/spec/transporter_spec.rb
CHANGED
@@ -79,8 +79,27 @@ describe ITunes::Store::Transporter::ITMSTransporter do
|
|
79
79
|
describe "#status" do
|
80
80
|
let(:method) { :status }
|
81
81
|
let(:command) { "Status" }
|
82
|
+
let(:status) { double("status command") }
|
82
83
|
|
83
84
|
it_behaves_like "a transporter method without a package argument"
|
85
|
+
|
86
|
+
context "when given :all => true" do
|
87
|
+
it "runs the status all command" do
|
88
|
+
expect(ITunes::Store::Transporter::Command::StatusAll).to receive(:new).and_return(status)
|
89
|
+
expect(status).to receive(:run)
|
90
|
+
|
91
|
+
subject.status(:all => true)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "when given :all => false" do
|
96
|
+
it "runs the status command" do
|
97
|
+
expect(ITunes::Store::Transporter::Command::Status).to receive(:new).and_return(status)
|
98
|
+
expect(status).to receive(:run)
|
99
|
+
|
100
|
+
subject.status(:all => false)
|
101
|
+
end
|
102
|
+
end
|
84
103
|
end
|
85
104
|
|
86
105
|
describe "#upload" do
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe ITunes::Store::Transporter::XML::Status do
|
4
|
+
context "given a valid XML doc with a single status" do
|
5
|
+
it "returns a Hash with a single status" do
|
6
|
+
status = described_class.new.parse(fixture("status.vendor_id_123123").join(""))
|
7
|
+
expect(status).to eq [{:apple_id=>"X9123X",
|
8
|
+
:vendor_id=>"123123",
|
9
|
+
:content_status=>
|
10
|
+
{:status=>"Unpolished",
|
11
|
+
:review_status=>"Ready-NotReviewed",
|
12
|
+
:itunes_connect_status=>"Other",
|
13
|
+
:store_status=>
|
14
|
+
{:not_on_store=>[], :on_store=>[], :ready_for_store=>["US"]},
|
15
|
+
:video_components=>
|
16
|
+
[{:name=>"Video",
|
17
|
+
:locale=>nil,
|
18
|
+
:status=>"In Review",
|
19
|
+
:delivered=>"2011-11-30 01:41:10"},
|
20
|
+
{:name=>"Audio",
|
21
|
+
:locale=>"en-US",
|
22
|
+
:status=>"In Review",
|
23
|
+
:delivered=>"2011-11-30 01:41:10"}]},
|
24
|
+
:info=>[{:created=>"2016-11-25 10:38:09", :status=>"Imported"}]}]
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "given an invalid XML doc" do
|
30
|
+
it "raises a ParseError" do
|
31
|
+
expect {
|
32
|
+
described_class.new.parse("<>")
|
33
|
+
# Comment out to satisfy 1.9.3, it results in an "not well-formed" error
|
34
|
+
#}.to raise_error( ITunes::Store::Transporter::ParseError, /invalid xml/i)
|
35
|
+
}.to raise_error(ITunes::Store::Transporter::ParseError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "given an XML doc that's not well-formed" do
|
40
|
+
it "raises a ParseError" do
|
41
|
+
expect {
|
42
|
+
described_class.new.parse("<a><b></a>")
|
43
|
+
}.to raise_error(ITunes::Store::Transporter::ParseError, /not well-formed/i)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "given an XML doc that contains an error message" do
|
48
|
+
it "raises a ExecutionError containing the message and its code" do
|
49
|
+
expect {
|
50
|
+
described_class.new.parse(fixture("status.error_message").join("\n"))
|
51
|
+
}.to raise_error(ITunes::Store::Transporter::ExecutionError) { |e|
|
52
|
+
expect(e.errors.size).to eq 2
|
53
|
+
expect(e.errors[0].message).to eq "Error message one."
|
54
|
+
expect(e.errors[0].code).to eq -1234
|
55
|
+
expect(e.errors[1].message).to eq "Error message two."
|
56
|
+
expect(e.errors[1].code).to eq 9999
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe ITunes::Store::Transporter::XML::Status do
|
4
|
+
context "given a valid XML doc with a single status" do
|
5
|
+
it "returns a Hash with a single status" do
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
context "given a valid XML doc with multiple statuses" do
|
12
|
+
it "returns a Hash with multiple statuses" do
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "given an XML invalid XML doc" do
|
18
|
+
it "raises a ParseError" do
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes_store_transporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skye Shaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/itunes/store/transporter/command/providers.rb
|
94
94
|
- lib/itunes/store/transporter/command/schema.rb
|
95
95
|
- lib/itunes/store/transporter/command/status.rb
|
96
|
+
- lib/itunes/store/transporter/command/status_all.rb
|
96
97
|
- lib/itunes/store/transporter/command/upload.rb
|
97
98
|
- lib/itunes/store/transporter/command/verify.rb
|
98
99
|
- lib/itunes/store/transporter/command/version.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/itunes/store/transporter/output_parser.rb
|
102
103
|
- lib/itunes/store/transporter/shell.rb
|
103
104
|
- lib/itunes/store/transporter/version.rb
|
105
|
+
- lib/itunes/store/transporter/xml/status.rb
|
104
106
|
- spec/command_spec.rb
|
105
107
|
- spec/errors_spec.rb
|
106
108
|
- spec/fixtures/errors_and_warnings.yml
|
@@ -112,6 +114,8 @@ files:
|
|
112
114
|
- spec/shell_spec.rb
|
113
115
|
- spec/spec_helper.rb
|
114
116
|
- spec/transporter_spec.rb
|
117
|
+
- spec/xml_status_spec.rb
|
118
|
+
- spec/xml_status_spec.rb~
|
115
119
|
homepage: http://github.com/sshaw/itunes_store_transporter
|
116
120
|
licenses:
|
117
121
|
- MIT
|
@@ -136,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
140
|
version: '0'
|
137
141
|
requirements: []
|
138
142
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.4.
|
143
|
+
rubygems_version: 2.4.8
|
140
144
|
signing_key:
|
141
145
|
specification_version: 4
|
142
146
|
summary: Upload and manage your assets in the iTunes Store using the iTunes Store's
|
@@ -153,3 +157,5 @@ test_files:
|
|
153
157
|
- spec/shell_spec.rb
|
154
158
|
- spec/spec_helper.rb
|
155
159
|
- spec/transporter_spec.rb
|
160
|
+
- spec/xml_status_spec.rb
|
161
|
+
- spec/xml_status_spec.rb~
|