lock_diff 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3d24a9de17d4e6d158bd759389b0dafa4c15cf58efc61452b4ce85c450644e2
4
- data.tar.gz: ffae4dd28a5385834069b856fcc888b10b397416f8305c026b369d220c944443
3
+ metadata.gz: db407b53c51962d6fb103f3d42d714e91799273cb73512ad46bf11ded0432325
4
+ data.tar.gz: 8c70ba785dd083ed785e3b5c7da5d6b3fcdd135a1a0b2f2c58ca46319eddc88b
5
5
  SHA512:
6
- metadata.gz: 71b5432a0d3ff82cf24ae95c61de3a2c3cbd8e00db8c601be84838549432370dd91da0ee4e7da2055d73917b641360ceef5406b32f6de429ab04a9dbbc1ba787
7
- data.tar.gz: 4952208e316746577f8bf051bc5d8f3967575e888c1d21296687ef18485d2e69b452521ff00980110e1ee2aa402169ca9e5d68f59dbdbfe9480b5225c5411e76
6
+ metadata.gz: 35a2eb2d40e3022fd1a2ad75ef5661f727ff0c5d9fea949b045350db605075532c8cc5d33bdac6afcc500f1737a7b48761afb5bdf87b84247cf4baed45f6ad6c
7
+ data.tar.gz: cf412bc9644cc4179b850199e5b10093e1e57770e8b207e17851de129a1b02d1cde6f96305ae8fb71a7b5a02d64c6c805e387589ee30b28dbb48994bcf65c0bb
@@ -63,7 +63,8 @@ module LockDiff
63
63
  Github::ChangelogUrlFinder.new(
64
64
  repository: package.repository,
65
65
  repository_url: package.repository_url,
66
- ref: @new_package.ref
66
+ ref: @new_package.ref,
67
+ package_name: package.name
67
68
  ).call.map do |url|
68
69
  Changelog.new(url)
69
70
  end
@@ -2,6 +2,7 @@ require_relative "github/access_token"
2
2
  require_relative "github/changelog_url_finder"
3
3
  require_relative "github/client"
4
4
  require_relative "github/content"
5
+ require_relative "github/directory"
5
6
  require_relative "github/url_detector"
6
7
  require_relative "github/pull_request"
7
8
  require_relative "github/repository_name_detector"
@@ -1,34 +1,25 @@
1
1
  module LockDiff
2
2
  module Github
3
3
  class ChangelogUrlFinder
4
- CHANGE_LOG_CANDIDATES = %w(
5
- changelog
6
- changes
7
- history
8
- releases
9
- releasenote
10
- news
11
- )
12
-
13
- def initialize(repository:, repository_url:, ref:)
4
+ def initialize(repository:, repository_url:, ref:, package_name:)
14
5
  @repository = repository
15
6
  @repository_url = repository_url
16
7
  @ref = ref
8
+ @package_name = package_name
17
9
  end
18
10
 
19
11
  def call
20
- change_log_urls.push(find_release_url).compact
12
+ directories.flat_map(&:change_log_urls).push(find_release_url).compact
21
13
  end
22
14
 
23
15
  private
24
16
 
25
- def change_log_urls
26
- Github.client.contents(@repository, ref: @ref).
27
- select(&:file?).
28
- select do |content|
29
- name = content.name.downcase.delete('_')
30
- CHANGE_LOG_CANDIDATES.any? { |candidate| name.start_with? candidate }
31
- end&.map(&:html_url)
17
+ def directories
18
+ [
19
+ Directory.new(@repository, @ref),
20
+ Directory.new(@repository, @ref, path: @package_name),
21
+ Directory.new(@repository, @ref, path: "gems/#{@package_name}")
22
+ ]
32
23
  end
33
24
 
34
25
  def find_release_url
@@ -37,7 +28,6 @@ module LockDiff
37
28
  @repository_url + "/releases"
38
29
  end
39
30
  end
40
-
41
31
  end
42
32
  end
43
33
  end
@@ -6,14 +6,34 @@ module LockDiff
6
6
 
7
7
  def_delegators :@content, :name, :html_url
8
8
 
9
+ CHANGE_LOG_CANDIDATES = %w[
10
+ changelog
11
+ changes
12
+ history
13
+ releases
14
+ releasenote
15
+ news
16
+ ].freeze
17
+
9
18
  def initialize(content)
10
19
  @content = content
11
20
  end
12
21
 
22
+ def change_log?
23
+ file? && CHANGE_LOG_CANDIDATES.any? do |candidate|
24
+ normalized_name.start_with?(candidate)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def normalized_name
31
+ @normalized_name ||= name.downcase.delete('_')
32
+ end
33
+
13
34
  def file?
14
35
  @content.type == 'file'
15
36
  end
16
-
17
37
  end
18
38
  end
19
39
  end
@@ -0,0 +1,23 @@
1
+ module LockDiff
2
+ module Github
3
+ class Directory
4
+ def initialize(repository, ref, path: nil)
5
+ @repository = repository
6
+ @ref = ref
7
+ @path = path
8
+ end
9
+
10
+ def change_log_urls
11
+ contents.select(&:change_log?).map(&:html_url)
12
+ rescue Octokit::NotFound
13
+ []
14
+ end
15
+
16
+ private
17
+
18
+ def contents
19
+ @contents ||= Github.client.contents(@repository, ref: @ref, path: @path)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module LockDiff
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lock_diff.gemspec CHANGED
@@ -32,4 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "pry"
33
33
  spec.add_development_dependency "pry-byebug"
34
34
  spec.add_development_dependency "codacy-coverage"
35
+ spec.add_development_dependency "vcr"
36
+ spec.add_development_dependency "webmock"
35
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vividmuimui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-27 00:00:00.000000000 Z
11
+ date: 2021-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: vcr
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: webmock
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: This gem detects changes to your package manager (e.g. Gemfile) and generates
126
154
  a Markdown-formatted diff.
127
155
  email:
@@ -159,6 +187,7 @@ files:
159
187
  - lib/lock_diff/github/changelog_url_finder.rb
160
188
  - lib/lock_diff/github/client.rb
161
189
  - lib/lock_diff/github/content.rb
190
+ - lib/lock_diff/github/directory.rb
162
191
  - lib/lock_diff/github/pull_request.rb
163
192
  - lib/lock_diff/github/repository_name_detector.rb
164
193
  - lib/lock_diff/github/tag_finder.rb
@@ -186,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
215
  - !ruby/object:Gem::Version
187
216
  version: '0'
188
217
  requirements: []
189
- rubygems_version: 3.2.3
218
+ rubygems_version: 3.0.6
190
219
  signing_key:
191
220
  specification_version: 4
192
221
  summary: This gem detects changes to your package manager (e.g. Gemfile) and generates