cdnget 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/cdnget_test.rb CHANGED
@@ -54,6 +54,7 @@ describe CDNGet do
54
54
  expected = <<END
55
55
  cdnjs # https://cdnjs.com/
56
56
  jsdelivr # https://www.jsdelivr.com/
57
+ unpkg # https://unpkg.com/
57
58
  google # https://developers.google.com/speed/libraries/
58
59
  #jquery # https://code.jquery.com/
59
60
  #aspnet # https://www.asp.net/ajax/cdn/
@@ -83,10 +84,17 @@ END
83
84
  end
84
85
 
85
86
  it "(jsdelivr) lists librareis." do
86
- actual = CDNGet::Main.new().run("jsdelivr")
87
- ok {actual} =~ /^jquery /
88
- ok {actual} =~ /^angularjs /
89
- ok {actual} =~ /^bootstrap /
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*'."
91
+ end
92
+
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*'."
90
98
  end
91
99
 
92
100
  end
@@ -114,11 +122,19 @@ END
114
122
  it "(jsdelivr) lists libraries starting to pattern." do
115
123
  actual = CDNGet::Main.new().run("jsdelivr", "jquery*")
116
124
  ok {actual} =~ /^jquery #/
117
- ok {actual} =~ /^jquery\.ui #/ # match
125
+ ok {actual} =~ /^jquery-datepicker #/ # match
118
126
  ok {actual} !~ /^angularjs/
119
127
  ok {actual} !~ /^bootstrap/
120
128
  end
121
129
 
130
+ it "(unpkg) lists libraries starting to pattern." do
131
+ actual = CDNGet::Main.new().run("unpkg", "jquery*")
132
+ ok {actual} =~ /^jquery #/
133
+ ok {actual} =~ /^jquery-ui #/ # match
134
+ ok {actual} !~ /^jquery\.ui /
135
+ ok {actual} !~ /^bootstrap/
136
+ end
137
+
122
138
  end
123
139
 
124
140
 
@@ -144,7 +160,15 @@ END
144
160
  it "(jsdelivr) lists libraries ending to pattern." do
145
161
  actual = CDNGet::Main.new().run("jsdelivr", "*jquery")
146
162
  ok {actual} =~ /^jquery #/
147
- ok {actual} !~ /^jquery\.ui #/ # not match
163
+ ok {actual} !~ /^jquery-datepicker / # not match
164
+ ok {actual} !~ /^angularjs/
165
+ ok {actual} !~ /^bootstrap/
166
+ end
167
+
168
+ it "(unpkg) lists libraries ending to pattern." do
169
+ actual = CDNGet::Main.new().run("unpkg", "*jquery")
170
+ ok {actual} =~ /^jquery #/
171
+ ok {actual} !~ /^jquery-ui #/ # not match
148
172
  ok {actual} !~ /^angularjs/
149
173
  ok {actual} !~ /^bootstrap/
150
174
  end
@@ -172,11 +196,21 @@ END
172
196
  ok {actual} =~ /^swfobject /
173
197
  end
174
198
 
175
- it "(google) lists libraries including pattern." do
199
+ it "(jsdelivr) lists libraries including pattern." do
176
200
  actual = CDNGet::Main.new().run("jsdelivr", "*jquery*")
177
201
  ok {actual} =~ /^jquery /
178
- ok {actual} =~ /^jasmine\.jquery /
179
- ok {actual} =~ /^jquery\.zoom /
202
+ ok {actual} =~ /^jasmine-jquery /
203
+ ok {actual} =~ /^jquery-form /
204
+ ok {actual} !~ /^angularjs/
205
+ ok {actual} !~ /^react/
206
+ end
207
+
208
+ it "(unpkg) lists libraries including pattern." do
209
+ actual = CDNGet::Main.new().run("unpkg", "*jquery*")
210
+ ok {actual} =~ /^jquery /
211
+ ok {actual} =~ /^jquery-csv /
212
+ ok {actual} =~ /^jquery\.terminal /
213
+ ok {actual} =~ /^nd-jquery /
180
214
  ok {actual} !~ /^angularjs/
181
215
  ok {actual} !~ /^bootstrap/
182
216
  end
@@ -189,9 +223,12 @@ END
189
223
  it "(cdnjs) lists versions of library." do
190
224
  actual = CDNGet::Main.new().run("cdnjs", "jquery")
191
225
  text1 = <<END
