blakey 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7347afd0683e9343367d0476e223681512906f393d7ac7401ee881e93d7e7bcf
4
- data.tar.gz: d49172043a2b76aeb2c3e39312be84856e757d1aa33a2bf2b234d7d8533134aa
3
+ metadata.gz: 112a99ff6e0d9969e2d1cd913b7a2dc7c6815a20d971e83234c080e49d821a39
4
+ data.tar.gz: 779c19500a850ab5d332b6ffb1031b6217099461db90f3be12ea5016532f1b55
5
5
  SHA512:
6
- metadata.gz: 68bae9613983e39eeb3ea58dbbab0029e8d56323a0ca928c98d1cd2a5e2bfd9d2f94de91dc6902728898e77b0ce2383f16bf70934411cad2d1dc644c106302d5
7
- data.tar.gz: c006d234bf9f278b33d1f1363341e1e351dafa478a29d8cdf6c711e6baa97e41b97fd207a78ffcb2dfc506e5f0ae4e6b89171971fdecf505e5fa008e4adc6258
6
+ metadata.gz: daabb1d929a69a99a6ee61dd65cca4c2b8005dcd890957ea550498f3202f641532bcffecef88f868e0266df7cabc83882d510a4831b9ae06da6d58cd530a7f4b
7
+ data.tar.gz: f8addd635dc00acd745cf20ccfcf9ccca596ad905d7bce3498ab3fa136caa5a4206db79b0a824bbdc392e471f8be449b76c23b74003ac1093fc5f6e61214299d
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_dependency 'octokit', '~> 4.19'
27
+ spec.add_dependency 'octokit', '~> 4.20'
28
28
  spec.add_dependency 'bundler', '>= 2.0.0'
29
29
 
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -30,11 +30,13 @@ Returns a hash with useful repository data from the GitHub API.
30
30
  github_source.repository_overview
31
31
  # => {
32
32
  # :open_issues_count=>143, # count of open issues
33
+ # :open_pull_requests_count=>21, # count of open pull requests
33
34
  # :language=>"Ruby", # configured language of the repo
34
35
  # :visibility=>"private", # visibility of the repo
35
36
  # :url=>"https://github.com/calvinhughes/blakey", # url of the repo
36
37
  # :updated_at=>2020-11-20 13:43:54 UTC, # when it was last updated
37
38
  # :created_at=>2012-03-16 09:14:34 UTC, # when it was created
38
39
  # :last_pushed_at=>2020-11-20 14:01:40 UTC, # when it was last pushed to
40
+ # :vulnerability_alerts_enabled=>false # whether vulnerability alerts are enabled
39
41
  # }
40
42
  ```
@@ -10,13 +10,21 @@ module Blakey
10
10
  end
11
11
 
12
12
  def version
13
- gemfile_lock_parser.ruby_version || fetch_version_from_ruby_version_file
13
+ format_version(fetched_version)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  attr_reader :gemfile_lock_parser, :source
19
19
 
20
+ def format_version(version_string)
21
+ version_string.gsub(/^(.*?)(?=[0-9])/, '').strip
22
+ end
23
+
24
+ def fetched_version
25
+ gemfile_lock_parser.ruby_version || fetch_version_from_ruby_version_file
26
+ end
27
+
20
28
  def fetch_version_from_ruby_version_file
21
29
  source.read_file('.ruby-version')
22
30
  end
@@ -4,6 +4,8 @@ require 'octokit'
4
4
  module Blakey
5
5
  module Source
6
6
  class Github < Base
7
+ VULNERABILITY_ALERTS_PREVIEW_HEADER = 'application/vnd.github.dorian-preview+json'.freeze
8
+
7
9
  def initialize(access_token: nil, repo_path: nil)
8
10
  @access_token = (access_token || ENV['BLAKEY_SOURCE_GITHUB_ACCESS_TOKEN'])
9
11
  @octokit_client ||= ::Octokit::Client.new(access_token: @access_token)
@@ -25,17 +27,29 @@ module Blakey
25
27
  def repository_overview
26
28
  {
27
29
  open_issues_count: repository.open_issues_count,
30
+ open_pull_requests_count: open_pull_requests_count,
28
31
  language: repository.language,
29
32
  visibility: repository.private? ? 'private' : 'public',
30
33
  url: repository.html_url,
31
34
  updated_at: repository.updated_at,
32
35
  created_at: repository.created_at,
33
- last_pushed_at: repository.pushed_at
36
+ last_pushed_at: repository.pushed_at,
37
+ vulnerability_alerts_enabled: vulnerability_alerts_enabled?
34
38
  }
35
39
  end
36
40
 
37
41
  private
38
42
 
43
+ def vulnerability_alerts_enabled?
44
+ octokit_client.vulnerability_alerts_enabled?(repo_path, accept: VULNERABILITY_ALERTS_PREVIEW_HEADER)
45
+ end
46
+
47
+ def open_pull_requests_count
48
+ search_query = "repo:#{repo_path} is:pr is:open"
49
+ search_issues_response = octokit_client.search_issues(search_query, per_page: 1)
50
+ search_issues_response.total_count
51
+ end
52
+
39
53
  def repository
40
54
  @repository ||= octokit_client.repo(repo_path)
41
55
  end
@@ -1,3 +1,3 @@
1
1
  module Blakey
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blakey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calvin Hughes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-28 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.19'
19
+ version: '4.20'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.19'
26
+ version: '4.20'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.3
147
+ rubygems_version: 3.0.9
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Blakey makes extracting basic statistics from your projects much easier