Module: Licensed
- Defined in:
- lib/licensed.rb,
lib/licensed/cli.rb,
lib/licensed/git.rb,
lib/licensed/shell.rb,
lib/licensed/license.rb,
lib/licensed/version.rb,
lib/licensed/ui/shell.rb,
lib/licensed/source/go.rb,
lib/licensed/dependency.rb,
lib/licensed/source/npm.rb,
lib/licensed/command/list.rb,
lib/licensed/source/bower.rb,
lib/licensed/source/cabal.rb,
lib/licensed/command/cache.rb,
lib/licensed/configuration.rb,
lib/licensed/command/status.rb,
lib/licensed/source/bundler.rb,
lib/licensed/source/manifest.rb
Defined Under Namespace
Modules: Command, Git, Shell, Source, UI Classes: AppConfiguration, CLI, Configuration, Dependency, License
Constant Summary collapse
- GITHUB_URL =
%r{\Ahttps://github.com/([a-z0-9]+(-[a-z0-9]+)*/(\w|\.|\-)+)}- LICENSE_CONTENT_TYPE =
"application/vnd.github.drax-preview+json"- VERSION =
"1.0.0".freeze
Class Attribute Summary collapse
-
.use_github ⇒ Object
Returns the value of attribute use_github.
Class Method Summary collapse
-
.from_github(url) ⇒ Object
Load license content from a GitHub url.
- .octokit ⇒ Object
Class Attribute Details
.use_github ⇒ Object
Returns the value of attribute use_github.
22 23 24 |
# File 'lib/licensed.rb', line 22 def use_github @use_github end |
Class Method Details
.from_github(url) ⇒ Object
Load license content from a GitHub url. Returns nil if the url does not point to a GitHub repository, or if the license content is not found
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/licensed.rb', line 32 def self.from_github(url) return unless use_github && match = GITHUB_URL.match(url) license_url = Octokit::Repository.path(match[1]) + "/license" response = octokit.get license_url, accept: LICENSE_CONTENT_TYPE content = Base64.decode64(response["content"]).force_encoding("UTF-8") Licensee::ProjectFiles::LicenseFile.new(content, response["name"]) rescue Octokit::NotFound nil end |
.octokit ⇒ Object
43 44 45 |
# File 'lib/licensed.rb', line 43 def self.octokit @octokit ||= Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) end |