lock_diff 0.2.1 → 0.3.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
  SHA1:
3
- metadata.gz: af0bcd9242683ea9865b9a683ca202573d9aa487
4
- data.tar.gz: a733cd081d65ad74fe452589c3632f69c0e6c3de
3
+ metadata.gz: b23d1f7cfd4a3dc35e0f44687cd981ef4b26c799
4
+ data.tar.gz: 2f81347131f8db3a177410c439ad8c24385b59bf
5
5
  SHA512:
6
- metadata.gz: 5067df24ba8bbcba4704bda9087219c837e2129dd429884fe1bd21569611f47968553b48808195571869d3e3c8b59f7c424bede48ce605730929d2314634cb21
7
- data.tar.gz: ebfe14362656f428129637dd292454ef01230f3b209b0b5df84764e5236cc9fb5f3e39ea819eb16f7b0b8815817fb9411a54115d0af010ab1dbeb7d4d7997888
6
+ metadata.gz: af50f03dcb70ad72b5ac821556c7818227e5c62d9578dbad00e4c0304d477699d77fea202d34d92f999ca8c17788fbd688123fa3fc4ffcf42aa9e75e65b1bba6
7
+ data.tar.gz: 28523b56956162aa7c840ab450982c31e0c244f170d2cd9a33ab88f44b8f19dd46e0c2e05fdd3326220a0559bafe5ec21920432ab0d9b8fdcd7d7982f7d21a35
@@ -1,36 +1,48 @@
1
1
  module LockDiff
2
2
  class DiffInfo
3
+ extend Forwardable
4
+
3
5
  UPGRADE = 'upgrade'
4
6
  DOWNGRADE = 'downgrade'
5
7
  DELETE = 'delete'
6
8
  NEW = 'new'
7
9
 
8
- def initialize(old_version:, new_version:, repository:, github_url:)
9
- @old_version = old_version
10
- @new_version = new_version
11
- @repository = repository
12
- @github_url = github_url
10
+ attr_reader :old_package, :new_package
11
+ def_delegators :package, :name, :url
12
+
13
+ def initialize(old_package:, new_package:)
14
+ @old_package = old_package
15
+ @new_package = new_package
13
16
  end
14
17
 
15
18
  def changed?
16
- @old_version.different?(@new_version)
19
+ @old_package.different?(@new_package)
17
20
  end
18
21
 
19
22
  def status
20
23
  case
21
- when @old_version.version && @new_version.version
22
- if @old_version.version < @new_version.version
24
+ when @old_package.version && @new_package.version
25
+ if @old_package.version < @new_package.version
23
26
  UPGRADE
24
27
  else
25
28
  DOWNGRADE
26
29
  end
27
- when @old_version.version
30
+ when @old_package.version
28
31
  DELETE
29
- when @new_version.version
32
+ when @new_package.version
30
33
  NEW
31
34
  end
32
35
  end
33
36
 
37
+ def package
38
+ case status
39
+ when UPGRADE, NEW
40
+ @new_package
41
+ when DOWNGRADE, DELETE
42
+ @old_package
43
+ end
44
+ end
45
+
34
46
  def status_emoji
35
47
  case status
36
48
  when UPGRADE
@@ -44,57 +56,57 @@ module LockDiff
44
56
  end
45
57
  end
46
58
 
47
- def change_log_url
48
- @change_log_url ||= begin
59
+ def changelog_url
60
+ @changelog_url ||= begin
49
61
  ref =
50
62
  case status
51
63
  when UPGRADE, NEW
52
- @new_version.ref
64
+ @new_package.ref
53
65
  when DOWNGRADE, DELETE
54
66
  nil # default branch(master)
55
67
  end
56
68
 