192
- name: jquery
193
- desc: JavaScript library for DOM operations
194
- tags: jquery, library, ajax, framework, toolkit, popular
226
+ name: jquery
227
+ desc: JavaScript library for DOM operations
228
+ tags: jquery, library, ajax, framework, toolkit, popular
229
+ site: http://jquery.com/
230
+ info: https://cdnjs.com/libraries/jquery
231
+ license: MIT
195
232
  versions:
196
233
  END
197
234
  ok {actual}.start_with?(text1)
@@ -210,8 +247,9 @@ END
210
247
  it "(google) lists versions of library." do
211
248
  actual = CDNGet::Main.new().run("google", "jquery")
212
249
  text1 = <<END
213
- name: jquery
214
- site: http://jquery.com/
250
+ name: jquery
251
+ site: http://jquery.com/
252
+ info: https://developers.google.com/speed/libraries/#jquery
215
253
  versions:
216
254
  END
217
255
  ok {actual}.start_with?(text1)
@@ -230,18 +268,46 @@ END
230
268
  it "(jsdelivr) lists versions of library." do
231
269
  actual = CDNGet::Main.new().run("jsdelivr", "jquery")
232
270
  text1 = <<END
233
- name: jquery
234
- desc: jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
235
- site: http://jquery.com/
271
+ name: jquery
272
+ desc: JavaScript library for DOM operations
273
+ tags: jquery, javascript, browser, library
274
+ site: https://jquery.com
275
+ info: https://www.jsdelivr.com/package/npm/jquery
276
+ license: MIT
277
+ versions:
278
+ END
279
+ ok {actual}.start_with?(text1)
280
+ text2 = <<END
281
+ - 1.8.2
282
+ - 1.7.3
283
+ - 1.7.2
284
+ - 1.6.3
285
+ - 1.6.2
286
+ - 1.5.1
287
+ END
288
+ ok {actual}.end_with?(text2)
289
+ ok {actual} =~ /^ - 2\.2\.0$/
290
+ ok {actual} =~ /^ - 1\.12\.0$/
291
+ end
292
+
293
+ it "(unpkg) lists versions of library." do
294
+ actual = CDNGet::Main.new().run("unpkg", "jquery")
295
+ text1 = <<END
296
+ name: jquery
297
+ desc: JavaScript library for DOM operations
298
+ tags: jquery, javascript, browser, library
299
+ site: https://jquery.com
300
+ info: https://unpkg.com/browse/jquery/
301
+ license: MIT
236
302
  versions:
237
303
  END
238
304
  ok {actual}.start_with?(text1)
239
305
  text2 = <<END
306
+ - 1.7.3
240
307
  - 1.7.2
241
- - 1.7.1
242
- - 1.7
308
+ - 1.6.3
309
+ - 1.6.2
243
310
  - 1.5.1
244
- - 1.4.4
245
311
  END
246
312
  ok {actual}.end_with?(text2)
247
313
  ok {actual} =~ /^ - 2\.2\.0$/
@@ -262,8 +328,13 @@ END
262
328
  end
263
329
 
264
330
  it "(jsdelivr) raises error when library name is wrong." do
265
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui") }
266
- ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
331
+ pr = proc { CDNGet::Main.new().run("jsdelivr", "jquery-foobar") }
332
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
333
+ end
334
+
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.")
267
338
  end
268
339
 
269
340
  end
@@ -277,6 +348,9 @@ name: jquery
277
348
  version: 2.2.0
278
349
  desc: JavaScript library for DOM operations
279
350
  tags: jquery, library, ajax, framework, toolkit, popular
351
+ site: http://jquery.com/
352
+ info: https://cdnjs.com/libraries/jquery/2.2.0
353
+ license: MIT
280
354
  urls:
281
355
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js
282
356
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js
@@ -291,6 +365,7 @@ END
291
365
  name: jquery
292
366
  version: 2.2.0
293
367
  site: http://jquery.com/
368
+ info: https://developers.google.com/speed/libraries/#jquery
294
369
  urls:
295
370
  - https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
296
371
  END
@@ -302,12 +377,162 @@ END
302
377
  expected = <<END
303
378
  name: jquery
304
379
  version: 2.2.0
380
+ desc: JavaScript library for DOM operations
381
+ tags: jquery, javascript, browser, library
382
+ site: https://jquery.com
383
+ info: https://www.jsdelivr.com/package/npm/jquery?version=2.2.0
384
+ npmpkg: https://registry.npmjs.org/jquery/-/jquery-2.2.0.tgz
385
+ default: /dist/jquery.min.js
386
+ license: MIT
305
387
  urls:
