cdnget 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 055befc004f39cde2638cf0cc31dc01e4cbc3226
4
- data.tar.gz: 694c18db9e4128ee93119f985c66c7d4656aee27
2
+ SHA256:
3
+ metadata.gz: 76f77978f1ad34c63939c6b3de40f5f37dce102e7fd007e5839485639f6139f0
4
+ data.tar.gz: 3af8ce6cbd1723c8e9b8b1e456e1e470355dfdcc2dafe0173dfe74f0c5177f24
5
5
  SHA512:
6
- metadata.gz: 4ab7fed7ebd4a61804930cf168deb89e1b30b2326ed9ca3bd609b755236f14d2c905066a24bb39f65b7a090bb4eeffb36b43996550c651d2c6acefdcf6f28b67
7
- data.tar.gz: dea35e5ab6ca166933650c0ff670b0e419ebc5e24b906b31ac45c492c87073cc78abd6840b556574519bacfc7881780cae21296532bca988603727fa684cd1d5
6
+ metadata.gz: 26d7e63a270feaeb099c1b2f3a94993bc0b06946bf09827d38e6161d748105ac1f1e0efd50c2207e86b5ef67fda4faf86c7323ae25d5b4f5a9166f72438cb897
7
+ data.tar.gz: bf2f70316d9176f6066f24533e1239d203c2bcf8063b3e3e3d3e7c2c37650ad1f244d10965b68369d8d77618eeafacc4a64bfb6fc6d3fe16ea119b74ecef3d42
data/CHANGES.md CHANGED
@@ -2,6 +2,13 @@ Changes
2
2
  =======
3
3
 
4
4
 
5
+ Release 0.3.1 (2021-09-30)
6
+ ---------------------------
7
+
8
+ * Fix to work on Ruby 3.
9
+ * Fix to follow API specification changes of CDNJS.com.
10
+
11
+
5
12
  Release 0.3.0 (2016-09-07)
6
13
  ---------------------------
7
14
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  CDNget
2
2
  ======
3
3
 
4
- ($Release: 0.3.0 $)
4
+ ($Release: 0.3.1 $)
5
5
 
6
6
  CDNget is a utility script to download files from CDNJS, jsDelivr or Google.
7
7
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ###
4
4
 
5
- RELEASE = '$Release: 0.3.0 $'.split()[1]
5
+ RELEASE = '$Release: 0.3.1 $'.split()[1]
6
6
  COPYRIGHT = 'copyright(c) 2016 kuwata-lab.com all rights reserved'
7
7
  LICENSE = 'MIT License'
8
8
 
data/bin/cdnget CHANGED
@@ -17,6 +17,7 @@
17
17
  ##
18
18
 
19
19
  require 'open-uri'
20
+ require 'uri'
20
21
  require 'json'
21
22
  require 'fileutils'
22
23
 
@@ -24,7 +25,7 @@ require 'fileutils'
24
25
  module CDNGet
25
26
 
26
27
 
27
- RELEASE = '$Release: 0.3.0 $'.split()[1]
28
+ RELEASE = '$Release: 0.3.1 $'.split()[1]
28
29
 
29
30
  CLASSES = []
30
31
 
@@ -79,7 +80,7 @@ module CDNGet
79
80
 
80
81
  def fetch(url, library=nil)
81
82
  begin
82
- html = open(url, 'rb') {|f| f.read() }
83
+ html = URI.open(url, 'rb') {|f| f.read() }
83
84
  return html
84
85
  rescue OpenURI::HTTPError => ex
85
86
  raise CommandError.new("GET #{url} : #{ex.message}")
@@ -114,23 +115,25 @@ module CDNGet
114
115
 
115
116
  def fetch(url, library=nil)
116
117
  begin
117
- json_str = open(url, 'rb') {|f| f.read() }
118
- if library
119
- if json_str == "{}"
120
- if library.end_with?('js')
121
- maybe = library.end_with?('.js') \
122
- ? library.sub('.js', 'js') \
123
- : library.sub(/js$/, '.js')
124
- raise CommandError.new("#{library}: Library not found (maybe '#{maybe}'?).")
125
- else
126
- raise CommandError.new("#{library}: Library not found.")
127
- end
128
- end
118
+ json_str = URI.open(url, 'rb') {|f| f.read() }
119
+ rescue OpenURI::HTTPError => exc
120
+ if exc.message == "404 Not Found"
121
+ json_str = "{}"
122
+ else
123
+ raise HttpError.new("GET #{url} : #{ex.message}")
124
+ end
125
+ end
126
+ if json_str == "{}" && library
127
+ if library.end_with?('js')
128
+ maybe = library.end_with?('.js') \
129
+ ? library.sub('.js', 'js') \
130
+ : library.sub(/js$/, '.js')
131
+ raise CommandError.new("#{library}: Library not found (maybe '#{maybe}'?).")
132
+ else
133
+ raise CommandError.new("#{library}: Library not found.")
129
134
  end
