cdnget 0.3.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/cdnget_test.rb CHANGED
@@ -1,101 +1,105 @@
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)
26
15
  end
27
16
 
17
+ before do
18
+ @tmpdir = "tmpdir1"
19
+ Dir.mkdir @tmpdir
20
+ end
28
21
 
29
- describe 'cdnget [-h][--help]' do
22
+ after do
23
+ FileUtils.rm_rf @tmpdir
24
+ end
30
25
 
31
- it "prints help message." do
26
+
27
+ topic 'cdnget [-h][--help]' do
28
+
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/
55
+ unpkg # https://unpkg.com/
57
56
  google # https://developers.google.com/speed/libraries/
58
57
  #jquery # https://code.jquery.com/
59
58
  #aspnet # https://www.asp.net/ajax/cdn/
60
59
  END
61
- actual = CDNGet::Main.new().run()
60
+ actual = run()
62
61
  ok {actual} == expected.gsub(/^\#.*\n/, '')
63
62
  end
64
63
 
65
64
  end
66
65
 
67
66
 
68
- describe 'cdnget CDN' do
67
+ topic 'cdnget <CDN>' do
69
68
 
70
- it "(cdnjs) lists librareis." do
71
- actual = CDNGet::Main.new().run("cdnjs")
69
+ spec "(cdnjs) lists librareis." do
70
+ actual = run("cdnjs")
72
71
  ok {actual} =~ /^jquery # JavaScript library for DOM operations$/
73
72
  ok {actual} =~ /^angular\.js # AngularJS is an MVC framework for building web applications\./
74
73
  ok {actual} =~ /^ember\.js # Ember is a JavaScript framework for creating ambitious web applications that eliminates boilerplate and provides a standard application architecture\./
75
74
  end
76
75
 
77
- it "(google) lists librareis." do
78
- actual = CDNGet::Main.new().run("google")
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*'.")
80
+ end
81
+
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*'.")
86
+ end
87
+
88
+ spec "(google) lists librareis." do
89
+ actual = run("google")
79
90
  ok {actual} =~ /^jquery /
80
91
  #ok {actual} =~ /^angularjs /
81
92
  ok {actual} =~ /^swfobject /
82
93
  ok {actual} =~ /^webfont /
83
94
  end
84
95
 
85
- it "(jsdelivr) lists librareis." do
86
- actual = CDNGet::Main.new().run("jsdelivr")
87
- ok {actual} =~ /^jquery /
88
- ok {actual} =~ /^angularjs /
89
- ok {actual} =~ /^bootstrap /
90
- end
91
-
92
96
  end
93
97
 
94
98
 
95
- describe 'cdnget CDN "jquery*"' do
99
+ topic 'cdnget <CDN> <pattern> (#1)' do
96
100
 
97
- it "(cdnjs) lists libraries starting to pattern." do
98
- actual = CDNGet::Main.new().run("cdnjs", "jquery*")
101
+ spec "(cdnjs) lists libraries starting to pattern." do
102
+ actual = run("cdnjs", "jquery*")
99
103
  ok {actual} =~ /^jquery #/
100
104
  ok {actual} =~ /^jqueryui #/ # match
101
105
  ok {actual} !~ /^require-jquery #/ # not match
@@ -104,28 +108,36 @@ END
104
108
  ok {actual} !~ /^ember\.js/
105
109
  end
106
110
 
107
- it "(google) lists libraries starting to pattern." do
108
- actual = CDNGet::Main.new().run("google", "jquery*")
111
+ spec "(jsdelivr) lists libraries starting to pattern." do
112
+ actual = run("jsdelivr", "jquery*")
109
113
  ok {actual} =~ /^jquery #/
110
- ok {actual} =~ /^jqueryui #/ # match
114
+ ok {actual} =~ /^jquery-datepicker #/ # match
111
115
  ok {actual} !~ /^angularjs/
116
+ ok {actual} !~ /^bootstrap/
112
117
  end
113
118
 
114
- it "(jsdelivr) lists libraries starting to pattern." do
115
- actual = CDNGet::Main.new().run("jsdelivr", "jquery*")
119
+ spec "(unpkg) lists libraries starting to pattern." do
120
+ actual = run("unpkg", "jquery*")
116
121
  ok {actual} =~ /^jquery #/
117
- ok {actual} =~ /^jquery\.ui #/ # match
118
- ok {actual} !~ /^angularjs/
122
+ ok {actual} =~ /^jquery-ui #/ # match
123
+ ok {actual} !~ /^jquery\.ui /
119
124
  ok {actual} !~ /^bootstrap/
120
125
  end
121
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
+
122
134
  end
123
135
 
124
136
 
125
- describe 'cdnget cdnjs "*jquery"' do
137
+ topic 'cdnget <CDN> <pattern> (#2)' do
126
138
 
127
- it "(cdnjs) lists libraries ending to pattern." do
128
- actual = CDNGet::Main.new().run("cdnjs", "*jquery")
139
+ spec "(cdnjs) lists libraries ending to pattern." do
140
+ actual = run("cdnjs", "*jquery")
129
141
  ok {actual} =~ /^jquery #/
130
142
  ok {actual} !~ /^jqueryui #/ # not match
131
143
  ok {actual} =~ /^require-jquery #/ # match
@@ -134,28 +146,36 @@ END
134
146
  ok {actual} !~ /^ember\.js/
135
147
  end
136
148
 
137
- it "(google) lists libraries ending to pattern." do
138
- actual = CDNGet::Main.new().run("google", "*jquery")
149
+ spec "(jsdelivr) lists libraries ending to pattern." do
150
+ actual = run("jsdelivr", "*jquery")
139
151
  ok {actual} =~ /^jquery #/
140
- ok {actual} !~ /^jqueryui #/ # not match
152
+ ok {actual} !~ /^jquery-datepicker / # not match
141
153
  ok {actual} !~ /^angularjs/
154
+ ok {actual} !~ /^bootstrap/
142
155
  end
143
156
 
144
- it "(jsdelivr) lists libraries ending to pattern." do
145
- actual = CDNGet::Main.new().run("jsdelivr", "*jquery")
157
+ spec "(unpkg) lists libraries ending to pattern." do
158
+ actual = run("unpkg", "*jquery")
146
159
  ok {actual} =~ /^jquery #/
147
- ok {actual} !~ /^jquery\.ui #/ # not match
160
+ ok {actual} !~ /^jquery-ui #/ # not match
148
161
  ok {actual} !~ /^angularjs/
149
162
  ok {actual} !~ /^bootstrap/
150
163
  end
151
164
 
165
+ spec "(google) lists libraries ending to pattern." do
166
+ actual = run("google", "*jquery")
167
+ ok {actual} =~ /^jquery #/
168
+ ok {actual} !~ /^jqueryui #/ # not match
169
+ ok {actual} !~ /^angularjs/
170
+ end
171
+
152
172
  end
153
173
 
154
174
 
155
- describe 'cdnget cdnjs "*jquery*"' do
175
+ topic 'cdnget <CDN> <pattern> (#3)' do
156
176
 
157
- it "(cdnjs) lists libraries including pattern." do
158
- actual = CDNGet::Main.new().run("cdnjs", "*jquery*")
177
+ spec "(cdnjs) lists libraries including pattern." do
178
+ actual = run("cdnjs", "*jquery*")
159
179
  ok {actual} =~ /^jquery #/
160
180
  ok {actual} =~ /^jqueryui #/ # match
161
181
  ok {actual} =~ /^require-jquery #/ # match
@@ -164,34 +184,47 @@ END
164
184
  ok {actual} !~ /^ember\.js/
165
185
  end
166
186
 
167
- it "(google) lists libraries including pattern." do
168
- actual = CDNGet::Main.new().run("google", "*o*")
169
- ok {actual} !~ /^jquery /
170
- ok {actual} !~ /^angularjs /
171
- ok {actual} =~ /^mootools /
172
- ok {actual} =~ /^swfobject /
187
+ spec "(jsdelivr) lists libraries including pattern." do
188
+ actual = run("jsdelivr", "*jquery*")
189
+ ok {actual} =~ /^jquery /
190
+ ok {actual} =~ /^jasmine-jquery /
191
+ ok {actual} =~ /^jquery-form /
192
+ ok {actual} !~ /^angularjs/
193
+ ok {actual} !~ /^react/
173
194
  end
174
195
 
175
- it "(google) lists libraries including pattern." do
176
- actual = CDNGet::Main.new().run("jsdelivr", "*jquery*")
196
+ spec "(unpkg) lists libraries including pattern." do
197
+ actual = run("unpkg", "*jquery*")
177
198
  ok {actual} =~ /^jquery /
178
- ok {actual} =~ /^jasmine\.jquery /
179
- ok {actual} =~ /^jquery\.zoom /
199
+ ok {actual} =~ /^jquery-csv /
200
+ ok {actual} =~ /^jquery\.terminal /
201
+ ok {actual} =~ /^nd-jquery /
180
202
  ok {actual} !~ /^angularjs/
181
203
  ok {actual} !~ /^bootstrap/
182
204
  end
183
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
+
184
214
  end
185
215
 
186
216
 
187
- describe "cdnget CDN jquery" do
217
+ topic "cdnget <CDN> <library> (exists)" do
188
218
 
189
- it "(cdnjs) lists versions of library." do
190
- actual = CDNGet::Main.new().run("cdnjs", "jquery")
219
+ spec "(cdnjs) lists versions of library." do
220
+ actual = run("cdnjs", "jquery")
191
221
  text1 = <<END
192
- name: jquery
193
- desc: JavaScript library for DOM operations
194
- tags: jquery, library, ajax, framework, toolkit, popular
222
+ name: jquery
223
+ desc: JavaScript library for DOM operations
224
+ tags: jquery, library, ajax, framework, toolkit, popular
225
+ site: http://jquery.com/
226
+ info: https://cdnjs.com/libraries/jquery
227
+ license: MIT
195
228
  versions:
196
229
  END
197
230
  ok {actual}.start_with?(text1)
@@ -207,116 +240,316 @@ END
207
240
  ok {actual} =~ /^ - 1\.12\.0$/
208
241
  end
209
242
 
210
- it "(google) lists versions of library." do
211
- actual = CDNGet::Main.new().run("google", "jquery")
243
+ spec "(jsdelivr) lists versions of library." do
244
+ actual = run("jsdelivr", "jquery")
212
245
  text1 = <<END
213
- name: jquery
214
- site: http://jquery.com/
246
+ name: jquery
247
+ desc: JavaScript library for DOM operations
248
+ tags: jquery, javascript, browser, library
249
+ site: https://jquery.com
250
+ info: https://www.jsdelivr.com/package/npm/jquery
251
+ license: MIT
215
252
  versions:
216
253
  END
217
254
  ok {actual}.start_with?(text1)
218
255
  text2 = <<END
219
- - 1.3.2
220
- - 1.3.1
221
- - 1.3.0
222
- - 1.2.6
223
- - 1.2.3
256
+ - 1.8.2
257
+ - 1.7.3
258
+ - 1.7.2
259
+ - 1.6.3
260
+ - 1.6.2
261
+ - 1.5.1
224
262
  END
225
263
  ok {actual}.end_with?(text2)
226
264
  ok {actual} =~ /^ - 2\.2\.0$/
227
265
  ok {actual} =~ /^ - 1\.12\.0$/
228
266
  end
229
267
 
230
- it "(jsdelivr) lists versions of library." do
231
- actual = CDNGet::Main.new().run("jsdelivr", "jquery")
268
+ spec "(unpkg) lists versions of library." do
269
+ actual = run("unpkg", "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://unpkg.com/browse/jquery/
276
+ license: MIT
236
277
  versions:
237
278
  END
238
279
  ok {actual}.start_with?(text1)
239
280
  text2 = <<END
281
+ - 1.7.3
240
282
  - 1.7.2
241
- - 1.7.1
242
- - 1.7
283
+ - 1.6.3
284
+ - 1.6.2
243
285
  - 1.5.1
244
- - 1.4.4
245
286
  END
246
287
  ok {actual}.end_with?(text2)
247
288
  ok {actual} =~ /^ - 2\.2\.0$/
248
289
  ok {actual} =~ /^ - 1\.12\.0$/
249
290
  end
250
291
 
251
- it "(cdnjs) raises error when library name is wrong." do
252
- 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") }
253
320
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
254
321
  #
255
- pr = proc { CDNGet::Main.new().run("cdnjs", "emberjs", "2.2.1") }
322
+ pr = proc { run("cdnjs", "emberjs", "2.2.1") }
256
323
  ok {pr}.raise?(CDNGet::CommandError, "emberjs: Library not found (maybe 'ember.js'?).")
257
324
  end
258
325
 
259
- it "(google) raises error when library name is wrong." do
260
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui") }
261
- 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.")
329
+ end
330
+
331
+ spec "(unpkg) raises error when library name is wrong." do
332
+ pr = proc { run("unpkg", "jquery-foobar") }
333
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
262
334
  end
263
335
 
264
- it "(jsdelivr) raises error when library name is wrong." do
265
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui") }
336
+ spec "(google) raises error when library name is wrong." do
337
+ pr = proc { run("google", "jquery-ui") }
266
338
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
267
339
  end
268
340
 
269
341
  end
270
342
 
271
343
 
272
- describe "cdnget cdnjs jquery 2.2.0" do
344
+ topic "cdnget <CDN> <library> <version> (only files)" do
273
345
 
274
- it "(cdnjs) lists files." do
346
+ spec "(cdnjs) lists files." do
275
347
  expected = <<END
276
348
  name: jquery
277
349
  version: 2.2.0
278
350
  desc: JavaScript library for DOM operations
279
351
  tags: jquery, library, ajax, framework, toolkit, popular
352
+ site: http://jquery.com/
353
+ info: https://cdnjs.com/libraries/jquery/2.2.0
354
+ license: MIT
280
355
  urls:
281
356
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js
282
357
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js
283
358
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.map
284
359
  END
285
- actual = CDNGet::Main.new().run("cdnjs", "jquery", "2.2.0")
360
+ actual = run("cdnjs", "jquery", "2.2.0")
286
361
  ok {actual} == expected
287
362
  end
288
363
 
289
- it "(google) lists files." do
364
+ spec "(jsdelivr) lists files." do
290
365
  expected = <<END
291
366
  name: jquery
292
367
  version: 2.2.0
293
- site: http://jquery.com/
368
+ desc: JavaScript library for DOM operations
369
+ tags: jquery, javascript, browser, library
370
+ site: https://jquery.com
371
+ info: https://www.jsdelivr.com/package/npm/jquery?version=2.2.0
372
+ npmpkg: https://registry.npmjs.org/jquery/-/jquery-2.2.0.tgz
373
+ default: /dist/jquery.min.js
374
+ license: MIT
294
375
  urls:
295
- - https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
376
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/AUTHORS.txt
377
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/bower.json
378
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.js
379
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.min.js
380
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/dist/jquery.min.map
381
+ - https://cdn.jsdelivr.net/npm/jquery@2.2.0/LICENSE.txt
296
382
  END
297
- actual = CDNGet::Main.new().run("google", "jquery", "2.2.0")
383
+ actual = run("jsdelivr", "jquery", "2.2.0")
384
+ ok {actual}.start_with?(expected)
385
+ end
386
+
387
+ spec "(unpkg) lists files." do
388
+ expected = <<END
389
+ name: jquery
390
+ version: 3.6.0
391
+ desc: JavaScript library for DOM operations
392
+ tags: jquery, javascript, browser, library
393
+ site: https://jquery.com
394
+ info: https://unpkg.com/browse/jquery@3.6.0/
395
+ npmpkg: https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz
396
+ license: MIT
397
+ urls:
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
410
+ - https://unpkg.com/jquery@3.6.0/src/core/access.js
411
+ - https://unpkg.com/jquery@3.6.0/src/core/camelCase.js
412
+ - https://unpkg.com/jquery@3.6.0/src/core/DOMEval.js
413
+ - https://unpkg.com/jquery@3.6.0/src/core/init.js
414
+ - https://unpkg.com/jquery@3.6.0/src/core/isAttached.js
415
+ - https://unpkg.com/jquery@3.6.0/src/core/nodeName.js
416
+ - https://unpkg.com/jquery@3.6.0/src/core/parseHTML.js
417
+ - https://unpkg.com/jquery@3.6.0/src/core/parseXML.js
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
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
422
+ - https://unpkg.com/jquery@3.6.0/src/core/stripAndCollapse.js
423
+ - https://unpkg.com/jquery@3.6.0/src/core/support.js
424
+ - https://unpkg.com/jquery@3.6.0/src/core/toType.js
425
+ - https://unpkg.com/jquery@3.6.0/src/css/addGetHookIf.js
426
+ - https://unpkg.com/jquery@3.6.0/src/css/adjustCSS.js
427
+ - https://unpkg.com/jquery@3.6.0/src/css/var/cssExpand.js
428
+ - https://unpkg.com/jquery@3.6.0/src/css/var/getStyles.js
429
+ - https://unpkg.com/jquery@3.6.0/src/css/var/isHiddenWithinTree.js
430
+ - https://unpkg.com/jquery@3.6.0/src/css/var/rboxStyle.js
431
+ - https://unpkg.com/jquery@3.6.0/src/css/var/rnumnonpx.js
432
+ - https://unpkg.com/jquery@3.6.0/src/css/var/swap.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
438
+ - https://unpkg.com/jquery@3.6.0/src/deprecated/ajax-event-alias.js
439
+ - https://unpkg.com/jquery@3.6.0/src/deprecated/event.js
440
+ - https://unpkg.com/jquery@3.6.0/src/ajax.js
441
+ - https://unpkg.com/jquery@3.6.0/src/exports/amd.js
442
+ - https://unpkg.com/jquery@3.6.0/src/exports/global.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
445
+ - https://unpkg.com/jquery@3.6.0/src/var/arr.js
446
+ - https://unpkg.com/jquery@3.6.0/src/var/class2type.js
447
+ - https://unpkg.com/jquery@3.6.0/src/var/document.js
448
+ - https://unpkg.com/jquery@3.6.0/src/var/documentElement.js
449
+ - https://unpkg.com/jquery@3.6.0/src/var/flat.js
450
+ - https://unpkg.com/jquery@3.6.0/src/var/fnToString.js
451
+ - https://unpkg.com/jquery@3.6.0/src/var/getProto.js
452
+ - https://unpkg.com/jquery@3.6.0/src/var/hasOwn.js
453
+ - https://unpkg.com/jquery@3.6.0/src/var/indexOf.js
454
+ - https://unpkg.com/jquery@3.6.0/src/var/isFunction.js
455
+ - https://unpkg.com/jquery@3.6.0/src/var/isWindow.js
456
+ - https://unpkg.com/jquery@3.6.0/src/var/ObjectFunctionString.js
457
+ - https://unpkg.com/jquery@3.6.0/src/var/pnum.js
458
+ - https://unpkg.com/jquery@3.6.0/src/var/push.js
459
+ - https://unpkg.com/jquery@3.6.0/src/var/rcheckableType.js
460
+ - https://unpkg.com/jquery@3.6.0/src/var/rcssNum.js
461
+ - https://unpkg.com/jquery@3.6.0/src/var/rnothtmlwhite.js
462
+ - https://unpkg.com/jquery@3.6.0/src/var/slice.js
463
+ - https://unpkg.com/jquery@3.6.0/src/var/support.js
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
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")
298
523
  ok {actual} == expected
299
524
  end
300
525
 
301
- it "(jsdelivr) lists files." do
526
+ spec "(google) lists files." do
302
527
  expected = <<END
303
528
  name: jquery
304
529
  version: 2.2.0
530
+ site: http://jquery.com/
531
+ info: https://developers.google.com/speed/libraries/#jquery
305
532
  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
533
+ - https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
309
534
  END
310
- actual = CDNGet::Main.new().run("jsdelivr", "jquery", "2.2.0")
535
+ actual = run("google", "jquery", "2.2.0")
311
536
  ok {actual} == expected
312
537
  end
313
538
 
314
- 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
315
545
  expected = <<END
316
546
  name: jquery-jcrop
317
547
  version: 0.9.12
318
548
  desc: Jcrop is the quick and easy way to add image cropping functionality to your web application.
319
549
  tags: jquery, crop
550
+ site: http://deepliquid.com/content/Jcrop.html
551
+ info: https://cdnjs.com/libraries/jquery-jcrop/0.9.12
552
+ license: MIT
320
553
  urls:
321
554
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/Jcrop.gif
322
555
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.css
@@ -327,44 +560,90 @@ urls:
327
560
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.min.js
328
561
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.min.js
329
562
  END
330
- actual = CDNGet::Main.new().run("cdnjs", "jquery-jcrop", "0.9.12")
563
+ actual = run("cdnjs", "jquery-jcrop", "0.9.12")
331
564
  ok {actual} == expected
332
565
  end
333
566
 
334
- it "(google) lists files containing subdirectory." do
335
- skip("no libraries containing subdirectory")
567
+ spec "(google) lists files containing subdirectory." do
568
+ skip_when true, "no libraries containing subdirectory"
336
569
  end
337
570
 
338
- it "(cdnjs) raises error when library name is wrong." do
339
- 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") }
340
578
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
341
579
  #
342
- pr = proc { CDNGet::Main.new().run("cdnjs", "emberjs", "2.2.1") }
580
+ pr = proc { run("cdnjs", "emberjs", "2.2.1") }
343
581
  ok {pr}.raise?(CDNGet::CommandError, "emberjs: Library not found (maybe 'ember.js'?).")
344
582
  end
345
583
 
346
- it "(google) raises error when library name is wrong." do
347
- pr = proc { CDNGet::Main.new().run("google", "jquery-ui", "1.9.2") }
348
- ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
584
+ spec "(jsdelivr) raises error when library name is wrong." do
585
+ pr = proc { run("jsdelivr", "jquery-ui", "1.9.2") }
586
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-ui@1.9.2: Library or version not found.")
587
+ end
588
+
589
+ spec "(unpkg) raises error when library name is wrong." do
590
+ pr = proc { run("unpkg", "jquery-foobar", "1.9.2") }
591
+ ok {pr}.raise?(CDNGet::CommandError, "jquery-foobar: Library not found.")
349
592
  end
350
593
 
351
- it "(jsdelivr) raises error when library name is wrong." do
352
- pr = proc { CDNGet::Main.new().run("jsdelivr", "jquery-ui", "1.9.2") }
594
+ spec "(google) raises error when library name is wrong." do
595
+ pr = proc { run("google", "jquery-ui", "1.9.2") }
353
596
  ok {pr}.raise?(CDNGet::CommandError, "jquery-ui: Library not found.")
354
597
  end
355
598
 
356
599
  end
357
600
 
358
601
 
359
- describe "cdnget CDN jquery 2.2.0 dir" do
602
+ topic "cdnget <CDN> <library> <not-existing-version>" do
360
603
 
361
- def _do_download_test1(cdn_code)
362
- tmpdir = "tmpdir1"
363
- Dir.mkdir(tmpdir)
364
- begin
365
- sout, serr = capture_io() do
366
- actual = CDNGet::Main.new().run("cdnjs", "jquery", "2.2.0", tmpdir)
367
- end
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.")
609
+ end
610
+
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.")
616
+ end
617
+
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)
640
+ end
641
+ yield sout, serr
642
+ end
643
+
644
+ spec "(cdnjs) downloads files into dir." do
645
+ tmpdir = @tmpdir
646
+ _do_download_test1("cdnjs", "jquery", "2.2.0") do |sout, serr|
368
647
  ok {"#{tmpdir}/jquery/2.2.0/jquery.js" }.file_exist?
369
648
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.js" }.file_exist?
370
649
  ok {"#{tmpdir}/jquery/2.2.0/jquery.min.map"}.file_exist?
@@ -373,28 +652,82 @@ END
373
652
  #{tmpdir}/jquery/2.2.0/jquery.min.js ... Done (85,589 byte)
374
653
  #{tmpdir}/jquery/2.2.0/jquery.min.map ... Done (129,544 byte)
375
654
  END
376
- ensure
377
- FileUtils.rm_r(tmpdir)
378
655
  end
379
656
  end
380
657
 
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)
658
+ spec "(jsdelivr) downloads files into dir." do
659
+ tmpdir = @tmpdir
660
+ _do_download_test1("jsdelivr", "chibijs", "3.0.9") do |sout, serr|
661
+ ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
662
+ ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
663
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
664
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi-min.js" }.file_exist?
665
+ ok {"#{tmpdir}/chibijs@3.0.9/gulpfile.js" }.file_exist?
666
+ ok {"#{tmpdir}/chibijs@3.0.9/package.json" }.file_exist?
667
+ ok {"#{tmpdir}/chibijs@3.0.9/README.md" }.file_exist?
668
+ ok {"#{tmpdir}/chibijs@3.0.9/tests/runner.html"}.file_exist?
669
+ ok {sout} == <<END
670
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
671
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
672
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
673
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
674
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
675
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
676
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
677
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
393
678
  END