306
- - https://cdn.jsdelivr.net/jquery/2.2.0/jquery.js
307
- - https://cdn.jsdelivr.net/jquery/2.2.0/jquery.min.js
308
- - https://cdn.jsdelivr.net/jquery/2.2.0/jquery.min.map
388
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/AUTHORS.txt
389
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/bower.json
390
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.js
391
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.min.js
392
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.min.map
393
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/LICENSE.txt
309
394
  END
310
395
  actual = CDNGet::Main.new().run("jsdelivr", "jquery", "2.2.0")
396
+ ok {actual}.start_with?(expected)
397
+ end
398
+
399
+ it "(unpkg) lists files." do
400
+ expected = <<END
401
+ name: jquery
402
+ version: 3.6.0
403
+ desc: JavaScript library for DOM operations
404
+ tags: jquery, javascript, browser, library
405
+ site: https://jquery.com
406
+ info: https://unpkg.com/browse/jquery@3.6.0/
407
+ npmpkg: https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz
408
+ default: /dist/jquery.min.js
409
+ license: MIT
410
+ 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
442
+ - https://unpkg.com/jquery@3.6.0/src/core/access.js
443
+ - https://unpkg.com/jquery@3.6.0/src/core/camelCase.js
444
+ - https://unpkg.com/jquery@3.6.0/src/core/DOMEval.js
445
+ - https://unpkg.com/jquery@3.6.0/src/core/init.js
446
+ - https://unpkg.com/jquery@3.6.0/src/core/isAttached.js
447
+ - https://unpkg.com/jquery@3.6.0/src/core/nodeName.js
448
+ - https://unpkg.com/jquery@3.6.0/src/core/parseHTML.js
449
+ - https://unpkg.com/jquery@3.6.0/src/core/parseXML.js
450
+ - https://unpkg.com/jquery@3.6.0/src/core/ready.js
451
+ - https://unpkg.com/jquery@3.6.0/src/core/ready-no-deferred.js
452
+ - https://unpkg.com/jquery@3.6.0/src/core/readyException.js
453
+ - https://unpkg.com/jquery@3.6.0/src/core/stripAndCollapse.js
454
+ - https://unpkg.com/jquery@3.6.0/src/core/support.js
455
+ - 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
+ - https://unpkg.com/jquery@3.6.0/src/css/addGetHookIf.js
459
+ - 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
+ - https://unpkg.com/jquery@3.6.0/src/css/var/cssExpand.js
466
+ - https://unpkg.com/jquery@3.6.0/src/css/var/getStyles.js
467
+ - https://unpkg.com/jquery@3.6.0/src/css/var/isHiddenWithinTree.js
468
+ - https://unpkg.com/jquery@3.6.0/src/css/var/rboxStyle.js
469
+ - https://unpkg.com/jquery@3.6.0/src/css/var/rnumnonpx.js
470
+ - 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
479
+ - https://unpkg.com/jquery@3.6.0/src/deprecated/ajax-event-alias.js
480
+ - 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
489
+ - https://unpkg.com/jquery@3.6.0/src/exports/amd.js
490
+ - 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
513
+ - https://unpkg.com/jquery@3.6.0/src/var/arr.js
514
+ - https://unpkg.com/jquery@3.6.0/src/var/class2type.js
515
+ - https://unpkg.com/jquery@3.6.0/src/var/document.js
516
+ - https://unpkg.com/jquery@3.6.0/src/var/documentElement.js
517
+ - https://unpkg.com/jquery@3.6.0/src/var/flat.js
518
+ - https://unpkg.com/jquery@3.6.0/src/var/fnToString.js
519
+ - https://unpkg.com/jquery@3.6.0/src/var/getProto.js
520
+ - https://unpkg.com/jquery@3.6.0/src/var/hasOwn.js
521
+ - https://unpkg.com/jquery@3.6.0/src/var/indexOf.js
522
+ - https://unpkg.com/jquery@3.6.0/src/var/isFunction.js
523
+ - https://unpkg.com/jquery@3.6.0/src/var/isWindow.js
524
+ - https://unpkg.com/jquery@3.6.0/src/var/ObjectFunctionString.js
525
+ - https://unpkg.com/jquery@3.6.0/src/var/pnum.js
526
+ - https://unpkg.com/jquery@3.6.0/src/var/push.js
527
+ - https://unpkg.com/jquery@3.6.0/src/var/rcheckableType.js
528
+ - https://unpkg.com/jquery@3.6.0/src/var/rcssNum.js
529
+ - https://unpkg.com/jquery@3.6.0/src/var/rnothtmlwhite.js
530
+ - https://unpkg.com/jquery@3.6.0/src/var/slice.js
531
+ - https://unpkg.com/jquery@3.6.0/src/var/support.js
532
+ - https://unpkg.com/jquery@3.6.0/src/var/toString.js
533
+ - https://unpkg.com/jquery@3.6.0/src/wrap.js
534
+ END
535
+ actual = CDNGet::Main.new().run("unpkg", "jquery", "3.6.0")
311
536
  ok {actual} == expected