57
- Github::ChangeLogUrlFinder.new(
58
- repository: @repository,
59
- github_url: @github_url,
69
+ Github::ChangelogUrlFinder.new(
70
+ repository: package.repository,
71
+ github_url: package.github_url,
60
72
  ref: ref
61
73
  ).call
62
74
  end
63
75
  end
64
76
 
65
- def change_log_name
66
- File.basename(change_log_url)
77
+ def changelog_name
78
+ File.basename(changelog_url)
67
79
  end
68
80
 
69
81
  def commits_url
70
- return unless @github_url
71
- old_ref = @old_version.ref
72
- new_ref = @new_version.ref
82
+ return unless package.github_url
83
+ old_ref = @old_package.ref
84
+ new_ref = @new_package.ref
73
85
  commits_url =
74
86
  case status
75
87
  when UPGRADE
76
- "compare/#{old_ref}...#{new_ref}"
88
+ "compare/#{old_ref}...#{new_ref}" if old_ref && new_ref
77
89
  when DOWNGRADE
78
- "compare/#{new_ref}...#{old_ref}"
90
+ "compare/#{new_ref}...#{old_ref}" if old_ref && new_ref
79
91
  when DELETE
80
- "commits/#{old_ref}"
92
+ "commits/#{old_ref}" if old_ref
81
93
  when NEW
82
- "commits/#{new_ref}"
94
+ "commits/#{new_ref}" if new_ref
83
95
  end
84
96
 
85
- "#{@github_url}/#{commits_url}"
97
+ "#{package.github_url}/#{commits_url}" if commits_url
86
98
  end
87
99
 
88
100
  def commits_url_text
89
101
  case status
90
102
  when UPGRADE
91
- "#{@old_version}...#{@new_version}"
103
+ "#{@old_package.version_str}...#{@new_package.version_str}"
92
104
  when DOWNGRADE
93
- "#{@new_version}...#{@old_version}"
105
+ "#{@new_package.version_str}...#{@old_package.version_str}"
94
106
  when DELETE
95
- "#{@old_version}"
107
+ "#{@old_package.version_str}"
96
108
  when NEW
97
- "#{@new_version}"
109
+ "#{@new_package.version_str}"
98
110
  end
99
111
  end
100
112
 
@@ -29,7 +29,7 @@ module LockDiff
29
29
 
30
30
  class DiffFormmater
31
31
  def initialize(diff_info)
32
- LockDiff.logger.debug diff_info.name
32
+ LockDiff.logger.info { diff_info.name }
33
33
  @diff_info = diff_info
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ module LockDiff
38
38
  text << name
39
39
  text << status
40
40
  text << commits_text
41
- text << change_log
41
+ text << changelog
42
42
  "| #{text.join(' | ')} |"
43
43
  end
44
44
 
@@ -51,7 +51,11 @@ module LockDiff
51
51
  end
52
52
 
53
53
  def name
54
- "[#{diff_info.name}](#{diff_info.url})"
54
+ if diff_info.url
55
+ "[#{diff_info.name}](#{diff_info.url})"
56
+ else
57
+ diff_info.name
58
+ end
55
59
  end
56
60
 
57
61
  def commits_text
@@ -62,9 +66,9 @@ module LockDiff
62
66
  end
63
67
  end
64
68
 
65
- def change_log
66
- if diff_info.change_log_url
67
- "[#{diff_info.change_log_name}](#{diff_info.change_log_url})"
69
+ def changelog
70
+ if diff_info.changelog_url
71
+ "[#{diff_info.changelog_name}](#{diff_info.changelog_url})"
68
72
  else
69
73
  ""
70
74
  end
@@ -14,14 +14,14 @@ module LockDiff
14
14
  end
15
15
 
16
16
  def call
17
- old_specs_by_name = Spec.specs_by(@old_lockfile).map { |spec| [spec.name, spec] }.to_h
18
- new_specs_by_name = Spec.specs_by(@new_lockfile).map { |spec| [spec.name, spec] }.to_h
17
+ old_specs_by_name = Spec.new(@old_lockfile).map { |spec| [spec.name, spec] }.to_h
18
+ new_specs_by_name = Spec.new(@new_lockfile).map { |spec| [spec.name, spec] }.to_h
19
19
  names = (old_specs_by_name.keys + new_specs_by_name.keys).uniq
20
20
 
21
21
  names.map { |name|
22
- DiffInfo.by(
23
- old_spec: old_specs_by_name[name] || NullSpec.new(name),
24
- new_spec: new_specs_by_name[name] || NullSpec.new(name)
22
+ DiffInfo.new(
23
+ old_package: (old_specs_by_name[name] || NullSpec.new(name)).to_package,
24
+ new_package: (new_specs_by_name[name] || NullSpec.new(name)).to_package
25
25
  )
26
26
  }.select(&:changed?)
27
27
  end
@@ -1,13 +1,11 @@
1
1
  module LockDiff
2
2
  module Gem
3
- class Version
3
+ class Package
4
4
  extend Forwardable
5
- include Comparable
6
5
 
7
- def_delegators :@spec, :revision, :version
6
+ def_delegators :@spec, :name, :revision, :version, :github_url
8
7
 
9
- def initialize(gem:, spec:)
10
- @gem = gem
8
+ def initialize(spec)
11
9
  @spec = spec
12
10
  end
13
11
 
@@ -15,7 +13,7 @@ module LockDiff
15
13
  revision || git_tag
16
14
  end
17
15
 
18
- def to_s
16
+ def version_str
19
17
  revision || version.to_s
20
18
  end
21
19
 
@@ -23,13 +21,12 @@ module LockDiff
23
21
  revision != other.revision || version != other.version
24
22
  end
25
23
 
26
- def <=>(other)
27
- case
28
- when version && other.version
29
- version.send("<=>", other.version)
30
- else
31
- nil
32
- end
24
+ def url
25
+ @spec.github_url || @spec.homepage_url
26
+ end
27
+
28
+ def repository
29
+ Github::RepositoryNameDetector.new(@spec.github_url).call
33
30
  end
34
31
 
35
32
  private
@@ -38,13 +35,12 @@ module LockDiff
38
35
  return unless version
39
36
  return @git_tag if defined? @git_tag
40
37
  @git_tag = Github::TagFinder.new(
41
- repository: @gem.repository,
42
- gem_name: @gem.name,
38
+ repository: repository,
39
+ package_name: name,
43
40
  version_str: version.to_s
44
41
  ).call
45
42
  end
46
43
 
47
44
  end
48
-
49
45
  end
50
46
  end
@@ -1,5 +1,6 @@
1
1
  require "httpclient"
2
2
  require 'ostruct'
3
+ require 'json'
3
4
 
4
5
  module LockDiff
5
6
  module Gem
@@ -7,9 +8,6 @@ module LockDiff
7
8
  class RubyGem
8
9
  extend Forwardable
9
10
 
10
- def_delegator :@ruby_gem, :homepage_uri, :homepage_url
11
- def_delegator :@ruby_gem, :source_code_uri, :source_code_url
12
-
13
11
  def initialize(name)
14
12
  content = HTTPClient.get_content("https://rubygems.org/api/v1/gems/#{name}.json")
15
13
  @ruby_gem = OpenStruct.new(JSON.parse(content))
@@ -22,6 +20,16 @@ module LockDiff
22
20
  @github_url ||= Github::GithubUrlDetector.new([source_code_url, homepage_url]).call
23
21
  end
24
22
 
23
+ def homepage_url
24
+ @ruby_gem.homepage_uri
25
+ end
26
+
27
+ private
28
+
29
+ def source_code_url
30
+ @ruby_gem.source_code_uri
31
+ end
32
+
25
33
  end
26
34
 
27
35
  class NullRubyGem
@@ -35,9 +43,6 @@ module LockDiff
35
43
  def source_code_uri
36
44
  end
37
45
 
38
- def github_url
39
- end
40
-
41
46
  end
42
47
  end
43
48
  end
@@ -0,0 +1,23 @@
1
+ module LockDiff
2
+ module Gem
3
+ class RubyGemRepository
4
+ class << self
5
+ def find(name)
6
+ ruby_gem = repository[name]
7
+ return ruby_gem if ruby_gem
8
+ repository[name] = RubyGem.new(name)
9
+ end
10
+
11
+ def repository
12
+ @repository ||= {}
13
+ end
14
+
15
+ def clear
16
+ @repository = {}
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -1,29 +1,68 @@
1
1
  module LockDiff
2
2
  module Gem
3
3
  # wrapper of lazy_specification
4
- class Spec
5
- extend Forwardable
4
+ module Spec
5
+ class UnSupportSource < StandardError; end
6
6
 
7
- def_delegators :@spec, :name, :version
8
-
9
- def self.specs_by(lockfile)
7
+ def self.new(lockfile)
10
8
  Bundler::LockfileParser.new(lockfile).specs.map do |lazy_specification|
11
- new(lazy_specification)
9
+ case lazy_specification.source
10
+ when Bundler::Source::Rubygems
11
+ RubyGemSpec.new(lazy_specification)
12
+ when Bundler::Source::Git
13
+ GitSpec.new(lazy_specification)
14
+ when Bundler::Source::Path
15
+ PathSpec.new(lazy_specification)
16
+ else
17
+ raise UnSupportSource, "#{lazy_specification.source.class} source by #{lazy_specification.name} is not supported"
18
+ end
12
19
  end
13
20
  end
14
21
 
15
- def initialize(lazy_specification)
16
- @spec = lazy_specification
22
+ class Base
23
+ extend Forwardable
24
+
25
+ def_delegators :@spec, :name, :version
26
+
27
+ def initialize(lazy_specification)
28
+ @spec = lazy_specification
29
+ end
30
+
31
+ def revision
32
+ @spec.git_version&.strip
33
+ end
34
+
35
+ def to_package
36
+ Package.new(self)
37
+ end
38
+
39
+ def github_url; end
40
+ def homepage_url; end
17
41
  end
18
42
 
19
- def revision
20
- @spec.git_version&.strip
43
+ class RubyGemSpec < Base
44
+ def_delegators :ruby_gem, :github_url, :homepage_url
45
+
46
+ private
47
+
48
+ def ruby_gem
49
+ @ruby_gem ||= RubyGemRepository.find(@spec.name)
50
+ end
51
+ end
52
+
53
+ class GitSpec < Base
54
+ def github_url
55
+ @github_url ||= Github::GithubUrlDetector.new(@spec.source.uri).call
56
+ end
21
57
  end
22
58
 
59
+ class PathSpec < Base
60
+ end
23
61
  end
24
62
 
25
63
  class NullSpec
26
64
  attr_reader :name
65
+
27
66
  def initialize(name)
28
67
  @name = name
29
68
  end
@@ -34,6 +73,13 @@ module LockDiff
34
73
  def version
35
74
  nil
36
75
  end
76
+
77
+ def github_url; end
78
+ def homepage_url; end
79
+
80
+ def to_package
81
+ Package.new(self)
82
+ end
37
83
  end
38
84
 
39
85
  end
data/lib/lock_diff/gem.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require "bundler"
2
- require_relative "gem/diff_info"
3
- require_relative "gem/gem"
4
2
  require_relative "gem/lockfile_comparator"
5
- require_relative "gem/pr_lockfile"
3
+ require_relative "gem/package"
6
4
  require_relative "gem/ruby_gem"
5
+ require_relative "gem/ruby_gem_repository"
7
6
  require_relative "gem/spec"
8
- require_relative "gem/version"
9
7
 
10
8
  module LockDiff
11
9
  module Gem
@@ -13,7 +11,7 @@ module LockDiff
13
11
  class NotChangedLockfile < StandardError; end
14
12
 
15
13
  def lock_file_diffs(pull_request)
16
- pr_lockfile = PrLockfile.new(pull_request)
14
+ pr_lockfile = Github::PrLockfile.new(pull_request, 'Gemfile.lock')
17
15
  raise NotChangedLockfile unless pr_lockfile.changed?
18
16
  LockfileComparator.compare_by(pr_lockfile)
19
17
  end
@@ -1,6 +1,6 @@
1
1
  module LockDiff
2
2
  module Github
3
- class ChangeLogUrlFinder
3
+ class ChangelogUrlFinder
4
4
  CHANGE_LOG_CANDIDATES = %w(
5
5
  changelog
6
6
  changes
@@ -3,7 +3,8 @@ require "httpclient"
3
3
  module LockDiff
4
4
  module Github
5
5
  class GithubUrlDetector
6
- REGEXP = %r!https?://([^/]+)\.github\.[^/]+/([^/]+)! # github.com, github.io
6
+ # xxx.github.aaa/yyyy
7
+ REGEXP = %r!https?://([^/]+)\.github\.[^/]+/([^/]+)!
7
8
 
8
9
  def initialize(urls)
9
10
  @urls = Array(urls).compact
@@ -13,8 +14,13 @@ module LockDiff
13
14
  url = @urls.find { |url| url.include?("github.com") }
14
15
  return unless url
15
16
 
16
- response = HTTPClient.get(url, follow_redirect: true)
17
- url = response.header.request_uri.to_s
17
+ begin
18
+ response = HTTPClient.get(url, follow_redirect: true)
19
+ url = response.header.request_uri.to_s
20
+ rescue
21
+ repository = RepositoryNameDetector.new(url).call
22
+ url = "https://github.com/#{repository}"
23
+ end
18
24
 
19
25
  if url.match?(REGEXP)
20
26
  _, owner, repo = url.match(REGEXP).to_a
@@ -1,8 +1,9 @@
1
1
  module LockDiff
2
- module Gem
2
+ module Github
3
3
  class PrLockfile
4
- def initialize(pull_request)
4
+ def initialize(pull_request, lockfile_name)
5
5
  @pr = pull_request
6
+ @lockfile_name = lockfile_name
6
7
  end
7
8
 
8
9
  def changed?
@@ -10,7 +11,7 @@ module LockDiff
10
11
  end
11
12
 
12
13
  def path
13
- @path ||= @pr.find_content_path("Gemfile.lock")
14
+ @path ||= @pr.find_content_path(@lockfile_name)
14
15
  end
15
16
 
16
17
  def base_file
@@ -1,7 +1,7 @@
1
1
  module LockDiff
2
2
  module Github
3
3
  class RepositoryNameDetector
4
- REGEXP = %r!github\.com/([^/]+)/([^/]+)!
4
+ REGEXP = %r!github\.com[/:](.*?)(?:.git)?\z!
5
5
 
6
6
  def initialize(url)
7
7
  @url = url
@@ -9,8 +9,9 @@ module LockDiff
9
9
 
10
10
  def call
11
11
  return unless @url
12
- _, repo_owner, repo_name = @url.match(REGEXP).to_a
13
- "#{repo_owner}/#{repo_name}"
12
+ @url.match(REGEXP).to_a.last.
13
+ split("/").first(2).
14
+ join("/")
14
15
  end
15
16
 
16
17
  end
@@ -1,9 +1,9 @@
1
1
  module LockDiff
2
2
  module Github
3
3
  class TagFinder
4
- def initialize(repository:, gem_name:, version_str:)
4
+ def initialize(repository:, package_name:, version_str:)
5
5
  @repository = repository
6
- @gem_name = gem_name
6
+ @package_name = package_name
7
7
  @version_str = version_str
8
8
  end
9
9
 
@@ -20,13 +20,13 @@ module LockDiff
20
20
  tag = fetched_tags.find do |tag_name|
21
21
  tag_name == @version_str ||
22
22
  tag_name == "v#{@version_str}" ||
23
- tag_name == "#{@gem_name}-#{@version_str}"
23
+ tag_name == "#{@package_name}-#{@version_str}"
24
24
  end
25
25
 
26
26
  if tag
27
27
  return tag
28
28
  else
29
- LockDiff.logger.debug { "Not found tag of #{@gem_name}, #{@version_str} by page: #{page}, per_page: #{per_page}"}
29
+ LockDiff.logger.debug { "Not found tag of #{@package_name}, #{@version_str} by page: #{page}, per_page: #{per_page}"}
30
30
  unless fetched_tags.count < per_page
31
31
  find_tag(page: page + 1, limit: limit, per_page: per_page)
32
32
  end
@@ -1,8 +1,9 @@
1
1
  require_relative "github/access_token"
2
- require_relative "github/change_log_url_finder"
2
+ require_relative "github/changelog_url_finder"
3
3
  require_relative "github/client"
4
4
  require_relative "github/content"
5
5
  require_relative "github/github_url_detector"
6
+ require_relative "github/pr_lockfile"
6
7
  require_relative "github/pull_request"
7
8
  require_relative "github/repository_name_detector"
8
9
  require_relative "github/tag_finder"
@@ -28,7 +28,8 @@ module LockDiff
28
28
 
29
29
  opt.separator("\nOptional flags")
30
30
  opt.on('--post-comment=true or false', 'Print result to stdout when false. (default is false)') { |v| options[:post_comment] = v }
31
- opt.on("-v", "--verbose", "Run verbosely") { |v| LockDiff.logger.level = :debug }
31
+ opt.on("-v", "--verbose", "Run verbosely") { LockDiff.logger.level = :info }
32
+ opt.on("--move-verbose", "Run move verbosely") { LockDiff.logger.level = :debug }
32
33
  opt.on_tail("--version", "Show version") do
33
34
  $stdout.puts LockDiff::VERSION
34
35
  exit
@@ -1,3 +1,3 @@
1
1
  module LockDiff
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/lock_diff.rb CHANGED
@@ -10,16 +10,24 @@ require "lock_diff/version"
10
10
 
11
11
  module LockDiff
12
12
  class << self
13
- attr_accessor :client_class, :formatter, :strategy, :logger
13
+ attr_accessor :config
14
+
15
+ def init!
16
+ self.config = Config.new
17
+ end
14
18
 
15
19
  def client
16
- client_class.client
20
+ config.client_class.client
21
+ end
22
+
23
+ def logger
24
+ config.logger
17
25
  end
18
26
 
19
27
  def run(repository:, number:, post_comment: false)
20
28
  pr = PullRequest.new(repository: repository, number: number)
21
- lockfile_diff_infos = strategy.lock_file_diffs(pr)
22
- result = formatter.format(lockfile_diff_infos)
29
+ lockfile_diff_infos = config.strategy.lock_file_diffs(pr)
30
+ result = config.formatter.format(lockfile_diff_infos)
23
31
 
24
32
  if post_comment
25
33
  client.add_comment(repository, number, result)
@@ -34,13 +42,21 @@ module LockDiff
34
42
  if pr
35
43
  run(repository: repository, number: pr.number, post_comment: post_comment)
36
44
  else
37
- LockDiff.logger.info("Not found pull request by tachikoma. (Hint: search pull request by whether branch name includes 'tachikoma'")
45
+ LockDiff.logger.warn("Not found pull request by tachikoma. (Hint: search pull request by whether branch name includes 'tachikoma'")
38
46
  end
39
47
  end
40
- end
41
48
 
42
- self.client_class = Github
43
- self.formatter = Formatter::GithubMarkdown
44
- self.strategy = Gem
45
- self.logger = Logger.new($stdout, level: :info)
49
+ class Config
50
+ attr_accessor :client_class, :formatter, :strategy, :logger
51
+
52
+ def initialize
53
+ @client_class = Github
54
+ @formatter = Formatter::GithubMarkdown
55
+ @strategy = Gem
56
+ @logger = Logger.new($stdout, level: :warn)
57
+ end
58
+ end
59
+ end
46
60
  end
61
+
62
+ LockDiff.init!
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.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vividmuimui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -134,19 +134,18 @@ files:
134
134
  - lib/lock_diff/diff_info.rb
135
135
  - lib/lock_diff/formatter/github_markdown.rb
136
136
  - lib/lock_diff/gem.rb
137
- - lib/lock_diff/gem/diff_info.rb
138
- - lib/lock_diff/gem/gem.rb
139
137
  - lib/lock_diff/gem/lockfile_comparator.rb
140
- - lib/lock_diff/gem/pr_lockfile.rb
138
+ - lib/lock_diff/gem/package.rb
141
139
  - lib/lock_diff/gem/ruby_gem.rb
140
+ - lib/lock_diff/gem/ruby_gem_repository.rb
142
141
  - lib/lock_diff/gem/spec.rb
143
- - lib/lock_diff/gem/version.rb
144
142
  - lib/lock_diff/github.rb
145
143
  - lib/lock_diff/github/access_token.rb
146
- - lib/lock_diff/github/change_log_url_finder.rb
144
+ - lib/lock_diff/github/changelog_url_finder.rb
147
145
  - lib/lock_diff/github/client.rb
148
146
  - lib/lock_diff/github/content.rb
149
147
  - lib/lock_diff/github/github_url_detector.rb
148
+ - lib/lock_diff/github/pr_lockfile.rb
150
149
  - lib/lock_diff/github/pull_request.rb
151
150
  - lib/lock_diff/github/repository_name_detector.rb
152
151
  - lib/lock_diff/github/tag_finder.rb
@@ -1,31 +0,0 @@
1
- module LockDiff
2
- module Gem
3
- class DiffInfo
4
- extend Forwardable
5
-
6
- attr_reader :old_version, :new_version
7
- def_delegators :@gem, :name, :url
8
- def_delegators :@diff_info, :changed?, :status, :status_emoji, :change_log_url, :change_log_name, :commits_url, :commits_url_text
9
-
10
- def self.by(old_spec:, new_spec:)
11
- gem = Gem.new(new_spec.name)
12
- new(
13
- gem: gem,
14
- old_version: Version.new(gem: gem, spec: old_spec),
15
- new_version: Version.new(gem: gem, spec: new_spec)
16
- )
17
- end
18
-
19
- def initialize(gem:, old_version:, new_version:)
20
- @gem = gem
21
- @diff_info = LockDiff::DiffInfo.new(
22
- old_version: old_version,
23
- new_version: new_version,
24
- github_url: gem.github_url,
25
- repository: gem.repository
26
- )
27
- end
28
-
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- module LockDiff
2
- module Gem
3
- class Gem
4
- extend Forwardable
5
-
6
- attr_reader :name
7
- def_delegator :@ruby_gem, :github_url
8
-
9
- def initialize(name)
10
- @name = name
11
- @ruby_gem = RubyGem.new(name)
12
- end
13
-
14
- def url
15
- @ruby_gem.github_url || @ruby_gem.homepage_url
16
- end
17
-
18
- def repository
19
- Github::RepositoryNameDetector.new(@ruby_gem.github_url).call
20
- end
21
-
22
- end
23
- end
24
- end