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/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/source/stack.rb,
lib/licensed/command/cache.rb,
lib/licensed/configuration.rb,
lib/licensed/command/verify.rb,
lib/licensed/source/bundler.rb,
lib/licensed/source/manifest.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.11.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.use_githubObject

Returns the value of attribute use_github.



20
21
22
# File 'lib/licensed.rb', line 20

def use_github
  @use_github
end

Class Method Details

.from_github(url) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/licensed.rb', line 28

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

.octokitObject



39
40
41
# File 'lib/licensed.rb', line 39

def self.octokit
  @octokit ||=  Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"])
end