Skip to content

Commit

Permalink
Add convenience methods for accessing version and requirement classes
Browse files Browse the repository at this point in the history
  • Loading branch information
greysteil committed Apr 1, 2018
1 parent 615a1c7 commit 114d233
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dependabot-core.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "./lib/dependabot/version"
require "./lib/dependabot"

Gem::Specification.new do |spec|
spec.name = "dependabot-core"
Expand Down
1 change: 1 addition & 0 deletions lib/dependabot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module Dependabot
VERSION = "0.52.29"
end
24 changes: 24 additions & 0 deletions lib/dependabot/requirement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require "dependabot/update_checkers/python/pip/requirement"
require "dependabot/update_checkers/java_script/npm_and_yarn/requirement"
require "dependabot/update_checkers/php/composer/requirement"
require "dependabot/update_checkers/elixir/hex/requirement"
require "dependabot/update_checkers/rust/cargo/requirement"

module Dependabot
module Requirement
def self.for_package_manager(package_manager)
case package_manager
when "bundler", "maven", "submodules", "docker" then Gem::Requirement
when "npm_and_yarn"
UpdateCheckers::JavaScript::NpmAndYarn::Requirement
when "pip" then UpdateCheckers::Python::Pip::Requirement
when "composer" then UpdateCheckers::Php::Composer::Requirement
when "hex" then UpdateCheckers::Elixir::Hex::Requirement
when "cargo" then UpdateCheckers::Rust::Cargo::Requirement
else raise "Unsupported package_manager #{package_manager}"
end
end
end
end
1 change: 1 addition & 0 deletions lib/dependabot/update_checkers/python/pip/requirement.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "dependabot/update_checkers/python/pip"
require "dependabot/update_checkers/python/pip/version"

module Dependabot
Expand Down
28 changes: 27 additions & 1 deletion lib/dependabot/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# frozen_string_literal: true

# These must be loaded first, or we get load order errors
require "dependabot/update_checkers/python/pip/requirement"
require "dependabot/update_checkers/elixir/hex/requirement"

require "dependabot/update_checkers/python/pip/version"
require "dependabot/update_checkers/java/maven/version"
require "dependabot/update_checkers/java_script/npm_and_yarn/version"
require "dependabot/update_checkers/php/composer/version"
require "dependabot/update_checkers/elixir/hex/version"
require "dependabot/update_checkers/rust/cargo/version"

module Dependabot
VERSION = "0.52.29"
module Version
# rubocop:disable Metrics/CyclomaticComplexity
def self.for_package_manager(package_manager)
case package_manager
when "bundler", "submodules", "docker" then Gem::Version
when "maven" then UpdateCheckers::Java::Maven::Version
when "npm_and_yarn" then UpdateCheckers::JavaScript::NpmAndYarn::Version
when "pip" then UpdateCheckers::Python::Pip::Version
when "composer" then UpdateCheckers::Php::Composer::Version
when "hex" then UpdateCheckers::Elixir::Hex::Version
when "cargo" then UpdateCheckers::Rust::Cargo::Version
else raise "Unsupported package_manager #{package_manager}"
end
end
# rubocop:enable Metrics/CyclomaticComplexity
end
end

0 comments on commit 114d233

Please sign in to comment.