312
537
  end
313
538
 
@@ -317,6 +542,9 @@ name: jquery-jcrop
317
542
  version: 0.9.12
318
543
  desc: Jcrop is the quick and easy way to add image cropping functionality to your web application.
319
544
  tags: jquery, crop
545
+ site: http://deepliquid.com/content/Jcrop.html
546
+ info: https://cdnjs.com/libraries/jquery-jcrop/0.9.12
547
+ license: MIT
320
548
  urls:
321
549
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/Jcrop.gif
322
550
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.css
@@ -350,7 +578,12 @@ END
350
578
 
351
579
  it "(jsdelivr) raises error when library name is wrong." do
352
580
  pr = proc { CDNGet::Main.new().run("jsdelivr", "jquery-ui", "1.9.2") }
353
- ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
581
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-ui@1.9.2: Library or version not found.")
582
+ end
583
+
584
+ it "(unpkg) raises error when library name is wrong." do
585
+ pr = proc { CDNGet::Main.new().run("unpkg", "jquery-foobar", "1.9.2") }
586
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
354
587
  end
355
588
 
356
589
  end
@@ -358,13 +591,56 @@ END
358
591
 
359
592
  describe "cdnget CDN jquery 2.2.0 dir" do
360
593
 
361
- def _do_download_test1(cdn_code)
362
- tmpdir = "tmpdir1"
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)
603
+ end
604
+
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)
614
+ end
615
+
616
+ def _do_download_test3(cdn_code, libname, version, expected)
617
+ @tmpdir = tmpdir = "tmpdir1"
363
618
  Dir.mkdir(tmpdir)
364
- begin
365
- sout, serr = capture_io() do
366
- actual = CDNGet::Main.new().run("cdnjs", "jquery", "2.2.0", 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)
629
+ end
630
+ ok {serr} == ""
631
+ ok {sout} == expected.gsub(/(\(Created\))?\n/) {
632
+ if $1
633
+ "(Already exists)\n"
634
+ else
635
+ " (Unchanged)\n"
367
636
  end
637
+ }
638
+ ensure
639
+ FileUtils.rm_r(tmpdir)
640
+ end
641
+
642
+ it "(cdnjs) downloads files into dir." do
643
+ _do_download_test1("cdnjs", "jquery", "2.2.0") do |tmpdir, sout, serr|
368
644
  ok {"#{tmpdir}/jquery/2.2.0/jquery.js" }.file_exist?
369
645
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.js" }.file_exist?
370
646
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.map"}.file_exist?
@@ -373,28 +649,66 @@ END
373
649
  #{tmpdir}/jquery/2.2.0/jquery.min.js ... Done (85,589 byte)
374
650
  #{tmpdir}/jquery/2.2.0/jquery.min.map ... Done (129,544 byte)
375
651
  END
376
- ensure
377
- FileUtils.rm_r(tmpdir)
378
652
  end
379
653
  end
380
654
 
381
- def _do_download_test2(cdn_code)
382
- tmpdir = "tmpdir1"
383
- Dir.mkdir(tmpdir)
384
- expected = <<END
385
- #{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif ... Done (329 byte)
386
- #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css ... Done (3,280 byte)
387
- #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css ... Done (2,102 byte)
388
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.js ... Done (42,434 byte)
389
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js ... Done (15,892 byte)
390
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js ... Done (16,142 byte)
391
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js ... Done (6,845 byte)
392
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js ... Done (93,068 byte)
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)
393
660
  END
