Module: Licensed
- Defined in:
- lib/licensed.rb,
lib/licensed/cli.rb,
lib/licensed/license.rb,
lib/licensed/version.rb,
lib/licensed/ui/shell.rb,
lib/licensed/dependency.rb,
lib/licensed/source/npm.rb,
lib/licensed/source/bower.rb,
lib/licensed/command/cache.rb,
lib/licensed/configuration.rb,
lib/licensed/command/verify.rb,
lib/licensed/source/bundler.rb
Defined Under Namespace
Modules: Command, Source, UI Classes: 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 =
"0.6.0"
Class Attribute Summary collapse
-
.use_github ⇒ Object
Returns the value of attribute use_github.
Class Method Summary collapse
Class Attribute Details
.use_github ⇒ Object
Returns the value of attribute use_github.
15 16 17 |
# File 'lib/licensed.rb', line 15 def use_github @use_github end |
Class Method Details
.from_github(url) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/licensed.rb', line 23 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 [ response["license"]["key"], Base64.decode64(response["content"]).force_encoding('UTF-8') ] rescue Octokit::NotFound nil end |
.octokit ⇒ Object
36 37 38 |
# File 'lib/licensed.rb', line 36 def self.octokit @octokit ||= Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"]) end |