Class: CodeLines::GitHub
- Defined in:
- lib/codelines/adapters/github.rb
Instance Method Summary collapse
- #authenticate(username, password) ⇒ Object (also: #login)
- #count(options = {}, &block) ⇒ Object
-
#initialize(profile) ⇒ GitHub
constructor
A new instance of GitHub.
Constructor Details
#initialize(profile) ⇒ GitHub
Returns a new instance of GitHub.
16 17 18 19 20 |
# File 'lib/codelines/adapters/github.rb', line 16 def initialize(profile) @profile = profile @github = Github.new @repositories = {} end |
Instance Method Details
#authenticate(username, password) ⇒ Object Also known as: login
22 23 24 |
# File 'lib/codelines/adapters/github.rb', line 22 def authenticate(username, password) @github = Github.new basic_auth: "#{username}:#{password}" end |
#count(options = {}, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/codelines/adapters/github.rb', line 27 def count( = {}, &block) repos = [:repository ] || [] ignore_comments = [:ignore_comments] || false reload = [:reload] || false lines = 0 repos.each { |repo| name = repo[:name] @repositories[name] = fetch(repo) if reload || !@repositories.include?(name) @repositories[name].each { |github| next if repo[:ignore].is_a?(Array) && repo[:ignore].include?(github.name) source = Base64.decode64 github.content source.gsub!(/\r\n?/m, "\n") source.gsub!(/\/\*![^*]*\*+(?:[^*\/][^*]*\*+)*\//m, '') if ignore_comments source.each_line { |line| lines += 1 if ignore_comments == false || !comment?(line) } yield github if block_given? } } lines end |