394
- begin
395
- sout, serr = capture_io() do
396
- actual = CDNGet::Main.new().run("cdnjs", "jquery-jcrop", "0.9.12", tmpdir)
397
- 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|
666
+ ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
667
+ ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
668
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
669
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi-min.js" }.file_exist?
670
+ ok {"#{tmpdir}/chibijs@3.0.9/gulpfile.js" }.file_exist?
671
+ ok {"#{tmpdir}/chibijs@3.0.9/package.json" }.file_exist?
672
+ ok {"#{tmpdir}/chibijs@3.0.9/README.md" }.file_exist?
673
+ ok {"#{tmpdir}/chibijs@3.0.9/tests/runner.html"}.file_exist?
674
+ ok {sout} == <<END
675
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
676
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
677
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
678
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
679
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
680
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
681
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
682
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
683
+ END
684
+ end
685
+ end
686
+
687
+ it "(unpkg) downloads files into dir." do
688
+ _do_download_test1("unpkg", "chibijs", "3.0.9") do |tmpdir, sout, serr|
689
+ ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
690
+ ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
691
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
692
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi-min.js" }.file_exist?
693
+ ok {"#{tmpdir}/chibijs@3.0.9/gulpfile.js" }.file_exist?
694
+ ok {"#{tmpdir}/chibijs@3.0.9/package.json" }.file_exist?
695
+ ok {"#{tmpdir}/chibijs@3.0.9/README.md" }.file_exist?
696
+ ok {"#{tmpdir}/chibijs@3.0.9/tests/runner.html"}.file_exist?
697
+ ok {sout} == <<END
698
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
699
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
700
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
701
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
702
+ #{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)
705
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
706
+ END
707
+ end
708
+ end
709
+
710
+ it "(cdnjs) downloads files (containing subdir) into dir." do
711
+ _do_download_test2("cdnjs", "jquery-jcrop", "0.9.12") do |tmpdir, sout, serr|
398
712
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif" }.file_exist?
399
713
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css" }.file_exist?
400
714
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css" }.file_exist?
@@ -403,32 +717,7 @@ END
403
717
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js" }.file_exist?
404
718
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js" }.file_exist?
405
719
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js" }.file_exist?
406
- ok {sout} == expected
407
- ensure
408
- FileUtils.rm_r(tmpdir)
409
- end
410
- end
411
-
412
- def _do_download_test3(cdn_code, libname)
413
- tmpdir = "tmpdir1"
414
- Dir.mkdir(tmpdir)
415
- case libname
416
- when "jquery"
417
- version = "2.2.4"
418
- if cdn_code == "google"
419
- expected = <<END
420
- #{tmpdir}/jquery/2.2.4/jquery.min.js ... Done (85,578 byte)
421
- END
422
- else
423
- expected = <<END
424
- #{tmpdir}/jquery/2.2.4/jquery.js ... Done (257,551 byte)
425
- #{tmpdir}/jquery/2.2.4/jquery.min.js ... Done (85,578 byte)
426
- #{tmpdir}/jquery/2.2.4/jquery.min.map ... Done (129,572 byte)
427
- END
428
- end
429
- when "jquery-jcrop"
430
- version = "0.9.12"
431
- expected = <<END
720
+ ok {sout} == <<END
432
721
  #{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif ... Done (329 byte)
433
722
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css ... Done (3,280 byte)
434
723
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css ... Done (2,102 byte)
@@ -439,59 +728,296 @@ END
439
728
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js ... Done (93,068 byte)
440
729
  END
441
730
  end
