Module: Repofetch::BitbucketCloud::Stats
- Included in:
- Repofetch::BitbucketCloud
- Defined in:
- lib/repofetch/bitbucketcloud/stats.rb
Overview
Methods to get Bitbucket Cloud stats.
Instance Method Summary collapse
- #clone_urls ⇒ Object protected
- #created ⇒ Object protected
- #forks ⇒ Object protected
- #http_clone_url ⇒ Object protected
- #issues ⇒ Object protected
- #pull_requests ⇒ Object protected
- #repo_data ⇒ Object protected
- #size ⇒ Object protected
- #ssh_clone_url ⇒ Object protected
- #updated ⇒ Object protected
- #watchers ⇒ Object protected
Instance Method Details
#clone_urls ⇒ Object (protected)
15 16 17 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 15 def clone_urls @clone_urls ||= repo_data['links']['clone'].to_h { |clone| [clone['name'].to_sym, clone['href']] } end |
#created ⇒ Object (protected)
37 38 39 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 37 def created Repofetch::TimespanStat.new('created', repo_data['created_on'], emoji: '🐣') end |
#forks ⇒ Object (protected)
32 33 34 35 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 32 def forks @fork_data ||= agent.call(:get, "repositories/#{@repo_identifier}/forks").data Repofetch::Stat.new('forks', @fork_data['size'], emoji: '🔱') end |
#http_clone_url ⇒ Object (protected)
19 20 21 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 19 def http_clone_url Repofetch::Stat.new('HTTP(S)', clone_urls[:https], emoji: '🌐') end |
#issues ⇒ Object (protected)
53 54 55 56 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 53 def issues @issue_data ||= agent.call(:get, "repositories/#{@repo_identifier}/issues").data Repofetch::Stat.new('issues', @issue_data['size'], emoji: '❗') end |
#pull_requests ⇒ Object (protected)
58 59 60 61 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 58 def pull_requests @pull_request_data ||= agent.call(:get, "repositories/#{@repo_identifier}/pullrequests").data Repofetch::Stat.new('pull requests', @pull_request_data['size'], emoji: '🔀') end |
#repo_data ⇒ Object (protected)
11 12 13 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 11 def repo_data @repo_data ||= agent.call(:get, "repositories/#{@repo_identifier}").data end |
#size ⇒ Object (protected)
45 46 47 48 49 50 51 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 45 def size # NOTE: Size is in bytes # TODO: Move this somewhere else instead of using a copy-paste byte_size = number_to_human_size(repo_data['size'] || 0, precision: 2, significant: false, strip_insignificant_zeros: false) Repofetch::Stat.new('size', byte_size, emoji: '💽') end |
#ssh_clone_url ⇒ Object (protected)
23 24 25 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 23 def ssh_clone_url Repofetch::Stat.new('SSH', clone_urls[:ssh], emoji: '🔑') end |
#updated ⇒ Object (protected)
41 42 43 |
# File 'lib/repofetch/bitbucketcloud/stats.rb', line 41 def updated Repofetch::TimespanStat.new('updated', repo_data['updated_on'], emoji: '📤') end |