open_gemdocs 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0f80355f3c2bf3eb6fccbfae95a5bcf2306493d19680820f74c30ebc8d1fbe25
4
+ data.tar.gz: 3624db7fb13cb8784e5db06f2a6ebf0a21858cec666b79efafa4daa5b38104e0
5
+ SHA512:
6
+ metadata.gz: 460e8b98333345f461e962e14c739d3f88b202b6a24e897d91050e05d2bc9f6f41ea746bb95a689c61577dafe2b3590cb68baaf83641755fa8ec3660972af10d
7
+ data.tar.gz: f13cffee516d76f47f7a1673fa68fee48e9308b286155cc3eb900d833692baa46a27ada5ecd9c48302bbad52f304de192085c105a04e1e343712d86294ced34a
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ FA��3�E���#b�G W�G�Q,}]G����!� ��)�Cm�K�=,��X�{���@"H��^���;RA՛e�F8 G����1f���t�:�A9�;��] �m\p���5|�K�
2
+ ��dʶb�I�� R g��l�>�K�����<襇�R���=>N��O���}�\�@���ҘgE�o�M:/ɲ�� D�V0
3
+ j���(f!�}�j����ڮ�uKD(>��Ec�x[��NU�Z7�`�/X�hʳU��–Ꮊ^,K%��5���B�9� =�͑�N:����N'p;����PhA�Ǧ��=yx���C�8�mX܋[��y `_d<��V�Ӎ�f�/��7RV3���J�����1/�������R�o �YC
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-04-25
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Sean McCleary
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # OpenGemdocs
2
+
3
+ This is a simple command line tool that helps open gem documentation on https://gemdocs.org.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```bash
10
+ bundle add open_gemdocs
11
+ ```
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ ```bash
16
+ gem install open_gemdocs
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Currently, this only works on Macs because of the `open` command. It opens the documentation for a gem in your default web browser.
22
+
23
+ For terminal use:
24
+
25
+ ```bash
26
+ open_gemdocs --help
27
+ ```
28
+
29
+ To see the available options.
30
+
31
+ If you pass in the name of a gem from a directory that contains a Gemfile.lock file, it will determine what version of the gem you are using when it opens the online documentation.
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mrinterweb/open_gemdocs.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MRAwDgYDVQQDDAdzZWFu
3
+ bWNjMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
4
+ HhcNMjUwNDI2MDY1OTA3WhcNMjYwNDI2MDY1OTA3WjA+MRAwDgYDVQQDDAdzZWFu
5
+ bWNjMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
6
+ ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQClsGKKD8z8vSV2l7CZdcsn
7
+ H7tJqy2gPOziPh8Ah9wCbSFoI/4CzVk5YwYUZsKsFUSUtY6aF+CIEDi7iPqoDT6Y
8
+ Qsj4P4jAL/TLy3qHFe8fE2UH3z5wimoGwoEDlmhe7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yn
24
+ eic7ZflI+cd7J3/Pmh0OBhhzi4f4l8znwVQ2/PFX2dOE/PLqQgf26jwvXJG+Z5Hr
25
+ zOgawVlgqyQ5ACIDUJIr+qMUWjeOKyJ2JTte9Jy4CC4=
26
+ -----END CERTIFICATE-----
@@ -0,0 +1 @@
1
+ df9bcef189d3511c88a2a9dcbe6e542d97b72b9ac77a2e5878600480681d41097da17fa26e1c83b958556402fb8bcaddb0239c4526105f67f1d5054a0032f519
data/exe/open-gem-docs ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'uri'
5
+ require 'net/http'
6
+ require 'json'
7
+ require 'optparse'
8
+ require_relative File.join('..', 'lib', 'open_gemdocs')
9
+
10
+ options = {}
11
+
12
+ OptionParser.new do |opts|
13
+ opts.banner = 'Usage: open-gem-docs [options] <gem_name>'
14
+
15
+ opts.on('-v', '--version VERSION', 'Specify the version') do |version|
16
+ options[:version] = version
17
+ end
18
+
19
+ opts.on('-l', '--latest', 'Use the latest version') do
20
+ options[:latest] = true
21
+ end
22
+
23
+ opts.on('-h', '--help', 'Display this help message') do
24
+ puts opts
25
+ exit
26
+ end
27
+ end.parse!
28
+
29
+ begin
30
+ OpenGemdocs::Browser.new(gem_name: ARGV[0], version: options[:version], use_latest: options[:latest]).open_browser
31
+ rescue OpenGemdocs::Error, ArgumentError => e
32
+ puts e.message
33
+ exit 1
34
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenGemdocs
4
+ class Browser
5
+ attr_reader :gem_name, :version, :use_latest
6
+
7
+ def initialize(gem_name:, version: nil, use_latest: false)
8
+ @gem_name = gem_name
9
+ raise ArgumentError, 'Gem name is required' if gem_name.nil? || gem_name.empty?
10
+
11
+ @version = version
12
+ @use_latest = use_latest
13
+ end
14
+
15
+ def resolve_version
16
+ return version if version
17
+
18
+ if !use_latest && File.exist?('Gemfile.lock')
19
+ @version = check_bundle_version
20
+ if @version
21
+ puts "Using version from Gemfile.lock: #{version}"
22
+ return version
23
+ end
24
+ end
25
+
26
+ @use_latest = true
27
+
28
+ puts 'No version specified, using latest version'
29
+ end
30
+
31
+ def open_browser
32
+ resolve_version
33
+ raise Error, 'No version URL found' unless version_url
34
+
35
+ version_str = version ? "@v#{version}" : ''
36
+ latest_str = use_latest ? ' (latest)' : ''
37
+ puts "Fetching gem documentation for #{gem_name}#{version_str}#{latest_str}..."
38
+ # open is a macOS command to open a URL in the default browser
39
+ raise Error, 'Could not resolve URL' if version_url.nil?
40
+
41
+ `open "#{version_url.sub('production.', '')}"`
42
+ end
43
+
44
+ def version_url
45
+ if use_latest
46
+ version_data.last['url']
47
+ else
48
+ version_data.detect { |row| row['version'] == version }&.fetch('url')
49
+ end
50
+ end
51
+
52
+ def check_bundle_version
53
+ `bundle show #{gem_name}`.strip.match(/#{gem_name}-([0-9.]+).*$/)&.[](1)
54
+ end
55
+
56
+ def version_data
57
+ @version_data ||= begin
58
+ uri = URI("https://gemdocs.org/gems/#{ARGV[0]}/versions.json")
59
+ res = Net::HTTP.get_response(uri)
60
+ unless res.is_a?(Net::HTTPSuccess)
61
+ raise Error, "HTTP request failed to uri: #{uri} -- #{res.code} #{res.message}"
62
+ end
63
+
64
+ JSON.parse(res.body)['versions']
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenGemdocs
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'open_gemdocs/version'
4
+ require_relative 'open_gemdocs/browser'
5
+
6
+ module OpenGemdocs
7
+ class Error < StandardError; end
8
+ end
@@ -0,0 +1,4 @@
1
+ module OpenGemdocs
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: open_gemdocs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean McCleary
8
+ bindir: exe
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MRAwDgYDVQQDDAdzZWFu
13
+ bWNjMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
14
+ HhcNMjUwNDI2MDY1OTA3WhcNMjYwNDI2MDY1OTA3WjA+MRAwDgYDVQQDDAdzZWFu
15
+ bWNjMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
16
+ ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQClsGKKD8z8vSV2l7CZdcsn
17
+ H7tJqy2gPOziPh8Ah9wCbSFoI/4CzVk5YwYUZsKsFUSUtY6aF+CIEDi7iPqoDT6Y
18
+ Qsj4P4jAL/TLy3qHFe8fE2UH3z5wimoGwoEDlmhe7LvTa4hMuDgtLhrL4E8WAygR
19
+ OoGEQVhaIIZx8BiDIdIus9YGZft1I9tB/f4XxHFwplFiS8Z8S/9ab2QZ2iv+S6XM
20
+ KUOEX9+Zp5/uEDE3pAbsGIyC8oWs1XhvHmdpCeAg34280oJK7IJ18vCthgVSn1Ny
21
+ mGZJQP9jRYrCapVzWazwUq7eoDyMmN5UTNbVUnQnUMXyZbUS6QnYD5+AnxRQxufI
22
+ 2z1dRpwnaF2D7i/HrxjbZ5mjnnQ5QZLiIh2g1jkozI9ZM2GUY1TMAjt9XdBWOxZ/
23
+ 1fctrXgiBV7k3/0oZzc94oNoIF9G1tSZvdO7yyvuDItP69GfjUnrgCVWRqxzOEJD
24
+ TBRa7t/FJd3sMum2eEgMTNXdxCiKgadfdVmGTtej+ZkCAwEAAaN1MHMwCQYDVR0T
25
+ BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFOoslEqN/n5L9VNugFgZSSvrwDTo
26
+ MBwGA1UdEQQVMBOBEXNlYW5tY2NAZ21haWwuY29tMBwGA1UdEgQVMBOBEXNlYW5t
27
+ Y2NAZ21haWwuY29tMA0GCSqGSIb3DQEBCwUAA4IBgQBHKwhncXb7vURi24CLRcLj
28
+ NOBLIyTNLu+0ezr80bofHRVEEDiN+CoMI1dwH5ZpjvlXxOXrq5SbVvdpPPzg1Cjp
29
+ y29tCP7oyHsPG9Q5ssF2VpDjgTVoY2EdON/iKKbPiOr1MaFqTcVK6SjpdBMzYyDa
30
+ suy/Zo3c+6R+gF+7D8oldqNO7Q43mBSkWNIW4CMtzLEQ20J18vLXj1hn9gd2E3Ai
31
+ kWUZ07LnKR4sqswnwGavFhs3/fJORiDRmRUoIin3Oay/vl7Mzx5UYYt7op6s+quu
32
+ VazWDwPqyMqnEJMgVGBUnESLknmS68hvd0s0jlZfeu9QgvomJk8Y722ASonu0IoX
33
+ u/tPcOlBWt5Y4lpQcCJKUvNWJd0/Ypaq6ngEWByqsuqmNaHRUO3nGteLUliuUhyn
34
+ eic7ZflI+cd7J3/Pmh0OBhhzi4f4l8znwVQ2/PFX2dOE/PLqQgf26jwvXJG+Z5Hr
35
+ zOgawVlgqyQ5ACIDUJIr+qMUWjeOKyJ2JTte9Jy4CC4=
36
+ -----END CERTIFICATE-----
37
+ date: 1980-01-02 00:00:00.000000000 Z
38
+ dependencies: []
39
+ description: ''
40
+ email:
41
+ - seanmcc@gmail.com
42
+ executables:
43
+ - open-gem-docs
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".rspec"
48
+ - ".rubocop.yml"
49
+ - CHANGELOG.md
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - certs/mrinterweb.pem
54
+ - checksums/open_gemdocs-0.1.0.gem.sha512
55
+ - exe/open-gem-docs
56
+ - lib/open_gemdocs.rb
57
+ - lib/open_gemdocs/browser.rb
58
+ - lib/open_gemdocs/version.rb
59
+ - sig/open_gemdocs.rbs
60
+ homepage: https://github.com/mrinterweb/open_gemdocs
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ allowed_push_host: https://rubygems.org
65
+ homepage_uri: https://github.com/mrinterweb/open_gemdocs
66
+ source_code_uri: https://github.com/mrinterweb/open_gemdocs
67
+ changelog_uri: https://github.com/mrinterweb/open_gemdocs/blob/main/CHANGELOG.md
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.6.8
83
+ specification_version: 4
84
+ summary: Simple command line tool to open the documentation for a gem.
85
+ test_files: []
metadata.gz.sig ADDED
Binary file