394
- begin
395
- sout, serr = capture_io() do
396
- actual = CDNGet::Main.new().run("cdnjs", "jquery-jcrop", "0.9.12", tmpdir)
397
- end
679
+ end
680
+ end
681
+
682
+ spec "(unpkg) downloads files into dir." do
683
+ tmpdir = @tmpdir
684
+ _do_download_test1("unpkg", "chibijs", "3.0.9") do |sout, serr|
685
+ ok {"#{tmpdir}/chibijs@3.0.9/.jshintrc" }.file_exist?
686
+ ok {"#{tmpdir}/chibijs@3.0.9/.npmignore" }.file_exist?
687
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi.js" }.file_exist?
688
+ ok {"#{tmpdir}/chibijs@3.0.9/chibi-min.js" }.file_exist?
689
+ ok {"#{tmpdir}/chibijs@3.0.9/gulpfile.js" }.file_exist?
690
+ ok {"#{tmpdir}/chibijs@3.0.9/package.json" }.file_exist?
691
+ ok {"#{tmpdir}/chibijs@3.0.9/README.md" }.file_exist?
692
+ ok {"#{tmpdir}/chibijs@3.0.9/tests/runner.html"}.file_exist?
693
+ ok {sout} == <<END
694
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
695
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
696
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
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)
699
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
700
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
701
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
702
+ END
703
+ end
704
+ end
705
+
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|
398
731
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif" }.file_exist?
399
732
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css" }.file_exist?
400
733
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css" }.file_exist?
@@ -403,32 +736,7 @@ END
403
736
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js" }.file_exist?
404
737
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js" }.file_exist?
405
738
  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
