cdnget 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (9) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +12 -0
  3. data/README.md +2 -1
  4. data/Rakefile +1 -1
  5. data/bin/cdnget +155 -105
  6. data/cdnget.gemspec +4 -5
  7. data/lib/cdnget.rb +155 -105
  8. data/test/cdnget_test.rb +707 -410
  9. metadata +11 -26
data/test/cdnget_test.rb CHANGED
@@ -1,56 +1,54 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'stringio'
4
-
5
- require 'minitest'
6
- require 'minitest/spec'
7
- require 'minitest/autorun'
8
- require 'minitest/ok'
4
+ require 'oktest'
9
5
 
10
6
  require 'cdnget'
11
7
 
12
8
 
13
- describe CDNGet do
9
+ Oktest.scope do
14
10
 
15
- def capture_io(stdin=nil)
16
- bkup = [$stdin, $stdout, $stderr]
17
- $stdin = StringIO.new(stdin || "")
18
- $stdout = StringIO.new
19
- $stderr = StringIO.new
20
- begin
21
- yield
22
- return $stdout.string(), $stderr.string()
23
- ensure
24
- $stdin, $stdout, $stderr = bkup
25
- end
11
+ CDN_NAMES = ['cdnjs', 'jsdelivr', 'unpkg', 'google']
12
+
13
+ def run(*args)
14
+ return CDNGet::Main.new("cdnget").run(*args)
15
+ end
16
+
17
+ before do
18
+ @tmpdir = "tmpdir1"
19
+ Dir.mkdir @tmpdir
20
+ end
21
+
22
+ after do
23
+ FileUtils.rm_rf @tmpdir
26
24
  end
27
25
 
28
26
 
29
- describe 'cdnget [-h][--help]' do
27
+ topic 'cdnget [-h][--help]' do
30
28
 
31
- it "prints help message." do
29
+ spec "prints help message." do
32
30
  expected = CDNGet::Main.new("cdnget").help_message()
33
- ok {CDNGet::Main.new("cdnget").run("-h")} == expected
34
- ok {CDNGet::Main.new("cdnget").run("--help")} == expected
31
+ ok {run("-h")} == expected
32
+ ok {run("--help")} == expected
35
33
  end
36
34
 
37
35
  end
38
36
 
39
37
 
40
- describe 'cdnget [-v][--version]' do
38
+ topic 'cdnget [-v][--version]' do
41
39
 
42
- it "prints help message." do
40
+ spec "prints help message." do
43
41
  expected = CDNGet::RELEASE + "\n"
44
- ok {CDNGet::Main.new("cdnget").run("-v")} == expected
45
- ok {CDNGet::Main.new("cdnget").run("--version")} == expected
42
+ ok {run("-v")} == expected
43
+ ok {run("--version")} == expected
46
44
  end
47
45
 
48
46
  end
49
47
 
50
48
 
51
- describe 'cdnget' do
49
+ topic 'cdnget' do
52
50
 
53
- it "lists CDN." do
51
+ spec "lists CDN." do
54
52
  expected = <<END
55
53
  cdnjs # https://cdnjs.com/
56
54
  jsdelivr # https://www.jsdelivr.com/
@@ -59,51 +57,49 @@ google # https://developers.google.com/speed/libraries/
59
57
  #jquery # https://code.jquery.com/
60
58
  #aspnet # https://www.asp.net/ajax/cdn/
61
59
  END
