bundler-ri 0.1.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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +31 -0
  3. data/Rakefile +5 -0
  4. data/lib/bundler/ri.rb +92 -0
  5. data/plugins.rb +3 -0
  6. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1380fa50c668f7811d3c1e822bd5ebce350ab0458a368f9d7bec082ee0491ac
4
+ data.tar.gz: 922ceb262eb90dc4093d16009f939132912af6881af88932a8da602392cda040
5
+ SHA512:
6
+ metadata.gz: a45d9ad89989ab850ed66be5ae5fd5414f79e3e66e4f825183065aa51875643a6d596b616bcf183850c5680b524cc4ec58566e113e96d7014324c5a0c895c77c
7
+ data.tar.gz: 6f1d7559ddc24c5931f04dabf8e69174385d76020fc6257bbe3fa088c920f9eb51c9f4c67c6690e82a4f4edf68a97abf25e85ca24af72072b550ea8e2a170741
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # bundler-ri
2
+
3
+ A bundler plugin to be able to browse bundle-relevant ri docs. Somewhat of a WIP but it does work (kinda)
4
+
5
+ ## Usage
6
+
7
+ Adds a hook to `bundle install` that will generate `rdoc --ri` docs for bundler dependencies and store them in `./.bundle/plugin/ri`. You probably don't want to check that into git if you're using this.
8
+
9
+ With the plugin installed `bundle ri` will do what `ri` usually does but its doc search path will include the generated docs for your dependencies.
10
+
11
+ See: https://bundler.io/man/bundle-plugin.1.html
12
+
13
+ See: https://guides.rubygems.org/bundler_plugins/
14
+
15
+ ## Development
16
+
17
+ `bundle install` for the dev dependencies
18
+
19
+ `bundle exec rspec` to run the tests
20
+
21
+ `bundle exec standardrb --fix` to lint and autocorrect
22
+
23
+ ### TODO
24
+
25
+ * tests
26
+ * don't regenerate docs we've already generated
27
+ * transitive dependencies (some things like `rails` really rely on them)
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bundler-ri.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ task default: :build
data/lib/bundler/ri.rb ADDED
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rdoc"
4
+
5
+ module Bundler
6
+ class RI < Plugin::API
7
+ VERSION = "0.1.0"
8
+
9
+ def self.register
10
+ Bundler::Plugin.add_command("ri", Command)
11
+ Bundler::Plugin.add_hook(Bundler::Plugin::Events::GEM_AFTER_INSTALL_ALL) do |deps|
12
+ AfterInstallHook.new(deps).run
13
+ end
14
+ end
15
+
16
+ module Helpers
17
+ def ri_path
18
+ Bundler::Plugin.root.join("ri")
19
+ end
20
+
21
+ def ri_path_for(dep)
22
+ ri_path.join(resolved_name_for(dep))
23
+ end
24
+
25
+ def resolved_name_for(dep)
26
+ abs_path_for(dep).split("/").last
27
+ end
28
+
29
+ def abs_path_for(dep)
30
+ if dep.source
31
+ Bundler.root.to_s
32
+ else
33
+ dep.to_spec.full_gem_path
34
+ end
35
+ end
36
+ end
37
+
38
+ class Command
39
+ include Helpers
40
+
41
+ def exec(command, args)
42
+ raise BundlerError.new("must run command 'ri' in root") unless SharedHelpers.in_bundle?
43
+
44
+ Bundler.definition.dependencies.map { ri_path_for(_1).to_s }.each do |p|
45
+ next unless File.directory?(p)
46
+
47
+ args << "--doc-dir"
48
+ args << p
49
+ end
50
+
51
+ RDoc::RI::Driver.run(args)
52
+ end
53
+ end
54
+
55
+ class AfterInstallHook
56
+ include Helpers
57
+
58
+ def initialize(deps)
59
+ @deps = deps
60
+ end
61
+
62
+ def run
63
+ puts "bundler-ri: installing ri docs"
64
+
65
+ current_docs = []
66
+
67
+ @deps.each do |dep|
68
+ src_path = abs_path_for(dep).to_s
69
+ doc_path = ri_path_for(dep).to_s
70
+
71
+ RDoc::RDoc.new.document(
72
+ [
73
+ "--root", src_path,
74
+ "-o", doc_path,
75
+ "-r",
76
+ "-q"
77
+ ]
78
+ )
79
+
80
+ current_docs << doc_path
81
+ end
82
+
83
+ puts "bundler-ri: docs installed"
84
+ current_docs.each { puts _1 }
85
+
86
+ Dir.glob(ri_path.join("*")).each do |p|
87
+ FileUtils.rm_rf(p) unless current_docs.include? p
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
data/plugins.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/ri"
2
+
3
+ Bundler::RI.register
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundler-ri
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aidan Coyle
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rdoc
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ email:
27
+ - packrat386@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - README.md
33
+ - Rakefile
34
+ - lib/bundler/ri.rb
35
+ - plugins.rb
36
+ homepage: https://github.com/packrat386/bundler-ri
37
+ licenses: []
38
+ metadata:
39
+ homepage_uri: https://github.com/packrat386/bundler-ri
40
+ source_code_uri: https://github.com/packrat386/bundler-ri
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 3.2.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 4.0.3
56
+ specification_version: 4
57
+ summary: plugin to search for ri docs in your bundle
58
+ test_files: []