739
+ ok {sout} == <<END
432
740
  #{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif ... Done (329 byte)
433
741
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css ... Done (3,280 byte)
434
742
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css ... Done (2,102 byte)
@@ -439,70 +747,607 @@ END
439
747
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js ... Done (93,068 byte)
440
748
  END
441
749
  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} == ""
750
+ end
751
+
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|
755
+ ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.js" }.file_exist?
756
+ ok {"#{tmpdir}/zepto@1.2.0/dist/zepto.min.js"}.file_exist?
757
+ ok {"#{tmpdir}/zepto@1.2.0/MIT-LICENSE" }.file_exist?
758
+ ok {"#{tmpdir}/zepto@1.2.0/package.json" }.file_exist?
759
+ ok {"#{tmpdir}/zepto@1.2.0/README.md" }.file_exist?
760
+ ok {"#{tmpdir}/zepto@1.2.0/src/ajax.js" }.file_exist?
761
+ ok {"#{tmpdir}/zepto@1.2.0/src/assets.js" }.file_exist?
762
+ ok {"#{tmpdir}/zepto@1.2.0/src/callbacks.js" }.file_exist?
763
+ ok {"#{tmpdir}/zepto@1.2.0/src/data.js" }.file_exist?
764
+ ok {"#{tmpdir}/zepto@1.2.0/src/deferred.js" }.file_exist?
765
+ ok {"#{tmpdir}/zepto@1.2.0/src/detect.js" }.file_exist?
766
+ ok {"#{tmpdir}/zepto@1.2.0/src/event.js" }.file_exist?
767
+ ok {"#{tmpdir}/zepto@1.2.0/src/form.js" }.file_exist?
768
+ ok {"#{tmpdir}/zepto@1.2.0/src/fx.js" }.file_exist?
769
+ ok {"#{tmpdir}/zepto@1.2.0/src/fx_methods.js"}.file_exist?
770
+ ok {"#{tmpdir}/zepto@1.2.0/src/gesture.js" }.file_exist?
771
+ ok {"#{tmpdir}/zepto@1.2.0/src/ie.js" }.file_exist?
772
+ ok {"#{tmpdir}/zepto@1.2.0/src/ios3.js" }.file_exist?
773
+ ok {"#{tmpdir}/zepto@1.2.0/src/selector.js" }.file_exist?
774
+ ok {"#{tmpdir}/zepto@1.2.0/src/stack.js" }.file_exist?
775
+ ok {"#{tmpdir}/zepto@1.2.0/src/touch.js" }.file_exist?
776
+ ok {"#{tmpdir}/zepto@1.2.0/src/zepto.js" }.file_exist?
777
+ ok {sout} == <<END
778
+ #{tmpdir}/zepto@1.2.0/dist/zepto.js ... Done (58,707 byte)
779
+ #{tmpdir}/zepto@1.2.0/dist/zepto.min.js ... Done (26,386 byte)
780
+ #{tmpdir}/zepto@1.2.0/MIT-LICENSE ... Done (1,081 byte)
781
+ #{tmpdir}/zepto@1.2.0/package.json ... Done (435 byte)
782
+ #{tmpdir}/zepto@1.2.0/README.md ... Done (6,711 byte)
783
+ #{tmpdir}/zepto@1.2.0/src/ajax.js ... Done (13,843 byte)
784
+ #{tmpdir}/zepto@1.2.0/src/assets.js ... Done (581 byte)
785
+ #{tmpdir}/zepto@1.2.0/src/callbacks.js ... Done (4,208 byte)
786
+ #{tmpdir}/zepto@1.2.0/src/data.js ... Done (2,789 byte)
787
+ #{tmpdir}/zepto@1.2.0/src/deferred.js ... Done (3,846 byte)
788
+ #{tmpdir}/zepto@1.2.0/src/detect.js ... Done (3,754 byte)
789
+ #{tmpdir}/zepto@1.2.0/src/event.js ... Done (9,546 byte)
790
+ #{tmpdir}/zepto@1.2.0/src/form.js ... Done (1,253 byte)
791
+ #{tmpdir}/zepto@1.2.0/src/fx.js ... Done (4,843 byte)
792
+ #{tmpdir}/zepto@1.2.0/src/fx_methods.js ... Done (2,102 byte)
793
+ #{tmpdir}/zepto@1.2.0/src/gesture.js ... Done (1,138 byte)
794
+ #{tmpdir}/zepto@1.2.0/src/ie.js ... Done (530 byte)
795
+ #{tmpdir}/zepto@1.2.0/src/ios3.js ... Done (1,140 byte)
796
+ #{tmpdir}/zepto@1.2.0/src/selector.js ... Done (3,187 byte)
797
+ #{tmpdir}/zepto@1.2.0/src/stack.js ... Done (560 byte)
798
+ #{tmpdir}/zepto@1.2.0/src/touch.js ... Done (6,067 byte)
799
+ #{tmpdir}/zepto@1.2.0/src/zepto.js ... Done (33,889 byte)
800
+ END
801
+ end
802
+ end
803
+
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|
807
+ ok {"#{tmpdir}/react@17.0.2/build-info.json" }.file_exist?
808
+ ok {"#{tmpdir}/react@17.0.2/cjs/react.development.js" }.file_exist?
809
+ ok {"#{tmpdir}/react@17.0.2/cjs/react.production.min.js"}.file_exist?
810
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.development.js" }.file_exist?
811
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.production.min.js"}.file_exist?
812
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.profiling.min.js" }.file_exist?
813
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.development.js" }.file_exist?
814
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.production.min.js" }.file_exist?
815
+ ok {"#{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.profiling.min.js" }.file_exist?
816
+ ok {"#{tmpdir}/react@17.0.2/index.js" }.file_exist?
817
+ ok {"#{tmpdir}/react@17.0.2/jsx-dev-runtime.js" }.file_exist?
818
+ ok {"#{tmpdir}/react@17.0.2/jsx-runtime.js" }.file_exist?
819
+ ok {"#{tmpdir}/react@17.0.2/LICENSE" }.file_exist?
820
+ ok {"#{tmpdir}/react@17.0.2/package.json" }.file_exist?
821
+ ok {"#{tmpdir}/react@17.0.2/README.md" }.file_exist?
822
+ ok {"#{tmpdir}/react@17.0.2/umd/react.development.js" }.file_exist?
823
+ ok {"#{tmpdir}/react@17.0.2/umd/react.production.min.js"}.file_exist?
824
+ ok {"#{tmpdir}/react@17.0.2/umd/react.profiling.min.js" }.file_exist?
825
+ expected = <<END
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)
830
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.development.js ... Done (37,753 byte)
831
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.production.min.js ... Done (456 byte)
832
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-dev-runtime.profiling.min.js ... Done (455 byte)
833
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.development.js ... Done (38,352 byte)
834
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.production.min.js ... Done (962 byte)
835
+ #{tmpdir}/react@17.0.2/cjs/react-jsx-runtime.profiling.min.js ... Done (961 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)
838
+ #{tmpdir}/react@17.0.2/umd/react.development.js ... Done (105,096 byte)
839
+ #{tmpdir}/react@17.0.2/umd/react.production.min.js ... Done (11,440 byte)
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)
844
+ END
449
845
  ok {sout} == expected
