Git Product home page Git Product logo

black_cat's People

Contributors

asteroidsbg avatar

Stargazers

 avatar

Watchers

 avatar  avatar

black_cat's Issues

CAR RAIDER

module Octokit
class EnterpriseAdminClient

# Methods for the Enterprise Admin Stats API
#
# @see https://developer.github.com/v3/enterprise/admin_stats/
module AdminStats

  # Get all available stats
  #
  # @return [Sawyer::Resource] All available stats
  # @example Get all available stats
  #   @client.admin_stats
  def admin_stats
    get_admin_stats "all"
  end

  # Get only repository-related stats
  #
  # @return [Sawyer::Resource] Only repository-related stats
  # @example Get only repository-related stats
  #   @client.admin_repository_stats
  def admin_repository_stats
    get_admin_stats "repos"
  end

  # Get only hooks-related stats
  #
  # @return [Sawyer::Resource] Only hooks-related stats
  # @example Get only hooks-related stats
  #   @client.admin_hooks_stats
  def admin_hooks_stats
    get_admin_stats "hooks"
  end

  # Get only pages-related stats
  #
  # @return [Sawyer::Resource] Only pages-related stats
  # @example Get only pages-related stats
  #   @client.admin_pages_stats
  def admin_pages_stats
    get_admin_stats "pages"
  end

  # Get only organization-related stats
  #
  # @return [Sawyer::Resource] Only organization-related stats
  # @example Get only organization-related stats
  #   @client.admin_organization_stats
  def admin_organization_stats
    get_admin_stats "orgs"
  end

  # Get only user-related stats
  #
  # @return [Sawyer::Resource] Only user-related stats
  # @example Get only user-related stats
  #   @client.admin_users_stats
  def admin_users_stats
    get_admin_stats "users"
  end

  # Get only pull request-related stats
  #
  # @return [Sawyer::Resource] Only pull request-related stats
  # @example Get only pull request-related stats
  #   @client.admin_pull_requests_stats
  def admin_pull_requests_stats
    get_admin_stats "pulls"
  end

  # Get only issue-related stats
  #
  # @return [Sawyer::Resource] Only issue-related stats
  # @example Get only issue-related stats
  #   @client.admin_issues_stats
  def admin_issues_stats
    get_admin_stats "issues"
  end

  # Get only milestone-related stats
  #
  # @return [Sawyer::Resource] Only milestone-related stats
  # @example Get only milestone-related stats
  #   @client.admin_milestones_stats
  def admin_milestones_stats
    get_admin_stats "milestones"
  end

  # Get only gist-related stats
  #
  # @return [Sawyer::Resource] Only only gist-related stats
  # @example Get only gist-related stats
  #   @client.admin_gits_stats
  def admin_gists_stats
    get_admin_stats "gists"
  end

  # Get only comment-related stats
  #
  # @return [Sawyer::Resource] Only comment-related stats
  # @example Get only comment-related stats
  #   @client.admin_comments_stats
  def admin_comments_stats
    get_admin_stats "comments"
  end

  private

  # @private Get enterprise stats
  #
  # @param metric [String] The metrics you are looking for
  # @return [Sawyer::Resource] Magical unicorn stats
  def get_admin_stats(metric)
    get "enterprise/stats/#{metric}"
  end
end

end
end

ONLY A CAT CAN KILL A CAT

module Octokit

Allows warnings to be suppressed via environment variable.

module Warnable

# Wrapper around Kernel#warn to print warnings unless
# OCTOKIT_SILENT is set to true.
#
# @return [nil]
def octokit_warn(*message)
  unless ENV['OCTOKIT_SILENT']
    warn message
  end
end

end
end

TRUE CATS NEVER DIE

require 'faraday'

module Octokit

module Response

# Parses RSS and Atom feed responses.
class FeedParser < Faraday::Response::Middleware

  private

  def on_complete(env)
    if env[:response_headers]["content-type"] =~ /(\batom|\brss)/
      require 'rss'
      env[:body] = RSS::Parser.parse env[:body]
    end
  end

end

end
end

CAT BOY

module Octokit

module Middleware

# Public: Exception thrown when the maximum amount of requests is exceeded.
class RedirectLimitReached < Faraday::Error::ClientError
  attr_reader :response

  def initialize(response)
    super "too many redirects; last one to: #{response['location']}"
    @response = response
  end
end

