andparcel 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/TODO +14 -60
- data/VERSION +1 -1
- data/andparcel.gemspec +2 -2
- data/lib/andparcel/catalog.rb +11 -3
- data/lib/andparcel/parcel.rb +11 -5
- data/test/ParcelToPackage/AndroidManifest.xml +1 -0
- data/test/test_install.rb +107 -109
- data/test/test_package.rb +166 -168
- data/test/test_remove.rb +41 -43
- metadata +2 -2
data/README.rdoc
CHANGED
data/TODO
CHANGED
@@ -1,37 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
pour rest of this TODO into RTM and GitHub Issues
|
1
|
+
Wednesday
|
2
|
+
---------
|
3
|
+
developer guide (appendix of AdvAndroid)
|
4
|
+
ABJ work
|
5
|
+
|
6
|
+
Thursday
|
7
|
+
--------
|
8
|
+
wrap developer guide
|
9
|
+
deploy
|
10
|
+
point cwac-colormixer README to this
|
11
|
+
ABJ work
|
13
12
|
|
14
|
-
|
13
|
+
Friday
|
15
14
|
------
|
16
|
-
|
17
|
-
|
18
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
19
|
-
adapterwrapper
|
20
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
21
|
-
sackofviewsadapter
|
22
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
23
|
-
colormixer
|
24
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
25
|
-
commit all
|
26
|
-
parcel
|
27
|
-
CWAC mods (need .gitignore fixes)
|
28
|
-
Web site w/ pointers to documentation, committed
|
29
|
-
announce parcel system
|
30
|
-
CW newsletter
|
31
|
-
cw-android
|
32
|
-
twitter
|
33
|
-
my blog
|
34
|
-
AG blog -> Tuesday
|
15
|
+
standards: parcel.json / catalog.json
|
16
|
+
ABJ work
|
35
17
|
|
36
18
|
Over Next Few Weeks
|
37
19
|
-------------------
|
@@ -62,31 +44,3 @@ get other key cwac- components parcel'd up
|
|
62
44
|
parcel.json
|
63
45
|
parcel & add to catalog
|
64
46
|
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
65
|
-
|
66
|
-
|
67
|
-
Future
|
68
|
-
------
|
69
|
-
deal with upgrade (if newer available, do...something)
|
70
|
-
support merging non-component manifest entries
|
71
|
-
deal with manifest collisions (e.g., sdk levels different)
|
72
|
-
input validation
|
73
|
-
regex on name, etc.
|
74
|
-
SemVer.org validation
|
75
|
-
support packaging assets/
|
76
|
-
multiple version support (a la gem versions)
|
77
|
-
mirror support
|
78
|
-
catalogs
|
79
|
-
parcels
|
80
|
-
fail remove if listed as a dependency of something else
|
81
|
-
catalog caching w/ If-Modified-Since/ETag support
|
82
|
-
100% rcov coverage
|
83
|
-
rfc5261 support for manifest merges?
|
84
|
-
optional signed ZIPs?
|
85
|
-
battle plan for new components (see list in sketchpad)
|
86
|
-
smart --replace: doesn't download/replace if version same
|
87
|
-
dependency tests
|
88
|
-
dependency version checking
|
89
|
-
version pinning (don't auto-upgrade)
|
90
|
-
remove --full gets rid of dependencies
|
91
|
-
lint tests
|
92
|
-
100% comments
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/andparcel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{andparcel}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark Murphy"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-24}
|
13
13
|
s.default_executable = %q{parcel}
|
14
14
|
s.description = %q{Supplies the parcel command for packaging, installing, and removing parcels from an Android project}
|
15
15
|
s.email = %q{mmurphy@commonsware.com}
|
data/lib/andparcel/catalog.rb
CHANGED
@@ -63,9 +63,17 @@ module AndParcel
|
|
63
63
|
package=packages['parcels'][name]
|
64
64
|
|
65
65
|
if package
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
if (urls=package['url'])
|
67
|
+
if urls.kind_of?(Enumerable)
|
68
|
+
return(urls.first)
|
69
|
+
end
|
70
|
+
|
71
|
+
return(urls)
|
72
|
+
elsif (path=package['path'])
|
73
|
+
uri=URI.parse cat['url']
|
74
|
+
|
75
|
+
return(uri+path)
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
71
79
|
|
data/lib/andparcel/parcel.rb
CHANGED
@@ -108,11 +108,11 @@ module AndParcel
|
|
108
108
|
|
109
109
|
begin
|
110
110
|
Zip::ZipFile.open(target, Zip::ZipFile::CREATE) do |zf|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
save_config(zf) if
|
112
|
+
manifest(zf) if
|
113
|
+
resources(zf) if
|
114
|
+
docs(zf) if
|
115
|
+
libs(zf)
|
116
116
|
end
|
117
117
|
|
118
118
|
target
|
@@ -178,6 +178,12 @@ module AndParcel
|
|
178
178
|
doc=Nokogiri::XML(open(File.join(opts[:project], opts[:manifest])))
|
179
179
|
out=Nokogiri::XML('<manifest-merge/>')
|
180
180
|
|
181
|
+
sdk=doc.search('uses-sdk').first
|
182
|
+
|
183
|
+
if sdk
|
184
|
+
config['minSdkVersion']=sdk['minSdkVersion']
|
185
|
+
end
|
186
|
+
|
181
187
|
doc.search('application').children.each do |node|
|
182
188
|
if node.element?
|
183
189
|
out.root.add_child(node)
|
data/test/test_install.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require "protest"
|
4
4
|
require "lib/andparcel"
|
5
5
|
|
6
|
-
Protest.context("
|
6
|
+
Protest.context("when installing a parcel into a project") do
|
7
7
|
def clone_receiver
|
8
8
|
FileUtils.cp_r 'test/ParcelReceiver', 'tmp2'
|
9
9
|
end
|
@@ -41,130 +41,128 @@ Protest.context("The parcel engine") do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
44
|
+
test "should support a parcel with no meaningful content" do
|
45
|
+
install_test
|
46
|
+
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
test "should support a parcel with JARs" do
|
49
|
+
install_test(['tmp2/libs/one.jar',
|
50
|
+
'tmp2/libs/two.jar'],
|
51
|
+
:jars=>'libs')
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
test "should support a parcel with documentation" do
|
55
|
+
install_test(['tmp2/parcels/andParcel-test/docs/README'],
|
56
|
+
:docs=>'docs')
|
57
|
+
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
test "should support a parcel with resources" do
|
60
|
+
install_test(['tmp2/res/layout/andParcel_test_row.xml',
|
61
|
+
'tmp2/res/values/strings.xml'],
|
62
|
+
:res=>'res')
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
65
|
+
test "should support a parcel with all sorts of stuff" do
|
66
|
+
install_test(['tmp2/res/layout/andParcel_test_row.xml',
|
67
|
+
'tmp2/res/values/strings.xml',
|
68
|
+
'tmp2/libs/one.jar',
|
69
|
+
'tmp2/libs/two.jar',
|
70
|
+
'tmp2/parcels/andParcel-test/docs/README'],
|
71
|
+
:res=>'res',
|
72
|
+
:jars=>'libs',
|
73
|
+
:docs=>['docs/README', 'docs/SomeOtherFile'])
|
74
|
+
end
|
75
|
+
|
76
|
+
test "should install a parcel off the network" do
|
77
|
+
begin
|
78
|
+
clone_receiver
|
79
|
+
FileUtils.mkdir 'tmp'
|
80
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
81
|
+
:dir=>'tmp')
|
82
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
83
|
+
AndParcel::Parcel.install('cwac-parcel',
|
84
|
+
:dir=>'tmp2')
|
85
|
+
assert_exists('tmp2/parcels/cwac-parcel')
|
86
|
+
ensure
|
87
|
+
FileUtils.rm_rf 'tmp'
|
88
|
+
FileUtils.rm_rf 'tmp2'
|
91
89
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
test "should replace a parcel with all sorts of stuff" do
|
93
|
+
begin
|
94
|
+
opts={:res=>'res',
|
95
|
+
:jars=>'libs',
|
96
|
+
:docs=>'docs'}
|
97
|
+
opts[:dir]='tmp'
|
98
|
+
opts[:manifest]='AndroidManifest.xml'
|
99
|
+
clone_receiver
|
100
|
+
FileUtils.mkdir 'tmp'
|
101
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
102
|
+
opts)
|
103
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
104
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
105
|
+
:dir=>'tmp2')
|
106
|
+
assert_exists('tmp2/res/layout/andParcel_test_row.xml',
|
107
|
+
'tmp2/res/values/strings.xml',
|
108
|
+
'tmp2/libs/one.jar',
|
109
|
+
'tmp2/libs/two.jar',
|
110
|
+
'tmp2/parcels/andParcel-test/docs/README')
|
111
|
+
assert_exists('tmp2/parcels',
|
112
|
+
'tmp2/parcels/andParcel-test/andParcel-test_0.1.0.zip')
|
113
|
+
|
114
|
+
doc=Nokogiri::XML(open('tmp2/AndroidManifest.xml'))
|
115
|
+
app=doc.search('application')[0]
|
116
|
+
existing=app.xpath("*[@android:name='ParcelToPackage']",
|
117
|
+
'android'=>"http://schemas.android.com/apk/res/android")
|
118
|
+
|
119
|
+
assert existing[0].name=='activity'
|
120
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
121
|
+
:dir=>'tmp2', :replace=>true)
|
122
|
+
assert_exists('tmp2/res/layout/andParcel_test_row.xml',
|
108
123
|
'tmp2/res/values/strings.xml',
|
109
124
|
'tmp2/libs/one.jar',
|
110
125
|
'tmp2/libs/two.jar',
|
111
126
|
'tmp2/parcels/andParcel-test/docs/README')
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
doc=Nokogiri::XML(open('tmp2/AndroidManifest.xml'))
|
116
|
-
app=doc.search('application')[0]
|
117
|
-
existing=app.xpath("*[@android:name='ParcelToPackage']",
|
118
|
-
'android'=>"http://schemas.android.com/apk/res/android")
|
119
|
-
|
120
|
-
assert existing[0].name=='activity'
|
121
|
-
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
122
|
-
:dir=>'tmp2', :replace=>true)
|
123
|
-
assert_exists('tmp2/res/layout/andParcel_test_row.xml',
|
124
|
-
'tmp2/res/values/strings.xml',
|
125
|
-
'tmp2/libs/one.jar',
|
126
|
-
'tmp2/libs/two.jar',
|
127
|
-
'tmp2/parcels/andParcel-test/docs/README')
|
128
|
-
ensure
|
129
|
-
FileUtils.rm_rf 'tmp'
|
130
|
-
FileUtils.rm_rf 'tmp2'
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
test "should fail to install a parcel that is already installed" do
|
135
|
-
begin
|
136
|
-
clone_receiver
|
137
|
-
FileUtils.mkdir 'tmp'
|
138
|
-
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
139
|
-
:dir=>'tmp')
|
140
|
-
assert target=='tmp/andParcel-test_0.1.0.zip'
|
141
|
-
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
142
|
-
:dir=>'tmp2')
|
143
|
-
|
144
|
-
begin
|
145
|
-
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
146
|
-
:dir=>'tmp2')
|
147
|
-
assert false
|
148
|
-
rescue
|
149
|
-
# OK, life is good
|
150
|
-
end
|
151
|
-
ensure
|
152
|
-
FileUtils.rm_rf 'tmp'
|
153
|
-
FileUtils.rm_rf 'tmp2'
|
154
|
-
end
|
127
|
+
ensure
|
128
|
+
FileUtils.rm_rf 'tmp'
|
129
|
+
FileUtils.rm_rf 'tmp2'
|
155
130
|
end
|
156
|
-
|
157
|
-
|
131
|
+
end
|
132
|
+
|
133
|
+
test "should fail to install a parcel that is already installed" do
|
134
|
+
begin
|
135
|
+
clone_receiver
|
136
|
+
FileUtils.mkdir 'tmp'
|
137
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
138
|
+
:dir=>'tmp')
|
139
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
140
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
141
|
+
:dir=>'tmp2')
|
142
|
+
|
158
143
|
begin
|
159
|
-
clone_receiver
|
160
144
|
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
161
|
-
|
145
|
+
:dir=>'tmp2')
|
162
146
|
assert false
|
163
147
|
rescue
|
164
148
|
# OK, life is good
|
165
|
-
ensure
|
166
|
-
FileUtils.rm_rf 'tmp2'
|
167
149
|
end
|
150
|
+
ensure
|
151
|
+
FileUtils.rm_rf 'tmp'
|
152
|
+
FileUtils.rm_rf 'tmp2'
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
test "should fail to install a parcel that does not exist" do
|
157
|
+
begin
|
158
|
+
clone_receiver
|
159
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
160
|
+
:dir=>'tmp2')
|
161
|
+
assert false
|
162
|
+
rescue
|
163
|
+
# OK, life is good
|
164
|
+
ensure
|
165
|
+
FileUtils.rm_rf 'tmp2'
|
168
166
|
end
|
169
167
|
end
|
170
168
|
end
|
data/test/test_package.rb
CHANGED
@@ -3,216 +3,214 @@ require 'rubygems'
|
|
3
3
|
require "protest"
|
4
4
|
require "lib/andparcel"
|
5
5
|
|
6
|
-
Protest.context("
|
6
|
+
Protest.context("when packaging a parcel") do
|
7
7
|
def load_config(target)
|
8
8
|
Zip::ZipFile.open(target) do |zf|
|
9
9
|
JSON.parse(zf.read('parcel.json'))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def config_assert(config)
|
13
|
+
def config_assert(config, has_manifest=false)
|
14
14
|
assert config['name']=='andParcel-test'
|
15
15
|
assert config['version']=='0.1.0'
|
16
16
|
assert config['parcel-version']==AndParcel.version
|
17
17
|
assert config['dependencies']==nil
|
18
|
+
assert config['minSdkVersion']=='4' if has_manifest
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
FileUtils.rm_rf 'tmp'
|
32
|
-
end
|
21
|
+
test "should support a parcel with no meaningful content" do
|
22
|
+
begin
|
23
|
+
FileUtils.mkdir 'tmp'
|
24
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
25
|
+
:dir=>'tmp')
|
26
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
27
|
+
assert File.exists?(target)
|
28
|
+
config=load_config(target)
|
29
|
+
config_assert(config)
|
30
|
+
ensure
|
31
|
+
FileUtils.rm_rf 'tmp'
|
33
32
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
test "should support a parcel with JARs" do
|
36
|
+
begin
|
37
|
+
FileUtils.mkdir 'tmp'
|
38
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
39
|
+
:dir=>'tmp',
|
40
|
+
:jars=>'libs')
|
41
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
42
|
+
assert File.exists?(target)
|
43
|
+
config=load_config(target)
|
44
|
+
config_assert(config)
|
45
|
+
|
46
|
+
matches=0
|
47
|
+
Zip::ZipFile.open(target) do |zf|
|
48
|
+
zf.entries.each do |entry|
|
49
|
+
if ('libs/one.jar'==entry.name ||
|
50
|
+
'libs/two.jar'==entry.name)
|
51
|
+
matches+=1
|
53
52
|
end
|
54
53
|
end
|
55
|
-
assert matches==2
|
56
|
-
ensure
|
57
|
-
FileUtils.rm_rf 'tmp'
|
58
54
|
end
|
55
|
+
assert matches==2
|
56
|
+
ensure
|
57
|
+
FileUtils.rm_rf 'tmp'
|
59
58
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
59
|
+
end
|
60
|
+
|
61
|
+
test "should support a parcel with documentation" do
|
62
|
+
begin
|
63
|
+
FileUtils.mkdir 'tmp'
|
64
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
65
|
+
:dir=>'tmp',
|
66
|
+
:docs=>'docs')
|
67
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
68
|
+
assert File.exists?(target)
|
69
|
+
config=load_config(target)
|
70
|
+
config_assert(config)
|
71
|
+
|
72
|
+
matches=0
|
73
|
+
Zip::ZipFile.open(target) do |zf|
|
74
|
+
zf.entries.each do |entry|
|
75
|
+
if ('docs/README'==entry.name)
|
76
|
+
matches+=1
|
78
77
|
end
|
79
78
|
end
|
80
|
-
assert matches==1
|
81
|
-
ensure
|
82
|
-
FileUtils.rm_rf 'tmp'
|
83
79
|
end
|
80
|
+
assert matches==1
|
81
|
+
ensure
|
82
|
+
FileUtils.rm_rf 'tmp'
|
84
83
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
84
|
+
end
|
85
|
+
|
86
|
+
test "should support a parcel with resources" do
|
87
|
+
begin
|
88
|
+
FileUtils.mkdir 'tmp'
|
89
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
90
|
+
:dir=>'tmp',
|
91
|
+
:res=>'res')
|
92
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
93
|
+
assert File.exists?(target)
|
94
|
+
config=load_config(target)
|
95
|
+
config_assert(config)
|
96
|
+
|
97
|
+
matches=0
|
98
|
+
Zip::ZipFile.open(target) do |zf|
|
99
|
+
zf.entries.each do |entry|
|
100
|
+
if ('res/layout/andParcel_test_row.xml'==entry.name ||
|
101
|
+
'res/values/strings.xml'==entry.name)
|
102
|
+
matches+=1
|
104
103
|
end
|
105
104
|
end
|
106
|
-
assert matches==2
|
107
|
-
ensure
|
108
|
-
FileUtils.rm_rf 'tmp'
|
109
105
|
end
|
106
|
+
assert matches==2
|
107
|
+
ensure
|
108
|
+
FileUtils.rm_rf 'tmp'
|
110
109
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
end
|
110
|
+
end
|
111
|
+
|
112
|
+
test "should support a parcel with all sorts of stuff" do
|
113
|
+
begin
|
114
|
+
FileUtils.mkdir 'tmp'
|
115
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
116
|
+
:dir=>'tmp',
|
117
|
+
:jars=>'libs',
|
118
|
+
:manifest=>'AndroidManifest.xml',
|
119
|
+
:docs=>'docs')
|
120
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
121
|
+
assert File.exists?(target)
|
122
|
+
config=load_config(target)
|
123
|
+
config_assert(config, true)
|
124
|
+
|
125
|
+
matches=0
|
126
|
+
Zip::ZipFile.open(target) do |zf|
|
127
|
+
zf.entries.each do |entry|
|
128
|
+
if ('libs/one.jar'==entry.name ||
|
129
|
+
'libs/two.jar'==entry.name)
|
130
|
+
matches+=1
|
133
131
|
end
|
134
132
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
133
|
+
end
|
134
|
+
assert matches==2
|
135
|
+
|
136
|
+
matches=0
|
137
|
+
Zip::ZipFile.open(target) do |zf|
|
138
|
+
zf.entries.each do |entry|
|
139
|
+
if ('docs/README'==entry.name)
|
140
|
+
matches+=1
|
143
141
|
end
|
144
142
|
end
|
145
|
-
assert matches==1
|
146
|
-
ensure
|
147
|
-
FileUtils.rm_rf 'tmp'
|
148
143
|
end
|
144
|
+
assert matches==1
|
145
|
+
ensure
|
146
|
+
FileUtils.rm_rf 'tmp'
|
149
147
|
end
|
150
|
-
|
151
|
-
|
148
|
+
end
|
149
|
+
|
150
|
+
test "should fail if try to package with missing parcel.json" do
|
151
|
+
begin
|
152
|
+
FileUtils.mkdir 'tmp'
|
153
|
+
|
152
154
|
begin
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
assert false
|
159
|
-
rescue
|
160
|
-
assert Dir['tmp/*'].empty?
|
161
|
-
end
|
162
|
-
ensure
|
163
|
-
FileUtils.rm_rf 'tmp'
|
155
|
+
target=AndParcel::Parcel.package('test/ThisDoesNotExist/parcel.json',
|
156
|
+
:dir=>'tmp')
|
157
|
+
assert false
|
158
|
+
rescue
|
159
|
+
assert Dir['tmp/*'].empty?
|
164
160
|
end
|
161
|
+
ensure
|
162
|
+
FileUtils.rm_rf 'tmp'
|
165
163
|
end
|
166
|
-
|
167
|
-
|
164
|
+
end
|
165
|
+
|
166
|
+
test "should fail if try to package with missing JARs" do
|
167
|
+
begin
|
168
|
+
FileUtils.mkdir 'tmp'
|
169
|
+
|
168
170
|
begin
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
assert false
|
176
|
-
rescue
|
177
|
-
assert Dir['tmp/*'].empty?
|
178
|
-
end
|
179
|
-
ensure
|
180
|
-
FileUtils.rm_rf 'tmp'
|
171
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
172
|
+
:dir=>'tmp',
|
173
|
+
:jars=>'libs-fake')
|
174
|
+
assert false
|
175
|
+
rescue
|
176
|
+
assert Dir['tmp/*'].empty?
|
181
177
|
end
|
178
|
+
ensure
|
179
|
+
FileUtils.rm_rf 'tmp'
|
182
180
|
end
|
183
|
-
|
184
|
-
|
181
|
+
end
|
182
|
+
|
183
|
+
test "should fail if try to package with missing documentation" do
|
184
|
+
begin
|
185
|
+
FileUtils.mkdir 'tmp'
|
186
|
+
|
185
187
|
begin
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
assert false
|
193
|
-
rescue
|
194
|
-
assert Dir['tmp/*'].empty?
|
195
|
-
end
|
196
|
-
ensure
|
197
|
-
FileUtils.rm_rf 'tmp'
|
188
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
189
|
+
:dir=>'tmp',
|
190
|
+
:docs=>'docs-fake')
|
191
|
+
assert false
|
192
|
+
rescue
|
193
|
+
assert Dir['tmp/*'].empty?
|
198
194
|
end
|
195
|
+
ensure
|
196
|
+
FileUtils.rm_rf 'tmp'
|
199
197
|
end
|
200
|
-
|
201
|
-
|
198
|
+
end
|
199
|
+
|
200
|
+
test "should fail if try to package with missing resources" do
|
201
|
+
begin
|
202
|
+
FileUtils.mkdir 'tmp'
|
203
|
+
|
202
204
|
begin
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
assert false
|
210
|
-
rescue
|
211
|
-
assert Dir['tmp/*'].empty?
|
212
|
-
end
|
213
|
-
ensure
|
214
|
-
FileUtils.rm_rf 'tmp'
|
205
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
206
|
+
:dir=>'tmp',
|
207
|
+
:res=>'res-fake')
|
208
|
+
assert false
|
209
|
+
rescue
|
210
|
+
assert Dir['tmp/*'].empty?
|
215
211
|
end
|
212
|
+
ensure
|
213
|
+
FileUtils.rm_rf 'tmp'
|
216
214
|
end
|
217
215
|
end
|
218
216
|
end
|
data/test/test_remove.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require "protest"
|
4
4
|
require "lib/andparcel"
|
5
5
|
|
6
|
-
Protest.context("
|
6
|
+
Protest.context("when removing a parcel from a project") do
|
7
7
|
def clone_receiver
|
8
8
|
FileUtils.cp_r 'test/ParcelReceiver', 'tmp2'
|
9
9
|
end
|
@@ -39,48 +39,46 @@ Protest.context("The parcel engine") do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
FileUtils.rm_rf 'tmp2'
|
83
|
-
end
|
42
|
+
test "should support a parcel with no meaningful content" do
|
43
|
+
remove_test
|
44
|
+
end
|
45
|
+
|
46
|
+
test "should support a parcel with JARs" do
|
47
|
+
remove_test(['tmp2/libs/one.jar',
|
48
|
+
'tmp2/libs/two.jar'],
|
49
|
+
:jars=>'libs')
|
50
|
+
end
|
51
|
+
|
52
|
+
test "should support a parcel with documentation" do
|
53
|
+
remove_test([],
|
54
|
+
:docs=>'docs')
|
55
|
+
end
|
56
|
+
|
57
|
+
test "should support a parcel with resources" do
|
58
|
+
remove_test(['tmp2/res/layout/andParcel_test_row.xml',
|
59
|
+
'tmp2/res/values/strings.xml'],
|
60
|
+
:res=>'res')
|
61
|
+
end
|
62
|
+
|
63
|
+
test "should support a parcel with all sorts of stuff" do
|
64
|
+
remove_test(['tmp2/libs/one.jar',
|
65
|
+
'tmp2/libs/two.jar',
|
66
|
+
'tmp2/res/layout/andParcel_test_row.xml',
|
67
|
+
'tmp2/res/values/strings.xml'],
|
68
|
+
:docs=>'docs',
|
69
|
+
:jars=>'libs',
|
70
|
+
:res=>'res')
|
71
|
+
end
|
72
|
+
|
73
|
+
test "should fail to remove a parcel that is not installed" do
|
74
|
+
begin
|
75
|
+
clone_receiver
|
76
|
+
AndParcel::Parcel.remove('andParcel-test', :dir=>'tmp2')
|
77
|
+
assert false
|
78
|
+
rescue
|
79
|
+
# Who-hoo!
|
80
|
+
ensure
|
81
|
+
FileUtils.rm_rf 'tmp2'
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: andparcel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Murphy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-05-
|
12
|
+
date: 2010-05-24 00:00:00 -04:00
|
13
13
|
default_executable: parcel
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|