web-puc 0.4.1 → 0.4.4
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 +4 -4
- data/lib/web-puc.rb +24 -49
- metadata +10 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf4dec93eaaca199a532e18f5af6ba2b1aac5d9818e58576646b5a8dec5ce91
|
4
|
+
data.tar.gz: eef7d51757f43f1914ab5c53b3fb2b8a7f74a5f3fadca68f04aa01633687db5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7674e18b3e5e3b845902ce9133dd174d1aa67d048460787c93f6609e9371ab2da6663b1c19afd778f851d7df4d973dd642513d425e4a158ba6156a6879491b87
|
7
|
+
data.tar.gz: ccd7b67f24ea5bee6a8e094b848ca1047fdb88a9b8d85bff9f28b79b156ab04ebbc3a234e6921e94683e49b29f17f4121f553264030874d41ef5d946f5c0f0af
|
data/lib/web-puc.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "ostruct"
|
3
|
+
require "optparse"
|
4
|
+
require "yaml"
|
5
|
+
require "net/http"
|
4
6
|
require 'shellwords'
|
5
|
-
require
|
6
|
-
require 'yaml'
|
7
|
-
require_relative 'version'
|
7
|
+
#require "gemrake"
|
8
8
|
|
9
9
|
DATA_STORE_FILENAME = File.expand_path('~/.web-puc-data.yml')
|
10
10
|
CACHE_EXPIRATION_PERIOD = 7*24*60*60
|
@@ -13,13 +13,11 @@ class LibraryNotImplementedException < Exception
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Optparse
|
16
|
-
|
17
16
|
def self.parse(args)
|
18
17
|
options = OpenStruct.new
|
19
18
|
options.exclude = []
|
20
19
|
options.libs = []
|
21
20
|
options.clear = false
|
22
|
-
options.stat = false
|
23
21
|
|
24
22
|
opt_parser = OptionParser.new do |opts|
|
25
23
|
opts.banner = 'Usage: web-puc [options] <files>'
|
@@ -32,10 +30,6 @@ class Optparse
|
|
32
30
|
options.clear = true
|
33
31
|
end
|
34
32
|
|
35
|
-
opts.on('--stat', 'Output in STAT format') do
|
36
|
-
options.stat = true
|
37
|
-
end
|
38
|
-
|
39
33
|
opts.on('-h', '--help', 'Show this message') do
|
40
34
|
puts opts
|
41
35
|
exit
|
@@ -45,16 +39,17 @@ class Optparse
|
|
45
39
|
options.libs = list
|
46
40
|
end
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
# TODO: make this work
|
43
|
+
#opts.on('-v', '--version', 'Show version') do
|
44
|
+
# puts Gem::Specification::load(File.expand_path('../web-puc.gemspec', __FILE__)).version
|
45
|
+
# exit
|
46
|
+
#end
|
47
|
+
|
52
48
|
end
|
53
49
|
|
54
50
|
opt_parser.parse!(args)
|
55
51
|
options
|
56
52
|
end
|
57
|
-
|
58
53
|
end
|
59
54
|
|
60
55
|
def get_link(lib, version)
|
@@ -99,14 +94,17 @@ else
|
|
99
94
|
end
|
100
95
|
|
101
96
|
options.libs.each { |lib|
|
102
|
-
if !libs_cached.nil? && !libs_cached[lib].nil? && libs_cached[lib]['expired'] < Time.now
|
97
|
+
if !libs_cached.nil? && !libs_cached[lib].nil? && Time.at(libs_cached[lib]['expired']) < Time.now
|
103
98
|
libs_versions[lib] = libs_cached[lib]
|
104
99
|
else
|
105
|
-
|
100
|
+
# Fetch using net/http
|
101
|
+
response_text = Net::HTTP.get(URI("https://api.cdnjs.com/libraries/#{lib}?fields=assets"))
|
102
|
+
# response = JSON.parse HTTP.get("https://api.cdnjs.com/libraries/#{lib}?fields=assets").body
|
103
|
+
response = JSON.parse response_text
|
106
104
|
unless response['assets'].nil?
|
107
105
|
libs_versions[lib] = Hash.new
|
108
106
|
libs_versions[lib]['version'] = Array.new
|
109
|
-
libs_versions[lib]['expired'] = Time.now + CACHE_EXPIRATION_PERIOD
|
107
|
+
libs_versions[lib]['expired'] = Time.now.to_i + CACHE_EXPIRATION_PERIOD
|
110
108
|
response['assets'].each_with_index { |asset, index|
|
111
109
|
# first version is a most actual
|
112
110
|
next if index == 0
|
@@ -117,16 +115,11 @@ options.libs.each { |lib|
|
|
117
115
|
}
|
118
116
|
File.write(DATA_STORE_FILENAME, libs_cached.merge(libs_versions).to_yaml)
|
119
117
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
process.maintainer = 'William Entriken'
|
124
|
-
process.email = 'github.com@phor.net'
|
125
|
-
process.website = 'https://github.com/fulldecent/web-puc'
|
126
|
-
process.repeatability = 'Volatile'
|
127
|
-
stat = StatModule::Stat.new(process)
|
118
|
+
puts "web-puc"
|
119
|
+
# Make this work:
|
120
|
+
# puts "web-puc #{Gem::Specification::load(File.expand_path('../web-puc.gemspec', __FILE__)).version}"
|
128
121
|
|
129
|
-
|
122
|
+
return_status = 0
|
130
123
|
files.each { |file|
|
131
124
|
file = file.shellescape
|
132
125
|
libs_versions.each { |lib, val|
|
@@ -137,29 +130,11 @@ files.each { |file|
|
|
137
130
|
matches.each { |match|
|
138
131
|
description = match[match.index(':') + 1, match.length]
|
139
132
|
line = match[0, match.index(':')].to_i
|
140
|
-
|
141
|
-
|
142
|
-
location.end_line = line
|
143
|
-
|
144
|
-
finding = StatModule::Finding.new(true, description, 'Old version')
|
145
|
-
finding.location = location
|
146
|
-
|
147
|
-
stat.findings.push(finding)
|
148
|
-
|
149
|
-
stat.print_finding if options.stat
|
133
|
+
puts "#{file}:#{line}:#{description}"
|
134
|
+
return_status = 1
|
150
135
|
}
|
151
136
|
}
|
152
137
|
}
|
153
138
|
}
|
154
139
|
|
155
|
-
|
156
|
-
stat.print_footer
|
157
|
-
else
|
158
|
-
if stat.findings.length > 0
|
159
|
-
stat.findings.each { |finding|
|
160
|
-
puts finding.print true
|
161
|
-
}
|
162
|
-
abort stat.summary_print true
|
163
|
-
end
|
164
|
-
puts stat.summary_print true
|
165
|
-
end
|
140
|
+
exit return_status
|
metadata
CHANGED
@@ -1,71 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-puc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Entriken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '12'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '12'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: structured-acceptance-test
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.6
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.6
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: http
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '5.1'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.5'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.5'
|
40
|
+
version: '5.1'
|
69
41
|
description: Validate your web project uses the latest CSS & JS includes
|
70
42
|
email: github.com@phor.net
|
71
43
|
executables:
|
@@ -79,7 +51,7 @@ homepage: https://github.com/fulldecent/web-puc
|
|
79
51
|
licenses:
|
80
52
|
- MIT
|
81
53
|
metadata: {}
|
82
|
-
post_install_message:
|
54
|
+
post_install_message:
|
83
55
|
rdoc_options: []
|
84
56
|
require_paths:
|
85
57
|
- lib
|
@@ -94,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
66
|
- !ruby/object:Gem::Version
|
95
67
|
version: '0'
|
96
68
|
requirements: []
|
97
|
-
rubygems_version: 3.
|
98
|
-
signing_key:
|
69
|
+
rubygems_version: 3.3.7
|
70
|
+
signing_key:
|
99
71
|
specification_version: 4
|
100
72
|
summary: Web Package Update Checker
|
101
73
|
test_files: []
|