130
- return json_str
131
- rescue OpenURI::HTTPError => ex
132
- raise HttpError.new("GET #{url} : #{ex.message}")
133
135
  end
136
+ return json_str
134
137
  end
135
138
  protected :fetch
136
139
 
@@ -146,11 +149,13 @@ module CDNGet
146
149
  validate(library, nil)
147
150
  jstr = fetch("https://api.cdnjs.com/libraries/#{library}", library)
148
151
  jdata = JSON.parse(jstr)
152
+ versions = jdata['assets'].collect {|d| d['version'] }\
153
+ .sort_by {|v| v.split(/[-.]/).map(&:to_i) }
149
154
  return {
150
155
  name: library,
151
156
  desc: jdata['description'],
152
157
  tags: (jdata['keywords'] || []).join(", "),
153
- versions: jdata['assets'].collect {|d| d['version'] },
158
+ versions: versions.reverse(),
154
159
  }
155
160
  end
156
161
 
data/cdnget.gemspec CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |o|
4
4
  o.name = "cdnget"
5
- o.version = '$Release: 0.3.0 $'.split()[1]
5
+ o.version = '$Release: 0.3.1 $'.split()[1]
6
6
  o.authors = ["makoto kuwata"]
7
7
  o.email = ["kwa@kuwata-lab.com"]
8
8
 
9
9
  o.summary = "Utility to download files from CDNJS, jsDelivr or Google."
10
10
  o.description = "Utility to download files from CDNJS, jsDelivr or Google."
11
- o.homepage = "https://github.com/kwatch/cdnget"
11
+ o.homepage = "https://github.com/kwatch/cdnget/tree/ruby-release"
12
12
  o.license = "MIT"
13
13
 