442
- begin
443
- path = "#{tmpdir}/#{libname}/#{version}"
444
- # 1st
445
- sout, serr = capture_io() do
446
- actual = CDNGet::Main.new().run(cdn_code, libname, version, tmpdir)
447
- end
448
- ok {serr} == ""
731
+ end
732
+
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|
739
+ ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.js" }.file_exist?
740
+ ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.min.js"}.file_exist?
741
+ ok {"#{tmpdir}/zepto@1.2.0/MIT-LICENSE" }.file_exist?
742
+ ok {"#{tmpdir}/zepto@1.2.0/package.json" }.file_exist?
743
+ ok {"#{tmpdir}/zepto@1.2.0/README.md" }.file_exist?
744
+ ok {"#{tmpdir}/zepto@1.2.0/src/ajax.js" }.file_exist?
745
+ ok {"#{tmpdir}/zepto@1.2.0/src/assets.js" }.file_exist?
746
+ ok {"#{tmpdir}/zepto@1.2.0/src/callbacks.js" }.file_exist?
747
+ ok {"#{tmpdir}/zepto@1.2.0/src/data.js" }.file_exist?
748
+ ok {"#{tmpdir}/zepto@1.2.0/src/deferred.js" }.file_exist?
749
+ ok {"#{tmpdir}/zepto@1.2.0/src/detect.js" }.file_exist?
750
+ ok {"#{tmpdir}/zepto@1.2.0/src/event.js" }.file_exist?
751
+ ok {"#{tmpdir}/zepto@1.2.0/src/form.js" }.file_exist?
752
+ ok {"#{tmpdir}/zepto@1.2.0/src/fx.js" }.file_exist?
753
+ ok {"#{tmpdir}/zepto@1.2.0/src/fx_methods.js"}.file_exist?
754
+ ok {"#{tmpdir}/zepto@1.2.0/src/gesture.js" }.file_exist?
755
+ ok {"#{tmpdir}/zepto@1.2.0/src/ie.js" }.file_exist?
756
+ ok {"#{tmpdir}/zepto@1.2.0/src/ios3.js" }.file_exist?
757
+ ok {"#{tmpdir}/zepto@1.2.0/src/selector.js" }.file_exist?
758
+ ok {"#{tmpdir}/zepto@1.2.0/src/stack.js" }.file_exist?
759
+ ok {"#{tmpdir}/zepto@1.2.0/src/touch.js" }.file_exist?
760
+ ok {"#{tmpdir}/zepto@1.2.0/src/zepto.js" }.file_exist?
761
+ ok {sout} == <<END
762
+ #{tmpdir}/zepto@1.2.0/dist/zepto.js ... Done (58,707 byte)
763
+ #{tmpdir}/zepto@1.2.0/dist/zepto.min.js ... Done (26,386 byte)
764
+ #{tmpdir}/zepto@1.2.0/MIT-LICENSE ... Done (1,081 byte)
765
+ #{tmpdir}/zepto@1.2.0/package.json ... Done (435 byte)
766
+ #{tmpdir}/zepto@1.2.0/README.md ... Done (6,711 byte)
767
+ #{tmpdir}/zepto@1.2.0/src/ajax.js ... Done (13,843 byte)
768
+ #{tmpdir}/zepto@1.2.0/src/assets.js ... Done (581 byte)
769
+ #{tmpdir}/zepto@1.2.0/src/callbacks.js ... Done (4,208 byte)
770
+ #{tmpdir}/zepto@1.2.0/src/data.js ... Done (2,789 byte)
771
+ #{tmpdir}/zepto@1.2.0/src/deferred.js ... Done (3,846 byte)
772
+ #{tmpdir}/zepto@1.2.0/src/detect.js ... Done (3,754 byte)
773
+ #{tmpdir}/zepto@1.2.0/src/event.js ... Done (9,546 byte)
774
+ #{tmpdir}/zepto@1.2.0/src/form.js ... Done (1,253 byte)
775
+ #{tmpdir}/zepto@1.2.0/src/fx.js ... Done (4,843 byte)
776
+ #{tmpdir}/zepto@1.2.0/src/fx_methods.js ... Done (2,102 byte)
777
+ #{tmpdir}/zepto@1.2.0/src/gesture.js ... Done (1,138 byte)
778
+ #{tmpdir}/zepto@1.2.0/src/ie.js ... Done (530 byte)
779
+ #{tmpdir}/zepto@1.2.0/src/ios3.js ... Done (1,140 byte)
780
+ #{tmpdir}/zepto@1.2.0/src/selector.js ... Done (3,187 byte)
781
+ #{tmpdir}/zepto@1.2.0/src/stack.js ... Done (560 byte)
782
+ #{tmpdir}/zepto@1.2.0/src/touch.js ... Done (6,067 byte)
783
+ #{tmpdir}/zepto@1.2.0/src/zepto.js ... Done (33,889 byte)
784
+ END
785
+ end
786
+ end
787
+
788
+ it "(unpkg) downloads files (containing subdir) into dir." do
789
+ _do_download_test2("unpkg", "react", "17.0.2") do |tmpdir, sout, serr|
790
+ ok {"#{tmpdir}/react@17.0.2/build-info.json" }.file_exist?
791
+ ok {"#{tmpdir}/react@17.0.2/cjs/react.development.js" }.file_exist?
792
+ ok {"#{tmpdir}/react@17.0.2/cjs/react.production.min.js"}.file_exist?
793
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.development.js" }.file_exist?
794
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.production.min.js"}.file_exist?
795
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.profiling.min.js" }.file_exist?
796
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.development.js" }.file_exist?
797
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.production.min.js" }.file_exist?
798
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.profiling.min.js" }.file_exist?
799
+ ok {"#{tmpdir}/react@17.0.2/index.js" }.file_exist?
800
+ ok {"#{tmpdir}/react@17.0.2/jsx-dev-runtime.js" }.file_exist?
801
+ ok {"#{tmpdir}/react@17.0.2/jsx-runtime.js" }.file_exist?
802
+ ok {"#{tmpdir}/react@17.0.2/LICENSE" }.file_exist?
803
+ ok {"#{tmpdir}/react@17.0.2/package.json" }.file_exist?
804
+ ok {"#{tmpdir}/react@17.0.2/README.md" }.file_exist?
805
+ ok {"#{tmpdir}/react@17.0.2/umd/react.development.js" }.file_exist?
806
+ ok {"#{tmpdir}/react@17.0.2/umd/react.production.min.js"}.file_exist?
807
+ ok {"#{tmpdir}/react@17.0.2/umd/react.profiling.min.js" }.file_exist?
808
+ 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)
812
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.development.js ... Done (37,753 byte)
813
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.production.min.js ... Done (456 byte)
814
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.profiling.min.js ... Done (455 byte)
815
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.development.js ... Done (38,352 byte)
816
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.production.min.js ... Done (962 byte)
817
+ #{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)
824
+ #{tmpdir}/react@17.0.2/umd/react.development.js ... Done (105,096 byte)
825
+ #{tmpdir}/react@17.0.2/umd/react.production.min.js ... Done (11,440 byte)
826
+ #{tmpdir}/react@17.0.2/umd/react.profiling.min.js ... Done (13,668 byte)
827
+ END
449
828
  ok {sout} == expected
