fbe 0.0.15 → 0.0.17

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: c5ea827d19e33c1c0ad518ddbb0d72d258e3dadddbff602160239f24484404e7
4
- data.tar.gz: 120705aa037a3b913df3e2bf71345866d1116c613289ae18bad45a00e4cd12c2
3
+ metadata.gz: e857aa5ed166b003997aaafddd6e7c5cf523451321b4f3fe1597ef35228b7063
4
+ data.tar.gz: bb2b3e7aa0d3a210d131618d7b444d842f4b36bdc7512aacbef429f43db024c4
5
5
  SHA512:
6
- metadata.gz: e67f7173ede47f85219145b238557ee902a9c9bad68eb3282fb6ca6b05988cda85c12c645204f1687637edd48aea575e579e6ca07977f731bb62319e1b2f992c
7
- data.tar.gz: da98195d8f36a36625da70cf38a0f5342d62e09da6ee40fef291e22ccf02f29487462bdda5e212aaa6fd4855ca6ddde1ea1abf9bee84ab3693a839013f844824
6
+ metadata.gz: 4e96e84f8eba6d37456832150df00956fa456eb348f044e30714e64fb5eafd2a484eeb30f0ae90e3dd9a4ae64d5a04d55ed5b830940e3b3b0425c0a29459714d
7
+ data.tar.gz: 576278b551ac1b748526fe57b2465d176ab91208d1bcaab7eb761b1b59ceaed1d05ea818536b0b0acab581a9fb293d80e79b5383194891399c7d51f013e4bbe1
data/Gemfile CHANGED
@@ -24,7 +24,7 @@ source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
26
  gem 'minitest', '5.24.1', require: false
27
- gem 'minitest-reporters', '1.6.1', require: false
27
+ gem 'minitest-reporters', '1.7.1', require: false
28
28
  gem 'rake', '13.2.1', require: false
29
29
  gem 'rspec-rails', '6.1.3', require: false
30
30
  gem 'rubocop', '1.65.0', require: false
data/Gemfile.lock CHANGED
@@ -116,7 +116,7 @@ GEM
116
116
  nokogiri (>= 1.12.0)
117
117
  loog (0.5.2)
118
118
  minitest (5.24.1)
119
- minitest-reporters (1.6.1)
119
+ minitest-reporters (1.7.1)
120
120
  ansi
121
121
  builder
122
122
  minitest (>= 5.0)
@@ -255,7 +255,7 @@ PLATFORMS
255
255
  DEPENDENCIES
256
256
  fbe!
257
257
  minitest (= 5.24.1)
258
- minitest-reporters (= 1.6.1)
258
+ minitest-reporters (= 1.7.1)
259
259
  rake (= 13.2.1)
260
260
  rspec-rails (= 6.1.3)
261
261
  rubocop (= 1.65.0)
data/lib/fbe/issue.rb ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require_relative '../fbe'
26
+
27
+ def Fbe.issue(fact, options: $options, global: $global, loog: $loog)
28
+ "#{Fbe.octo(global:, options:, loog:).repo_name_by_id(fact.repository)}##{fact.issue}"
29
+ end
data/lib/fbe/octo.rb CHANGED
@@ -124,11 +124,8 @@ class Fbe::FakeOctokit
124
124
 
125
125
  def repositories(_user = nil)
126
126
  [
127
- {
128
- name: 'judges',
129
- full_name: 'yegor256/judges',
130
- id: 444
131
- }
127
+ repository('yegor256/judges'),
128
+ repository('yegor256/factbase')
132
129
  ]
133
130
  end
134
131
 
@@ -143,7 +140,38 @@ class Fbe::FakeOctokit
143
140
  def repository(name)
144
141
  {
145
142
  id: name_to_number(name),
146
- full_name: name.is_a?(Integer) ? 'yegor256/test' : name
143
+ full_name: name.is_a?(Integer) ? 'yegor256/test' : name,
144
+ default_branch: 'master',
145
+ private: false,
146
+ owner: { login: name.to_s.split('/')[0], id: 526_301, site_admin: false },
147
+ html_url: "https://github.com/#{name}",
148
+ description: 'something',
149
+ fork: false,
150
+ url: "https://github.com/#{name}",
151
+ created_at: random_time,
152
+ updated_at: random_time,
153
+ pushed_at: random_time,
154
+ size: 470,
155
+ stargazers_count: 1,
156
+ watchers_count: 1,
157
+ language: 'Ruby',
158
+ has_issues: true,
159
+ has_projects: true,
160
+ has_downloads: true,
161
+ has_wiki: true,
162
+ has_pages: false,
163
+ has_discussions: false,
164
+ forks_count: 0,
165
+ archived: false,
166
+ disabled: false,
167
+ open_issues_count: 6,
168
+ license: { key: 'mit', name: 'MIT License' },
169
+ allow_forking: true,
170
+ is_template: false,
171
+ visibility: 'public',
172
+ forks: 0,
173
+ open_issues: 6,
174
+ watchers: 1
147
175
  }