14
14
  o.files = Dir[*%w[
@@ -24,5 +24,5 @@ Gem::Specification.new do |o|
24
24
  o.required_ruby_version = '>= 2.0'
25
25
 
26
26
  o.add_development_dependency "minitest", "~> 5.4"
27
- o.add_development_dependency "minitest-ok", "~> 1.0"
27
+ o.add_development_dependency "minitest-ok", "~> 0.3"
28
28
  end
data/lib/cdnget.rb CHANGED
@@ -17,6 +17,7 @@
17
17
  ##
18
18
 
19
19
  require 'open-uri'
20
+ require 'uri'
20
21
  require 'json'
21
22
  require 'fileutils'
22
23
 
@@ -24,7 +25,7 @@ require 'fileutils'
24
25
  module CDNGet
25
26
 
26
27
 
27
- RELEASE = '$Release: 0.3.0 $'.split()[1]
28
+ RELEASE = '$Release: 0.3.1 $'.split()[1]
28
29
 
29
30
  CLASSES = []
30
31
 
@@ -79,7 +80,7 @@ module CDNGet
79
80
 
80
81
  def fetch(url, library=nil)
81
82
  begin
82
- html = open(url, 'rb') {|f| f.read() }
83
+ html = URI.open(url, 'rb') {|f| f.read() }
83
84
  return html
84
85
  rescue OpenURI::HTTPError => ex
85
86
  raise CommandError.new("GET #{url} : #{ex.message}")
@@ -114,23 +115,25 @@ module CDNGet
114
115
 
115
116
  def fetch(url, library=nil)
116
117
  begin
117
- json_str = open(url, 'rb') {|f| f.read() }
118
- if library
119
- if json_str == "{}"
120
- if library.end_with?('js')
121
- maybe = library.end_with?('.js') \
122
- ? library.sub('.js', 'js') \
123
- : library.sub(/js$/, '.js')
124
- raise CommandError.new("#{library}: Library not found (maybe '#{maybe}'?).")
125
- else
126
- raise CommandError.new("#{library}: Library not found.")
127
- end
128
- end
118
+ json_str = URI.open(url, 'rb') {|f| f.read() }
119
+ rescue OpenURI::HTTPError => exc
120
+ if exc.message == "404 Not Found"
121
+ json_str = "{}"
122
+ else
123
+ raise HttpError.new("GET #{url} : #{ex.message}")
124
+ end
125
+ end
126
+ if json_str == "{}" && library
127
+ if library.end_with?('js')
128
+ maybe = library.end_with?('.js') \
129
+ ? library.sub('.js', 'js') \
130
+ : library.sub(/js$/, '.js')
131
+ raise CommandError.new("#{library}: Library not found (maybe '#{maybe}'?).")
132
+ else
133
+ raise CommandError.new("#{library}: Library not found.")
129
134
  end
130
- return json_str
131
- rescue OpenURI::HTTPError => ex
132
- raise HttpError.new("GET #{url} : #{ex.message}")
133
135
  end
136
+ return json_str
134
137
  end
135
138
  protected :fetch
136
139
 
@@ -146,11 +149,13 @@ module CDNGet
146
149
  validate(library, nil)
147
150
  jstr = fetch("https://api.cdnjs.com/libraries/#{library}", library)
148
151
  jdata = JSON.parse(jstr)
152
+ versions = jdata['assets'].collect {|d| d['version'] }\
153
+ .sort_by {|v| v.split(/[-.]/).map(&:to_i) }
149
154
  return {
150
155
  name: library,
151
156
  desc: jdata['description'],
152
157
  tags: (jdata['keywords'] || []).join(", "),
153
- versions: jdata['assets'].collect {|d| d['version'] },
158
+ versions: versions.reverse(),
154
159
  }
155
160
  end
156
161
 
data/test/cdnget_test.rb CHANGED
@@ -77,7 +77,8 @@ END
77
77
  it "(google) lists librareis." do
78
78
  actual = CDNGet::Main.new().run("google")
79
79
  ok {actual} =~ /^jquery /
80
- ok {actual} =~ /^angularjs /
80
+ #ok {actual} =~ /^angularjs /
81
+ ok {actual} =~ /^swfobject /
81
82
  ok {actual} =~ /^webfont /
82
83
  end
83
84
 
@@ -274,6 +275,7 @@ END
274
275
  expected = <<END
275
276
  name: jquery
276
277
  version: 2.2.0
278
+ desc: JavaScript library for DOM operations
277
279
  tags: jquery, library, ajax, framework, toolkit, popular
278
280
  urls:
279
281
  - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js
@@ -313,15 +315,16 @@ END
313
315
  expected = <<END
314
316
  name: jquery-jcrop
315
317
  version: 0.9.12
318
+ desc: Jcrop is the quick and easy way to add image cropping functionality to your web application.
316
319
  tags: jquery, crop
317
320
  urls:
318
321
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/Jcrop.gif
319
322
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.css
320
323
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css
321
- - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.js
322
- - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.min.js
323
324
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.Jcrop.js
324
325
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js
326
+ - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.js
327
+ - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.color.min.js
325
328
  - https://cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.min.js
326
329
  END
327
330
  actual = CDNGet::Main.new().run("cdnjs", "jquery-jcrop", "0.9.12")
@@ -382,10 +385,10 @@ END
382
385
  #{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif ... Done (329 byte)
383
386
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css ... Done (3,280 byte)
384
387
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css ... Done (2,102 byte)
385
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js ... Done (16,142 byte)
386
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js ... Done (6,845 byte)
387
388
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.js ... Done (42,434 byte)
388
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)
389
392
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js ... Done (93,068 byte)
390
393
  END
391
394
  begin
@@ -395,10 +398,10 @@ END
395
398
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif" }.file_exist?
396
399
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css" }.file_exist?
397
400
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css" }.file_exist?
398
- ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js" }.file_exist?
399
- ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js" }.file_exist?
400
401
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.js" }.file_exist?
401
402
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js" }.file_exist?
403
+ ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js" }.file_exist?
404
+ ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js" }.file_exist?
402
405
  ok {"#{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js" }.file_exist?
403
406
  ok {sout} == expected
404
407
  ensure
@@ -429,10 +432,10 @@ END
429
432
  #{tmpdir}/jquery-jcrop/0.9.12/css/Jcrop.gif ... Done (329 byte)
430
433
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.css ... Done (3,280 byte)
431
434
  #{tmpdir}/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css ... Done (2,102 byte)
432
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js ... Done (16,142 byte)
433
- #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js ... Done (6,845 byte)
434
435
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.js ... Done (42,434 byte)
435
436
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js ... Done (15,892 byte)
437
+ #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.js ... Done (16,142 byte)
438
+ #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.color.min.js ... Done (6,845 byte)
436
439
  #{tmpdir}/jquery-jcrop/0.9.12/js/jquery.min.js ... Done (93,068 byte)
437
440
  END
438
441
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdnget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - makoto kuwata
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-06 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '0.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '0.3'
41
41
  description: Utility to download files from CDNJS, jsDelivr or Google.
42
42
  email:
43
43
  - kwa@kuwata-lab.com
@@ -54,11 +54,11 @@ files:
54
54
  - cdnget.gemspec
55
55
  - lib/cdnget.rb
56
56
  - test/cdnget_test.rb
57
- homepage: https://github.com/kwatch/cdnget
57
+ homepage: https://github.com/kwatch/cdnget/tree/ruby-release
58
58
  licenses:
59
59
  - MIT
60
60
  metadata: {}
61
- post_install_message:
61
+ post_install_message:
62
62
  rdoc_options: []
63
63
  require_paths:
64
64
  - lib
@@ -73,9 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.5.1
78
- signing_key:
76
+ rubygems_version: 3.2.22
77
+ signing_key:
79
78
  specification_version: 4
80
79
  summary: Utility to download files from CDNJS, jsDelivr or Google.
81
80
  test_files: []