450
- # 2nd
451
- sout, serr = capture_io() do
452
- actual = CDNGet::Main.new().run(cdn_code, libname, version, tmpdir)
453
- end
454
- ok {serr} == ""
455
- ok {sout} == expected.gsub(/\n/, " (Unchanged)\n")
456
- ensure
457
- FileUtils.rm_r(tmpdir)
458
829
  end
459
830
  end
460
831
 
461
- it "(cdnjs) downloads files into dir." do
462
- _do_download_test1("cdnjs")
832
+ it "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
833
+ tmpdir = "tmpdir1"
834
+ expected = <<END
835
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.css ... Done (7,401 byte)
836
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.gif ... Done (329 byte)
837
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.min.css ... Done (5,281 byte)
838
+ #{tmpdir}/jquery-jcrop/2.0.4/js/Jcrop.js ... Done (75,652 byte)
839
+ #{tmpdir}/jquery-jcrop/2.0.4/js/Jcrop.min.js ... Done (38,379 byte)
840
+ END
841
+ _do_download_test3("cdnjs", "jquery-jcrop", "2.0.4", expected)
463
842
  end
464
843
 
465
- it "(google) downloads files into dir." do
466
- _do_download_test1("google")
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)
467
850
  end
468
851
 
469
- it "(jsdelivr) downloads files into dir." do
470
- _do_download_test1("jsdelivr")
852
+ it "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
853
+ tmpdir = "tmpdir1"
854
+ expected = <<END
855
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
856
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
857
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
858
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
859
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
860
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
861
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
862
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
863
+ END
864
+ _do_download_test3("jsdelivr", "chibijs", "3.0.9", expected)
471
865
  end
472
866
 
473
- it "(cdnjs) downloads files (containing subdir) into dir." do
474
- _do_download_test2("cdnjs")
867
+ it "(unpkg) doesn't override existing files when they are identical to downloaded files." do
868
+ tmpdir = "tmpdir1"
869
+ expected = <<END
870
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
871
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
872
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
873
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
874
+ #{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)
877
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
878
+ END
879
+ _do_download_test3("unpkg", "chibijs", "3.0.9", expected)
475
880
  end
476
881
 
477
- it "(google) downloads files (containing subdir) into dir." do
478
- skip("no libraries containing subdirectory")
882
+ end
883
+
884
+
885
+ describe "cdnget CDN swfobject latest" do
886
+
887
+ it "(cdnjs) shows latest version." do
888
+ actual = CDNGet::Main.new("cdnget").run("cdnjs", "swfobject", "latest")
889
+ ok {actual} == <<END
890
+ name: swfobject
891
+ version: 2.2
892
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
893
+ tags: swf, flash
894
+ site: http://code.google.com/p/swfobject/
895
+ info: https://cdnjs.com/libraries/swfobject/2.2
896
+ license: MIT
897
+ urls:
898
+ - https://cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.js
899
+ - https://cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.min.js
900
+ END
479
901
  end
480
902
 
