bundler-ri 0.1.1 → 1.0.0
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/README.md +1 -2
- data/lib/bundler/ri.rb +62 -25
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e20850cc5c40c8956e3a50cf6c4aa297a60a98c01e7a060b6e013a7b4293df5f
|
|
4
|
+
data.tar.gz: 48c2c0765c72c5e3162894693ea86119ea4a188a54f0e7b7db6b6f51e06bfdf5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 255138dc53a7524d3ed5c05ca2c8913947ad3409e63d6fa97e59a1e2037776990d3b110a158ce84fd780ecf658fecb0bd17c3211711bcf50b0c83066041065c6
|
|
7
|
+
data.tar.gz: ba116a44f8389a20d43b0258d98553c89b4500207425bfad18668964b9e9022dfaad6c0bf1a3b89bafc4c8f0b0883f7db8c70cdeed47b340c3e2c168255d7794
|
data/README.md
CHANGED
data/lib/bundler/ri.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "rdoc"
|
|
4
|
+
require "digest/sha2"
|
|
4
5
|
|
|
5
6
|
module Bundler
|
|
6
7
|
class RI < Plugin::API
|
|
7
|
-
VERSION = "0.
|
|
8
|
+
VERSION = "1.0.0"
|
|
8
9
|
|
|
9
10
|
def self.register
|
|
10
11
|
Bundler::Plugin.add_command("ri", Command)
|
|
@@ -14,24 +15,16 @@ module Bundler
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
module Helpers
|
|
17
|
-
def
|
|
18
|
-
Bundler::Plugin.root.join("ri")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def ri_path_for(dep)
|
|
22
|
-
ri_path.join(resolved_name_for(dep))
|
|
18
|
+
def plugin_data_path
|
|
19
|
+
Bundler::Plugin.root.join("bundler-ri")
|
|
23
20
|
end
|
|
24
21
|
|
|
25
|
-
def
|
|
26
|
-
|
|
22
|
+
def ri_path
|
|
23
|
+
plugin_data_path.join("ri")
|
|
27
24
|
end
|
|
28
25
|
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
Bundler.root.to_s
|
|
32
|
-
else
|
|
33
|
-
dep.to_spec.full_gem_path
|
|
34
|
-
end
|
|
26
|
+
def checksum_path
|
|
27
|
+
plugin_data_path.join("checksum")
|
|
35
28
|
end
|
|
36
29
|
end
|
|
37
30
|
|
|
@@ -41,7 +34,7 @@ module Bundler
|
|
|
41
34
|
def exec(command, args)
|
|
42
35
|
raise BundlerError.new("must run command 'ri' in root") unless SharedHelpers.in_bundle?
|
|
43
36
|
|
|
44
|
-
|
|
37
|
+
Dir.glob(ri_path.join("*")).select do |p|
|
|
45
38
|
next unless File.directory?(p)
|
|
46
39
|
|
|
47
40
|
args << "--doc-dir"
|
|
@@ -59,32 +52,76 @@ module Bundler
|
|
|
59
52
|
@deps = deps
|
|
60
53
|
end
|
|
61
54
|
|
|
55
|
+
def checksum_for(spec)
|
|
56
|
+
normalized_filenames = RDoc::RDoc.new.tap { _1.options = RDoc::Options.new }.gather_files([spec.full_gem_path])
|
|
57
|
+
content = normalized_filenames.map { |f| File.read(f) }.join("\n")
|
|
58
|
+
::Digest::SHA256.hexdigest(content)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def checksum_path_for(spec)
|
|
62
|
+
checksum_path.join(slug(spec))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def slug(spec)
|
|
66
|
+
"#{spec.name}-#{spec.version}"
|
|
67
|
+
end
|
|
68
|
+
|
|
62
69
|
def run
|
|
63
|
-
|
|
70
|
+
FileUtils.mkdir_p checksum_path
|
|
71
|
+
current_gems = []
|
|
72
|
+
|
|
73
|
+
Bundler.ui.info "bundler-ri: installing ri docs"
|
|
74
|
+
|
|
75
|
+
Bundler.load.specs.materialized_for_all_platforms.each do |spec|
|
|
76
|
+
Bundler.ui.debug "installing docs for #{slug(spec)}"
|
|
77
|
+
current_gems << slug(spec)
|
|
78
|
+
|
|
79
|
+
new_checksum = checksum_for(spec)
|
|
80
|
+
Bundler.ui.debug "checksum: #{spec.full_gem_path} -> #{new_checksum}"
|
|
64
81
|
|
|
65
|
-
|
|
82
|
+
old_checksum = begin
|
|
83
|
+
File.read(checksum_path_for(spec))
|
|
84
|
+
rescue
|
|
85
|
+
""
|
|
86
|
+
end
|
|
66
87
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
if old_checksum == new_checksum
|
|
89
|
+
Bundler.ui.debug "checksums match, skipping"
|
|
90
|
+
next
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Bundler.ui.debug "checksum mismatch, regenerating ri docs"
|
|
94
|
+
|
|
95
|
+
src_path = spec.full_gem_path
|
|
96
|
+
doc_path = ri_path.join(slug(spec)).to_s
|
|
70
97
|
|
|
71
98
|
RDoc::RDoc.new.document(
|
|
72
99
|
[
|
|
73
100
|
"--root", src_path,
|
|
74
101
|
"-o", doc_path,
|
|
102
|
+
"-x", %q(\.rbs\z),
|
|
75
103
|
"-r",
|
|
76
104
|
"-q"
|
|
77
105
|
]
|
|
78
106
|
)
|
|
79
107
|
|
|
80
|
-
|
|
108
|
+
File.write(checksum_path_for(spec), new_checksum)
|
|
81
109
|
end
|
|
82
110
|
|
|
83
|
-
|
|
84
|
-
current_docs.each { puts _1 }
|
|
111
|
+
Bundler.ui.info "bundler-ri: docs installed"
|
|
85
112
|
|
|
86
113
|
Dir.glob(ri_path.join("*")).each do |p|
|
|
87
|
-
|
|
114
|
+
unless current_gems.include?(File.basename(p))
|
|
115
|
+
Bundler.ui.debug "deleting stale ri data: #{p}"
|
|
116
|
+
FileUtils.rm_rf(p)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
Dir.glob(checksum_path.join("*")).each do |p|
|
|
121
|
+
unless current_gems.include?(File.basename(p))
|
|
122
|
+
Bundler.ui.debug "deleting stale ri data: #{p}"
|
|
123
|
+
FileUtils.rm_rf(p)
|
|
124
|
+
end
|
|
88
125
|
end
|
|
89
126
|
end
|
|
90
127
|
end
|