450
- # 2nd
451
- sout, serr = capture_io() do
452
- actual = CDNGet::Main.new().run(cdn_code, libname, version, tmpdir)
846
+ end
847
+ end
848
+
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"
453
877
  end
454
- ok {serr} == ""
455
- ok {sout} == expected.gsub(/\n/, " (Unchanged)\n")
456
- ensure
457
- FileUtils.rm_r(tmpdir)
878
+ }
879
+ end
880
+
881
+ spec "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
882
+ tmpdir = @tmpdir
883
+ expected = <<END
884
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.css ... Done (7,401 byte)
885
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.gif ... Done (329 byte)
886
+ #{tmpdir}/jquery-jcrop/2.0.4/css/Jcrop.min.css ... Done (5,281 byte)
887
+ #{tmpdir}/jquery-jcrop/2.0.4/js/Jcrop.js ... Done (75,652 byte)
888
+ #{tmpdir}/jquery-jcrop/2.0.4/js/Jcrop.min.js ... Done (38,379 byte)
889
+ END
890
+ _do_download_test3("cdnjs", "jquery-jcrop", "2.0.4", expected)
891
+ end
892
+
893
+ spec "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
894
+ tmpdir = @tmpdir
895
+ expected = <<END
896
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
897
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
898
+ #{tmpdir}/chibijs@3.0.9/chibi.js ... Done (18,429 byte)
899
+ #{tmpdir}/chibijs@3.0.9/chibi-min.js ... Done (7,321 byte)
900
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
901
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
902
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
903
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
904
+ END
905
+ _do_download_test3("jsdelivr", "chibijs", "3.0.9", expected)
906
+ end
907
+
908
+ spec "(unpkg) doesn't override existing files when they are identical to downloaded files." do
909
+ tmpdir = @tmpdir
910
+ expected = <<END
911
+ #{tmpdir}/chibijs@3.0.9/package.json ... Done (756 byte)
912
+ #{tmpdir}/chibijs@3.0.9/.npmignore ... Done (46 byte)
913
+ #{tmpdir}/chibijs@3.0.9/README.md ... Done (21,283 byte)
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)
916
+ #{tmpdir}/chibijs@3.0.9/gulpfile.js ... Done (1,395 byte)
917
+ #{tmpdir}/chibijs@3.0.9/.jshintrc ... Done (5,323 byte)
918
+ #{tmpdir}/chibijs@3.0.9/tests/runner.html ... Done (14,302 byte)
919
+ END
920
+ _do_download_test3("unpkg", "chibijs", "3.0.9", expected)
921
+ end
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
+
931
+ end
932
+
933
+
934
+ topic "cdnget <CDN> <library> latest" do
935
+
936
+ spec "(cdnjs) shows latest version." do
937
+ actual = run("cdnjs", "swfobject", "latest")
938
+ ok {actual} == <<END
939
+ name: swfobject
940
+ version: 2.2
941
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
942
+ tags: swf, flash
943
+ site: http://code.google.com/p/swfobject/
944
+ info: https://cdnjs.com/libraries/swfobject/2.2
945
+ license: MIT
946
+ urls:
947
+ - https://cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.js
948
+ - https://cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.min.js
949
+ END
950
+ end
951
+
952
+ spec "(jsdelivr) shows latest version." do
953
+ actual = run("jsdelivr", "swfobject", "latest")
954
+ ok {actual} == <<END
955
+ name: swfobject
956
+ version: 2.2.1
957
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
958
+ tags: SWFObject, swf, object, flash, embed, content
959
+ info: https://www.jsdelivr.com/package/npm/swfobject?version=2.2.1
960
+ npmpkg: https://registry.npmjs.org/swfobject/-/swfobject-2.2.1.tgz
961
+ default: /index.min.js
962
+ license: MIT
963
+ urls:
964
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/.npmignore
965
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/download.sh
966
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/expressInstall.swf
967
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/index.js
968
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/package.json
969
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/patch.js
970
+ - https://cdn.jsdelivr.net/npm/swfobject@2.2.1/README.md
971
+ END
972
+ end
973
+
974
+ spec "(unpkg) shows latest version." do
975
+ actual = run("unpkg", "swfobject", "latest")
976
+ ok {actual} == <<END
977
+ name: swfobject
978
+ version: 2.2.1
979
+ desc: SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file
980
+ tags: SWFObject, swf, object, flash, embed, content
981
+ site: https://github.com/unshiftio/swfobject
982
+ info: https://unpkg.com/browse/swfobject@2.2.1/
983
+ npmpkg: https://registry.npmjs.org/swfobject/-/swfobject-2.2.1.tgz
984
+ license: MIT
985
+ urls:
986
+ - https://unpkg.com/swfobject@2.2.1/package.json
987
+ - https://unpkg.com/swfobject@2.2.1/.npmignore
988
+ - https://unpkg.com/swfobject@2.2.1/README.md
989
+ - https://unpkg.com/swfobject@2.2.1/index.js
990
+ - https://unpkg.com/swfobject@2.2.1/patch.js
991
+ - https://unpkg.com/swfobject@2.2.1/download.sh
992
+ - https://unpkg.com/swfobject@2.2.1/expressInstall.swf
993
+ END
994
+ end
995
+
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
1007
+
1008
+ end
1009
+
1010
+
1011
+ topic "cdnget CDN <library> latest <dir>" do
1012
+
1013
+ spec "(cdnjs) downlaods latest version." do
1014
+ sout, serr = capture_sio do()
1015
+ run("cdnjs", "swfobject", "latest", @tmpdir)
458
1016
  end