481
- it "(jsdelivr) downloads files (containing subdir) into dir." do
482
- _do_download_test2("jsdelivr")
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
483
913
  end
484
914
 
485
- it "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
486
- _do_download_test3("cdnjs", "jquery-jcrop")
915
+ it "(jsdelivr) shows latest version." do
916
+ actual = CDNGet::Main.new("cdnget").run("jsdelivr", "swfobject", "latest")
917
+ ok {actual} == <<END
918
+ name: swfobject
919
+ version: 2.2.1
920
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
921
+ tags: SWFObject, swf, object, flash, embed, content
922
+ info: https://www.jsdelivr.com/package/npm/swfobject?version=2.2.1
923
+ npmpkg: https://registry.npmjs.org/swfobject/-/swfobject-2.2.1.tgz
924
+ default: /index.min.js
925
+ license: MIT
926
+ urls:
927
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/.npmignore
928
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/download.sh
929
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/expressInstall.swf
930
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/index.js
931
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/package.json
932
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/patch.js
933
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/README.md
934
+ END
487
935
  end
488
936
 
489
- it "(google) doesn't override existing files when they are identical to downloaded files." do
490
- _do_download_test3("google", "jquery")
937
+ it "(unpkg) shows latest version." do
938
+ actual = CDNGet::Main.new("cdnget").run("unpkg", "swfobject", "latest")
939
+ ok {actual} == <<END
940
+ name: swfobject
941
+ version: 2.2.1
942
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
943
+ tags: SWFObject, swf, object, flash, embed, content
944
+ site: https://github.com/unshiftio/swfobject
945
+ info: https://unpkg.com/browse/swfobject@2.2.1/
946
+ npmpkg: https://registry.npmjs.org/swfobject/-/swfobject-2.2.1.tgz
947
+ default: /index.min.js
948
+ license: MIT
949
+ urls:
950
+ - 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
953
+ - https://unpkg.com/swfobject@2.2.1/index.js
954
+ - https://unpkg.com/swfobject@2.2.1/package.json
955
+ - https://unpkg.com/swfobject@2.2.1/patch.js
956
+ - https://unpkg.com/swfobject@2.2.1/README.md
957
+ END
491
958
  end
492
959
 
493
- it "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
494
- _do_download_test3("jsdelivr", "jquery")
960
+ end
961
+
962
+
963
+ describe "cdnget CDN swfobject latest dir" do
964
+
965
+ before do
966
+ @tmpdir = "tmpdir1"
967
+ Dir.mkdir @tmpdir
968
+ end
969
+
970
+ after do
971
+ FileUtils.rm_rf @tmpdir
972
+ end
973
+
974
+ it "(cdnjs) downlaods latest version." do
975
+ sout, serr = capture_io do()
976
+ CDNGet::Main.new("cdnget").run("cdnjs", "swfobject", "latest", @tmpdir)
977
+ end
978
+ ok {sout} == <<"END"
979
+ #{@tmpdir}/swfobject/2.2/swfobject.js ... Done (10,220 byte)
980
+ #{@tmpdir}/swfobject/2.2/swfobject.min.js ... Done (9,211 byte)
981
+ END
982
+ end
983
+
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)
996
+ end
997
+ ok {sout} == <<"END"
998
+ #{@tmpdir}/swfobject@2.2.1/.npmignore ... Done (13 byte)
999
+ #{@tmpdir}/swfobject@2.2.1/download.sh ... Done (517 byte)
1000
+ #{@tmpdir}/swfobject@2.2.1/expressInstall.swf ... Done (727 byte)
1001
+ #{@tmpdir}/swfobject@2.2.1/index.js ... Done (10,331 byte)
1002
+ #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1003
+ #{@tmpdir}/swfobject@2.2.1/patch.js ... Done (277 byte)
1004
+ #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1005
+ END
1006
+ end
1007
+
1008
+ it "(unpkg) downlaods latest version." do
1009
+ sout, serr = capture_io do()
1010
+ CDNGet::Main.new("cdnget").run("unpkg", "swfobject", "latest", @tmpdir)
1011
+ end
1012
+ ok {sout} == <<"END"
1013
+ #{@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)
1016
+ #{@tmpdir}/swfobject@2.2.1/index.js ... Done (10,331 byte)
1017
+ #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1018
+ #{@tmpdir}/swfobject@2.2.1/patch.js ... Done (277 byte)
1019
+ #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1020
+ END
495
1021
  end
496
1022
 
497
1023
  end