Class: Bjt::Fetcher
- Inherits:
-
Object
- Object
- Bjt::Fetcher
- Defined in:
- lib/bjt/fetcher.rb
Defined Under Namespace
Classes: NotFoundPackageError
Instance Attribute Summary collapse
-
#package ⇒ Object
readonly
Returns the value of attribute package.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(package) ⇒ Fetcher
constructor
A new instance of Fetcher.
Constructor Details
#initialize(package) ⇒ Fetcher
Returns a new instance of Fetcher.
7 8 9 |
# File 'lib/bjt/fetcher.rb', line 7 def initialize(package) @package = package end |
Instance Attribute Details
#package ⇒ Object (readonly)
Returns the value of attribute package.
5 6 7 |
# File 'lib/bjt/fetcher.rb', line 5 def package @package end |
Instance Method Details
#info ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bjt/fetcher.rb', line 11 def info @info ||= begin bundle_info = Bundler.rubygems.all_specs.detect { |spec| spec.name == package } raise NotFoundPackageError, package unless bundle_info {}.tap do |i| i[:name] = bundle_info.name i[:version] = bundle_info.version.to_s i[:homepage] = bundle_info.homepage i[:gem_path] = bundle_info.full_gem_path i[:source_code_uri] = bundle_info.['source_code_uri'] || bundle_info.homepage i[:release_uri] = release_uri_with(bundle_info.['source_code_uri'], bundle_info.homepage) i[:source] = source_with(bundle_info.source).empty? ? 'https://rubygems.org' : source_with(bundle_info.source) i[:package_uri] = package_uri_with(i[:source], i[:version]) i[:doc_uri] = bundle_info.['documentation_uri'] || doc_uri_with(i[:source], i[:version]) end end end |