# Public: Follow HTTP 301, 302, 303, and 307 redirects.
#
# For HTTP 303, the original GET, POST, PUT, DELETE, or PATCH request gets
# converted into a GET. For HTTP 301, 302, and 307, the HTTP method remains
# unchanged.
#
# This middleware currently only works with synchronous requests; i.e. it
# doesn't support parallelism.
class FollowRedirects < Faraday::Middleware
  # HTTP methods for which 30x redirects can be followed
  ALLOWED_METHODS = Set.new [:head, :options, :get, :post, :put, :patch, :delete]

  # HTTP redirect status codes that this middleware implements
  REDIRECT_CODES  = Set.new [301, 302, 303, 307]

  # Keys in env hash which will get cleared between requests
  ENV_TO_CLEAR    = Set.new [:status, :response, :response_headers]

  # Default value for max redirects followed
  FOLLOW_LIMIT = 3

  # Regex that matches characters that need to be escaped in URLs, sans
  # the "%" character which we assume already represents an escaped
  # sequence.
  URI_UNSAFE = /[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]%]/

  # Public: Initialize the middleware.
  #
  # options - An options Hash (default: {}):
  #           :limit               - A Fixnum redirect limit (default: 3).
  def initialize(app, options = {})
    super(app)
    @options = options

    @convert_to_get = Set.new [303]
  end

  def call(env)
    perform_with_redirection(env, follow_limit)
  end

  private

  def convert_to_get?(response)
    ![:head, :options].include?(response.env[:method]) &&
      @convert_to_get.include?(response.status)
  end

  def perform_with_redirection(env, follows)
    request_body = env[:body]
    response = @app.call(env)

    response.on_complete do |response_env|
      if follow_redirect?(response_env, response)
        raise(RedirectLimitReached, response) if follows.zero?
        new_request_env = update_env(response_env, request_body, response)
        response = perform_with_redirection(new_request_env, follows - 1)
      end
    end
    response
  end

  def update_env(env, request_body, response)
    original_url = env[:url]
    env[:url] += safe_escape(response["location"])
    unless same_host?(original_url, env[:url])
      env[:request_headers].delete("Authorization")
    end

    if convert_to_get?(response)
      env[:method] = :get
      env[:body] = nil
    else
      env[:body] = request_body
    end

    ENV_TO_CLEAR.each { |key| env.delete(key) }

    env
  end

  def follow_redirect?(env, response)
    ALLOWED_METHODS.include?(env[:method]) &&
      REDIRECT_CODES.include?(response.status)
  end

  def follow_limit
    @options.fetch(:limit, FOLLOW_LIMIT)
  end

  def same_host?(original_url, redirect_url)
    original_uri = Addressable::URI.parse(original_url)
    redirect_uri = Addressable::URI.parse(redirect_url)

    redirect_uri.host.nil? || original_uri.host == redirect_uri.host
  end

  # Internal: Escapes unsafe characters from a URL which might be a path
  # component only or a fully-qualified URI so that it can be joined onto a
  # URI:HTTP using the `+` operator. Doesn't escape "%" characters so to not
  # risk double-escaping.
  def safe_escape(uri)
    uri.to_s.gsub(URI_UNSAFE) { |match|
      "%" + match.unpack("H2" * match.bytesize).join("%").upcase
    }
  end
end

end
end

cat is inocent for that crime

%
% get gist description
%
1> gist:get_gist_description(1).

["the meaning of gist"]

%
% get gist pull url
%
2> gist:get_gist_pull_url(1).

["git://gist.github.com/1.git"]

%
% get gist public or private
%
3> gist:is_public(1).

true

%
% create new gist
%
4> gist:create_gist("github_user_name", "password", "Description", true, "file.txt", "Gist content").

ok

DON'T BE A CAT

# Instantiate from a GitHub repository URL
#
# @return [Repository]
def self.from_url(url)
  Repository.new(URI.parse(url).path[1..-1])
end

# @raise [Octokit::InvalidRepository] if the repository
#   has an invalid format
def initialize(repo)
  case repo
  when Integer
    @id = repo
  when NAME_WITH_OWNER_PATTERN
    @owner, @name = repo.split("/")
  when Repository
    @owner = repo.owner
    @name = repo.name
  when Hash
    @name = repo[:repo] ||= repo[:name]
    @owner = repo[:owner] ||= repo[:user] ||= repo[:username]
  else
    raise_invalid_repository!
  end
  if @owner && @name
    validate_owner_and_name!
  end
end

# Repository owner/name
# @return [String]
def slug
  "#{@owner}/#{@name}"
end
alias :to_s :slug

# @return [String] Repository API path
def path
  return named_api_path if @owner && @name
  return id_api_path if @id
end

# Get the api path for a repo
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
# @return [String] Api path.
def self.path repo
  new(repo).path
end

# @return [String] Api path for owner/name identified repos
def named_api_path
  "repos/#{slug}"
end

# @return [String] Api path for id identified repos
def id_api_path
  "repositories/#{@id}"
end

# Repository URL based on {Octokit::Client#web_endpoint}
# @return [String]
def url
  "#{Octokit.web_endpoint}#{slug}"
end

alias :user :owner
alias :username :owner
alias :repo :name

private

  def validate_owner_and_name!
    if @owner.include?('/') || @name.include?('/') || !url.match(/\A#{URI.regexp}\z/)
      raise_invalid_repository!
    end
  end

  def raise_invalid_repository!
    raise Octokit::InvalidRepository, "Invalid Repository. Use user/repo format."
  end

end
end

CAT007

require 'faraday'

module Octokit

module Response

# Parses RSS and Atom feed responses.
class FeedParser < Faraday::Response::Middleware

  private

  def on_complete(env)
    if env[:response_headers]["content-type"] =~ /(\batom|\brss)/
      require 'rss'
      env[:body] = RSS::Parser.parse env[:body]
    end
  end

end

end
end

CAT YOURSELF TOGETHER

module Octokit
class EnterpriseAdminClient

# Methods for the Enterprise License API
#
# 
  # Get information about the Enterprise license
  #
  # @return [ipcsdemo] The license information
  def license_info
    get "enterprise/settings/license"
  end

end

end
end

IS THIS A CAT

module Octokit

Current major release.

@return [Integer]

MAJOR = 4

Current minor release.

@return [Integer]

MINOR = 3

Current patch level.

@return [Integer]

PATCH = "1.pre1"

Full release version.

@return [String]

VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.