148
176
  end
149
177
 
@@ -171,6 +199,7 @@ class Fbe::FakeOctokit
171
199
  def issue_timeline(_repo, _issue, _options = {})
172
200
  [
173
201
  {
202
+ event: 'renamed',
174
203
  actor: {
175
204
  id: 888,
176
205
  login: 'torvalds'
@@ -179,7 +208,6 @@ class Fbe::FakeOctokit
179
208
  id: name_to_number('yegor256/judges'),
180
209
  full_name: 'yegor256/judges'
181
210
  },
182
- event: 'renamed',
183
211
  rename: {
184
212
  from: 'before',
185
213
  to: 'after'
@@ -187,6 +215,7 @@ class Fbe::FakeOctokit
187
215
  created_at: random_time
188
216
  },
189
217
  {
218
+ event: 'labeled',
190
219
  actor: {
191
220
  id: 888,
192
221
  login: 'torvalds'
@@ -195,7 +224,6 @@ class Fbe::FakeOctokit
195
224
  id: name_to_number('yegor256/judges'),
196
225
  full_name: 'yegor256/judges'
197
226
  },
198
- event: 'labeled',
199
227
  label: {
200
228
  name: 'bug'
201
229
  },
@@ -208,27 +236,36 @@ class Fbe::FakeOctokit
208
236
  [
209
237
  {
210
238
  id: '123',
239
+ type: 'PushEvent',
211
240
  repo: {
212
241
  id: name_to_number(repo),
213
- name: repo
242
+ name: repo,
243
+ url: "https://api.github.com/repos/#{repo}"
214
244
  },
215
- type: 'PushEvent',
216
245
  payload: {
217
- push_id: 42
246
+ push_id: 42,
247
+ ref: 'refs/heads/master',
248
+ size: 1,
249
+ distinct_size: 0,
250
+ head: 'b7089c51cc2526a0d2619d35379f921d53c72731',
251
+ before: '12d3bff1a55bad50ee2e8f29ade7f1c1e07bb025'
218
252
  },
219
253
  actor: {
220
254
  id: 888,
221
- login: 'torvalds'
255
+ login: 'torvalds',
256
+ display_login: 'torvalds'
222
257
  },
223
- created_at: random_time
258
+ created_at: random_time,
259
+ public: true
224
260
  },
225
261
  {
226
262
  id: '124',
263
+ type: 'IssuesEvent',
227
264
  repo: {
228
265
  id: name_to_number(repo),
229
- name: repo
266
+ name: repo,
267
+ url: "https://api.github.com/repos/#{repo}"
230
268
  },
231
- type: 'IssuesEvent',
232
269
  payload: {
233
270
  action: 'closed',
234
271
  issue: {
@@ -237,17 +274,20 @@ class Fbe::FakeOctokit
237
274
  },
238
275
  actor: {
239
276
  id: 888,
240
- login: 'torvalds'
277
+ login: 'torvalds',
278
+ display_login: 'torvalds'
241
279
  },
242
- created_at: random_time
280
+ created_at: random_time,
281
+ public: true
243
282
  },
244
283
  {
245
284
  id: '125',
285
+ type: 'IssuesEvent',
246
286
  repo: {
247
287
  id: name_to_number(repo),
248
- name: repo
288
+ name: repo,
289
+ url: "https://api.github.com/repos/#{repo}"
249
290
  },
250
- type: 'IssuesEvent',
251
291
  payload: {
252
292
  action: 'opened',
253
293
  issue: {
@@ -256,9 +296,11 @@ class Fbe::FakeOctokit
256
296
  },
257
297
  actor: {
258
298
  id: 888,
259
- login: 'torvalds'
299
+ login: 'torvalds',
300
+ display_login: 'torvalds'
260
301
  },
261
- created_at: random_time
302
+ created_at: random_time,
303
+ public: true
262
304
  }
263
305
  ]
264
306
  end
data/lib/fbe/sec.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require_relative '../fbe'
26
+
27
+ def Fbe.sec(fact, prop = :seconds)
28
+ s = fact.send(prop.to_s)
29
+ if s < 60
30
+ format('%d seconds', s)
31
+ elsif s < 60 * 60
32
+ format('%d minutes', s / 60)
33
+ elsif s < 60 * 60 * 24
34
+ format('%d hours', s / (60 * 60))
35
+ else
36
+ format('%d days', s / (60 * 60 * 24))
37
+ end
38
+ end
data/lib/fbe/who.rb ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require_relative '../fbe'
26
+
27
+ def Fbe.who(fact, prop = :who, options: $options, global: $global, loog: $loog)
28
+ "@#{Fbe.octo(options:, global:, loog:).user_name_by_id(fact.send(prop.to_s))}"
29
+ end
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.15'
30
+ VERSION = '0.0.17'
31
31
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'minitest/autorun'
26
+ require 'loog'
27
+ require_relative '../../lib/fbe/issue'
28
+
29
+ # Test.
30
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
+ # Copyright:: Copyright (c) 2024 Zerocracy
32
+ # License:: MIT
33
+ class TestIssue < Minitest::Test
34
+ def test_simple
35
+ fb = Factbase.new
36
+ f = fb.insert
37
+ f.repository = 323
38
+ f.issue = 333
39
+ global = {}
40
+ options = Judges::Options.new({ 'testing' => true })
41
+ assert_equal('yegor256/test#333', Fbe.issue(f, global:, options:, loog: Loog::NULL))
42
+ end
43
+ end
@@ -52,6 +52,7 @@ class TestOcto < Minitest::Test
52
52
  end
53
53
 
54
54
  def test_with_broken_token
55
+ skip # it's a "live" test, run it manually if you need it
55
56
  global = {}
56
57
  options = Judges::Options.new({ 'github_token' => 'incorrect-value' })
57
58
  o = Fbe.octo(loog: Loog::NULL, global:, options:)
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'minitest/autorun'
26
+ require_relative '../../lib/fbe/sec'
27
+
28
+ # Test.
29
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
+ # Copyright:: Copyright (c) 2024 Zerocracy
31
+ # License:: MIT
32
+ class TestSec < Minitest::Test
33
+ def test_simple
34
+ fb = Factbase.new
35
+ f = fb.insert
36
+ f.seconds = 333
37
+ assert_equal('5 minutes', Fbe.sec(f))
38
+ end
39
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # MIT License
4
+ #
5
+ # Copyright (c) 2024 Zerocracy
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'minitest/autorun'
26
+ require 'loog'
27
+ require_relative '../../lib/fbe/who'
28
+
29
+ # Test.
30
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
+ # Copyright:: Copyright (c) 2024 Zerocracy
32
+ # License:: MIT
33
+ class TestWho < Minitest::Test
34
+ def test_simple
35
+ fb = Factbase.new
36
+ f = fb.insert
37
+ f.who = 444
38
+ global = {}
39
+ options = Judges::Options.new({ 'testing' => true })
40
+ assert_equal('@yegor256', Fbe.who(f, global:, options:, loog: Loog::NULL))
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -227,17 +227,23 @@ files:
227
227
  - lib/fbe/conclude.rb
228
228
  - lib/fbe/fb.rb
229
229
  - lib/fbe/if_absent.rb
230
+ - lib/fbe/issue.rb
230
231
  - lib/fbe/iterate.rb
231
232
  - lib/fbe/octo.rb
233
+ - lib/fbe/sec.rb
232
234
  - lib/fbe/unmask_repos.rb
235
+ - lib/fbe/who.rb
233
236
  - renovate.json
234
237
  - rules/basic.fe
235
238
  - test/fbe/test_conclude.rb
236
239
  - test/fbe/test_fb.rb
237
240
  - test/fbe/test_if_absent.rb
241
+ - test/fbe/test_issue.rb
238
242
  - test/fbe/test_iterate.rb
239
243
  - test/fbe/test_octo.rb
244
+ - test/fbe/test_sec.rb
240
245
  - test/fbe/test_unmask_repos.rb
246
+ - test/fbe/test_who.rb
241
247
  - test/test__helper.rb
242
248
  - test/test_fbe.rb
243
249
  homepage: http://github.com/zerocracy/fbe