git-trend 1.4.2 → 1.4.3

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.
@@ -1,405 +0,0 @@
1
- require "git_trend/scraper"
2
-
3
- RSpec.describe GitTrend::CLI do
4
- shared_examples "since daily ranking" do |since|
5
- it "display daily ranking" do
6
- expect { cli.invoke(:list, [], since: since, description: false) }.to output(dummy_result_without_description).to_stdout
7
- end
8
- end
9
-
10
- shared_examples "since weekly ranking" do |since|
11
- it "display weekly ranking" do
12
- expect { cli.invoke(:list, [], since: since, description: false) }.to output(dummy_weekly_result).to_stdout
13
- end
14
- end
15
-
16
- shared_examples "since monthly ranking" do |since|
17
- it "display monthly ranking" do
18
- expect { cli.invoke(:list, [], since: since, description: false) }.to output(dummy_monthly_result).to_stdout
19
- end
20
- end
21
-
22
- describe "#list" do
23
- let(:cli) { described_class.new }
24
-
25
- describe "with -n option" do
26
- context "with 3" do
27
- before { stub_request_get("trending") }
28
-
29
- let(:number) { 3 }
30
-
31
- it "display top 3 daily ranking" do
32
- res = <<-OUTPUT.unindent
33
- |No. Name Lang Star
34
- |--- ---------------------------------------- ---------------- ------
35
- | 1 linexjlin/GPTs 445
36
- | 2 ml-explore/mlx-examples Python 161
37
- | 3 PRIS-CV/DemoFusion Jupyter Notebook 169
38
-
39
- OUTPUT
40
- expect { cli.invoke(:list, [], number: number, description: false) }.to output(res).to_stdout
41
- end
42
- end
43
-
44
- context "with over 25" do
45
- before { stub_request_get("trending") }
46
-
47
- let(:number) { 26 }
48
-
49
- it "display daily ranking" do
50
- expect { cli.invoke(:list, [], number: number, description: false) }.to output(dummy_result_without_description).to_stdout
51
- end
52
- end
53
- end
54
-
55
- describe "with -l option" do
56
- context "with ruby" do
57
- before { stub_request_get("trending/#{language}") }
58
-
59
- let(:language) { "ruby" }
60
-
61
- it "display daily ranking by language" do
62
- res = <<-OUTPUT.unindent
63
- |No. Name Lang Star
64
- |--- ---------------------------------------- ---------- ------
65
- | 1 greatghoul/remote-working Ruby 34
66
- | 2 huginn/huginn Ruby 13
67
- | 3 jekyll/jekyll Ruby 11
68
- | 4 fastlane/fastlane Ruby 6
69
- | 5 rapid7/metasploit-framework Ruby 8
70
- | 6 ankane/pghero Ruby 16
71
- | 7 joemasilotti/daily-log Ruby 7
72
- | 8 hashicorp/vagrant Ruby 5
73
- | 9 fluent/fluentd Ruby 5
74
- | 10 rubygems/rubygems Ruby 1
75
- | 11 otwcode/otwarchive Ruby 2
76
- | 12 freeCodeCamp/devdocs Ruby 5
77
- | 13 gitlabhq/gitlabhq Ruby 1
78
- | 14 gollum/gollum Ruby 2
79
- | 15 ruby/ruby Ruby 2
80
- | 16 TheOdinProject/theodinproject Ruby 6
81
- | 17 wpscanteam/wpscan Ruby 0
82
- | 18 mastodon/mastodon Ruby 12
83
- | 19 github/explore Ruby 0
84
- | 20 tradingview/charting-library-examples Ruby 0
85
- | 21 jwt/ruby-jwt Ruby 0
86
- | 22 forem/forem Ruby 4
87
- | 23 urbanadventurer/WhatWeb Ruby 3
88
- | 24 chef/chef Ruby 0
89
- | 25 instructure/canvas-lms Ruby 0
90
-
91
- OUTPUT
92
- expect { cli.invoke(:list, [], language: language, description: false) }.to output(res).to_stdout
93
- end
94
- end
95
-
96
- context "with alloy : when trending is nothing" do
97
- before { stub_request_get("trending/#{language}") }
98
-
99
- let(:language) { "alloy" }
100
-
101
- it "display the 0cases message" do
102
- res = <<-OUTPUT.unindent
103
- |It looks like we don’t have any trending repositories.
104
-
105
- OUTPUT
106
- expect { cli.invoke(:list, [], language: language, description: false) }.to output(res).to_stdout
107
- end
108
- end
109
- end
110
-
111
- describe "with -s option" do
112
- context "with no option" do
113
- before { stub_request_get("trending?since=") }
114
-
115
- it_behaves_like "since daily ranking", ""
116
- end
117
-
118
- describe "since daily" do
119
- before { stub_request_get("trending?since=daily") }
120
-
121
- context "with d" do
122
- it_behaves_like "since daily ranking", "d"
123
- end
124
-
125
- context "with day" do
126
- it_behaves_like "since daily ranking", "day"
127
- end
128
-
129
- context "with daily" do
130
- it_behaves_like "since daily ranking", "daily"
131
- end
132
- end
133
-
134
- describe "since weekly" do
135
- before { stub_request_get("trending?since=weekly") }
136
-
137
- context "with w" do
138
- it_behaves_like "since weekly ranking", "w"
139
- end
140
-
141
- context "with week" do
142
- it_behaves_like "since weekly ranking", "week"
143
- end
144
-
145
- context "with weekly" do
146
- it_behaves_like "since weekly ranking", "weekly"
147
- end
148
- end
149
-
150
- describe "since monthly" do
151
- before { stub_request_get("trending?since=monthly") }
152
-
153
- context "with m" do
154
- it_behaves_like "since monthly ranking", "m"
155
- end
156
-
157
- context "with month" do
158
- it_behaves_like "since monthly ranking", "month"
159
- end
160
-
161
- context "with monthly" do
162
- it_behaves_like "since monthly ranking", "monthly"
163
- end
164
- end
165
- end
166
-
167
- describe "with -d option (or with no option)" do
168
- after do
169
- ENV["COLUMNS"] = nil
170
- ENV["LINES"] = nil
171
- end
172
-
173
- before do
174
- stub_request_get("trending")
175
- ENV["COLUMNS"] = "140"
176
- ENV["LINES"] = "40"
177
- end
178
-
179
- context "with no option" do
180
- it "display daily ranking" do
181
- expect { cli.invoke(:list, []) }.to output(dummy_result_no_options).to_stdout
182
- end
183
- end
184
-
185
- context "terminal width is enough" do
186
- it "display daily ranking with description" do
187
- expect { cli.invoke(:list, [], description: true) }.to output(dummy_result_no_options).to_stdout
188
- end
189
- end
190
-
191
- context "terminal width is tiny" do
192
- before do
193
- ENV["COLUMNS"] = "83" # it is not enough for description.
194
- ENV["LINES"] = "40"
195
- end
196
-
197
- it "display daily ranking about the same as no option" do
198
- expect { cli.invoke(:list, [], description: false) }.to output(dummy_result_without_description).to_stdout
199
- end
200
- end
201
- end
202
-
203
- describe "with -l and -s option" do
204
- context "with ruby and weekly" do
205
- before { stub_request_get("trending/#{language}?since=#{since}") }
206
-
207
- let(:language) { "ruby" }
208
- let(:since) { "weekly" }
209
-
210
- it "display weekly ranking by language" do
211
- res = <<-OUTPUT.unindent
212
- |No. Name Lang Star
213
- |--- ---------------------------------------- ---------- ------
214
- | 1 mastodon/mastodon Ruby 115
215
- | 2 community/community Ruby 25
216
- | 3 freeCodeCamp/devdocs Ruby 65
217
- | 4 rapid7/metasploit-framework Ruby 84
218
- | 5 github-linguist/linguist Ruby 14
219
- | 6 ankane/pghero Ruby 32
220
- | 7 chatwoot/chatwoot Ruby 59
221
- | 8 department-of-veterans-affairs/vets-api Ruby 2
222
- | 9 ekylibre/ekylibre Ruby 21
223
- | 10 mileszs/wicked_pdf Ruby 5
224
- | 11 elastic/elasticsearch-rails Ruby 2
225
- | 12 heartcombo/devise Ruby 16
226
- | 13 aws/aws-sdk-ruby Ruby 2
227
- | 14 endoflife-date/endoflife.date Ruby 19
228
- | 15 jekyll/jekyll Ruby 50
229
- | 16 heartcombo/simple_form Ruby 6
230
- | 17 thoughtbot/shoulda-matchers Ruby 5
231
- | 18 spree/spree Ruby 13
232
- | 19 solidusio/solidus Ruby 8
233
- | 20 huginn/huginn Ruby 67
234
- | 21 CanCanCommunity/cancancan Ruby 2
235
- | 22 tradingview/charting-library-examples Ruby 3
236
- | 23 kaminari/kaminari Ruby 5
237
- | 24 rubocop/rubocop Ruby 10
238
- | 25 paper-trail-gem/paper_trail Ruby 3
239
-
240
- OUTPUT
241
- expect { cli.invoke(:list, [], language: language, since: since, description: false) }.to output(res).to_stdout
242
- end
243
- end
244
- end
245
- end
246
-
247
- describe "#languages" do
248
- before { stub_request_get("trending") }
249
-
250
- let(:cli) { described_class.new }
251
-
252
- context "with no option" do
253
- it "display languages" do
254
- expect { cli.languages }.to output(include("C++", "HTML", "Ruby")).to_stdout
255
- end
256
- end
257
- end
258
-
259
- private
260
-
261
- def stub_request_get(stub_url_path, stub_file_name = nil)
262
- url = GitTrend::Scraper::BASE_HOST.dup
263
- url << "/#{stub_url_path}" if stub_url_path
264
- uri = URI.parse(url)
265
- stub_file = stub_file_name || stub_url_path
266
- stub_request(:get, uri)
267
- .to_return(
268
- status: 200,
269
- headers: { content_type: "text/html" },
270
- body: load_http_stub(stub_file)
271
- )
272
- end
273
-
274
- def dummy_result_without_description
275
- <<-OUTPUT.unindent
276
- |No. Name Lang Star
277
- |--- ------------------------------------------ ---------------- ------
278
- | 1 linexjlin/GPTs 445
279
- | 2 ml-explore/mlx-examples Python 161
280
- | 3 PRIS-CV/DemoFusion Jupyter Notebook 169
281
- | 4 jmpoep/vmprotect-3.5.1 C++ 489
282
- | 5 prasanthrangan/hyprdots Shell 21
283
- | 6 MichaelYuhe/ai-group-tabs TypeScript 230
284
- | 7 mli/paper-reading 129
285
- | 8 SuperDuperDB/superduperdb Python 497
286
- | 9 ByteByteGoHq/system-design-101 268
287
- | 10 yformer/EfficientSAM Jupyter Notebook 117
288
- | 11 xuchengsheng/spring-reading Java 413
289
- | 12 Flode-Labs/vid2densepose Python 164
290
- | 13 huggingface/optimum-nvidia Python 133
291
- | 14 sweepai/sweep Python 55
292
- | 15 practical-tutorials/project-based-learning 2058
293
- | 16 home-assistant/core Python 33
294
- | 17 100xdevs-cohort-2/assignments JavaScript 117
295
- | 18 kgrzybek/modular-monolith-with-ddd C# 21
296
- | 19 rmcelreath/stat_rethinking_2024 R 41
297
- | 20 jackfrued/Python-100-Days Python 192
298
- | 21 01-ai/Yi Python 18
299
- | 22 facebookresearch/Pearl Python 95
300
- | 23 zzzgydi/clash-verge TypeScript 31
301
- | 24 ytdl-org/youtube-dl Python 24
302
- | 25 dunglas/frankenphp Go 53
303
-
304
- OUTPUT
305
- end
306
-
307
- def dummy_result_no_options
308
- <<-OUTPUT.unindent
309
- |No. Name Lang Star Description
310
- |--- ------------------------------------------ ---------------- ------ ---------------------------------------------------------------------
311
- | 1 linexjlin/GPTs 445 leaked prompts of GPTs
312
- | 2 ml-explore/mlx-examples Python 161 Examples in the MLX framework
313
- | 3 PRIS-CV/DemoFusion Jupyter Notebook 169 Let us democratise high-resolution generation! (arXiv 2023)
314
- | 4 jmpoep/vmprotect-3.5.1 C++ 489
315
- | 5 prasanthrangan/hyprdots Shell 21 // Aesthetic, dynamic and minimal dots for Arch hyprland
316
- | 6 MichaelYuhe/ai-group-tabs TypeScript 230 A Chrome extension helps you group your tabs with AI.
317
- | 7 mli/paper-reading 129 深度学习经典、新论文逐段精读
318
- | 8 SuperDuperDB/superduperdb Python 497 🔮 SuperDuperDB: Bring AI to your database: Integrate, train and m...
319
- | 9 ByteByteGoHq/system-design-101 268 Explain complex systems using visuals and simple terms. Help you p...
320
- | 10 yformer/EfficientSAM Jupyter Notebook 117 EfficientSAM: Leveraged Masked Image Pretraining for Efficient Seg...
321
- | 11 xuchengsheng/spring-reading Java 413 涵盖了 Spring 框架的核心概念和关键功能,包括控制反转(IOC)容器的...
322
- | 12 Flode-Labs/vid2densepose Python 164 Convert your videos to densepose and use it on MagicAnimate
323
- | 13 huggingface/optimum-nvidia Python 133
324
- | 14 sweepai/sweep Python 55 Sweep: AI-powered Junior Developer for small features and bug fixes.
325
- | 15 practical-tutorials/project-based-learning 2058 Curated list of project-based tutorials
326
- | 16 home-assistant/core Python 33 🏡 Open source home automation that puts local control and privacy...
327
- | 17 100xdevs-cohort-2/assignments JavaScript 117
328
- | 18 kgrzybek/modular-monolith-with-ddd C# 21 Full Modular Monolith application with Domain-Driven Design approach.
329
- | 19 rmcelreath/stat_rethinking_2024 R 41
330
- | 20 jackfrued/Python-100-Days Python 192 Python - 100天从新手到大师
331
- | 21 01-ai/Yi Python 18 A series of large language models trained from scratch by develope...
332
- | 22 facebookresearch/Pearl Python 95 A Production-ready Reinforcement Learning AI Agent Library brought...
333
- | 23 zzzgydi/clash-verge TypeScript 31 A Clash GUI based on tauri. Supports Windows, macOS and Linux.
334
- | 24 ytdl-org/youtube-dl Python 24 Command-line program to download videos from YouTube.com and other...
335
- | 25 dunglas/frankenphp Go 53 The modern PHP app server
336
-
337
- OUTPUT
338
- end
339
-
340
- def dummy_weekly_result
341
- <<-OUTPUT.unindent
342
- |No. Name Lang Star
343
- |--- ------------------------------------------ ---------------- ------
344
- | 1 LC044/WeChatMsg Python 10719
345
- | 2 microsoft/TaskWeaver Python 1957
346
- | 3 facebookresearch/seamless_communication C 1568
347
- | 4 lllyasviel/Fooocus Python 3406
348
- | 5 sherlock-project/sherlock Python 996
349
- | 6 pytorch-labs/gpt-fast Python 2147
350
- | 7 comfyanonymous/ComfyUI Python 1518
351
- | 8 VikParuchuri/marker Python 1497
352
- | 9 xuchengsheng/spring-reading Java 637
353
- | 10 Mozilla-Ocho/llamafile C++ 1833
354
- | 11 go-gost/gost Go 487
355
- | 12 microsoft/PowerToys C# 905
356
- | 13 songquanpeng/one-api Go 323
357
- | 14 nocodb/nocodb TypeScript 392
358
- | 15 AleoHQ/leo Rust 744
359
- | 16 modularml/mojo Jupyter Notebook 386
360
- | 17 gkd-kit/gkd Kotlin 1272
361
- | 18 danny-avila/LibreChat TypeScript 647
362
- | 19 practical-tutorials/project-based-learning 1670
363
- | 20 pocketbase/pocketbase Go 457
364
- | 21 symfony/symfony PHP 35
365
- | 22 awesome-selfhosted/awesome-selfhosted 2239
366
- | 23 upscayl/upscayl TypeScript 266
367
- | 24 coolsnowwolf/lede C 132
368
- | 25 QwenLM/Qwen Python 377
369
-
370
- OUTPUT
371
- end
372
-
373
- def dummy_monthly_result
374
- <<-OUTPUT.unindent
375
- |No. Name Lang Star
376
- |--- ---------------------------------------- ---------------- ------
377
- | 1 SawyerHood/draw-a-ui TypeScript 11761
378
- | 2 Stability-AI/generative-models Python 7286
379
- | 3 microsoft/ML-For-Beginners HTML 9252
380
- | 4 microsoft/generative-ai-for-beginners Jupyter Notebook 15174
381
- | 5 lllyasviel/Fooocus Python 10023
382
- | 6 langchain-ai/opengpts Rich Text Format 3978
383
- | 7 facebookresearch/seamless_communication C 2607
384
- | 8 microsoft/AI-For-Beginners Jupyter Notebook 5708
385
- | 9 tldraw/tldraw TypeScript 6750
386
- | 10 atomicals/atomicals-js TypeScript 627
387
- | 11 githubnext/monaspace TypeScript 9912
388
- | 12 udlbook/udlbook Jupyter Notebook 1551
389
- | 13 comfyanonymous/ComfyUI Python 4197
390
- | 14 langgenius/dify TypeScript 2906
391
- | 15 lobehub/lobe-chat TypeScript 2622
392
- | 16 luosiallen/latent-consistency-model Python 2706
393
- | 17 daveshap/OpenAI_Agent_Swarm Python 2310
394
- | 18 chenzomi12/DeepLearningSystem Jupyter Notebook 1760
395
- | 19 biomejs/biome Rust 2372
396
- | 20 openai/openai-python Python 2811
397
- | 21 AppFlowy-IO/AppFlowy Dart 3071
398
- | 22 saadeghi/daisyui Svelte 1773
399
- | 23 nlohmann/json C++ 1080
400
- | 24 SillyTavern/SillyTavern JavaScript 1566
401
- | 25 1Panel-dev/1Panel Go 1950
402
-
403
- OUTPUT
404
- end
405
- end
@@ -1,36 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.shared_examples_for "without_options" do |examples|
4
- examples.each do |example|
5
- input = example[:inputs]
6
- it "#{example[:object].inspect}.mb_truncate(#{input}) should return #{example[:expected].inspect}" do
7
- expect(example[:object].send(:mb_truncate, input)).to eq example[:expected]
8
- end
9
- end
10
- end
11
-
12
- RSpec.describe String do
13
- describe "#mb_truncate" do
14
- context "ascii strings" do
15
- examples = [
16
- { object: "abc", inputs: 2, expected: "..." },
17
- { object: "abc", inputs: 3, expected: "abc" },
18
- { object: "abcde", inputs: 3, expected: "..." },
19
- { object: "abcde", inputs: 4, expected: "a..." },
20
- { object: "abcde", inputs: 5, expected: "abcde" },
21
- ]
22
- it_behaves_like "without_options", examples
23
- end
24
-
25
- context "multi-bytes strings" do
26
- examples = [
27
- { object: "あいう", inputs: 2, expected: "..." },
28
- { object: "あいう", inputs: 3, expected: "..." },
29
- { object: "あいう", inputs: 4, expected: "..." },
30
- { object: "あいう", inputs: 5, expected: "あ..." },
31
- { object: "あいう", inputs: 6, expected: "あいう" },
32
- ]
33
- it_behaves_like "without_options", examples
34
- end
35
- end
36
- end
@@ -1,39 +0,0 @@
1
- include GitTrend # rubocop:disable Style/MixinUsage
2
-
3
- RSpec.describe GitTrend::Scraper do
4
- let(:scraper) { Scraper.new }
5
-
6
- describe "settings" do
7
- subject { scraper.instance_variable_get(:@agent) }
8
-
9
- before do
10
- allow(ENV).to receive(:[]).with("http_proxy").and_return("http://#{proxy_user}:#{proxy_pass}@#{proxy_addr}:#{proxy_port}")
11
- end
12
-
13
- let(:proxy_addr) { "192.168.1.99" }
14
- let(:proxy_port) { 9999 }
15
- let(:proxy_user) { "proxy_user" }
16
- let(:proxy_pass) { "proxy_pass" }
17
-
18
- it "uses proxy settings of ENV" do
19
- aggregate_failures do
20
- expect(subject.proxy_addr).to eq proxy_addr
21
- expect(subject.proxy_user).to eq proxy_user
22
- expect(subject.proxy_pass).to eq proxy_pass
23
- expect(subject.proxy_port).to eq proxy_port
24
- expect(subject.user_agent).to eq "git-trend #{VERSION}"
25
- end
26
- end
27
- end
28
-
29
- describe "#get" do
30
- context "when a network error occurred" do
31
- before do
32
- stub_request(:get, Scraper::BASE_URL)
33
- .to_return(status: 500, body: "[]")
34
- end
35
-
36
- it { expect { scraper.get }.to raise_error(Exception) }
37
- end
38
- end
39
- end
@@ -1,99 +0,0 @@
1
- RSpec.describe GitTrend do
2
- include described_class
3
-
4
- let(:scraper_mock) { instance_double(Scraper) }
5
-
6
- before do
7
- allow(Scraper).to receive(:new).and_return(scraper_mock)
8
- stub_request(:get, /.*/)
9
- .to_return(status: 200, headers: { content_type: "text/html" }, body: load_http_stub("trending"))
10
- end
11
-
12
- describe "#get" do
13
- context "normal" do
14
- before do
15
- allow(scraper_mock).to receive(:get)
16
- end
17
-
18
- context "without options" do
19
- it "Scraper#get call without options" do
20
- described_class.get
21
- expect(scraper_mock).to have_received(:get).with(no_args)
22
- end
23
- end
24
-
25
- context "parameter is 'ruby'" do
26
- it "Scraper#get call with 'ruby'" do
27
- described_class.get("ruby")
28
- expect(scraper_mock).to have_received(:get).with("ruby")
29
- end
30
- end
31
-
32
- context "parameter is :ruby" do
33
- it "Scraper#get call with :ruby" do
34
- described_class.get(:ruby)
35
- expect(scraper_mock).to have_received(:get).with(:ruby)
36
- end
37
- end
38
-
39
- context "parameter is since: :weekly" do
40
- it "Scraper#get call with [nil, :weekly]" do
41
- described_class.get(since: :weekly)
42
- expect(scraper_mock).to have_received(:get).with(nil, :weekly)
43
- end
44
- end
45
-
46
- context "parameter is since: :week" do
47
- it "Scraper#get call with [nil, :week]" do
48
- described_class.get(since: :week)
49
- expect(scraper_mock).to have_received(:get).with(nil, :week)
50
- end
51
- end
52
-
53
- context "parameter is since: :w" do
54
- it "Scraper#get call with [nil, :w]" do
55
- described_class.get(since: :w)
56
- expect(scraper_mock).to have_received(:get).with(nil, :w)
57
- end
58
- end
59
-
60
- context "parameters are 'ruby', 'weekly'" do
61
- it "Scraper#get call with ['ruby', 'weekly']" do
62
- described_class.get("ruby", "weekly")
63
- expect(scraper_mock).to have_received(:get).with("ruby", "weekly")
64
- end
65
- end
66
-
67
- context "parameters are :ruby, :weekly" do
68
- it "Scraper#get call with [:ruby, :weekly]" do
69
- described_class.get(:ruby, :weekly)
70
- expect(scraper_mock).to have_received(:get).with(:ruby, :weekly)
71
- end
72
- end
73
-
74
- context "parameters are language: :ruby, since: :weekly" do
75
- it "Scraper#get call with [:ruby, :weekly]" do
76
- described_class.get(language: :ruby, since: :weekly)
77
- expect(scraper_mock).to have_received(:get).with(:ruby, :weekly)
78
- end
79
- end
80
- end
81
-
82
- context "abnormal" do
83
- context "when too many parameters" do
84
- it { expect { described_class.get("ruby", "weekly", "many_params") }.to raise_error(Exception) }
85
- end
86
- end
87
-
88
- describe "#languages" do
89
- before do
90
- allow(scraper_mock).to receive(:languages)
91
- end
92
-
93
- it "Scraper#languages call" do
94
- described_class.languages
95
- expect(scraper_mock).to have_received(:languages).with(no_args)
96
- end
97
- end
98
- end
99
- end