Module: Unwrappr

Defined in:
lib/unwrappr.rb,
lib/unwrappr/cli.rb,
lib/unwrappr/version.rb,
lib/unwrappr/ruby_gems.rb,
lib/unwrappr/gem_change.rb,
lib/unwrappr/gem_version.rb,
lib/unwrappr/github/client.rb,
lib/unwrappr/writers/title.rb,
lib/unwrappr/github/pr_sink.rb,
lib/unwrappr/lock_file_diff.rb,
lib/unwrappr/github/pr_source.rb,
lib/unwrappr/writers/composite.rb,
lib/unwrappr/git_command_runner.rb,
lib/unwrappr/lock_file_annotator.rb,
lib/unwrappr/lock_file_comparator.rb,
lib/unwrappr/researchers/composite.rb,
lib/unwrappr/writers/project_links.rb,
lib/unwrappr/bundler_command_runner.rb,
lib/unwrappr/writers/version_change.rb,
lib/unwrappr/researchers/github_repo.rb,
lib/unwrappr/spec_version_comparator.rb,
lib/unwrappr/writers/github_commit_log.rb,
lib/unwrappr/researchers/ruby_gems_info.rb,
lib/unwrappr/researchers/github_comparison.rb,
lib/unwrappr/writers/security_vulnerabilities.rb,
lib/unwrappr/researchers/security_vulnerabilities.rb

Overview

Welcome to unwrappr…

Defined Under Namespace

Modules: BundlerCommandRunner, GitCommandRunner, GitHub, Github, LockFileComparator, Researchers, RubyGems, Writers Classes: CLI, GemChange, GemVersion, LockFileAnnotator, LockFileDiff, SpecVersionComparator

Constant Summary collapse

VERSION =
'0.8.2'

Class Method Summary collapse

Class Method Details

.any_lockfile_present?(lock_files) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/unwrappr/cli.rb', line 100

def self.any_lockfile_present?(lock_files)
  lock_files.any? { |lock_file| GitCommandRunner.file_exist?(lock_file) }
end

.bundle_update!(lock_files:, recursive:) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/unwrappr/cli.rb', line 104

def self.bundle_update!(lock_files:, recursive:)
  directories(lock_files: lock_files, recursive: recursive).each do |dir|
    Dir.chdir(dir) do
      puts "Doing the unwrappr thing in #{Dir.pwd}"
      BundlerCommandRunner.bundle_update!
    end
  end
end

.directories(lock_files:, recursive:) ⇒ Object



113
114
115
116
117
118
119
120
121
122
# File 'lib/unwrappr/cli.rb', line 113

def self.directories(lock_files:, recursive:)
  if recursive
    lock_files
      .flat_map { |f| Dir.glob("**/#{f}") }
      .map { |f| File.dirname(f) }
      .uniq
  else
    %w[.]
  end
end

.run_unwrappr_in_pwd(base_branch:, lock_files:, recursive:) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/unwrappr/cli.rb', line 91

def self.run_unwrappr_in_pwd(base_branch:, lock_files:, recursive:)
  return unless any_lockfile_present?(lock_files)

  GitCommandRunner.create_branch!(base_branch: base_branch)
  bundle_update!(lock_files: lock_files, recursive: recursive)
  GitCommandRunner.commit_and_push_changes!
  GitHub::Client.make_pull_request!(lock_files)
end