git-trend 1.4.0 → 1.4.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: e0747b72131e24ecb5c876c337ce33be1941683110562847152189e4ddbb5c72
4
- data.tar.gz: 47412945f045abb2cd8af2d959ca9cb01547649d7904b5eeec0a3791f5476be6
3
+ metadata.gz: 48d85d080f7f9e48254ad02bbdb327ac0e4c811ce2db883a8b6f712119892028
4
+ data.tar.gz: 8f083dfb30dc9af3aefd6c1a33facebbd77cf5704cdd534c867260d84affd829
5
5
  SHA512:
6
- metadata.gz: 8a55d7452c04a64ad860e52e19a9673dedd0ef585b9615e1ad2e385100892540cff76209b807ae81087665436379219c351546f9f05115df006e93783050c09a
7
- data.tar.gz: 041bb27a4b62b0114231b6d0d66cf285ca0dd7b2326d8dee5c3faa31667506960300e7bfb59e05c5e06eb46b81e0c5a14f189ab14a4c3fb466347061a7a9fbe3
6
+ metadata.gz: b4d7b80c1f86a6e8756854c08d86c3047d717438e8fe7a162bf18a7d1f0835604424cf50edf51cfba690778b5be258a1cf9ff8cb2a45daea6ffa4176f0c9b9d8
7
+ data.tar.gz: 1bcae8a943eeeeb5f2185b156cfc7f26e2b5165d84712de3619a199d25c786f4656097e048a74c826fbadfc3721bda74da6d46ca5afbc23c14d9d537c4d7e5e1
@@ -5,65 +5,24 @@ on:
5
5
  pull_request:
6
6
 
7
7
  jobs:
8
- ruby27:
8
+ test:
9
9
  runs-on: ubuntu-latest
10
10
  timeout-minutes: 10
11
+ strategy:
12
+ matrix:
13
+ ruby-version: ['3.2.9', '3.3.9', '3.4.7']
14
+ include:
15
+ - ruby-version: '3.4.7'
16
+ upload-coverage: true
11
17
 
12
18
  steps:
13
19
  - name: Checkout code
14
- uses: actions/checkout@v2
20
+ uses: actions/checkout@v4
15
21
 
16
22
  - name: Setup Ruby
17
23
  uses: ruby/setup-ruby@v1
18
24
  with:
19
- ruby-version: '2.7.5'
20
- bundler-cache: true
21
-
22
- - name: Show ruby version
23
- run: ruby -v
24
-
25
- - name: Run tests
26
- run: bundle exec rspec
27
-
28
- - name: Run lint
29
- run: bundle exec rubocop
30
-
31
-
32
- ruby31:
33
- runs-on: ubuntu-latest
34
- timeout-minutes: 10
35
-
36
- steps:
37
- - name: Checkout code
38
- uses: actions/checkout@v2
39
-
40
- - name: Setup Ruby
41
- uses: ruby/setup-ruby@v1
42
- with:
43
- ruby-version: '3.1.3'
44
- bundler-cache: true
45
-
46
- - name: Show ruby version
47
- run: ruby -v
48
-
49
- - name: Run tests
50
- run: bundle exec rspec
51
-
52
- - name: Run lint
53
- run: bundle exec rubocop
54
-
55
- ruby32:
56
- runs-on: ubuntu-latest
57
- timeout-minutes: 10
58
-
59
- steps:
60
- - name: Checkout code
61
- uses: actions/checkout@v2
62
-
63
- - name: Setup Ruby
64
- uses: ruby/setup-ruby@v1
65
- with:
66
- ruby-version: '3.2.2'
25
+ ruby-version: ${{ matrix.ruby-version }}
67
26
  bundler-cache: true
68
27
 
69
28
  - name: Show ruby version
@@ -76,6 +35,7 @@ jobs:
76
35
  run: bundle exec rubocop
77
36
 
78
37
  - name: Upload coverage reports to Codecov
38
+ if: matrix.upload-coverage
79
39
  uses: codecov/codecov-action@v3
80
40
  with:
81
41
  files: ./coverage/.resultset.json
data/.rubocop.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- require:
3
+ plugins:
4
4
  - rubocop-performance
5
5
  - rubocop-rake
6
6
  - rubocop-rspec
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: 2.7
9
+ TargetRubyVersion: 3.2
10
10
  Exclude:
11
11
  - '**/tmp/**/*'
12
12
  - '**/vendor/**/*'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v1.4.1 (Tue Oct 14 2025)
2
+ - Drop support of Ruby 3.1 and earlier [d2b4080]
3
+
1
4
  ## v1.4.0 (Mon Mar 13 2023)
2
5
 
3
6
  - Drop support of Ruby 2.6 and earlier [41e871e]
data/README.md CHANGED
@@ -7,6 +7,10 @@
7
7
  `git-trend` is a gem that fetches [Trending repositories on GitHub](https://github.com/trending).
8
8
  And this also work as a command line utility.
9
9
 
10
+ ## Buy me a coffee
11
+
12
+ If you can contribute or you want to, feel free to do it at [__Buy me a coffee! :coffee:__](https://www.buymeacoffee.com/rochefort), I will be really thankfull for anything even if it is a coffee or just a kind comment towards my work, because that helps me a lot. Whenever you contribute with a donation, I will read your message and it will be shown in my main site.
13
+
10
14
  # TOC
11
15
  * [Requirements](#requirements)
12
16
  * [Installation](#installation)
@@ -18,7 +22,7 @@ And this also work as a command line utility.
18
22
 
19
23
  ## Requirements
20
24
 
21
- Ruby versions is 2.7 or later.
25
+ Ruby versions is 3.2 or later.
22
26
 
23
27
  ## Installation
24
28
  Add this line to your application's Gemfile:
data/git-trend.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.description = spec.summary
18
18
  spec.homepage = "https://github.com/rochefort/git-trend"
19
19
  spec.license = "MIT"
20
- spec.required_ruby_version = ">= 2.7.0"
20
+ spec.required_ruby_version = ">= 3.2.0"
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0")
23
23
  spec.bindir = "exe"
@@ -27,10 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.post_install_message = install_message
28
28
 
29
29
  spec.add_dependency "addressable", "~> 2.8"
30
- spec.add_dependency "mb_string"
31
- spec.add_dependency "mechanize", ">= 2.8.5", "< 2.10.0"
32
- spec.add_dependency "thor", ">= 0.20.0", "< 1.3.0"
33
- spec.add_dependency "unicode-display_width"
30
+ spec.add_dependency "mechanize", ">= 2.8.5", "< 2.11.0"
31
+ spec.add_dependency "thor", ">= 0.20.0", "< 1.4.0"
34
32
 
33
+ # FIXME: mfa
35
34
  spec.metadata["rubygems_mfa_required"] = "true"
36
35
  end
data/lib/git_trend/cli.rb CHANGED
@@ -35,7 +35,7 @@ module GitTrend
35
35
  formatter.print(projects, enable_description: !!options[:description])
36
36
  rescue => e
37
37
  say "An unexpected #{e.class} has occurred.", :red
38
- say e.message unless e.instance_of?(e.message) # エラー内容がクラス名の場合は表示しない
38
+ say e.message unless e.message == e.class.to_s # エラー内容がクラス名の場合は表示しない
39
39
 
40
40
  puts exception.backtrace if options[:verbose]
41
41
  end
@@ -0,0 +1,27 @@
1
+ class String
2
+ def mb_truncate(truncate_at)
3
+ return self if display_width <= truncate_at
4
+
5
+ ellipsis = "..."
6
+ return ellipsis if truncate_at <= ellipsis.length
7
+
8
+ max_width = truncate_at - ellipsis.length
9
+ result = ""
10
+ current_width = 0
11
+ each_char do |char|
12
+ char_width = char.bytesize == 1 ? 1 : 2
13
+ break if current_width + char_width > max_width
14
+
15
+ result += char
16
+ current_width += char_width
17
+ end
18
+
19
+ "#{result}#{ellipsis}"
20
+ rescue
21
+ self
22
+ end
23
+
24
+ def display_width
25
+ each_char.sum { |char| char.bytesize == 1 ? 1 : 2 }
26
+ end
27
+ end
@@ -1,5 +1,3 @@
1
- require "mb_string"
2
-
3
1
  module GitTrend::Formatters
4
2
  class TextFormatter
5
3
  HEADER_COLUMNS = %w[no. name lang star description].freeze
@@ -1,3 +1,3 @@
1
1
  module GitTrend
2
- VERSION = "1.4.0".freeze
2
+ VERSION = "1.4.1".freeze
3
3
  end
data/lib/git_trend.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "git_trend/cli"
2
+ require "git_trend/core_ext/string"
2
3
  require "git_trend/formatter"
3
4
  require "git_trend/formatters/text_formatter"
4
5
  require "git_trend/formatters/json_formatter"
@@ -1,6 +1,6 @@
1
- RSpec.describe GitTrend::CLI do
2
- include GitTrend
1
+ require "git_trend/scraper"
3
2
 
3
+ RSpec.describe GitTrend::CLI do
4
4
  shared_examples "since daily ranking" do |since|
5
5
  it "display daily ranking" do
6
6
  expect { cli.invoke(:list, [], since: since, description: false) }.to output(dummy_result_without_description).to_stdout
@@ -20,7 +20,7 @@ RSpec.describe GitTrend::CLI do
20
20
  end
21
21
 
22
22
  describe "#list" do
23
- let(:cli) { CLI.new }
23
+ let(:cli) { described_class.new }
24
24
 
25
25
  describe "with -n option" do
26
26
  context "with 3" do
@@ -112,22 +112,22 @@ RSpec.describe GitTrend::CLI do
112
112
  context "with no option" do
113
113
  before { stub_request_get("trending?since=") }
114
114
 
115
- include_examples "since daily ranking", ""
115
+ it_behaves_like "since daily ranking", ""
116
116
  end
117
117
 
118
118
  describe "since daily" do
119
119
  before { stub_request_get("trending?since=daily") }
120
120
 
121
121
  context "with d" do
122
- include_examples "since daily ranking", "d"
122
+ it_behaves_like "since daily ranking", "d"
123
123
  end
124
124
 
125
125
  context "with day" do
126
- include_examples "since daily ranking", "day"
126
+ it_behaves_like "since daily ranking", "day"
127
127
  end
128
128
 
129
129
  context "with daily" do
130
- include_examples "since daily ranking", "daily"
130
+ it_behaves_like "since daily ranking", "daily"
131
131
  end
132
132
  end
133
133
 
@@ -135,15 +135,15 @@ RSpec.describe GitTrend::CLI do
135
135
  before { stub_request_get("trending?since=weekly") }
136
136
 
137
137
  context "with w" do
138
- include_examples "since weekly ranking", "w"
138
+ it_behaves_like "since weekly ranking", "w"
139
139
  end
140
140
 
141
141
  context "with week" do
142
- include_examples "since weekly ranking", "week"
142
+ it_behaves_like "since weekly ranking", "week"
143
143
  end
144
144
 
145
145
  context "with weekly" do
146
- include_examples "since weekly ranking", "weekly"
146
+ it_behaves_like "since weekly ranking", "weekly"
147
147
  end
148
148
  end
149
149
 
@@ -151,15 +151,15 @@ RSpec.describe GitTrend::CLI do
151
151
  before { stub_request_get("trending?since=monthly") }
152
152
 
153
153
  context "with m" do
154
- include_examples "since monthly ranking", "m"
154
+ it_behaves_like "since monthly ranking", "m"
155
155
  end
156
156
 
157
157
  context "with month" do
158
- include_examples "since monthly ranking", "month"
158
+ it_behaves_like "since monthly ranking", "month"
159
159
  end
160
160
 
161
161
  context "with monthly" do
162
- include_examples "since monthly ranking", "monthly"
162
+ it_behaves_like "since monthly ranking", "monthly"
163
163
  end
164
164
  end
165
165
  end
@@ -247,7 +247,7 @@ RSpec.describe GitTrend::CLI do
247
247
  describe "#languages" do
248
248
  before { stub_request_get("trending") }
249
249
 
250
- let(:cli) { CLI.new }
250
+ let(:cli) { described_class.new }
251
251
 
252
252
  context "with no option" do
253
253
  it "display languages" do
@@ -259,7 +259,7 @@ RSpec.describe GitTrend::CLI do
259
259
  private
260
260
 
261
261
  def stub_request_get(stub_url_path, stub_file_name = nil)
262
- url = Scraper::BASE_HOST.dup
262
+ url = GitTrend::Scraper::BASE_HOST.dup
263
263
  url << "/#{stub_url_path}" if stub_url_path
264
264
  uri = URI.parse(url)
265
265
  stub_file = stub_file_name || stub_url_path
@@ -0,0 +1,36 @@
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,4 +1,5 @@
1
1
  include GitTrend # rubocop:disable Style/MixinUsage
2
+
2
3
  RSpec.describe GitTrend::Scraper do
3
4
  let(:scraper) { Scraper.new }
4
5
 
@@ -1,5 +1,6 @@
1
1
  RSpec.describe GitTrend do
2
2
  include described_class
3
+
3
4
  let(:scraper_mock) { instance_double(Scraper) }
4
5
 
5
6
  before do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-trend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rochefort
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: addressable
@@ -24,20 +23,6 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '2.8'
27
- - !ruby/object:Gem::Dependency
28
- name: mb_string
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
26
  - !ruby/object:Gem::Dependency
42
27
  name: mechanize
43
28
  requirement: !ruby/object:Gem::Requirement
@@ -47,7 +32,7 @@ dependencies:
47
32
  version: 2.8.5
48
33
  - - "<"
49
34
  - !ruby/object:Gem::Version
50
- version: 2.10.0
35
+ version: 2.11.0
51
36
  type: :runtime
52
37
  prerelease: false
53
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +42,7 @@ dependencies:
57
42
  version: 2.8.5
58
43
  - - "<"
59
44
  - !ruby/object:Gem::Version
60
- version: 2.10.0
45
+ version: 2.11.0
61
46
  - !ruby/object:Gem::Dependency
62
47
  name: thor
63
48
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +52,7 @@ dependencies:
67
52
  version: 0.20.0
68
53
  - - "<"
69
54
  - !ruby/object:Gem::Version
70
- version: 1.3.0
55
+ version: 1.4.0
71
56
  type: :runtime
72
57
  prerelease: false
73
58
  version_requirements: !ruby/object:Gem::Requirement
@@ -77,21 +62,7 @@ dependencies:
77
62
  version: 0.20.0
78
63
  - - "<"
79
64
  - !ruby/object:Gem::Version
80
- version: 1.3.0
81
- - !ruby/object:Gem::Dependency
82
- name: unicode-display_width
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: '0'
65
+ version: 1.4.0
95
66
  description: CLI-Based tool that show Trending repository on github
96
67
  email:
97
68
  - terasawan@gmail.com
@@ -119,6 +90,7 @@ files:
119
90
  - lib/git-trend.rb
120
91
  - lib/git_trend.rb
121
92
  - lib/git_trend/cli.rb
93
+ - lib/git_trend/core_ext/string.rb
122
94
  - lib/git_trend/formatter.rb
123
95
  - lib/git_trend/formatters/json_formatter.rb
124
96
  - lib/git_trend/formatters/text_formatter.rb
@@ -136,6 +108,7 @@ files:
136
108
  - spec/fixtures/trending?since=monthly.html
137
109
  - spec/fixtures/trending?since=weekly
138
110
  - spec/git_trend/cli_spec.rb
111
+ - spec/git_trend/core_ext/string_spec.rb
139
112
  - spec/git_trend/scraper_spec.rb
140
113
  - spec/git_trend_spec.rb
141
114
  - spec/spec_helper.rb
@@ -152,15 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
125
  requirements:
153
126
  - - ">="
154
127
  - !ruby/object:Gem::Version
155
- version: 2.7.0
128
+ version: 3.2.0
156
129
  required_rubygems_version: !ruby/object:Gem::Requirement
157
130
  requirements:
158
131
  - - ">="
159
132
  - !ruby/object:Gem::Version
160
133
  version: '0'
161
134
  requirements: []
162
- rubygems_version: 3.4.10
163
- signing_key:
135
+ rubygems_version: 3.7.1
164
136
  specification_version: 4
165
137
  summary: CLI-Based tool that show Trending repository on github
166
138
  test_files: []