fbe 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 485d65ab1a72472bc118062f665516e8092e0f35b6b566acf567cad26259944c
4
- data.tar.gz: c558708f7897da86b6c2133154cfb5861aa6fd1aeef8686eb109290de43b7b03
3
+ metadata.gz: 3828337a178cb00363cfde7328b72d719e412861b1faeedeacbfa90ecdf55f01
4
+ data.tar.gz: 13e04faef8302ce164266d19cf5b54d9876376500c113a692467c30bde96345e
5
5
  SHA512:
6
- metadata.gz: 684d4072dbe3ae3fc6043abbeddf6e0cce131948516df23a64b784777fa6a9a63e11e9eb09880116a4376be7d5292b2df983d472ae8d12bed00ea75c434a7c62
7
- data.tar.gz: 56469e2fa299e1b411415b787b2edd3d19e75a7850a7a737dfb427505e8ec1c924a9e7935709d6bb05d13247e453eec25a5c5da84b7df15e9a5f4f29bf6f2dbf
6
+ metadata.gz: 7f35b12b769b206e111a63de0575f673be0c8514c42b3b90b33009a65529d8572f98d173d6c18dce29e8edd231afb7cd890c8dbe17af1b2e58733e7359453e73
7
+ data.tar.gz: 1743b4a1fe9deb57b39763f666683eb51ea6878fd56b86bc99fe1189c4fa58fcb42762b8e6f14cb7b0fd4256aca858824b8ca4ca6c0a7238d4f547c80d673b45
data/lib/fbe/octo.rb CHANGED
@@ -96,13 +96,16 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
96
96
  end
97
97
 
98
98
  def user_name_by_id(id)
99
+ raise 'The ID of the user is nil' if id.nil?
100
+ raise 'The ID of the user must be an Integer' unless id.is_a?(Integer)
99
101
  json = @origin.user(id)
100
- name = json[:login]
102
+ name = json[:login].downcase
101
103
  @loog.debug("GitHub user ##{id} has a name: @#{name}")
102
104
  name
103
105
  end
104
106
 
105
107
  def repo_id_by_name(name)
108
+ raise 'The name of the repo is nil' if name.nil?
106
109
  json = @origin.repository(name)
107
110
  id = json[:id]
108
111
  @loog.debug("GitHub repository #{name.inspect} has an ID: ##{id}")
@@ -110,8 +113,10 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
110
113
  end
111
114
 
112
115
  def repo_name_by_id(id)
116
+ raise 'The ID of the repo is nil' if id.nil?
117
+ raise 'The ID of the repo must be an Integer' unless id.is_a?(Integer)
113
118
  json = @origin.repository(id)
114
- name = json[:full_name]
119
+ name = json[:full_name].downcase
115
120
  @loog.debug("GitHub repository ##{id} has a name: #{name}")
116
121
  name
117
122
  end
data/lib/fbe.rb CHANGED
@@ -10,5 +10,5 @@
10
10
  # License:: MIT
11
11
  module Fbe
12
12
  # Current version of the gem (changed by +.rultor.yml+ on every release)
13
- VERSION = '0.8.0' unless const_defined?(:VERSION)
13
+ VERSION = '0.8.1' unless const_defined?(:VERSION)
14
14
  end
@@ -51,6 +51,28 @@ class TestOcto < Fbe::Test
51
51
  assert_equal(100, o.rate_limit.remaining)
52
52
  end
53
53
 
54
+ def test_reads_nickname_by_id
55
+ WebMock.disable_net_connect!
56
+ global = {}
57
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
58
+ stub_request(:get, 'https://api.github.com/user/42').to_return(
59
+ body: { login: 'Dude56' }.to_json, headers: { 'Content-Type': 'application/json' }
60
+ )
61
+ nick = o.user_name_by_id(42)
62
+ assert_equal('dude56', nick)
63
+ end
64
+
65
+ def test_reads_repo_name_by_id
66
+ WebMock.disable_net_connect!
67
+ global = {}
68
+ o = Fbe.octo(loog: Loog::NULL, global:, options: Judges::Options.new)
69
+ stub_request(:get, 'https://api.github.com/repositories/42').to_return(
70
+ body: { full_name: 'Foo/bar56-Ff' }.to_json, headers: { 'Content-Type': 'application/json' }
71
+ )
72
+ nick = o.repo_name_by_id(42)
73
+ assert_equal('foo/bar56-ff', nick)
74
+ end
75
+
54
76
  def test_caching
55
77
  WebMock.disable_net_connect!
56
78
  global = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko