lock_diff 0.4.0 → 0.7.0

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
- SHA1:
3
- metadata.gz: 32ea1d5332489c1a0c065898274bec884df86f0f
4
- data.tar.gz: 20690289ef5f89c78b8718015a3150e87666e013
2
+ SHA256:
3
+ metadata.gz: db407b53c51962d6fb103f3d42d714e91799273cb73512ad46bf11ded0432325
4
+ data.tar.gz: 8c70ba785dd083ed785e3b5c7da5d6b3fcdd135a1a0b2f2c58ca46319eddc88b
5
5
  SHA512:
6
- metadata.gz: aab3e4cc4d530c6cccbc0e0decfb97419ad6fbdd1be5027b5ddfef442107c224b76c290776613bc6851a320d30a72d0517080ded83455fe8aa020b4b43a8a9a0
7
- data.tar.gz: 1aec7ef811fceaf5ba63510c0713770e8020f42f4d19b70aae57d5632ff98a6438c2bd150c0d435b0009f01c2ca373f40b18dcb00e791cfc2a645441afdf1f8c
6
+ metadata.gz: 35a2eb2d40e3022fd1a2ad75ef5661f727ff0c5d9fea949b045350db605075532c8cc5d33bdac6afcc500f1737a7b48761afb5bdf87b84247cf4baed45f6ad6c
7
+ data.tar.gz: cf412bc9644cc4179b850199e5b10093e1e57770e8b207e17851de129a1b02d1cde6f96305ae8fb71a7b5a02d64c6c805e387589ee30b28dbb48994bcf65c0bb
data/.travis.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
4
- - 2.4.2
3
+ - 2.5
4
+ - 2.6
5
+ - 2.7
6
+ - 3.0
5
7
  script:
6
- - bundle exec rspec
8
+ - bundle exec rspec
7
9
  notifications:
8
10
  slack:
9
11
  secure: DKSdr5uEtNXGpAARGV+Q694eNv9IGi30RjSIjk8lRZrmLxE0WJbk/17FkmjgVF2w1onO/knFWgCiPBoIncihy4hh6nfAJZDaRI8AwXqYGGi10KeUBu4309r/7SL60KnFUFsQ9o47tar09TY6HS55IesNjN2/mKIEJlpw2c7McPz58rIzlFizTW5OPShsfWQnuLAz9iUYjknZfrntirav+mwkqVKqDZoMM7MRzedk1KjlkRbun/EVrgMEYPqsbpmhfYV0DZkcymorhH6d/FBsrWeqB7QMT6KwROMBHDZGeGzYgaN3KgjZV35gw6pK2VlsETm7E/Fk9Imrjalq87Q28aqX5nq/MR6Llo9yfE4J7PkGOTxcvZlXqp/W+2xT/8Ne6Dy29gb/7TeJY9K4nmkbkrmkanKBBmvIjbhwT46BOPjn1Sz4kbceoZNgihI2hMMPypH61+U6v0eUcGLuxRyDaUsyrgRnBEDHFZHMpfZ1eE7uXnCO9IvqGm5Tn4goP0s67H98CFhP+j3cIM2HKdns6ZyGsAHVakw7bnB90mKc9bIaaPSKEyZZD4MpkJxnMxR453OlSwJZIXesIkbBJMZA4wdOAsPQSBaSCY2w566LsUs4izRVLpdeILa/NOaxb+l1OvmejGyiihUjSUfH7fiIhoD5E0+SgOsDIdd0TV17rb4=
data/README.md CHANGED
@@ -1,13 +1,9 @@
1
1
  # LockDiff
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/lock_diff.svg)](https://badge.fury.io/rb/lock_diff)
4
- [![GitHub tag](https://img.shields.io/github/tag/vividmuimui/lock_diff.svg)](https://github.com/vividmuimui/lock_diff/tags)
5
4
  [![Build Status](https://travis-ci.org/vividmuimui/lock_diff.svg?branch=master)](https://travis-ci.org/vividmuimui/lock_diff)
6
5
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d05b439bc5064e30ad84ecfa8e57b448)](https://www.codacy.com/app/vividmuimui/lock_diff?utm_source=github.com&utm_medium=referral&utm_content=vividmuimui/lock_diff&utm_campaign=badger)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/vividmuimui/lock_diff.svg)](https://gemnasium.com/github.com/vividmuimui/lock_diff)
8
6
  [![Code Climate](https://codeclimate.com/github/vividmuimui/lock_diff/badges/gpa.svg)](https://codeclimate.com/github/vividmuimui/lock_diff)
9
- [![Issue Count](https://codeclimate.com/github/vividmuimui/lock_diff/badges/issue_count.svg)](https://codeclimate.com/github/vividmuimui/lock_diff)
10
- [![ghit.me](https://ghit.me/badge.svg?repo=vividmuimui/lock_diff)](https://ghit.me/repo/vividmuimui/lock_diff)
11
7
 
12
8
  This gem detects changes to your package manager (e.g. Gemfile) and generates a Markdown-formatted diff including:
13
9
 
@@ -109,7 +105,7 @@ TODO:
109
105
 
110
106
  ## Contributing
111
107
 
112
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lock_diff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
108
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vividmuimui/lock_diff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
113
109
 
114
110
  ## License
115
111
 
@@ -117,7 +113,7 @@ The gem is available as open source under the terms of the [MIT License](http://
117
113
 
118
114
  ### Original
119
115
 
120
- Most source code in this pepository is by https://github.com/kyanny/compare_linker .
116
+ Most of the source code in this repository is by https://github.com/kyanny/compare_linker.
121
117
 
122
118
  ```
123
119
  Copyright (c) 2014 Kensuke Nagae
@@ -147,4 +143,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
147
143
 
148
144
  ## Code of Conduct
149
145
 
150
- Everyone interacting in the LockDiff project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lock_diff/blob/master/CODE_OF_CONDUCT.md).
146
+ Everyone interacting in the LockDiff project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/vividmuimui/lock_diff/blob/master/CODE_OF_CONDUCT.md).
@@ -4,4 +4,4 @@ require "lock_diff"
4
4
  require "lock_diff/cli/option_parser"
5
5
 
6
6
  options = LockDiff::Cli::OptionParser.parse(ARGV, require_flags: %i(repository))
7
- LockDiff.run_by_latest_tachikoma(options)
7
+ LockDiff.run_by_latest_tachikoma(**options)
data/lib/lock_diff.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "logger"
2
2
  require "forwardable"
3
3
 
4
+ require "lock_diff/changelog"
4
5
  require "lock_diff/diff_info"
5
6
  require "lock_diff/formatter/github_markdown"
6
7
  require "lock_diff/gem"
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LockDiff
4
+ class Changelog
5
+ attr_reader :url
6
+
7
+ def initialize(url)
8
+ @url = url
9
+ end
10
+
11
+ def name
12
+ File.basename(@url)
13
+ end
14
+ end
15
+ end
@@ -57,28 +57,19 @@ module LockDiff
57
57
  end
58
58
  end
59
59
 
60
- def changelog_url
61
- @changelog_url ||= begin
62
- ref =
63
- case status
64
- when UPGRADE, NEW
65
- @new_package.ref
66
- when DOWNGRADE, DELETE
67
- nil # default branch(master)
68
- end
60
+ def changelogs
61
+ return nil if [DOWNGRADE, DELETE].include?(status)
69
62
 
70
- Github::ChangelogUrlFinder.new(
71
- repository: package.repository,
72
- repository_url: package.repository_url,
73
- ref: ref
74
- ).call
63
+ Github::ChangelogUrlFinder.new(
64
+ repository: package.repository,
65
+ repository_url: package.repository_url,
66
+ ref: @new_package.ref,
67
+ package_name: package.name
68
+ ).call.map do |url|
69
+ Changelog.new(url)
75
70
  end
76
71
  end
77
72
 
78
- def changelog_name
79
- File.basename(changelog_url)
80
- end
81
-
82
73
  def commits_url
83
74
  return unless package.repository_url
84
75
  old_ref = @old_package.ref
@@ -41,7 +41,7 @@ module LockDiff
41
41
  text << repository
42
42
  text << status
43
43
  text << commits_text
44
- text << changelog
44
+ text << changelogs
45
45
  "| #{text.join(' | ')} |"
46
46
  end
47
47
 
@@ -77,15 +77,16 @@ module LockDiff
77
77
  end
78
78
  end
79
79
 
80
- def changelog
81
- if diff_info.changelog_url
82
- "[#{diff_info.changelog_name}](#{diff_info.changelog_url})"
80
+ def changelogs
81
+ if diff_info.changelogs
82
+ diff_info.changelogs.map do |changelog|
83
+ "[#{changelog.name}](#{changelog.url})"
84
+ end.join(" ")
83
85
  else
84
86
  ""
85
87
  end
86
88
  end
87
89
  end
88
-
89
90
  end
90
91
  end
91
92
  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
- find_change_log_url || find_release_url
12
+ directories.flat_map(&:change_log_urls).push(find_release_url).compact
21
13
  end
22
14
 
23
15
  private
24
16
 
25
- def find_change_log_url
26
- Github.client.contents(@repository, ref: @ref).
27
- select(&:file?).
28
- find { |content|
29
- name = content.name.downcase.delete('_')
30
- CHANGE_LOG_CANDIDATES.any? { |candidate| name.start_with? candidate }
31
- }&.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,7 +1,7 @@
1
1
  module LockDiff
2
2
  module Github
3
3
  class RepositoryNameDetector
4
- REGEXP = %r!github\.com[/:](.*?)(?:.git)?\z!
4
+ REGEXP = %r!github\.com[/:](.*?)(?:\.git)?\z!
5
5
 
6
6
  def initialize(url)
7
7
  @url = url
@@ -9,7 +9,7 @@ module LockDiff
9
9
 
10
10
  def call
11
11
  return unless @url
12
- path = @url.match(REGEXP).to_a.last
12
+ path = @url.match(REGEXP).to_a.last&.split('#')&.first
13
13
  return unless path
14
14
  repository_name = path.split("/").first(2).join("/")
15
15
  repository_name if repository_name.match?(/.+\/.+/)
@@ -1,3 +1,3 @@
1
1
  module LockDiff
2
- VERSION = "0.4.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lock_diff.gemspec CHANGED
@@ -26,10 +26,12 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "octokit", "~> 4.0"
27
27
  spec.add_dependency "httpclient"
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.15"
30
- spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "bundler", "> 1.15"
30
+ spec.add_development_dependency "rake", ">= 13"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
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.4.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vividmuimui
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-11 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
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.15'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.15'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '13'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -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:
@@ -145,6 +173,7 @@ files:
145
173
  - exe/lock_diff
146
174
  - exe/lock_diff_for_tachikoma
147
175
  - lib/lock_diff.rb
176
+ - lib/lock_diff/changelog.rb
148
177
  - lib/lock_diff/cli/option_parser.rb
149
178
  - lib/lock_diff/diff_info.rb
150
179
  - lib/lock_diff/formatter/github_markdown.rb
@@ -158,6 +187,7 @@ files:
158
187
  - lib/lock_diff/github/changelog_url_finder.rb
159
188
  - lib/lock_diff/github/client.rb
160
189
  - lib/lock_diff/github/content.rb
190
+ - lib/lock_diff/github/directory.rb
161
191
  - lib/lock_diff/github/pull_request.rb
162
192
  - lib/lock_diff/github/repository_name_detector.rb
163
193
  - lib/lock_diff/github/tag_finder.rb
@@ -170,7 +200,7 @@ homepage: ''
170
200
  licenses:
171
201
  - MIT
172
202
  metadata: {}
173
- post_install_message:
203
+ post_install_message:
174
204
  rdoc_options: []
175
205
  require_paths:
176
206
  - lib
@@ -185,9 +215,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
215
  - !ruby/object:Gem::Version
186
216
  version: '0'
187
217
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.6.14.1
190
- signing_key:
218
+ rubygems_version: 3.0.6
219
+ signing_key:
191
220
  specification_version: 4
192
221
  summary: This gem detects changes to your package manager (e.g. Gemfile) and generates
193
222
  a Markdown-formatted diff.