andparcel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +60 -0
- data/TODO +92 -0
- data/VERSION +1 -0
- data/andparcel.gemspec +103 -0
- data/bin/parcel +161 -0
- data/lib/andparcel/base.rb +22 -0
- data/lib/andparcel/catalog.rb +75 -0
- data/lib/andparcel/fileref.rb +21 -0
- data/lib/andparcel/parcel.rb +533 -0
- data/lib/andparcel.rb +3 -0
- data/test/ParcelReceiver/AndroidManifest.xml +15 -0
- data/test/ParcelReceiver/build.properties +17 -0
- data/test/ParcelReceiver/build.xml +67 -0
- data/test/ParcelReceiver/default.properties +11 -0
- data/test/ParcelReceiver/local.properties +10 -0
- data/test/ParcelReceiver/res/layout/main.xml +13 -0
- data/test/ParcelReceiver/res/values/strings.xml +4 -0
- data/test/ParcelReceiver/src/com/commonsware/android/pr/ParcelReceiver.java +15 -0
- data/test/ParcelToPackage/AndroidManifest.xml +15 -0
- data/test/ParcelToPackage/build.properties +17 -0
- data/test/ParcelToPackage/build.xml +67 -0
- data/test/ParcelToPackage/default.properties +11 -0
- data/test/ParcelToPackage/docs/README +1 -0
- data/test/ParcelToPackage/docs/SomeOtherFile +0 -0
- data/test/ParcelToPackage/libs/one.jar +0 -0
- data/test/ParcelToPackage/libs/two.jar +0 -0
- data/test/ParcelToPackage/local.properties +10 -0
- data/test/ParcelToPackage/parcel.json +17 -0
- data/test/ParcelToPackage/res/layout/andParcel_test_row.xml +13 -0
- data/test/ParcelToPackage/res/values/strings.xml +4 -0
- data/test/ParcelToPackage/src/com/commonsware/android/p2pkg/ParcelToPackage.java +15 -0
- data/test/ParcelToPackage/tmp/andParcel-test_0.1.0.zip +0 -0
- data/test/test_init.rb +42 -0
- data/test/test_install.rb +170 -0
- data/test/test_package.rb +218 -0
- data/test/test_remove.rb +86 -0
- metadata +158 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
package="com.commonsware.android.p2pkg"
|
4
|
+
android:versionCode="1"
|
5
|
+
android:versionName="1.0">
|
6
|
+
<application android:label="@string/app_name">
|
7
|
+
<activity android:name="ParcelToPackage"
|
8
|
+
android:label="@string/app_name">
|
9
|
+
<intent-filter>
|
10
|
+
<action android:name="android.intent.action.MAIN" />
|
11
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
12
|
+
</intent-filter>
|
13
|
+
</activity>
|
14
|
+
</application>
|
15
|
+
</manifest>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file is used to override default values used by the Ant build system.
|
2
|
+
#
|
3
|
+
# This file must be checked in Version Control Systems, as it is
|
4
|
+
# integral to the build system of your project.
|
5
|
+
|
6
|
+
# This file is only used by the Ant script.
|
7
|
+
|
8
|
+
# You can use this to override default values such as
|
9
|
+
# 'source.dir' for the location of your java source folder and
|
10
|
+
# 'out.dir' for the location of your output folder.
|
11
|
+
|
12
|
+
# You can also use it define how the release builds are signed by declaring
|
13
|
+
# the following properties:
|
14
|
+
# 'key.store' for the location of your keystore and
|
15
|
+
# 'key.alias' for the name of the key to use.
|
16
|
+
# The password will be asked during the build when you use the 'release' target.
|
17
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project name="ParcelToPackage" default="help">
|
3
|
+
|
4
|
+
<!-- The local.properties file is created and updated by the 'android' tool.
|
5
|
+
It contains the path to the SDK. It should *NOT* be checked in in Version
|
6
|
+
Control Systems. -->
|
7
|
+
<property file="local.properties" />
|
8
|
+
|
9
|
+
<!-- The build.properties file can be created by you and is never touched
|
10
|
+
by the 'android' tool. This is the place to change some of the default property values
|
11
|
+
used by the Ant rules.
|
12
|
+
Here are some properties you may want to change/update:
|
13
|
+
|
14
|
+
application.package
|
15
|
+
the name of your application package as defined in the manifest. Used by the
|
16
|
+
'uninstall' rule.
|
17
|
+
source.dir
|
18
|
+
the name of the source directory. Default is 'src'.
|
19
|
+
out.dir
|
20
|
+
the name of the output directory. Default is 'bin'.
|
21
|
+
|
22
|
+
Properties related to the SDK location or the project target should be updated
|
23
|
+
using the 'android' tool with the 'update' action.
|
24
|
+
|
25
|
+
This file is an integral part of the build system for your application and
|
26
|
+
should be checked in in Version Control Systems.
|
27
|
+
|
28
|
+
-->
|
29
|
+
<property file="build.properties" />
|
30
|
+
|
31
|
+
<!-- The default.properties file is created and updated by the 'android' tool, as well
|
32
|
+
as ADT.
|
33
|
+
This file is an integral part of the build system for your application and
|
34
|
+
should be checked in in Version Control Systems. -->
|
35
|
+
<property file="default.properties" />
|
36
|
+
|
37
|
+
<!-- Custom Android task to deal with the project target, and import the proper rules.
|
38
|
+
This requires ant 1.6.0 or above. -->
|
39
|
+
<path id="android.antlibs">
|
40
|
+
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
|
41
|
+
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
|
42
|
+
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
|
43
|
+
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
|
44
|
+
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
|
45
|
+
</path>
|
46
|
+
|
47
|
+
<taskdef name="setup"
|
48
|
+
classname="com.android.ant.SetupTask"
|
49
|
+
classpathref="android.antlibs" />
|
50
|
+
|
51
|
+
<!-- Execute the Android Setup task that will setup some properties specific to the target,
|
52
|
+
and import the build rules files.
|
53
|
+
|
54
|
+
The rules file is imported from
|
55
|
+
<SDK>/platforms/<target_platform>/templates/android_rules.xml
|
56
|
+
|
57
|
+
To customize some build steps for your project:
|
58
|
+
- copy the content of the main node <project> from android_rules.xml
|
59
|
+
- paste it in this build.xml below the <setup /> task.
|
60
|
+
- disable the import by changing the setup task below to <setup import="false" />
|
61
|
+
|
62
|
+
This will ensure that the properties are setup correctly but that your customized
|
63
|
+
build steps are used.
|
64
|
+
-->
|
65
|
+
<setup />
|
66
|
+
|
67
|
+
</project>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file is automatically generated by Android Tools.
|
2
|
+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
3
|
+
#
|
4
|
+
# This file must be checked in Version Control Systems.
|
5
|
+
#
|
6
|
+
# To customize properties used by the Ant build system use,
|
7
|
+
# "build.properties", and override values to adapt the script to your
|
8
|
+
# project structure.
|
9
|
+
|
10
|
+
# Project target.
|
11
|
+
target=android-4
|
@@ -0,0 +1 @@
|
|
1
|
+
Hi, Mom!
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file is automatically generated by Android Tools.
|
2
|
+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
3
|
+
#
|
4
|
+
# This file must *NOT* be checked in Version Control Systems,
|
5
|
+
# as it contains information specific to your local configuration.
|
6
|
+
|
7
|
+
# location of the SDK. This is only used by Ant
|
8
|
+
# For customization when using a Version Control System, please read the
|
9
|
+
# header note.
|
10
|
+
sdk.dir=/opt/android-sdk-linux_x86-1.6_r1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "andParcel-test",
|
3
|
+
"description": "A test parcel for testing the parcel engine for Android",
|
4
|
+
"version": "0.1.0",
|
5
|
+
"maintainers": [
|
6
|
+
{
|
7
|
+
"name": "Mark Murphy",
|
8
|
+
"web": "http://commonsware.com"
|
9
|
+
}
|
10
|
+
],
|
11
|
+
"licenses": [
|
12
|
+
{
|
13
|
+
"type": "Apache License, 2.0",
|
14
|
+
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
15
|
+
}
|
16
|
+
]
|
17
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
android:orientation="vertical"
|
4
|
+
android:layout_width="fill_parent"
|
5
|
+
android:layout_height="fill_parent"
|
6
|
+
>
|
7
|
+
<TextView
|
8
|
+
android:layout_width="fill_parent"
|
9
|
+
android:layout_height="wrap_content"
|
10
|
+
android:text="Hello World, ParcelToPackage"
|
11
|
+
/>
|
12
|
+
</LinearLayout>
|
13
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
package com.commonsware.android.p2pkg;
|
2
|
+
|
3
|
+
import android.app.Activity;
|
4
|
+
import android.os.Bundle;
|
5
|
+
|
6
|
+
public class ParcelToPackage extends Activity
|
7
|
+
{
|
8
|
+
/** Called when the activity is first created. */
|
9
|
+
@Override
|
10
|
+
public void onCreate(Bundle savedInstanceState)
|
11
|
+
{
|
12
|
+
super.onCreate(savedInstanceState);
|
13
|
+
setContentView(R.layout.main);
|
14
|
+
}
|
15
|
+
}
|
Binary file
|
data/test/test_init.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "lib/andparcel"
|
2
|
+
require "rubygems"
|
3
|
+
require "protest"
|
4
|
+
|
5
|
+
Protest.context("The parcel engine") do
|
6
|
+
setup do
|
7
|
+
`rm -rf #{AndParcel.home}`
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should properly initialize" do
|
11
|
+
assert !File.exists?(AndParcel.home)
|
12
|
+
AndParcel.init
|
13
|
+
assert File.exists?(AndParcel.home)
|
14
|
+
assert File.directory?(AndParcel.home)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should properly list the catalogs in a new environment" do
|
18
|
+
assert !File.exists?(AndParcel.home)
|
19
|
+
catalogs=AndParcel.catalogs
|
20
|
+
assert catalogs.size==1
|
21
|
+
end
|
22
|
+
|
23
|
+
test "should support adding a new catalog" do
|
24
|
+
assert !File.exists?(AndParcel.home)
|
25
|
+
catalogs=AndParcel.catalogs
|
26
|
+
catalogs.add('test', 'http://pub.andparcel.com/foo.json')
|
27
|
+
assert catalogs.size==2
|
28
|
+
assert catalogs.names.include?('test')
|
29
|
+
end
|
30
|
+
|
31
|
+
test "should support removing an existing catalog" do
|
32
|
+
assert !File.exists?(AndParcel.home)
|
33
|
+
catalogs=AndParcel.catalogs
|
34
|
+
assert catalogs.size==1
|
35
|
+
cat=catalogs.add('test', 'http://pub.andparcel.com/foo.json')
|
36
|
+
assert catalogs.size==2
|
37
|
+
assert catalogs.names.include?('test')
|
38
|
+
catalogs.remove('test')
|
39
|
+
assert catalogs.size==1
|
40
|
+
assert !catalogs.names.include?('test')
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems'
|
3
|
+
require "protest"
|
4
|
+
require "lib/andparcel"
|
5
|
+
|
6
|
+
Protest.context("The parcel engine") do
|
7
|
+
def clone_receiver
|
8
|
+
FileUtils.cp_r 'test/ParcelReceiver', 'tmp2'
|
9
|
+
end
|
10
|
+
|
11
|
+
def assert_exists(*items)
|
12
|
+
items.each do |f|
|
13
|
+
assert File.exists?(f)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def install_test(files=[], opts={})
|
18
|
+
begin
|
19
|
+
opts[:dir]='tmp'
|
20
|
+
opts[:manifest]='AndroidManifest.xml'
|
21
|
+
clone_receiver
|
22
|
+
FileUtils.mkdir 'tmp'
|
23
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
24
|
+
opts)
|
25
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
26
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
27
|
+
:dir=>'tmp2')
|
28
|
+
assert_exists(*files)
|
29
|
+
assert_exists('tmp2/parcels',
|
30
|
+
'tmp2/parcels/andParcel-test/andParcel-test_0.1.0.zip')
|
31
|
+
|
32
|
+
doc=Nokogiri::XML(open('tmp2/AndroidManifest.xml'))
|
33
|
+
app=doc.search('application')[0]
|
34
|
+
existing=app.xpath("*[@android:name='ParcelToPackage']",
|
35
|
+
'android'=>"http://schemas.android.com/apk/res/android")
|
36
|
+
|
37
|
+
assert existing[0].name=='activity'
|
38
|
+
ensure
|
39
|
+
FileUtils.rm_rf 'tmp'
|
40
|
+
FileUtils.rm_rf 'tmp2'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context("when installing a parcel into a project") do
|
45
|
+
test "should support a parcel with no meaningful content" do
|
46
|
+
install_test
|
47
|
+
end
|
48
|
+
|
49
|
+
test "should support a parcel with JARs" do
|
50
|
+
install_test(['tmp2/libs/one.jar',
|
51
|
+
'tmp2/libs/two.jar'],
|
52
|
+
:jars=>'libs')
|
53
|
+
end
|
54
|
+
|
55
|
+
test "should support a parcel with documentation" do
|
56
|
+
install_test(['tmp2/parcels/andParcel-test/docs/README'],
|
57
|
+
:docs=>'docs')
|
58
|
+
end
|
59
|
+
|
60
|
+
test "should support a parcel with resources" do
|
61
|
+
install_test(['tmp2/res/layout/andParcel_test_row.xml',
|
62
|
+
'tmp2/res/values/strings.xml'],
|
63
|
+
:res=>'res')
|
64
|
+
end
|
65
|
+
|
66
|
+
test "should support a parcel with all sorts of stuff" do
|
67
|
+
install_test(['tmp2/res/layout/andParcel_test_row.xml',
|
68
|
+
'tmp2/res/values/strings.xml',
|
69
|
+
'tmp2/libs/one.jar',
|
70
|
+
'tmp2/libs/two.jar',
|
71
|
+
'tmp2/parcels/andParcel-test/docs/README'],
|
72
|
+
:res=>'res',
|
73
|
+
:jars=>'libs',
|
74
|
+
:docs=>['docs/README', 'docs/SomeOtherFile'])
|
75
|
+
end
|
76
|
+
|
77
|
+
test "should install a parcel off the network" do
|
78
|
+
begin
|
79
|
+
clone_receiver
|
80
|
+
FileUtils.mkdir 'tmp'
|
81
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
82
|
+
:dir=>'tmp')
|
83
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
84
|
+
AndParcel::Parcel.install('cwac-parcel',
|
85
|
+
:dir=>'tmp2')
|
86
|
+
assert_exists('tmp2/parcels/cwac-parcel')
|
87
|
+
ensure
|
88
|
+
FileUtils.rm_rf 'tmp'
|
89
|
+
FileUtils.rm_rf 'tmp2'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
test "should replace a parcel with all sorts of stuff" do
|
94
|
+
begin
|
95
|
+
opts={:res=>'res',
|
96
|
+
:jars=>'libs',
|
97
|
+
:docs=>'docs'}
|
98
|
+
opts[:dir]='tmp'
|
99
|
+
opts[:manifest]='AndroidManifest.xml'
|
100
|
+
clone_receiver
|
101
|
+
FileUtils.mkdir 'tmp'
|
102
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
103
|
+
opts)
|
104
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
105
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
106
|
+
:dir=>'tmp2')
|
107
|
+
assert_exists('tmp2/res/layout/andParcel_test_row.xml',
|
108
|
+
'tmp2/res/values/strings.xml',
|
109
|
+
'tmp2/libs/one.jar',
|
110
|
+
'tmp2/libs/two.jar',
|
111
|
+
'tmp2/parcels/andParcel-test/docs/README')
|
112
|
+
assert_exists('tmp2/parcels',
|
113
|
+
'tmp2/parcels/andParcel-test/andParcel-test_0.1.0.zip')
|
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
|
155
|
+
end
|
156
|
+
|
157
|
+
test "should fail to install a parcel that does not exist" do
|
158
|
+
begin
|
159
|
+
clone_receiver
|
160
|
+
AndParcel::Parcel.install('tmp/andParcel-test_0.1.0.zip',
|
161
|
+
:dir=>'tmp2')
|
162
|
+
assert false
|
163
|
+
rescue
|
164
|
+
# OK, life is good
|
165
|
+
ensure
|
166
|
+
FileUtils.rm_rf 'tmp2'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems'
|
3
|
+
require "protest"
|
4
|
+
require "lib/andparcel"
|
5
|
+
|
6
|
+
Protest.context("The parcel engine") do
|
7
|
+
def load_config(target)
|
8
|
+
Zip::ZipFile.open(target) do |zf|
|
9
|
+
JSON.parse(zf.read('parcel.json'))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_assert(config)
|
14
|
+
assert config['name']=='andParcel-test'
|
15
|
+
assert config['version']=='0.1.0'
|
16
|
+
assert config['parcel-version']==AndParcel.version
|
17
|
+
assert config['dependencies']==nil
|
18
|
+
end
|
19
|
+
|
20
|
+
context("when packaging a parcel") do
|
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'
|
32
|
+
end
|
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
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
assert matches==2
|
56
|
+
ensure
|
57
|
+
FileUtils.rm_rf 'tmp'
|
58
|
+
end
|
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
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
assert matches==1
|
81
|
+
ensure
|
82
|
+
FileUtils.rm_rf 'tmp'
|
83
|
+
end
|
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
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
assert matches==2
|
107
|
+
ensure
|
108
|
+
FileUtils.rm_rf 'tmp'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# test "should support a parcel with dependencies"
|
113
|
+
|
114
|
+
test "should support a parcel with all sorts of stuff" do
|
115
|
+
begin
|
116
|
+
FileUtils.mkdir 'tmp'
|
117
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
118
|
+
:dir=>'tmp',
|
119
|
+
:jars=>'libs',
|
120
|
+
:docs=>'docs')
|
121
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
122
|
+
assert File.exists?(target)
|
123
|
+
config=load_config(target)
|
124
|
+
config_assert(config)
|
125
|
+
|
126
|
+
matches=0
|
127
|
+
Zip::ZipFile.open(target) do |zf|
|
128
|
+
zf.entries.each do |entry|
|
129
|
+
if ('libs/one.jar'==entry.name ||
|
130
|
+
'libs/two.jar'==entry.name)
|
131
|
+
matches+=1
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
assert matches==2
|
136
|
+
|
137
|
+
matches=0
|
138
|
+
Zip::ZipFile.open(target) do |zf|
|
139
|
+
zf.entries.each do |entry|
|
140
|
+
if ('docs/README'==entry.name)
|
141
|
+
matches+=1
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
assert matches==1
|
146
|
+
ensure
|
147
|
+
FileUtils.rm_rf 'tmp'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
test "should fail if try to package with missing parcel.json" do
|
152
|
+
begin
|
153
|
+
FileUtils.mkdir 'tmp'
|
154
|
+
|
155
|
+
begin
|
156
|
+
target=AndParcel::Parcel.package('test/ThisDoesNotExist/parcel.json',
|
157
|
+
:dir=>'tmp')
|
158
|
+
assert false
|
159
|
+
rescue
|
160
|
+
assert Dir['tmp/*'].empty?
|
161
|
+
end
|
162
|
+
ensure
|
163
|
+
FileUtils.rm_rf 'tmp'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
test "should fail if try to package with missing JARs" do
|
168
|
+
begin
|
169
|
+
FileUtils.mkdir 'tmp'
|
170
|
+
|
171
|
+
begin
|
172
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
173
|
+
:dir=>'tmp',
|
174
|
+
:jars=>'libs-fake')
|
175
|
+
assert false
|
176
|
+
rescue
|
177
|
+
assert Dir['tmp/*'].empty?
|
178
|
+
end
|
179
|
+
ensure
|
180
|
+
FileUtils.rm_rf 'tmp'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
test "should fail if try to package with missing documentation" do
|
185
|
+
begin
|
186
|
+
FileUtils.mkdir 'tmp'
|
187
|
+
|
188
|
+
begin
|
189
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
190
|
+
:dir=>'tmp',
|
191
|
+
:docs=>'docs-fake')
|
192
|
+
assert false
|
193
|
+
rescue
|
194
|
+
assert Dir['tmp/*'].empty?
|
195
|
+
end
|
196
|
+
ensure
|
197
|
+
FileUtils.rm_rf 'tmp'
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
test "should fail if try to package with missing resources" do
|
202
|
+
begin
|
203
|
+
FileUtils.mkdir 'tmp'
|
204
|
+
|
205
|
+
begin
|
206
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
207
|
+
:dir=>'tmp',
|
208
|
+
:res=>'res-fake')
|
209
|
+
assert false
|
210
|
+
rescue
|
211
|
+
assert Dir['tmp/*'].empty?
|
212
|
+
end
|
213
|
+
ensure
|
214
|
+
FileUtils.rm_rf 'tmp'
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|