62
- actual = CDNGet::Main.new().run()
60
+ actual = run()
63
61
  ok {actual} == expected.gsub(/^\#.*\n/, '')
64
62
  end
65
63
 
66
64
  end
67
65
 
68
66
 
69
- describe 'cdnget CDN' do
67
+ topic 'cdnget <CDN>' do
70
68
 
71
- it "(cdnjs) lists librareis." do
72
- actual = CDNGet::Main.new().run("cdnjs")
69
+ spec "(cdnjs) lists librareis." do
70
+ actual = run("cdnjs")
73
71
  ok {actual} =~ /^jquery # JavaScript library for DOM operations$/
74
72
  ok {actual} =~ /^angular\.js # AngularJS is an MVC framework for building web applications\./
75
73
  ok {actual} =~ /^ember\.js # Ember is a JavaScript framework for creating ambitious web applications that eliminates boilerplate and provides a standard application architecture\./
76
74
  end
77
75
 
78
- it "(google) lists librareis." do
79
- actual = CDNGet::Main.new().run("google")
80
- ok {actual} =~ /^jquery /
81
- #ok {actual} =~ /^angularjs /
82
- ok {actual} =~ /^swfobject /
83
- ok {actual} =~ /^webfont /
76
+ spec "(jsdelivr) lists librareis." do
77
+ pr = proc { run("jsdelivr") }
78
+ ok {pr}.raise?(CDNGet::CommandError,
79
+ "jsdelivr: cannot list libraries; please specify pattern such as 'jquery*'.")
84
80
  end
85
81
 
86
- it "(jsdelivr) lists librareis." do
87
- exc = assert_raises(CDNGet::CommandError) do
88
- actual = CDNGet::Main.new().run("jsdelivr")
89
- end
90
- ok {exc.message} == "jsdelivr: cannot list libraries; please specify pattern such as 'jquery*'."
82
+ spec "(unpkg) lists librareis." do
83
+ pr = proc { run("unpkg") }
84
+ ok {pr}.raise?(CDNGet::CommandError,
85
+ "unpkg: cannot list libraries; please specify pattern such as 'jquery*'.")
91
86
  end
92
87
 
93
- it "(unpkg) lists librareis." do
94
- exc = assert_raises(CDNGet::CommandError) do
95
- actual = CDNGet::Main.new().run("unpkg")
96
- end
97
- ok {exc.message} == "unpkg: cannot list libraries; please specify pattern such as 'jquery*'."
88
+ spec "(google) lists librareis." do
89
+ actual = run("google")
90
+ ok {actual} =~ /^jquery /
91
+ #ok {actual} =~ /^angularjs /
92
+ ok {actual} =~ /^swfobject /
93
+ ok {actual} =~ /^webfont /
98
94
  end
99
95
 
100
96
  end
101
97
 
102
98
 
103
- describe 'cdnget CDN "jquery*"' do
99
+ topic 'cdnget <CDN> <pattern> (#1)' do
104
100
 
105
- it "(cdnjs) lists libraries starting to pattern." do
106
- actual = CDNGet::Main.new().run("cdnjs", "jquery*")
101
+ spec "(cdnjs) lists libraries starting to pattern." do
102
+ actual = run("cdnjs", "jquery*")
107
103
  ok {actual} =~ /^jquery #/
108
104
  ok {actual} =~ /^jqueryui #/ # match
109
105
  ok {actual} !~ /^require-jquery #/ # not match
@@ -112,36 +108,36 @@ END
112
108
  ok {actual} !~ /^ember\.js/
113
109
  end
114
110
 
115
- it "(google) lists libraries starting to pattern." do
116
- actual = CDNGet::Main.new().run("google", "jquery*")
117
- ok {actual} =~ /^jquery #/
118
- ok {actual} =~ /^jqueryui #/ # match
119
- ok {actual} !~ /^angularjs/
120
- end
121
-
122
- it "(jsdelivr) lists libraries starting to pattern." do
123
- actual = CDNGet::Main.new().run("jsdelivr", "jquery*")
111
+ spec "(jsdelivr) lists libraries starting to pattern." do
112
+ actual = run("jsdelivr", "jquery*")
124
113
  ok {actual} =~ /^jquery #/
125
114
  ok {actual} =~ /^jquery-datepicker #/ # match
126
115
  ok {actual} !~ /^angularjs/
127
116
  ok {actual} !~ /^bootstrap/
128
117
  end
129
118
 
130
- it "(unpkg) lists libraries starting to pattern." do
131
- actual = CDNGet::Main.new().run("unpkg", "jquery*")
119
+ spec "(unpkg) lists libraries starting to pattern." do
120
+ actual = run("unpkg", "jquery*")
132
121
  ok {actual} =~ /^jquery #/
133
122
  ok {actual} =~ /^jquery-ui #/ # match
134
123
  ok {actual} !~ /^jquery\.ui /
135
124
  ok {actual} !~ /^bootstrap/
136
125
  end
137
126
 
127
+ spec "(google) lists libraries starting to pattern." do
128
+ actual = run("google", "jquery*")
129
+ ok {actual} =~ /^jquery #/
130
+ ok {actual} =~ /^jqueryui #/ # match
131
+ ok {actual} !~ /^angularjs/
132
+ end
133
+
138
134
  end
139
135
 
140
136
 
141
- describe 'cdnget cdnjs "*jquery"' do
137
+ topic 'cdnget <CDN> <pattern> (#2)' do
142
138
 
143
- it "(cdnjs) lists libraries ending to pattern." do
144
- actual = CDNGet::Main.new().run("cdnjs", "*jquery")
139
+ spec "(cdnjs) lists libraries ending to pattern." do
140
+ actual = run("cdnjs", "*jquery")
145
141
  ok {actual} =~ /^jquery #/
146
142
  ok {actual} !~ /^jqueryui #/ # not match
147
143
  ok {actual} =~ /^require-jquery #/ # match
@@ -150,36 +146,36 @@ END
150
146
  ok {actual} !~ /^ember\.js/
151
147
  end
152
148
 
153
- it "(google) lists libraries ending to pattern." do
154
- actual = CDNGet::Main.new().run("google", "*jquery")
149
+ spec "(jsdelivr) lists libraries ending to pattern." do
150
+ actual = run("jsdelivr", "*jquery")
155
151
  ok {actual} =~ /^jquery #/
156
- ok {actual} !~ /^jqueryui #/ # not match
152
+ ok {actual} !~ /^jquery-datepicker / # not match
157
153
  ok {actual} !~ /^angularjs/
154
+ ok {actual} !~ /^bootstrap/
158
155
  end
159
156
 
160
- it "(jsdelivr) lists libraries ending to pattern." do
161
- actual = CDNGet::Main.new().run("jsdelivr", "*jquery")
157
+ spec "(unpkg) lists libraries ending to pattern." do
158
+ actual = run("unpkg", "*jquery")
162
159
  ok {actual} =~ /^jquery #/
163
- ok {actual} !~ /^jquery-datepicker / # not match
160
+ ok {actual} !~ /^jquery-ui #/ # not match
164
161
  ok {actual} !~ /^angularjs/
165
162
  ok {actual} !~ /^bootstrap/
166
163
  end
167
164
 
168
- it "(unpkg) lists libraries ending to pattern." do
169
- actual = CDNGet::Main.new().run("unpkg", "*jquery")
165
+ spec "(google) lists libraries ending to pattern." do
166
+ actual = run("google", "*jquery")
170
167
  ok {actual} =~ /^jquery #/
171
- ok {actual} !~ /^jquery-ui #/ # not match
168
+ ok {actual} !~ /^jqueryui #/ # not match
172
169
  ok {actual} !~ /^angularjs/
173
- ok {actual} !~ /^bootstrap/
174
170
  end
175
171
 
176
172
  end
177
173
 
178
174
 
179
- describe 'cdnget cdnjs "*jquery*"' do
175
+ topic 'cdnget <CDN> <pattern> (#3)' do
180
176
 
181
- it "(cdnjs) lists libraries including pattern." do
182
- actual = CDNGet::Main.new().run("cdnjs", "*jquery*")
177
+ spec "(cdnjs) lists libraries including pattern." do
178
+ actual = run("cdnjs", "*jquery*")
183
179
  ok {actual} =~ /^jquery #/
184
180
  ok {actual} =~ /^jqueryui #/ # match
185
181
  ok {actual} =~ /^require-jquery #/ # match
@@ -188,16 +184,8 @@ END
188
184
  ok {actual} !~ /^ember\.js/
189
185
  end
190
186
 
191
- it "(google) lists libraries including pattern." do
192
- actual = CDNGet::Main.new().run("google", "*o*")
193
- ok {actual} !~ /^jquery /
194
- ok {actual} !~ /^angularjs /
195
- ok {actual} =~ /^mootools /
196
- ok {actual} =~ /^swfobject /
197
- end
198
-
199
- it "(jsdelivr) lists libraries including pattern." do
200
- actual = CDNGet::Main.new().run("jsdelivr", "*jquery*")
187
+ spec "(jsdelivr) lists libraries including pattern." do
188
+ actual = run("jsdelivr", "*jquery*")
201
189
  ok {actual} =~ /^jquery /
202
190
  ok {actual} =~ /^jasmine-jquery /
203
191
  ok {actual} =~ /^jquery-form /
@@ -205,8 +193,8 @@ END
205
193
  ok {actual} !~ /^react/
206
194
  end
207
195
 
208
- it "(unpkg) lists libraries including pattern." do
209
- actual = CDNGet::Main.new().run("unpkg", "*jquery*")
196
+ spec "(unpkg) lists libraries including pattern." do
197
+ actual = run("unpkg", "*jquery*")
210
198
  ok {actual} =~ /^jquery /
211
199
  ok {actual} =~ /^jquery-csv /
212
200
  ok {actual} =~ /^jquery\.terminal /
@@ -215,13 +203,21 @@ END
215
203
  ok {actual} !~ /^bootstrap/
216
204
  end
217
205
 
206
+ spec "(google) lists libraries including pattern." do
207
+ actual = run("google", "*o*")
208
+ ok {actual} !~ /^jquery /
209
+ ok {actual} !~ /^angularjs /
210
+ ok {actual} =~ /^mootools /
211
+ ok {actual} =~ /^swfobject /
212
+ end
213
+
218
214
  end
219
215
 
220
216
 
221
- describe "cdnget CDN jquery" do
217
+ topic "cdnget <CDN> <library> (exists)" do
222
218
 
223
- it "(cdnjs) lists versions of library." do
224
- actual = CDNGet::Main.new().run("cdnjs", "jquery")
219
+ spec "(cdnjs) lists versions of library." do
220
+ actual = run("cdnjs", "jquery")
225
221
  text1 = <<END
226
222
  name: jquery
227
223
  desc: JavaScript library for DOM operations
@@ -244,29 +240,8 @@ END
244
240
  ok {actual} =~ /^ - 1\.12\.0$/
245
241
  end
246
242
 
247
- it "(google) lists versions of library." do
248
- actual = CDNGet::Main.new().run("google", "jquery")
249
- text1 = <<END
250
- name: jquery
251
- site: http://jquery.com/
252
- info: https://developers.google.com/speed/libraries/#jquery
253
- versions:
254
- END
255
- ok {actual}.start_with?(text1)
256
- text2 = <<END
257
- - 1.3.2
258
- - 1.3.1
259
- - 1.3.0
260
- - 1.2.6
261
- - 1.2.3
262
- END
263
- ok {actual}.end_with?(text2)
264
- ok {actual} =~ /^ - 2\.2\.0$/
265
- ok {actual} =~ /^ - 1\.12\.0$/
266
- end
267
-
268
- it "(jsdelivr) lists versions of library." do
269
- actual = CDNGet::Main.new().run("jsdelivr", "jquery")
243
+ spec "(jsdelivr) lists versions of library." do
244
+ actual = run("jsdelivr", "jquery")
270
245
  text1 = <<END
271
246
  name: jquery
272
247
  desc: JavaScript library for DOM operations
@@ -290,8 +265,8 @@ END
290
265
  ok {actual} =~ /^ - 1\.12\.0$/
291
266
  end
292
267
 
293
- it "(unpkg) lists versions of library." do
294
- actual = CDNGet::Main.new().run("unpkg", "jquery")
268
+ spec "(unpkg) lists versions of library." do
269
+ actual = run("unpkg", "jquery")
295
270
  text1 = <<END
296
271
  name: jquery
297
272
  desc: JavaScript library for DOM operations
@@ -314,35 +289,61 @@ END
314
289
  ok {actual} =~ /^ - 1\.12\.0$/
315
290
  end
316
291
 
317
- it "(cdnjs) raises error when library name is wrong." do
318
- pr = proc { CDNGet::Main.new().run("cdnjs", "jquery-ui") }
292
+ spec "(google) lists versions of library." do
293
+ actual = run("google", "jquery")
294
+ text1 = <<END
295
+ name: jquery
296
+ site: http://jquery.com/
297
+ info: https://developers.google.com/speed/libraries/#jquery
298
+ versions:
299
+ END
300
+ ok {actual}.start_with?(text1)
301
+ text2 = <<END
302
+ - 1.3.2
303
+ - 1.3.1
304
+ - 1.3.0
305
+ - 1.2.6
306
+ - 1.2.3
307
+ END
308
+ ok {actual}.end_with?(text2)
309
+ ok {actual} =~ /^ - 2\.2\.0$/
310
+ ok {actual} =~ /^ - 1\.12\.0$/
311
+ end
312
+
313
+ end
314
+
315
+
316
+ topic "cdnget <CDN> <library> (not exist)" do
317
+
318
+ spec "(cdnjs) raises error when library name is wrong." do
319
+ pr = proc { run("cdnjs", "jquery-ui") }
319
320
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
320
321
  #
321
- pr = proc { CDNGet::Main.new().run("cdnjs", "emberjs", "2.2.1") }
322
+ pr = proc { run("cdnjs", "emberjs", "2.2.1") }
322
323
  ok {pr}.raise?(CDNGet::CommandError, "emberjs: Library not found (maybe 'ember.js'?).")
323
324
  end
324
325
 
325
- it "(google) raises error when library name is wrong." do
326
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui") }
327
- ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
326
+ spec "(jsdelivr) raises error when library name is wrong." do
327
+ pr = proc { run("jsdelivr", "jquery-foobar") }
328
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
328
329
  end
329
330
 
330
- it "(jsdelivr) raises error when library name is wrong." do
331
- pr = proc { CDNGet::Main.new().run("jsdelivr", "jquery-foobar") }
331
+ spec "(unpkg) raises error when library name is wrong." do
332
+ pr = proc { run("unpkg", "jquery-foobar") }
332
333
  ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
333
334
  end
334
335
 
335
- it "(unpkg) raises error when library name is wrong." do
336
- pr = proc { CDNGet::Main.new().run("unpkg", "jquery-foobar") }
337
- ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
336
+ spec "(google) raises error when library name is wrong." do
337
+ pr = proc { run("google", "jquery-ui") }
338
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
338
339
  end
339
340
 
340
341
  end
341
342
 
342
343
 
343
- describe "cdnget cdnjs jquery 2.2.0" do
344
+ topic "cdnget <CDN> <library> <version> (only files)" do
344
345
 
345
- it "(cdnjs) lists files." do
346
+ spec "(cdnjs) lists files." do
346
347
  expected = <<END
347
348
  name: jquery
348
349
  version: 2.2.0
@@ -356,24 +357,11 @@ urls:
356
357
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js
357
358
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.map
358
359
  END
359
- actual = CDNGet::Main.new().run("cdnjs", "jquery", "2.2.0")
360
- ok {actual} == expected
361
- end
362
-
363
- it "(google) lists files." do
364
- expected = <<END
365
- name: jquery
366
- version: 2.2.0
367
- site: http://jquery.com/
368
- info: https://developers.google.com/speed/libraries/#jquery
369
- urls:
370
- - https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
371
- END
372
- actual = CDNGet::Main.new().run("google", "jquery", "2.2.0")
360
+ actual = run("cdnjs", "jquery", "2.2.0")
373
361
  ok {actual} == expected
374
362
  end
375
363
 
376
- it "(jsdelivr) lists files." do
364
+ spec "(jsdelivr) lists files." do
377
365
  expected = <<END
378
366
  name: jquery
379
367
  version: 2.2.0
@@ -392,11 +380,11 @@ urls:
392
380
  - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.min.map
393
381
  - https://cdn.jsdelivr.net/npm/jquery@2.2.0/LICENSE.txt
394
382
  END
395
- actual = CDNGet::Main.new().run("jsdelivr", "jquery", "2.2.0")
383
+ actual = run("jsdelivr", "jquery", "2.2.0")
396
384
  ok {actual}.start_with?(expected)
397
385
  end
398
386
 
399
- it "(unpkg) lists files." do
387
+ spec "(unpkg) lists files." do
400
388
  expected = <<END
401
389
  name: jquery
402
390
  version: 3.6.0
@@ -405,40 +393,20 @@ tags: jquery, javascript, browser, library
405
393
  site: https://jquery.com
406
394
  info: https://unpkg.com/browse/jquery@3.6.0/
407
395
  npmpkg: https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz
408
- default: /dist/jquery.min.js
409
396
  license: MIT
410
397
  urls:
411
- - https://unpkg.com/jquery@3.6.0/AUTHORS.txt
412
- - https://unpkg.com/jquery@3.6.0/bower.json
413
- - https://unpkg.com/jquery@3.6.0/dist/jquery.js
414
- - https://unpkg.com/jquery@3.6.0/dist/jquery.min.js
415
- - https://unpkg.com/jquery@3.6.0/dist/jquery.min.map
416
- - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.js
417
- - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.min.js
418
- - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.min.map
419
- - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.js
420
- - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.min.js
421
- - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.min.map
422
- - https://unpkg.com/jquery@3.6.0/external/sizzle/LICENSE.txt
423
- - https://unpkg.com/jquery@3.6.0/LICENSE.txt
424
- - https://unpkg.com/jquery@3.6.0/package.json
425
- - https://unpkg.com/jquery@3.6.0/README.md
426
- - https://unpkg.com/jquery@3.6.0/src/ajax.js
427
- - https://unpkg.com/jquery@3.6.0/src/ajax/jsonp.js
428
- - https://unpkg.com/jquery@3.6.0/src/ajax/load.js
429
- - https://unpkg.com/jquery@3.6.0/src/ajax/script.js
430
- - https://unpkg.com/jquery@3.6.0/src/ajax/var/location.js
431
- - https://unpkg.com/jquery@3.6.0/src/ajax/var/nonce.js
432
- - https://unpkg.com/jquery@3.6.0/src/ajax/var/rquery.js
433
- - https://unpkg.com/jquery@3.6.0/src/ajax/xhr.js
434
- - https://unpkg.com/jquery@3.6.0/src/attributes.js
435
- - https://unpkg.com/jquery@3.6.0/src/attributes/attr.js
436
- - https://unpkg.com/jquery@3.6.0/src/attributes/classes.js
437
- - https://unpkg.com/jquery@3.6.0/src/attributes/prop.js
438
- - https://unpkg.com/jquery@3.6.0/src/attributes/support.js
439
- - https://unpkg.com/jquery@3.6.0/src/attributes/val.js
440
- - https://unpkg.com/jquery@3.6.0/src/callbacks.js
441
- - https://unpkg.com/jquery@3.6.0/src/core.js
398
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/_evalUrl.js
399
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/buildFragment.js
400
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/getAll.js
401
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/var/rscriptType.js
402
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/var/rtagName.js
403
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/setGlobalEval.js
404
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/support.js
405
+ - https://unpkg.com/jquery@3.6.0/src/manipulation/wrapMap.js
406
+ - https://unpkg.com/jquery@3.6.0/src/data/var/acceptData.js
407
+ - https://unpkg.com/jquery@3.6.0/src/data/var/dataPriv.js
408
+ - https://unpkg.com/jquery@3.6.0/src/data/var/dataUser.js
409
+ - https://unpkg.com/jquery@3.6.0/src/data/Data.js
442
410
  - https://unpkg.com/jquery@3.6.0/src/core/access.js
443
411
  - https://unpkg.com/jquery@3.6.0/src/core/camelCase.js
444
412
  - https://unpkg.com/jquery@3.6.0/src/core/DOMEval.js
@@ -447,69 +415,33 @@ urls:
447
415
  - https://unpkg.com/jquery@3.6.0/src/core/nodeName.js
448
416
  - https://unpkg.com/jquery@3.6.0/src/core/parseHTML.js
449
417
  - https://unpkg.com/jquery@3.6.0/src/core/parseXML.js
450
- - https://unpkg.com/jquery@3.6.0/src/core/ready.js
451
418
  - https://unpkg.com/jquery@3.6.0/src/core/ready-no-deferred.js
419
+ - https://unpkg.com/jquery@3.6.0/src/core/ready.js
452
420
  - https://unpkg.com/jquery@3.6.0/src/core/readyException.js
421
+ - https://unpkg.com/jquery@3.6.0/src/core/var/rsingleTag.js
453
422
  - https://unpkg.com/jquery@3.6.0/src/core/stripAndCollapse.js
454
423
  - https://unpkg.com/jquery@3.6.0/src/core/support.js
455
424
  - https://unpkg.com/jquery@3.6.0/src/core/toType.js
456
- - https://unpkg.com/jquery@3.6.0/src/core/var/rsingleTag.js
457
- - https://unpkg.com/jquery@3.6.0/src/css.js
458
425
  - https://unpkg.com/jquery@3.6.0/src/css/addGetHookIf.js
459
426
  - https://unpkg.com/jquery@3.6.0/src/css/adjustCSS.js
460
- - https://unpkg.com/jquery@3.6.0/src/css/curCSS.js
461
- - https://unpkg.com/jquery@3.6.0/src/css/finalPropName.js
462
- - https://unpkg.com/jquery@3.6.0/src/css/hiddenVisibleSelectors.js
463
- - https://unpkg.com/jquery@3.6.0/src/css/showHide.js
464
- - https://unpkg.com/jquery@3.6.0/src/css/support.js
465
427
  - https://unpkg.com/jquery@3.6.0/src/css/var/cssExpand.js
466
428
  - https://unpkg.com/jquery@3.6.0/src/css/var/getStyles.js
467
429
  - https://unpkg.com/jquery@3.6.0/src/css/var/isHiddenWithinTree.js
468
430
  - https://unpkg.com/jquery@3.6.0/src/css/var/rboxStyle.js
469
431
  - https://unpkg.com/jquery@3.6.0/src/css/var/rnumnonpx.js
470
432
  - https://unpkg.com/jquery@3.6.0/src/css/var/swap.js
471
- - https://unpkg.com/jquery@3.6.0/src/data.js
472
- - https://unpkg.com/jquery@3.6.0/src/data/Data.js
473
- - https://unpkg.com/jquery@3.6.0/src/data/var/acceptData.js
474
- - https://unpkg.com/jquery@3.6.0/src/data/var/dataPriv.js
475
- - https://unpkg.com/jquery@3.6.0/src/data/var/dataUser.js
476
- - https://unpkg.com/jquery@3.6.0/src/deferred.js
477
- - https://unpkg.com/jquery@3.6.0/src/deferred/exceptionHook.js
478
- - https://unpkg.com/jquery@3.6.0/src/deprecated.js
433
+ - https://unpkg.com/jquery@3.6.0/src/css/curCSS.js
434
+ - https://unpkg.com/jquery@3.6.0/src/css/finalPropName.js
435
+ - https://unpkg.com/jquery@3.6.0/src/css/hiddenVisibleSelectors.js
436
+ - https://unpkg.com/jquery@3.6.0/src/css/showHide.js
437
+ - https://unpkg.com/jquery@3.6.0/src/css/support.js
479
438
  - https://unpkg.com/jquery@3.6.0/src/deprecated/ajax-event-alias.js
480
439
  - https://unpkg.com/jquery@3.6.0/src/deprecated/event.js
481
- - https://unpkg.com/jquery@3.6.0/src/dimensions.js
482
- - https://unpkg.com/jquery@3.6.0/src/effects.js
483
- - https://unpkg.com/jquery@3.6.0/src/effects/animatedSelector.js
484
- - https://unpkg.com/jquery@3.6.0/src/effects/Tween.js
485
- - https://unpkg.com/jquery@3.6.0/src/event.js
486
- - https://unpkg.com/jquery@3.6.0/src/event/focusin.js
487
- - https://unpkg.com/jquery@3.6.0/src/event/support.js
488
- - https://unpkg.com/jquery@3.6.0/src/event/trigger.js
440
+ - https://unpkg.com/jquery@3.6.0/src/ajax.js
489
441
  - https://unpkg.com/jquery@3.6.0/src/exports/amd.js
490
442
  - https://unpkg.com/jquery@3.6.0/src/exports/global.js
491
- - https://unpkg.com/jquery@3.6.0/src/jquery.js
492
- - https://unpkg.com/jquery@3.6.0/src/manipulation.js
493
- - https://unpkg.com/jquery@3.6.0/src/manipulation/_evalUrl.js
494
- - https://unpkg.com/jquery@3.6.0/src/manipulation/buildFragment.js
495
- - https://unpkg.com/jquery@3.6.0/src/manipulation/getAll.js
496
- - https://unpkg.com/jquery@3.6.0/src/manipulation/setGlobalEval.js
497
- - https://unpkg.com/jquery@3.6.0/src/manipulation/support.js
498
- - https://unpkg.com/jquery@3.6.0/src/manipulation/var/rscriptType.js
499
- - https://unpkg.com/jquery@3.6.0/src/manipulation/var/rtagName.js
500
- - https://unpkg.com/jquery@3.6.0/src/manipulation/wrapMap.js
501
- - https://unpkg.com/jquery@3.6.0/src/offset.js
502
- - https://unpkg.com/jquery@3.6.0/src/queue.js
503
- - https://unpkg.com/jquery@3.6.0/src/queue/delay.js
504
- - https://unpkg.com/jquery@3.6.0/src/selector.js
505
- - https://unpkg.com/jquery@3.6.0/src/selector-native.js
506
- - https://unpkg.com/jquery@3.6.0/src/selector-sizzle.js
507
- - https://unpkg.com/jquery@3.6.0/src/serialize.js
508
- - https://unpkg.com/jquery@3.6.0/src/traversing.js
509
- - https://unpkg.com/jquery@3.6.0/src/traversing/findFilter.js
510
- - https://unpkg.com/jquery@3.6.0/src/traversing/var/dir.js
511
- - https://unpkg.com/jquery@3.6.0/src/traversing/var/rneedsContext.js
512
- - https://unpkg.com/jquery@3.6.0/src/traversing/var/siblings.js
443
+ - https://unpkg.com/jquery@3.6.0/src/effects/animatedSelector.js
444
+ - https://unpkg.com/jquery@3.6.0/src/effects/Tween.js
513
445
  - https://unpkg.com/jquery@3.6.0/src/var/arr.js
514
446
  - https://unpkg.com/jquery@3.6.0/src/var/class2type.js
515
447
  - https://unpkg.com/jquery@3.6.0/src/var/document.js
@@ -530,13 +462,86 @@ urls:
530
462
  - https://unpkg.com/jquery@3.6.0/src/var/slice.js
531
463
  - https://unpkg.com/jquery@3.6.0/src/var/support.js
532
464
  - https://unpkg.com/jquery@3.6.0/src/var/toString.js
465
+ - https://unpkg.com/jquery@3.6.0/src/attributes/attr.js
466
+ - https://unpkg.com/jquery@3.6.0/src/attributes/classes.js
467
+ - https://unpkg.com/jquery@3.6.0/src/attributes/prop.js
468
+ - https://unpkg.com/jquery@3.6.0/src/attributes/support.js
469
+ - https://unpkg.com/jquery@3.6.0/src/attributes/val.js
470
+ - https://unpkg.com/jquery@3.6.0/src/attributes.js
471
+ - https://unpkg.com/jquery@3.6.0/src/callbacks.js
472
+ - https://unpkg.com/jquery@3.6.0/src/core.js
473
+ - https://unpkg.com/jquery@3.6.0/src/css.js
474
+ - https://unpkg.com/jquery@3.6.0/src/data.js
475
+ - https://unpkg.com/jquery@3.6.0/src/deferred.js
476
+ - https://unpkg.com/jquery@3.6.0/src/queue/delay.js
477
+ - https://unpkg.com/jquery@3.6.0/src/deprecated.js
478
+ - https://unpkg.com/jquery@3.6.0/src/dimensions.js
479
+ - https://unpkg.com/jquery@3.6.0/src/traversing/var/dir.js
480
+ - https://unpkg.com/jquery@3.6.0/src/traversing/var/rneedsContext.js
481
+ - https://unpkg.com/jquery@3.6.0/src/traversing/var/siblings.js
482
+ - https://unpkg.com/jquery@3.6.0/src/traversing/findFilter.js
483
+ - https://unpkg.com/jquery@3.6.0/src/effects.js
484
+ - https://unpkg.com/jquery@3.6.0/src/event.js
485
+ - https://unpkg.com/jquery@3.6.0/src/deferred/exceptionHook.js
486
+ - https://unpkg.com/jquery@3.6.0/src/event/focusin.js
487
+ - https://unpkg.com/jquery@3.6.0/src/event/support.js
488
+ - https://unpkg.com/jquery@3.6.0/src/event/trigger.js
489
+ - https://unpkg.com/jquery@3.6.0/src/jquery.js
490
+ - https://unpkg.com/jquery@3.6.0/src/ajax/jsonp.js
491
+ - https://unpkg.com/jquery@3.6.0/src/ajax/load.js
492
+ - https://unpkg.com/jquery@3.6.0/src/ajax/var/location.js
493
+ - https://unpkg.com/jquery@3.6.0/src/ajax/var/nonce.js
494
+ - https://unpkg.com/jquery@3.6.0/src/ajax/var/rquery.js
495
+ - https://unpkg.com/jquery@3.6.0/src/ajax/script.js
496
+ - https://unpkg.com/jquery@3.6.0/src/ajax/xhr.js
497
+ - https://unpkg.com/jquery@3.6.0/src/manipulation.js
498
+ - https://unpkg.com/jquery@3.6.0/src/offset.js
499
+ - https://unpkg.com/jquery@3.6.0/src/queue.js
500
+ - https://unpkg.com/jquery@3.6.0/src/selector-native.js
501
+ - https://unpkg.com/jquery@3.6.0/src/selector-sizzle.js
502
+ - https://unpkg.com/jquery@3.6.0/src/selector.js
503
+ - https://unpkg.com/jquery@3.6.0/src/serialize.js
504
+ - https://unpkg.com/jquery@3.6.0/src/traversing.js
533
505
  - https://unpkg.com/jquery@3.6.0/src/wrap.js
506
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.js
507
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.min.js
508
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.js
509
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.min.js
510
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.min.map
511
+ - https://unpkg.com/jquery@3.6.0/dist/jquery.slim.min.map
512
+ - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.js
513
+ - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.min.js
514
+ - https://unpkg.com/jquery@3.6.0/external/sizzle/dist/sizzle.min.map
515
+ - https://unpkg.com/jquery@3.6.0/external/sizzle/LICENSE.txt
516
+ - https://unpkg.com/jquery@3.6.0/bower.json
517
+ - https://unpkg.com/jquery@3.6.0/package.json
518
+ - https://unpkg.com/jquery@3.6.0/README.md
519
+ - https://unpkg.com/jquery@3.6.0/AUTHORS.txt
520
+ - https://unpkg.com/jquery@3.6.0/LICENSE.txt
521
+ END
522
+ actual = run("unpkg", "jquery", "3.6.0")
523
+ ok {actual} == expected
524
+ end
525
+
526
+ spec "(google) lists files." do
527
+ expected = <<END
528
+ name: jquery
529
+ version: 2.2.0
530
+ site: http://jquery.com/
531
+ info: https://developers.google.com/speed/libraries/#jquery
532
+ urls:
533
+ - https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
534
534
  END
535
- actual = CDNGet::Main.new().run("unpkg", "jquery", "3.6.0")
535
+ actual = run("google", "jquery", "2.2.0")
536
536
  ok {actual} == expected
537
537
  end
538
538
 
539
- it "(cdnjs) lists files containing subdirectory." do
539
+ end
540
+
541
+
542
+ topic "cdnget <CDN> <library> <version> (containing subdirectory)" do
543
+
544
+ spec "(cdnjs) lists files containing subdirectory." do
540
545
  expected = <<END
541
546
  name: jquery-jcrop
542
547
  version: 0.9.12
@@ -555,92 +560,90 @@ urls:
555
560
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.min.js
556
561
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.min.js
557
562
  END
558
- actual = CDNGet::Main.new().run("cdnjs", "jquery-jcrop", "0.9.12")
563
+ actual = run("cdnjs", "jquery-jcrop", "0.9.12")
559
564
  ok {actual} == expected
560
565
  end
561
566
 
562
- it "(google) lists files containing subdirectory." do
563
- skip("no libraries containing subdirectory")
567
+ spec "(google) lists files containing subdirectory." do
568
+ skip_when true, "no libraries containing subdirectory"
564
569
  end
565
570
 
566
- it "(cdnjs) raises error when library name is wrong." do
567
- pr = proc { CDNGet::Main.new().run("cdnjs", "jquery-ui", "1.9.2") }
571
+ end
572
+
573
+
574
+ topic "cdnget <CDN> <not-existing-library> <version>" do
575
+
576
+ spec "(cdnjs) raises error when library name is wrong." do
577
+ pr = proc { run("cdnjs", "jquery-ui", "1.9.2") }
568
578
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
569
579
  #
570
- pr = proc { CDNGet::Main.new().run("cdnjs", "emberjs", "2.2.1") }
580
+ pr = proc { run("cdnjs", "emberjs", "2.2.1") }
571
581
  ok {pr}.raise?(CDNGet::CommandError, "emberjs: Library not found (maybe 'ember.js'?).")
572
582
  end
573
583
 
574
- it "(google) raises error when library name is wrong." do
575
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui", "1.9.2") }
576
- ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
577
- end
578
-
579
- it "(jsdelivr) raises error when library name is wrong." do
580
- pr = proc { CDNGet::Main.new().run("jsdelivr", "jquery-ui", "1.9.2") }
584
+ spec "(jsdelivr) raises error when library name is wrong." do
585
+ pr = proc { run("jsdelivr", "jquery-ui", "1.9.2") }
581
586
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui@1.9.2: Library or version not found.")
582
587
  end
583
588
 
584
- it "(unpkg) raises error when library name is wrong." do
585
- pr = proc { CDNGet::Main.new().run("unpkg", "jquery-foobar", "1.9.2") }
589
+ spec "(unpkg) raises error when library name is wrong." do
590
+ pr = proc { run("unpkg", "jquery-foobar", "1.9.2") }
586
591
  ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
587
592
  end
588
593
 
594
+ spec "(google) raises error when library name is wrong." do
595
+ pr = proc { run("google", "jquery-ui", "1.9.2") }
596
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
597
+ end
598
+
589
599
  end
590
600
 
591
601
 
592
- describe "cdnget CDN jquery 2.2.0 dir" do
602
+ topic "cdnget <CDN> <library> <not-existing-version>" do
593
603
 
594
- def _do_download_test1(cdn_code, library="jquery", version="2.2.0")
595
- @tmpdir = tmpdir = "tmpdir1"
596
- Dir.mkdir(tmpdir)
597
- sout, serr = capture_io() do
598
- actual = CDNGet::Main.new().run(cdn_code, library, version, tmpdir)
599
- end
600
- yield tmpdir, sout, serr
601
- ensure
602
- FileUtils.rm_r(tmpdir) if File.directory?(tmpdir)
604
+ spec "(cdnjs) raises error when version is wrong." do
605
+ pr = proc { run("cdnjs", "jquery", "1.0.0") }
606
+ ok {pr}.raise?(CDNGet::CommandError, "jquery/1.0.0: Library or version not found.")
607
+ pr = proc { run("cdnjs", "jquery", "blabla") }
608
+ ok {pr}.raise?(CDNGet::CommandError, "blabla: Invalid version number.")
603
609
  end
604
610
 
605
- def _do_download_test2(cdn_code, library="jquery-jcrop", version="0.9.12")
606
- @tmpdir = tmpdir = "tmpdir1"
607
- Dir.mkdir(tmpdir)
608
- sout, serr = capture_io() do
609
- actual = CDNGet::Main.new().run(cdn_code, library, version, tmpdir)
610
- end
611
- yield tmpdir, sout, serr
612
- ensure
613
- FileUtils.rm_r(tmpdir) if File.directory?(tmpdir)
611
+ spec "(jsdelivr) raises error when version is wrong." do
612
+ pr = proc { run("jsdelivr", "jquery", "1.0.0") }
613
+ ok {pr}.raise?(CDNGet::CommandError, "jquery@1.0.0: Library or version not found.")
614
+ pr = proc { run("jsdelivr", "jquery", "blabla") }
615
+ ok {pr}.raise?(CDNGet::CommandError, "blabla: Invalid version number.")
614
616
  end
615
617
 
616
- def _do_download_test3(cdn_code, libname, version, expected)
617
- @tmpdir = tmpdir = "tmpdir1"
618
- Dir.mkdir(tmpdir)
619
- path = "#{tmpdir}/#{libname}/#{version}"
620
- # 1st
621
- sout, serr = capture_io() do
622
- actual = CDNGet::Main.new().run(cdn_code, libname, version, tmpdir)
623
- end
624
- ok {serr} == ""
625
- ok {sout} == expected
626
- # 2nd
627
- sout, serr = capture_io() do
628
- actual = CDNGet::Main.new().run(cdn_code, libname, version, tmpdir)
618
+ spec "(unpkg) raises error when version is wrong." do
619
+ pr = proc { run("unpkg", "jquery", "1.0.0") }
620
+ ok {pr}.raise?(CDNGet::CommandError, "jquery@1.0.0: Version not found.")
621
+ pr = proc { run("unpkg", "jquery", "blabla") }
622
+ ok {pr}.raise?(CDNGet::CommandError, "blabla: Invalid version number.")
623
+ end
624
+
625
+ spec "(google) raises error when version is wrong." do
626
+ pr = proc { run("google", "jquery", "1.0.0") }
627
+ ok {pr}.raise?(CDNGet::CommandError, "jquery 1.0.0: Version not found.")
628
+ pr = proc { run("google", "jquery", "blabla") }
629
+ ok {pr}.raise?(CDNGet::CommandError, "blabla: Invalid version number.")
630
+ end
631
+
632
+ end
633
+
634
+
635
+ topic "cdnget <CDN> <library> <version> <dir> (only files)" do
636
+
637
+ def _do_download_test1(cdn_code, library="jquery", version="2.2.0")
638
+ sout, serr = capture_sio() do
639
+ actual = run(cdn_code, library, version, @tmpdir)
629
640
  end
630
- ok {serr} == ""
631
- ok {sout} == expected.gsub(/(\(Created\))?\n/) {
632
- if $1
633
- "(Already exists)\n"
634
- else
635
- " (Unchanged)\n"
636
- end
637
- }
638
- ensure
639
- FileUtils.rm_r(tmpdir)
641
+ yield sout, serr
640
642
  end
641
643
 
642
- it "(cdnjs) downloads files into dir." do
643
- _do_download_test1("cdnjs", "jquery", "2.2.0") do |tmpdir, sout, serr|
644
+ spec "(cdnjs) downloads files into dir." do
645
+ tmpdir = @tmpdir
646
+ _do_download_test1("cdnjs", "jquery", "2.2.0") do |sout, serr|
644
647
  ok {"#{tmpdir}/jquery/2.2.0/jquery.js" }.file_exist?
645
648
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.js" }.file_exist?
646
649
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.map"}.file_exist?
@@ -652,17 +655,9 @@ END
652
655
  end
653
656
  end
654
657
 
655
- it "(google) downloads files into dir." do
656
- _do_download_test1("google", "jquery", "2.2.0") do |tmpdir, sout, serr|
657
- ok {"#{tmpdir}/jquery/2.2.0/jquery.min.js" }.file_exist?
658
- ok {sout} == <<END
659
- #{tmpdir}/jquery/2.2.0/jquery.min.js ... Done (85,589 byte)
660
- END
661
- end
662
- end
663
-
664
- it "(jsdelivr) downloads files into dir." do
665
- _do_download_test1("jsdelivr", "chibijs", "3.0.9") do |tmpdir, sout, serr|
658
+ spec "(jsdelivr) downloads files into dir." do
659
+ tmpdir = @tmpdir
660
+ _do_download_test1("jsdelivr", "chibijs", "3.0.9") do |sout, serr|
666
661
  ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
667
662
  ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
668
663
  ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
@@ -684,8 +679,9 @@ END
684
679
  end
685
680
  end
686
681
 
687
- it "(unpkg) downloads files into dir." do
688
- _do_download_test1("unpkg", "chibijs", "3.0.9") do |tmpdir, sout, serr|
682
+ spec "(unpkg) downloads files into dir." do
683
+ tmpdir = @tmpdir
684
+ _do_download_test1("unpkg", "chibijs", "3.0.9") do |sout, serr|
689
685
  ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
690
686
  ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
691
687
  ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
@@ -695,20 +691,43 @@ END
695
691
  ok {"#{tmpdir}/chibijs@3.0.9/README.md" }.file_exist?
696
692
  ok {"#{tmpdir}/chibijs@3.0.9/tests/runner.html"}.file_exist?
697
693
  ok {sout} == <<END
698
- #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
694
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
699
695
  #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
700
- #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
696
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
701
697
  #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
698
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
702
699
  #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
703
- #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
704
- #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
700
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
705
701
  #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
706
702
  END
707
703
  end
708
704
  end
709
705
 
710
- it "(cdnjs) downloads files (containing subdir) into dir." do
711
- _do_download_test2("cdnjs", "jquery-jcrop", "0.9.12") do |tmpdir, sout, serr|
706
+ spec "(google) downloads files into dir." do
707
+ tmpdir = @tmpdir
708
+ _do_download_test1("google", "jquery", "2.2.0") do |sout, serr|
709
+ ok {"#{tmpdir}/jquery/2.2.0/jquery.min.js" }.file_exist?
710
+ ok {sout} == <<END
711
+ #{tmpdir}/jquery/2.2.0/jquery.min.js ... Done (85,589 byte)
712
+ END
713
+ end
714
+ end
715
+
716
+ end
717
+
718
+
719
+ topic "cdnget <CDN> <library> <version> <dir> (containing subdirectory)" do
720
+
721
+ def _do_download_test2(cdn_code, library="jquery-jcrop", version="0.9.12")
722
+ sout, serr = capture_sio() do
723
+ actual = run(cdn_code, library, version, @tmpdir)
724
+ end
725
+ yield sout, serr
726
+ end
727
+
728
+ spec "(cdnjs) downloads files (containing subdir) into dir." do
729
+ tmpdir = @tmpdir
730
+ _do_download_test2("cdnjs", "jquery-jcrop", "0.9.12") do |sout, serr|
712
731
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif" }.file_exist?
713
732
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css" }.file_exist?
714
733
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css" }.file_exist?
@@ -730,12 +749,9 @@ END
730
749
  end
731
750
  end
732
751
 
733
- it "(google) downloads files (containing subdir) into dir." do
734
- skip("no libraries containing subdirectory")
735
- end
736
-
737
- it "(jsdelivr) downloads files (containing subdir) into dir." do
738
- _do_download_test2("jsdelivr", "zepto", "1.2.0") do |tmpdir, sout, serr|
752
+ spec "(jsdelivr) downloads files (containing subdir) into dir." do
753
+ tmpdir = @tmpdir
754
+ _do_download_test2("jsdelivr", "zepto", "1.2.0") do |sout, serr|
739
755
  ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.js" }.file_exist?
740
756
  ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.min.js"}.file_exist?
741
757
  ok {"#{tmpdir}/zepto@1.2.0/MIT-LICENSE" }.file_exist?
@@ -785,8 +801,9 @@ END
785
801
  end
786
802
  end
787
803
 
788
- it "(unpkg) downloads files (containing subdir) into dir." do
789
- _do_download_test2("unpkg", "react", "17.0.2") do |tmpdir, sout, serr|
804
+ spec "(unpkg) downloads files (containing subdir) into dir." do
805
+ tmpdir = @tmpdir
806
+ _do_download_test2("unpkg", "react", "17.0.2") do |sout, serr|
790
807
  ok {"#{tmpdir}/react@17.0.2/build-info.json" }.file_exist?
791
808
  ok {"#{tmpdir}/react@17.0.2/cjs/react.development.js" }.file_exist?
792
809
  ok {"#{tmpdir}/react@17.0.2/cjs/react.production.min.js"}.file_exist?
@@ -806,31 +823,63 @@ END
806
823
  ok {"#{tmpdir}/react@17.0.2/umd/react.production.min.js"}.file_exist?
807
824
  ok {"#{tmpdir}/react@17.0.2/umd/react.profiling.min.js" }.file_exist?
808
825
  expected = <<END
809
- #{tmpdir}/react@17.0.2/build-info.json ... Done (167 byte)
810
- #{tmpdir}/react@17.0.2/cjs/react.development.js ... Done (72,141 byte)
811
- #{tmpdir}/react@17.0.2/cjs/react.production.min.js ... Done (6,450 byte)
826
+ #{tmpdir}/react@17.0.2/LICENSE ... Done (1,086 byte)
827
+ #{tmpdir}/react@17.0.2/index.js ... Done (190 byte)
828
+ #{tmpdir}/react@17.0.2/jsx-dev-runtime.js ... Done (222 byte)
829
+ #{tmpdir}/react@17.0.2/jsx-runtime.js ... Done (214 byte)
812
830
  #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.development.js ... Done (37,753 byte)
813
831
  #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.production.min.js ... Done (456 byte)
814
832
  #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.profiling.min.js ... Done (455 byte)
815
833
  #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.development.js ... Done (38,352 byte)
816
834
  #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.production.min.js ... Done (962 byte)
817
835
  #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.profiling.min.js ... Done (961 byte)
818
- #{tmpdir}/react@17.0.2/index.js ... Done (190 byte)
819
- #{tmpdir}/react@17.0.2/jsx-dev-runtime.js ... Done (222 byte)
820
- #{tmpdir}/react@17.0.2/jsx-runtime.js ... Done (214 byte)
821
- #{tmpdir}/react@17.0.2/LICENSE ... Done (1,086 byte)
822
- #{tmpdir}/react@17.0.2/package.json ... Done (777 byte)
823
- #{tmpdir}/react@17.0.2/README.md ... Done (737 byte)
836
+ #{tmpdir}/react@17.0.2/cjs/react.development.js ... Done (72,141 byte)
837
+ #{tmpdir}/react@17.0.2/cjs/react.production.min.js ... Done (6,450 byte)
824
838
  #{tmpdir}/react@17.0.2/umd/react.development.js ... Done (105,096 byte)
825
839
  #{tmpdir}/react@17.0.2/umd/react.production.min.js ... Done (11,440 byte)
826
840
  #{tmpdir}/react@17.0.2/umd/react.profiling.min.js ... Done (13,668 byte)
841
+ #{tmpdir}/react@17.0.2/build-info.json ... Done (167 byte)
842
+ #{tmpdir}/react@17.0.2/package.json ... Done (777 byte)
843
+ #{tmpdir}/react@17.0.2/README.md ... Done (737 byte)
827
844
  END
828
845
  ok {sout} == expected
829
846
  end
830
847
  end
831
848
 
832
- it "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
833
- tmpdir = "tmpdir1"
849
+ spec "(google) downloads files (containing subdir) into dir." do
850
+ skip_when true, "no libraries containing subdirectory"
851
+ end
852
+
853
+ end
854
+
855
+
856
+ topic "cdnget <CDN> <library> <version> <dir> (not override existing files)" do
857
+
858
+ def _do_download_test3(cdn_code, libname, version, expected)
859
+ tmpdir = @tmpdir
860
+ path = "#{tmpdir}/#{libname}/#{version}"
861
+ # 1st
862
+ sout, serr = capture_sio() do
863
+ actual = run(cdn_code, libname, version, tmpdir)
864
+ end
865
+ ok {serr} == ""
866
+ ok {sout} == expected
867
+ # 2nd
868
+ sout, serr = capture_sio() do
869
+ actual = run(cdn_code, libname, version, tmpdir)
870
+ end
871
+ ok {serr} == ""
872
+ ok {sout} == expected.gsub(/(\(Created\))?\n/) {
873
+ if $1
874
+ "(Already exists)\n"
875
+ else
876
+ " (Unchanged)\n"
877
+ end
878
+ }
879
+ end
880
+
881
+ spec "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
882
+ tmpdir = @tmpdir
834
883
  expected = <<END
835
884
  #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.css ... Done (7,401 byte)
836
885
  #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.gif ... Done (329 byte)
@@ -841,16 +890,8 @@ END
841
890
  _do_download_test3("cdnjs", "jquery-jcrop", "2.0.4", expected)
842
891
  end
843
892
 
844
- it "(google) doesn't override existing files when they are identical to downloaded files." do
845
- tmpdir = "tmpdir1"
846
- expected = <<END
847
- #{tmpdir}/jquery/3.6.0/jquery.min.js ... Done (89,501 byte)
848
- END
849
- _do_download_test3("google", "jquery", "3.6.0", expected)
850
- end
851
-
852
- it "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
853
- tmpdir = "tmpdir1"
893
+ spec "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
894
+ tmpdir = @tmpdir
854
895
  expected = <<END
855
896
  #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
856
897
  #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
@@ -864,28 +905,36 @@ END
864
905
  _do_download_test3("jsdelivr", "chibijs", "3.0.9", expected)
865
906
  end
866
907
 
867
- it "(unpkg) doesn't override existing files when they are identical to downloaded files." do
868
- tmpdir = "tmpdir1"
908
+ spec "(unpkg) doesn't override existing files when they are identical to downloaded files." do
909
+ tmpdir = @tmpdir
869
910
  expected = <<END
870
- #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
911
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
871
912
  #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
872
- #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
913
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
873
914
  #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
915
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
874
916
  #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
875
- #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
876
- #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
917
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
877
918
  #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
878
919
  END
879
920
  _do_download_test3("unpkg", "chibijs", "3.0.9", expected)
880
921
  end
881
922
 
923
+ spec "(google) doesn't override existing files when they are identical to downloaded files." do
924
+ tmpdir = @tmpdir
925
+ expected = <<END
926
+ #{tmpdir}/jquery/3.6.0/jquery.min.js ... Done (89,501 byte)
927
+ END
928
+ _do_download_test3("google", "jquery", "3.6.0", expected)
929
+ end
930
+
882
931
  end
883
932
 
884
933
 
885
- describe "cdnget CDN swfobject latest" do
934
+ topic "cdnget <CDN> <library> latest" do
886
935
 
887
- it "(cdnjs) shows latest version." do
888
- actual = CDNGet::Main.new("cdnget").run("cdnjs", "swfobject", "latest")
936
+ spec "(cdnjs) shows latest version." do
937
+ actual = run("cdnjs", "swfobject", "latest")
889
938
  ok {actual} == <<END
890
939
  name: swfobject
891
940
  version: 2.2
@@ -900,20 +949,8 @@ urls:
900
949
  END
901
950
  end
902
951
 
903
- it "(google) shows latest version." do
904
- actual = CDNGet::Main.new("cdnget").run("google", "swfobject", "latest")
905
- ok {actual} == <<END
906
- name: swfobject
907
- version: 2.2
908
- site: https://github.com/swfobject/swfobject
909
- info: https://developers.google.com/speed/libraries/#swfobject
910
- urls:
911
- - https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
912
- END
913
- end
914
-
915
- it "(jsdelivr) shows latest version." do
916
- actual = CDNGet::Main.new("cdnget").run("jsdelivr", "swfobject", "latest")
952
+ spec "(jsdelivr) shows latest version." do
953
+ actual = run("jsdelivr", "swfobject", "latest")
917
954
  ok {actual} == <<END
918
955
  name: swfobject
919
956
  version: 2.2.1
@@ -934,8 +971,8 @@ urls:
934
971
  END
935
972
  end
936
973
 
937
- it "(unpkg) shows latest version." do
938
- actual = CDNGet::Main.new("cdnget").run("unpkg", "swfobject", "latest")
974
+ spec "(unpkg) shows latest version." do
975
+ actual = run("unpkg", "swfobject", "latest")
939
976
  ok {actual} == <<END
940
977
  name: swfobject
941
978
  version: 2.2.1
@@ -944,36 +981,38 @@ tags: SWFObject, swf, object, flash, embed, content
944
981
  site: https://github.com/unshiftio/swfobject
945
982
  info: https://unpkg.com/browse/swfobject@2.2.1/
946
983
  npmpkg: https://registry.npmjs.org/swfobject/-/swfobject-2.2.1.tgz
947
- default: /index.min.js
948
984
  license: MIT
949
985
  urls:
986
+ - https://unpkg.com/swfobject@2.2.1/package.json
950
987
  - https://unpkg.com/swfobject@2.2.1/.npmignore
951
- - https://unpkg.com/swfobject@2.2.1/download.sh
952
- - https://unpkg.com/swfobject@2.2.1/expressInstall.swf
988
+ - https://unpkg.com/swfobject@2.2.1/README.md
953
989
  - https://unpkg.com/swfobject@2.2.1/index.js
954
- - https://unpkg.com/swfobject@2.2.1/package.json
955
990
  - https://unpkg.com/swfobject@2.2.1/patch.js
956
- - https://unpkg.com/swfobject@2.2.1/README.md
991
+ - https://unpkg.com/swfobject@2.2.1/download.sh
992
+ - https://unpkg.com/swfobject@2.2.1/expressInstall.swf
957
993
  END
958
994
  end
959
995
 
960
- end
961
-
996
+ spec "(google) shows latest version." do
997
+ actual = run("google", "swfobject", "latest")
998
+ ok {actual} == <<END
999
+ name: swfobject
1000
+ version: 2.2
1001
+ site: https://github.com/swfobject/swfobject
1002
+ info: https://developers.google.com/speed/libraries/#swfobject
1003
+ urls:
1004
+ - https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
1005
+ END
1006
+ end
962
1007
 
963
- describe "cdnget CDN swfobject latest dir" do
1008
+ end
964
1009
 
965
- before do
966
- @tmpdir = "tmpdir1"
967
- Dir.mkdir @tmpdir
968
- end
969
1010
 
970
- after do
971
- FileUtils.rm_rf @tmpdir
972
- end
1011
+ topic "cdnget CDN <library> latest <dir>" do
973
1012
 
974
- it "(cdnjs) downlaods latest version." do
975
- sout, serr = capture_io do()
976
- CDNGet::Main.new("cdnget").run("cdnjs", "swfobject", "latest", @tmpdir)
1013
+ spec "(cdnjs) downlaods latest version." do
1014
+ sout, serr = capture_sio do()
1015
+ run("cdnjs", "swfobject", "latest", @tmpdir)
977
1016
  end
978
1017
  ok {sout} == <<"END"
979
1018
  #{@tmpdir}/swfobject/2.2/swfobject.js ... Done (10,220 byte)
@@ -981,18 +1020,9 @@ END
981
1020
  END
982
1021
  end
983
1022
 
984
- it "(google) downlaods latest version." do
985
- sout, serr = capture_io do()
986
- CDNGet::Main.new("cdnget").run("google", "swfobject", "latest", @tmpdir)
987
- end
988
- ok {sout} == <<"END"
989
- #{@tmpdir}/swfobject/2.2/swfobject.js ... Done (10,220 byte)
990
- END
991
- end
992
-
993
- it "(jsdelivr) downlaods latest version." do
994
- sout, serr = capture_io do()
995
- CDNGet::Main.new("cdnget").run("jsdelivr", "swfobject", "latest", @tmpdir)
1023
+ spec "(jsdelivr) downlaods latest version." do
1024
+ sout, serr = capture_sio do()
1025
+ run("jsdelivr", "swfobject", "latest", @tmpdir)
996
1026
  end
997
1027
  ok {sout} == <<"END"
998
1028
  #{@tmpdir}/swfobject@2.2.1/.npmignore ... Done (13 byte)
@@ -1005,38 +1035,303 @@ END
1005
1035
  END
1006
1036
  end
1007
1037
 
1008
- it "(unpkg) downlaods latest version." do
1009
- sout, serr = capture_io do()
1010
- CDNGet::Main.new("cdnget").run("unpkg", "swfobject", "latest", @tmpdir)
1038
+ spec "(unpkg) downlaods latest version." do
1039
+ sout, serr = capture_sio do()
1040
+ run("unpkg", "swfobject", "latest", @tmpdir)
1011
1041
  end
1012
1042
  ok {sout} == <<"END"
1043
+ #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1013
1044
  #{@tmpdir}/swfobject@2.2.1/.npmignore ... Done (13 byte)
1014
- #{@tmpdir}/swfobject@2.2.1/download.sh ... Done (517 byte)
1015
- #{@tmpdir}/swfobject@2.2.1/expressInstall.swf ... Done (727 byte)
1045
+ #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1016
1046
  #{@tmpdir}/swfobject@2.2.1/index.js ... Done (10,331 byte)
1017
- #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1018
1047
  #{@tmpdir}/swfobject@2.2.1/patch.js ... Done (277 byte)
1019
- #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1048
+ #{@tmpdir}/swfobject@2.2.1/download.sh ... Done (517 byte)
1049
+ #{@tmpdir}/swfobject@2.2.1/expressInstall.swf ... Done (727 byte)
1050
+ END
1051
+ end
1052
+
1053
+ spec "(google) downlaods latest version." do
1054
+ sout, serr = capture_sio do()
1055
+ run("google", "swfobject", "latest", @tmpdir)
1056
+ end
1057
+ ok {sout} == <<"END"
1058
+ #{@tmpdir}/swfobject/2.2/swfobject.js ... Done (10,220 byte)
1059
+ END
1060
+ end
1061
+
1062
+ end
1063
+
1064
+
1065
+ topic "cdnget <CDN> @babel/core" do
1066
+
1067
+ spec "(cdnjs) raises error." do
1068
+ pr = proc { run("cdnjs", "@babel/core") }
1069
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1070
+ end
1071
+
1072
+ spec "(jsdelivr) show details of package." do
1073
+ output = run("jsdelivr", "@babel/core")
1074
+ ok {output}.start_with? <<'END'
1075
+ name: @babel/core
1076
+ desc: Babel compiler core.
1077
+ tags: 6to5, babel, classes, const, es6, harmony, let, modules, transpile, transpiler, var, babel-core, compiler
1078
+ site: https://babel.dev/docs/en/next/babel-core
1079
+ info: https://www.jsdelivr.com/package/npm/@babel/core
1080
+ license: MIT
1081
+ versions:
1082
+ END
1083
+ ok {output}.end_with? <<'END'
1084
+ - 7.0.0-beta.33
1085
+ - 7.0.0-beta.32
1086
+ - 7.0.0-beta.31
1087
+ - 7.0.0-beta.5
1088
+ - 7.0.0-beta.4
1089
+ - 6.0.0-bridge.1
1090
+ END
1091
+ end
1092
+
1093
+ spec "(unpkg) show details of package." do
1094
+ output = run("unpkg", "@babel/core")
1095
+ ok {output}.start_with? <<'END'
1096
+ name: @babel/core
1097
+ desc: Babel compiler core.
1098
+ tags: 6to5, babel, classes, const, es6, harmony, let, modules, transpile, transpiler, var, babel-core, compiler
1099
+ site: https://babel.dev/docs/en/next/babel-core
1100
+ info: https://unpkg.com/browse/@babel/core/
1101
+ license: MIT
1102
+ versions:
1103
+ END
1104
+ ok {output}.end_with? <<'END'
1105
+ - 7.0.0-beta.33
1106
+ - 7.0.0-beta.32
1107
+ - 7.0.0-beta.31
1108
+ - 7.0.0-beta.5
1109
+ - 7.0.0-beta.4
1110
+ - 6.0.0-bridge.1
1111
+ END
1112
+ end
1113
+
1114
+ spec "(google) raises error." do
1115
+ pr = proc { run("google", "@babel/core") }
1116
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1117
+ end
1118
+
1119
+ end
1120
+
1121
+
1122
+ topic "cdnget <CDN> @babel/core <version>"do
1123
+
1124
+ spec "(cdnjs) raises error." do
1125
+ pr = proc { run("cdnjs", "@babel/core", "7.15.5") }
1126
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1127
+ end
1128
+
1129
+ spec "(jsdelivr) lists files." do
1130
+ output = run("jsdelivr", "@babel/core", "7.15.5")
1131
+ ok {output}.start_with? <<'END'
1132
+ name: @babel/core
1133
+ version: 7.15.5
1134
+ desc: Babel compiler core.
1135
+ tags: 6to5, babel, classes, const, es6, harmony, let, modules, transpile, transpiler, var, babel-core, compiler
1136
+ site: https://babel.dev/docs/en/next/babel-core
1137
+ info: https://www.jsdelivr.com/package/npm/@babel/core?version=7.15.5
1138
+ npmpkg: https://registry.npmjs.org/@babel%2fcore/-//core-7.15.5.tgz
1139
+ default: /lib/index.min.js
1140
+ license: MIT
1141
+ urls:
1142
+ - https://cdn.jsdelivr.net/npm/@babel/core@7.15.5/lib/config/cache-contexts.js
1143
+ - https://cdn.jsdelivr.net/npm/@babel/core@7.15.5/lib/config/caching.js
1144
+ - https://cdn.jsdelivr.net/npm/@babel/core@7.15.5/lib/config/config-chain.js
1145
+ - https://cdn.jsdelivr.net/npm/@babel/core@7.15.5/lib/config/config-descriptors.js
1146
+ END
1147
+ end
1148
+
1149
+ spec "(unpkg) lists files" do
1150
+ output = run("unpkg", "@babel/core", "7.15.5")
1151
+ ok {output}.start_with? <<'END'
1152
+ name: @babel/core
1153
+ version: 7.15.5
1154
+ desc: Babel compiler core.
1155
+ tags: 6to5, babel, classes, const, es6, harmony, let, modules, transpile, transpiler, var, babel-core, compiler
1156
+ site: https://babel.dev/docs/en/next/babel-core
1157
+ info: https://unpkg.com/browse/@babel/core@7.15.5/
1158
+ npmpkg: https://registry.npmjs.org/@babel%2fcore/-//core-7.15.5.tgz
1159
+ license: MIT
1160
+ urls:
1161
+ - https://unpkg.com/@babel/core@7.15.5/LICENSE
1162
+ - https://unpkg.com/@babel/core@7.15.5/README.md
1163
+ - https://unpkg.com/@babel/core@7.15.5/lib/config/cache-contexts.js
1164
+ - https://unpkg.com/@babel/core@7.15.5/lib/config/caching.js
1165
+ - https://unpkg.com/@babel/core@7.15.5/lib/config/config-chain.js
1020
1166
  END
1021
1167
  end
1022
1168
 
1169
+ spec "(google) raises error." do
1170
+ pr = proc { run("google", "@babel/core", "7.15.5") }
1171
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1172
+ end
1173
+
1023
1174
  end
1024
1175
 
1025
1176
 
1026
- describe "cdnget CDN bulma 0.9.3 dir" do
1177
+ topic "cdnget <CDN> @babel/core <version> <dir>" do
1178
+
1179
+ spec "(cdnjs) raises error." do
1180
+ pr = proc { run("cdnjs", "@babel/core", "7.15.5", @tmpdir) }
1181
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1182
+ end
1183
+
1184
+ spec "(jsdelivr) download files." do
1185
+ sout, serr = capture_sio do
1186
+ run("jsdelivr", "@babel/core", "7.15.5", @tmpdir)
1187
+ end
1188
+ ok {sout} == <<"END"
1189
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/cache-contexts.js ... Done (0 byte)
1190
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/caching.js ... Done (7,327 byte)
1191
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/config-chain.js ... Done (17,871 byte)
1192
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/config-descriptors.js ... Done (6,756 byte)
1193
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/configuration.js ... Done (9,975 byte)
1194
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/import.js ... Done (165 byte)
1195
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/index.js ... Done (1,760 byte)
1196
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/index-browser.js ... Done (1,550 byte)
1197
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/module-types.js ... Done (2,731 byte)
1198
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/package.js ... Done (1,509 byte)
1199
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/plugins.js ... Done (6,287 byte)
1200
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/types.js ... Done (0 byte)
1201
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/utils.js ... Done (856 byte)
1202
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/full.js ... Done (9,211 byte)
1203
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/helpers/config-api.js ... Done (2,593 byte)
1204
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/helpers/environment.js ... Done (227 byte)
1205
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/index.js ... Done (2,462 byte)
1206
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/item.js ... Done (1,802 byte)
1207
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/partial.js ... Done (5,647 byte)
1208
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/pattern-to-regex.js ... Done (1,143 byte)
1209
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/plugin.js ... Done (744 byte)
1210
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/printer.js ... Done (2,893 byte)
1211
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/resolve-targets.js ... Done (1,430 byte)
1212
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/resolve-targets-browser.js ... Done (945 byte)
1213
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/util.js ... Done (887 byte)
1214
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/option-assertions.js ... Done (9,985 byte)
1215
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/options.js ... Done (7,749 byte)
1216
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/plugins.js ... Done (1,982 byte)
1217
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/removed.js ... Done (2,374 byte)
1218
+ #{@tmpdir}/@babel/core@7.15.5/lib/gensync-utils/async.js ... Done (1,775 byte)
1219
+ #{@tmpdir}/@babel/core@7.15.5/lib/gensync-utils/fs.js ... Done (576 byte)
1220
+ #{@tmpdir}/@babel/core@7.15.5/lib/index.js ... Done (5,697 byte)
1221
+ #{@tmpdir}/@babel/core@7.15.5/lib/parse.js ... Done (1,085 byte)
1222
+ #{@tmpdir}/@babel/core@7.15.5/lib/parser/index.js ... Done (2,260 byte)
1223
+ #{@tmpdir}/@babel/core@7.15.5/lib/parser/util/missing-plugin-helper.js ... Done (7,985 byte)
1224
+ #{@tmpdir}/@babel/core@7.15.5/lib/tools/build-external-helpers.js ... Done (4,331 byte)
1225
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform.js ... Done (1,059 byte)
1226
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-ast.js ... Done (1,257 byte)
1227
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-file.js ... Done (1,059 byte)
1228
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-file-browser.js ... Done (692 byte)
1229
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/block-hoist-plugin.js ... Done (1,802 byte)
1230
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/file.js ... Done (5,864 byte)
1231
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/generate.js ... Done (1,903 byte)
1232
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/merge-map.js ... Done (5,412 byte)
1233
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/index.js ... Done (3,296 byte)
1234
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/normalize-file.js ... Done (3,796 byte)
1235
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/normalize-opts.js ... Done (1,543 byte)
1236
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/plugin-pass.js ... Done (1,035 byte)
1237
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/util/clone-deep.js ... Done (453 byte)
1238
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/util/clone-deep-browser.js ... Done (599 byte)
1239
+ #{@tmpdir}/@babel/core@7.15.5/LICENSE ... Done (1,106 byte)
1240
+ #{@tmpdir}/@babel/core@7.15.5/package.json ... Done (2,395 byte)
1241
+ #{@tmpdir}/@babel/core@7.15.5/README.md ... Done (404 byte)
1242
+ #{@tmpdir}/@babel/core@7.15.5/src/config/files/index.ts ... Done (735 byte)
1243
+ #{@tmpdir}/@babel/core@7.15.5/src/config/files/index-browser.ts ... Done (2,846 byte)
1244
+ #{@tmpdir}/@babel/core@7.15.5/src/config/resolve-targets.ts ... Done (1,612 byte)
1245
+ #{@tmpdir}/@babel/core@7.15.5/src/config/resolve-targets-browser.ts ... Done (1,074 byte)
1246
+ #{@tmpdir}/@babel/core@7.15.5/src/transform-file.ts ... Done (1,475 byte)
1247
+ #{@tmpdir}/@babel/core@7.15.5/src/transform-file-browser.ts ... Done (716 byte)
1248
+ #{@tmpdir}/@babel/core@7.15.5/src/transformation/util/clone-deep.ts ... Done (223 byte)
1249
+ #{@tmpdir}/@babel/core@7.15.5/src/transformation/util/clone-deep-browser.ts ... Done (500 byte)
1250
+ END
1251
+ end
1027
1252
 
1028
- before do
1029
- @tmpdir = "tmpdir1"
1030
- Dir.mkdir @tmpdir
1253
+ spec "(unpkg) download files" do
1254
+ sout, serr = capture_sio do
1255
+ run("unpkg", "@babel/core", "7.15.5", @tmpdir)
1256
+ end
1257
+ ok {sout} == <<"END"
1258
+ #{@tmpdir}/@babel/core@7.15.5/LICENSE ... Done (1,106 byte)
1259
+ #{@tmpdir}/@babel/core@7.15.5/README.md ... Done (404 byte)
1260
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/cache-contexts.js ... Done (0 byte)
1261
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/caching.js ... Done (7,327 byte)
1262
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/config-chain.js ... Done (17,871 byte)
1263
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/config-descriptors.js ... Done (6,756 byte)
1264
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/configuration.js ... Done (9,975 byte)
1265
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/import.js ... Done (165 byte)
1266
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/index-browser.js ... Done (1,550 byte)
1267
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/index.js ... Done (1,760 byte)
1268
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/module-types.js ... Done (2,731 byte)
1269
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/package.js ... Done (1,509 byte)
1270
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/plugins.js ... Done (6,287 byte)
1271
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/types.js ... Done (0 byte)
1272
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/files/utils.js ... Done (856 byte)
1273
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/full.js ... Done (9,211 byte)
1274
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/helpers/config-api.js ... Done (2,593 byte)
1275
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/helpers/environment.js ... Done (227 byte)
1276
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/index.js ... Done (2,462 byte)
1277
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/item.js ... Done (1,802 byte)
1278
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/partial.js ... Done (5,647 byte)
1279
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/pattern-to-regex.js ... Done (1,143 byte)
1280
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/plugin.js ... Done (744 byte)
1281
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/printer.js ... Done (2,893 byte)
1282
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/resolve-targets-browser.js ... Done (945 byte)
1283
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/resolve-targets.js ... Done (1,430 byte)
1284
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/util.js ... Done (887 byte)
1285
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/option-assertions.js ... Done (9,985 byte)
1286
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/options.js ... Done (7,749 byte)
1287
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/plugins.js ... Done (1,982 byte)
1288
+ #{@tmpdir}/@babel/core@7.15.5/lib/config/validation/removed.js ... Done (2,374 byte)
1289
+ #{@tmpdir}/@babel/core@7.15.5/lib/gensync-utils/async.js ... Done (1,775 byte)
1290
+ #{@tmpdir}/@babel/core@7.15.5/lib/gensync-utils/fs.js ... Done (576 byte)
1291
+ #{@tmpdir}/@babel/core@7.15.5/lib/index.js ... Done (5,697 byte)
1292
+ #{@tmpdir}/@babel/core@7.15.5/lib/parse.js ... Done (1,085 byte)
1293
+ #{@tmpdir}/@babel/core@7.15.5/lib/parser/index.js ... Done (2,260 byte)
1294
+ #{@tmpdir}/@babel/core@7.15.5/lib/parser/util/missing-plugin-helper.js ... Done (7,985 byte)
1295
+ #{@tmpdir}/@babel/core@7.15.5/lib/tools/build-external-helpers.js ... Done (4,331 byte)
1296
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-ast.js ... Done (1,257 byte)
1297
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-file-browser.js ... Done (692 byte)
1298
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform-file.js ... Done (1,059 byte)
1299
+ #{@tmpdir}/@babel/core@7.15.5/lib/transform.js ... Done (1,059 byte)
1300
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/block-hoist-plugin.js ... Done (1,802 byte)
1301
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/file.js ... Done (5,864 byte)
1302
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/generate.js ... Done (1,903 byte)
1303
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/file/merge-map.js ... Done (5,412 byte)
1304
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/index.js ... Done (3,296 byte)
1305
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/normalize-file.js ... Done (3,796 byte)
1306
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/normalize-opts.js ... Done (1,543 byte)
1307
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/plugin-pass.js ... Done (1,035 byte)
1308
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/util/clone-deep-browser.js ... Done (599 byte)
1309
+ #{@tmpdir}/@babel/core@7.15.5/lib/transformation/util/clone-deep.js ... Done (453 byte)
1310
+ #{@tmpdir}/@babel/core@7.15.5/package.json ... Done (2,395 byte)
1311
+ #{@tmpdir}/@babel/core@7.15.5/src/config/files/index-browser.ts ... Done (2,846 byte)
1312
+ #{@tmpdir}/@babel/core@7.15.5/src/config/files/index.ts ... Done (735 byte)
1313
+ #{@tmpdir}/@babel/core@7.15.5/src/config/resolve-targets-browser.ts ... Done (1,074 byte)
1314
+ #{@tmpdir}/@babel/core@7.15.5/src/config/resolve-targets.ts ... Done (1,612 byte)
1315
+ #{@tmpdir}/@babel/core@7.15.5/src/transform-file-browser.ts ... Done (716 byte)
1316
+ #{@tmpdir}/@babel/core@7.15.5/src/transform-file.ts ... Done (1,475 byte)
1317
+ #{@tmpdir}/@babel/core@7.15.5/src/transformation/util/clone-deep-browser.ts ... Done (500 byte)
1318
+ #{@tmpdir}/@babel/core@7.15.5/src/transformation/util/clone-deep.ts ... Done (223 byte)
1319
+ END
1031
1320
  end
1032
1321
 
1033
- after do
1034
- FileUtils.rm_rf @tmpdir
1322
+ spec "(google) raises error." do
1323
+ pr = proc { run("google", "@babel/core", "7.15.5", @tmpdir) }
1324
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
1035
1325
  end
1036
1326
 
1037
- it "(unpkg) skips '.DS_Store' files." do
1038
- sout, serr = capture_io do()
1039
- CDNGet::Main.new("cdnget").run("unpkg", "bulma", "0.9.3", @tmpdir)
1327
+ end
1328
+
1329
+
1330
+ topic "cdnget <CDN> bulma 0.9.3 <dir> (containing '.DS_Store')" do
1331
+
1332
+ spec "(unpkg) skips '.DS_Store' files." do
1333
+ sout, serr = capture_sio do()
1334
+ run("unpkg", "bulma", "0.9.3", @tmpdir)
1040
1335
  end
1041
1336
  ok {sout}.include?("#{@tmpdir}/bulma@0.9.3/sass/.DS_Store ... Skipped\n")
1042
1337
  ok {sout}.include?("#{@tmpdir}/bulma@0.9.3/sass/base/.DS_Store ... Skipped\n")
@@ -1045,12 +1340,14 @@ END
1045
1340
  end
1046
1341
 
1047
1342
 
1048
- describe "cdnget CDN jquery 2.2.0 foo bar" do
1343
+ topic "cdnget <CDN> <library> <version> <dir> foo bar" do
1049
1344
 
1050
- it "results in argument error." do
1051
- args = ["cdnjs", "jquery", "2.2.0", "foo", "bar"]
1052
- pr = proc { CDNGet::Main.new("cdnget").run(*args) }
1053
- ok {pr}.raise?(CDNGet::CommandError, "'bar': Too many arguments.")
1345
+ spec "results in argument error." do
1346
+ CDN_NAMES.each do |cdn|
1347
+ args = [cdn, "jquery", "2.2.0", "foo", "bar"]
1348
+ pr = proc { run(*args) }
1349
+ ok {pr}.raise?(CDNGet::CommandError, "'bar': Too many arguments.")
1350
+ end
1054
1351
  end
1055
1352
 
1056
1353
  end