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 +4 -4
- data/lib/fbe/octo.rb +7 -2
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_octo.rb +22 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3828337a178cb00363cfde7328b72d719e412861b1faeedeacbfa90ecdf55f01
|
4
|
+
data.tar.gz: 13e04faef8302ce164266d19cf5b54d9876376500c113a692467c30bde96345e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/test/fbe/test_octo.rb
CHANGED
@@ -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 = {}
|