1017
+ ok {sout} == <<"END"
1018
+ #{@tmpdir}/swfobject/2.2/swfobject.js ... Done (10,220 byte)
1019
+ #{@tmpdir}/swfobject/2.2/swfobject.min.js ... Done (9,211 byte)
1020
+ END
1021
+ end
1022
+
1023
+ spec "(jsdelivr) downlaods latest version." do
1024
+ sout, serr = capture_sio do()
1025
+ run("jsdelivr", "swfobject", "latest", @tmpdir)
1026
+ end
1027
+ ok {sout} == <<"END"
1028
+ #{@tmpdir}/swfobject@2.2.1/.npmignore ... Done (13 byte)
1029
+ #{@tmpdir}/swfobject@2.2.1/download.sh ... Done (517 byte)
1030
+ #{@tmpdir}/swfobject@2.2.1/expressInstall.swf ... Done (727 byte)
1031
+ #{@tmpdir}/swfobject@2.2.1/index.js ... Done (10,331 byte)
1032
+ #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1033
+ #{@tmpdir}/swfobject@2.2.1/patch.js ... Done (277 byte)
1034
+ #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1035
+ END
1036
+ end
1037
+
1038
+ spec "(unpkg) downlaods latest version." do
1039
+ sout, serr = capture_sio do()
1040
+ run("unpkg", "swfobject", "latest", @tmpdir)
1041
+ end
1042
+ ok {sout} == <<"END"
1043
+ #{@tmpdir}/swfobject@2.2.1/package.json ... Done (524 byte)
1044
+ #{@tmpdir}/swfobject@2.2.1/.npmignore ... Done (13 byte)
1045
+ #{@tmpdir}/swfobject@2.2.1/README.md ... Done (764 byte)
1046
+ #{@tmpdir}/swfobject@2.2.1/index.js ... Done (10,331 byte)
1047
+ #{@tmpdir}/swfobject@2.2.1/patch.js ... Done (277 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.")
459
1070
  end
460
1071
 
461
- it "(cdnjs) downloads files into dir." do
462
- _do_download_test1("cdnjs")
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
463
1091
  end
464
1092
 
465
- it "(google) downloads files into dir." do
466
- _do_download_test1("google")
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
467
1112
  end
468
1113
 
469
- it "(jsdelivr) downloads files into dir." do
470
- _do_download_test1("jsdelivr")
1114
+ spec "(google) raises error." do
1115
+ pr = proc { run("google", "@babel/core") }
1116
+ ok {pr}.raise?(CDNGet::CommandError, "@babel/core: Invalid library name.")
471
1117
  end
472
1118
 
473
- it "(cdnjs) downloads files (containing subdir) into dir." do
474
- _do_download_test2("cdnjs")
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.")
475
1127
  end
476
1128
 
477
- it "(google) downloads files (containing subdir) into dir." do
478
- skip("no libraries containing subdirectory")
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
479
1147
  end
480
1148
 
481
- it "(jsdelivr) downloads files (containing subdir) into dir." do
482
- _do_download_test2("jsdelivr")
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
1166
+ END
483
1167
  end
484
1168
 
485
- it "(cdnjs) doesn't override existing files when they are identical to downloaded files." do
486
- _do_download_test3("cdnjs", "jquery-jcrop")
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.")
487
1172
  end
