andparcel 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/TODO +5 -46
- data/VERSION +1 -1
- data/andparcel.gemspec +5 -3
- data/bin/parcel +26 -0
- data/lib/andparcel/parcel.rb +62 -10
- data/test/ParcelToPackage/assets/andParcel_test_foo.txt +1 -0
- data/test/ParcelToPackage/assets/bar/andParcel_test_goo.txt +1 -0
- data/test/ParcelToPackage/res/values/{strings.xml → andParcel_test_strings.xml} +0 -0
- data/test/test_install.rb +9 -0
- data/test/test_package.rb +42 -2
- data/test/test_remove.rb +11 -2
- metadata +5 -3
data/TODO
CHANGED
@@ -1,46 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Thursday
|
7
|
-
--------
|
8
|
-
wrap developer guide
|
9
|
-
deploy
|
10
|
-
point cwac-colormixer README to this
|
11
|
-
ABJ work
|
12
|
-
|
13
|
-
Friday
|
14
|
-
------
|
15
|
-
standards: parcel.json / catalog.json
|
16
|
-
ABJ work
|
17
|
-
|
18
|
-
Over Next Few Weeks
|
19
|
-
-------------------
|
20
|
-
get other key cwac- components parcel'd up
|
21
|
-
task
|
22
|
-
sample code into separate project
|
23
|
-
Ant builds
|
24
|
-
main
|
25
|
-
sample -- do replace
|
26
|
-
parcel.json
|
27
|
-
parcel & add to catalog
|
28
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
29
|
-
wakefulintentservice
|
30
|
-
sample code into separate project
|
31
|
-
Ant builds
|
32
|
-
main
|
33
|
-
sample -- do replace
|
34
|
-
parcel.json
|
35
|
-
parcel & add to catalog
|
36
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
37
|
-
endlessadapter
|
38
|
-
Ant builds
|
39
|
-
parcel.json
|
40
|
-
parcel & add to catalog
|
41
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
42
|
-
mergeadapter
|
43
|
-
Ant builds
|
44
|
-
parcel.json
|
45
|
-
parcel & add to catalog
|
46
|
-
put CW logo/links on CWAC README's, add links to CWAC blog posts, other updates
|
1
|
+
generate gem, confirm gem works in a VBox image
|
2
|
+
push gem; commit, tag as v0.3.0
|
3
|
+
update docs & republish
|
4
|
+
blog; comment/close issues
|
5
|
+
add issue: integrate -v/--version with git tags
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.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.3.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-31}
|
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}
|
@@ -42,6 +42,8 @@ Gem::Specification.new do |s|
|
|
42
42
|
"test/ParcelReceiver/res/values/strings.xml",
|
43
43
|
"test/ParcelReceiver/src/com/commonsware/android/pr/ParcelReceiver.java",
|
44
44
|
"test/ParcelToPackage/AndroidManifest.xml",
|
45
|
+
"test/ParcelToPackage/assets/andParcel_test_foo.txt",
|
46
|
+
"test/ParcelToPackage/assets/bar/andParcel_test_goo.txt",
|
45
47
|
"test/ParcelToPackage/build.properties",
|
46
48
|
"test/ParcelToPackage/build.xml",
|
47
49
|
"test/ParcelToPackage/default.properties",
|
@@ -52,7 +54,7 @@ Gem::Specification.new do |s|
|
|
52
54
|
"test/ParcelToPackage/local.properties",
|
53
55
|
"test/ParcelToPackage/parcel.json",
|
54
56
|
"test/ParcelToPackage/res/layout/andParcel_test_row.xml",
|
55
|
-
"test/ParcelToPackage/res/values/
|
57
|
+
"test/ParcelToPackage/res/values/andParcel_test_strings.xml",
|
56
58
|
"test/ParcelToPackage/src/com/commonsware/android/p2pkg/ParcelToPackage.java",
|
57
59
|
"test/ParcelToPackage/tmp/andParcel-test_0.1.0.zip",
|
58
60
|
"test/test_init.rb",
|
data/bin/parcel
CHANGED
@@ -14,7 +14,13 @@ require 'rubygems'
|
|
14
14
|
require 'trollop'
|
15
15
|
require 'andparcel'
|
16
16
|
|
17
|
+
|
18
|
+
|
17
19
|
module AndParcel
|
20
|
+
def self.version
|
21
|
+
"0.3.0"
|
22
|
+
end
|
23
|
+
|
18
24
|
def self.commands
|
19
25
|
@commands||={}
|
20
26
|
end
|
@@ -45,6 +51,7 @@ module AndParcel
|
|
45
51
|
opt :manifest, "manifest containing components to package (defaults to AndroidManifest.xml in project)", :type=>:string, :short=>'m'
|
46
52
|
# opt :dependencies, "names of parcels this parcel depends on", :type=>:strings
|
47
53
|
opt :res, "files/directories of resources to package (defaults to res/ in project)", :type=>:strings, :short=>'r'
|
54
|
+
opt :assets, "files/directories of assets to package (defaults to assets/ in project)", :type=>:strings, :short=>'a'
|
48
55
|
end
|
49
56
|
|
50
57
|
pkg_info=ARGV.shift || "package.json"
|
@@ -60,6 +67,10 @@ module AndParcel
|
|
60
67
|
opts[:res]=['res']
|
61
68
|
end
|
62
69
|
|
70
|
+
if !opts[:assets]
|
71
|
+
opts[:assets]=['assets']
|
72
|
+
end
|
73
|
+
|
63
74
|
if !opts[:manifest]
|
64
75
|
opts[:manifest]='AndroidManifest.xml'
|
65
76
|
end
|
@@ -127,6 +138,8 @@ module AndParcel
|
|
127
138
|
opt :project, "path to Android project (defaults to parcel.json directory)", :short=>'p'
|
128
139
|
opt :repair, "tells parcel to repair problems", :short=>'r', :default=>false
|
129
140
|
opt :quiet, "whether it should print output on success", :short=>'q', :default=>false
|
141
|
+
opt :res, "files/directories of resources to package (defaults to res/ in project)", :type=>:strings, :short=>'r'
|
142
|
+
opt :assets, "files/directories of assets to package (defaults to assets/ in project)", :type=>:strings, :short=>'a'
|
130
143
|
end
|
131
144
|
|
132
145
|
Trollop::die "parcel not provided" if ARGV.size==0
|
@@ -140,12 +153,25 @@ module AndParcel
|
|
140
153
|
pkg_info=File.basename(pkg_info)
|
141
154
|
end
|
142
155
|
|
156
|
+
if !opts[:res]
|
157
|
+
opts[:res]=['res']
|
158
|
+
end
|
159
|
+
|
160
|
+
if !opts[:assets]
|
161
|
+
opts[:assets]=['assets']
|
162
|
+
end
|
163
|
+
|
143
164
|
AndParcel::Parcel.lint(pkg_info, opts)
|
144
165
|
end
|
145
166
|
end
|
146
167
|
end
|
147
168
|
|
148
169
|
if ARGV.size>0
|
170
|
+
if ARGV.include?('--version') || ARGV.include?('-v')
|
171
|
+
$stderr.puts "parcel: an Android Parcel Project client\nVersion #{AndParcel.version}"
|
172
|
+
exit(0)
|
173
|
+
end
|
174
|
+
|
149
175
|
name=ARGV.shift
|
150
176
|
cls=AndParcel.commands[name]
|
151
177
|
|
data/lib/andparcel/parcel.rb
CHANGED
@@ -110,9 +110,10 @@ module AndParcel
|
|
110
110
|
Zip::ZipFile.open(target, Zip::ZipFile::CREATE) do |zf|
|
111
111
|
save_config(zf) if
|
112
112
|
manifest(zf) if
|
113
|
-
|
114
|
-
|
115
|
-
|
113
|
+
assets(zf) if
|
114
|
+
resources(zf) if
|
115
|
+
docs(zf) if
|
116
|
+
libs(zf)
|
116
117
|
end
|
117
118
|
|
118
119
|
target
|
@@ -171,6 +172,19 @@ module AndParcel
|
|
171
172
|
true
|
172
173
|
end
|
173
174
|
|
175
|
+
# For each asset to go into the ZIP file, add it
|
176
|
+
def assets(zf)
|
177
|
+
if opts[:assets]
|
178
|
+
files=AndParcel.glob(opts[:assets], opts[:project])
|
179
|
+
|
180
|
+
files.each do |fr|
|
181
|
+
zf.add(File.join('assets', fr.relative), fr.local)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
true
|
186
|
+
end
|
187
|
+
|
174
188
|
# Scan the manifest template and grab all children of
|
175
189
|
# the <application> element
|
176
190
|
def manifest(zf)
|
@@ -256,10 +270,11 @@ module AndParcel
|
|
256
270
|
begin
|
257
271
|
dependencies if
|
258
272
|
manifest(zf) if
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
273
|
+
assets(zf) if
|
274
|
+
resources(zf) if
|
275
|
+
docs(zf) if
|
276
|
+
libs(zf) if
|
277
|
+
load_config(zf)
|
263
278
|
|
264
279
|
FileUtils.mv dest, @parcel_root
|
265
280
|
ensure
|
@@ -346,6 +361,22 @@ module AndParcel
|
|
346
361
|
true
|
347
362
|
end
|
348
363
|
|
364
|
+
def assets(zf)
|
365
|
+
dir=File.join(@root, 'assets')
|
366
|
+
|
367
|
+
zf.entries.each do |entry|
|
368
|
+
if (/^assets\/(.+)$/.match entry.name)
|
369
|
+
name=$1
|
370
|
+
dest=File.join(dir, File.dirname(name), File.basename(name))
|
371
|
+
FileUtils.mkdir_p File.dirname(dest)
|
372
|
+
File.unlink(dest) if File.exists?(dest)
|
373
|
+
entry.extract dest
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
true
|
378
|
+
end
|
379
|
+
|
349
380
|
# If the parcel has a +ManifestMerge.xml+ file, back up and
|
350
381
|
# then open the project's +AndroidManifest.xml+ file,
|
351
382
|
# and merge in anything with a distinct name.
|
@@ -410,8 +441,9 @@ module AndParcel
|
|
410
441
|
if dest
|
411
442
|
Zip::ZipFile.open(dest) do |zf|
|
412
443
|
manifest(zf) if
|
413
|
-
|
414
|
-
|
444
|
+
assets(zf) if
|
445
|
+
resources(zf) if
|
446
|
+
libs(zf)
|
415
447
|
end
|
416
448
|
|
417
449
|
FileUtils.rm_rf @parcel_root
|
@@ -446,6 +478,20 @@ module AndParcel
|
|
446
478
|
true
|
447
479
|
end
|
448
480
|
|
481
|
+
def assets(zf)
|
482
|
+
dir=File.join(@root, 'assets')
|
483
|
+
|
484
|
+
zf.entries.each do |entry|
|
485
|
+
if (/^assets\/(.+)$/.match entry.name)
|
486
|
+
name=$1
|
487
|
+
dest=File.join(dir, File.dirname(name), File.basename(name))
|
488
|
+
File.unlink(dest) if File.exists?(dest)
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
true
|
493
|
+
end
|
494
|
+
|
449
495
|
def manifest(zf)
|
450
496
|
end
|
451
497
|
end
|
@@ -465,7 +511,7 @@ module AndParcel
|
|
465
511
|
@prefix_regexp=Regexp.compile(@prefix+'.*')
|
466
512
|
@issues=0
|
467
513
|
|
468
|
-
resources=AndParcel.glob(
|
514
|
+
resources=AndParcel.glob(opts[:res], opts[:project])
|
469
515
|
|
470
516
|
resources.each do |fr|
|
471
517
|
if fr.local.split('').last!='~'
|
@@ -481,6 +527,12 @@ module AndParcel
|
|
481
527
|
end
|
482
528
|
end
|
483
529
|
|
530
|
+
AndParcel.glob(opts[:assets], opts[:project]).each do |fr|
|
531
|
+
if fr.local.split('').last!='~'
|
532
|
+
do_simple_resource(fr)
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
484
536
|
if @issues>0
|
485
537
|
out.puts "#{@issues} issues reported #{'and fixed' if opts[:repair]}"
|
486
538
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello, world
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello, world
|
File without changes
|
data/test/test_install.rb
CHANGED
@@ -62,13 +62,22 @@ Protest.context("when installing a parcel into a project") do
|
|
62
62
|
:res=>'res')
|
63
63
|
end
|
64
64
|
|
65
|
+
test "should support a parcel with assets" do
|
66
|
+
install_test(['tmp2/assets/andParcel_test_foo.txt',
|
67
|
+
'tmp2/assets/bar/andParcel_test_goo.txt'],
|
68
|
+
:assets=>'assets')
|
69
|
+
end
|
70
|
+
|
65
71
|
test "should support a parcel with all sorts of stuff" do
|
66
72
|
install_test(['tmp2/res/layout/andParcel_test_row.xml',
|
67
73
|
'tmp2/res/values/strings.xml',
|
68
74
|
'tmp2/libs/one.jar',
|
69
75
|
'tmp2/libs/two.jar',
|
76
|
+
'tmp2/assets/andParcel_test_foo.txt',
|
77
|
+
'tmp2/assets/bar/andParcel_test_goo.txt',
|
70
78
|
'tmp2/parcels/andParcel-test/docs/README'],
|
71
79
|
:res=>'res',
|
80
|
+
:assets=>'assets',
|
72
81
|
:jars=>'libs',
|
73
82
|
:docs=>['docs/README', 'docs/SomeOtherFile'])
|
74
83
|
end
|
data/test/test_package.rb
CHANGED
@@ -98,7 +98,34 @@ Protest.context("when packaging a parcel") do
|
|
98
98
|
Zip::ZipFile.open(target) do |zf|
|
99
99
|
zf.entries.each do |entry|
|
100
100
|
if ('res/layout/andParcel_test_row.xml'==entry.name ||
|
101
|
-
'res/values/
|
101
|
+
'res/values/andParcel_test_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 assets" do
|
113
|
+
begin
|
114
|
+
FileUtils.mkdir 'tmp'
|
115
|
+
target=AndParcel::Parcel.package('test/ParcelToPackage/parcel.json',
|
116
|
+
:dir=>'tmp',
|
117
|
+
:assets=>'assets')
|
118
|
+
assert target=='tmp/andParcel-test_0.1.0.zip'
|
119
|
+
assert File.exists?(target)
|
120
|
+
config=load_config(target)
|
121
|
+
config_assert(config)
|
122
|
+
|
123
|
+
matches=0
|
124
|
+
|
125
|
+
Zip::ZipFile.open(target) do |zf|
|
126
|
+
zf.entries.each do |entry|
|
127
|
+
if ('assets/andParcel_test_foo.txt'==entry.name ||
|
128
|
+
'assets/bar/andParcel_test_goo.txt'==entry.name)
|
102
129
|
matches+=1
|
103
130
|
end
|
104
131
|
end
|
@@ -116,7 +143,8 @@ Protest.context("when packaging a parcel") do
|
|
116
143
|
:dir=>'tmp',
|
117
144
|
:jars=>'libs',
|
118
145
|
:manifest=>'AndroidManifest.xml',
|
119
|
-
:docs=>'docs'
|
146
|
+
:docs=>'docs',
|
147
|
+
:assets=>'assets')
|
120
148
|
assert target=='tmp/andParcel-test_0.1.0.zip'
|
121
149
|
assert File.exists?(target)
|
122
150
|
config=load_config(target)
|
@@ -142,6 +170,18 @@ Protest.context("when packaging a parcel") do
|
|
142
170
|
end
|
143
171
|
end
|
144
172
|
assert matches==1
|
173
|
+
|
174
|
+
matches=0
|
175
|
+
|
176
|
+
Zip::ZipFile.open(target) do |zf|
|
177
|
+
zf.entries.each do |entry|
|
178
|
+
if ('assets/andParcel_test_foo.txt'==entry.name ||
|
179
|
+
'assets/bar/andParcel_test_goo.txt'==entry.name)
|
180
|
+
matches+=1
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
assert matches==2
|
145
185
|
ensure
|
146
186
|
FileUtils.rm_rf 'tmp'
|
147
187
|
end
|
data/test/test_remove.rb
CHANGED
@@ -56,17 +56,26 @@ Protest.context("when removing a parcel from a project") do
|
|
56
56
|
|
57
57
|
test "should support a parcel with resources" do
|
58
58
|
remove_test(['tmp2/res/layout/andParcel_test_row.xml',
|
59
|
-
'tmp2/res/values/
|
59
|
+
'tmp2/res/values/andParcel_test_strings.xml'],
|
60
60
|
:res=>'res')
|
61
61
|
end
|
62
62
|
|
63
|
+
test "should support a parcel with assets" do
|
64
|
+
remove_test(['tmp2/assets/andParcel_test_foo.txt',
|
65
|
+
'tmp2/assets/bar/andParcel_test_goo.txt'],
|
66
|
+
:assets=>'assets')
|
67
|
+
end
|
68
|
+
|
63
69
|
test "should support a parcel with all sorts of stuff" do
|
64
70
|
remove_test(['tmp2/libs/one.jar',
|
65
71
|
'tmp2/libs/two.jar',
|
72
|
+
'tmp2/assets/andParcel_test_foo.txt',
|
73
|
+
'tmp2/assets/bar/andParcel_test_goo.txt',
|
66
74
|
'tmp2/res/layout/andParcel_test_row.xml',
|
67
|
-
'tmp2/res/values/
|
75
|
+
'tmp2/res/values/andParcel_test_strings.xml'],
|
68
76
|
:docs=>'docs',
|
69
77
|
:jars=>'libs',
|
78
|
+
:assets=>'assets',
|
70
79
|
:res=>'res')
|
71
80
|
end
|
72
81
|
|
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.3.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-31 00:00:00 -04:00
|
13
13
|
default_executable: parcel
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -105,6 +105,8 @@ files:
|
|
105
105
|
- test/ParcelReceiver/res/values/strings.xml
|
106
106
|
- test/ParcelReceiver/src/com/commonsware/android/pr/ParcelReceiver.java
|
107
107
|
- test/ParcelToPackage/AndroidManifest.xml
|
108
|
+
- test/ParcelToPackage/assets/andParcel_test_foo.txt
|
109
|
+
- test/ParcelToPackage/assets/bar/andParcel_test_goo.txt
|
108
110
|
- test/ParcelToPackage/build.properties
|
109
111
|
- test/ParcelToPackage/build.xml
|
110
112
|
- test/ParcelToPackage/default.properties
|
@@ -115,7 +117,7 @@ files:
|
|
115
117
|
- test/ParcelToPackage/local.properties
|
116
118
|
- test/ParcelToPackage/parcel.json
|
117
119
|
- test/ParcelToPackage/res/layout/andParcel_test_row.xml
|
118
|
-
- test/ParcelToPackage/res/values/
|
120
|
+
- test/ParcelToPackage/res/values/andParcel_test_strings.xml
|
119
121
|
- test/ParcelToPackage/src/com/commonsware/android/p2pkg/ParcelToPackage.java
|
120
122
|
- test/ParcelToPackage/tmp/andParcel-test_0.1.0.zip
|
121
123
|
- test/test_init.rb
|