488
1173
 
489
- it "(google) doesn't override existing files when they are identical to downloaded files." do
490
- _do_download_test3("google", "jquery")
1174
+ end
1175
+
1176
+
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
1252
+
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
491
1320
  end
492
1321
 
493
- it "(jsdelivr) doesn't override existing files when they are identical to downloaded files." do
494
- _do_download_test3("jsdelivr", "jquery")
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.")
495
1325
  end
496
1326
 
497
1327
  end
498
1328
 
499
1329
 
500
- describe "cdnget CDN jquery 2.2.0 foo bar" do
1330
+ topic "cdnget <CDN> bulma 0.9.3 <dir> (containing '.DS_Store')" do
501
1331
 
502
- it "results in argument error." do
503
- args = ["cdnjs", "jquery", "2.2.0", "foo", "bar"]
504
- pr = proc { CDNGet::Main.new("cdnget").run(*args) }
505
- ok {pr}.raise?(CDNGet::CommandError, "'bar': Too many arguments.")
1332
+ spec "(unpkg) skips '.DS_Store' files." do
1333
+ sout, serr = capture_sio do()
1334
+ run("unpkg", "bulma", "0.9.3", @tmpdir)
1335
+ end
1336
+ ok {sout}.include?("#{@tmpdir}/bulma@0.9.3/sass/.DS_Store ... Skipped\n")
1337
+ ok {sout}.include?("#{@tmpdir}/bulma@0.9.3/sass/base/.DS_Store ... Skipped\n")
1338
+ end
1339
+
1340
+ end
1341
+
1342
+
1343
+ topic "cdnget <CDN> <library> <version> <dir> foo bar" do
1344
+
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
506
1351
  end
507
1352
 
508
1353
  end