[DRE-commits] [librarian-puppet] 74/97: Remove duplicated code
Stig Sandbeck Mathisen
ssm at debian.org
Tue Mar 11 12:12:51 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository librarian-puppet.
commit b6bc0b84643ce50cd39f340b15e2a2cbeae4099e
Author: Carlos Sanchez <csanchez at maestrodev.com>
Date: Mon Jan 27 12:32:42 2014 +0100
Remove duplicated code
---
lib/librarian/puppet/extension.rb | 187 --------------------------------------
1 file changed, 187 deletions(-)
diff --git a/lib/librarian/puppet/extension.rb b/lib/librarian/puppet/extension.rb
index 5262cbb..f11ed51 100644
--- a/lib/librarian/puppet/extension.rb
+++ b/lib/librarian/puppet/extension.rb
@@ -5,11 +5,8 @@ module Librarian
module Puppet
extend self
extend Librarian
-
end
-end
-module Librarian
class Dependency
class Requirement
def initialize(*args)
@@ -38,7 +35,6 @@ module Librarian
def hash
self.to_s.hash
end
-
end
# Fixes for librarian not yet released in their gem
@@ -71,189 +67,6 @@ module Librarian
end
end
-
- module Action
- class Install < Base
-
- private
-
- def create_install_path
- install_path.rmtree if install_path.exist? && destructive?
- install_path.mkpath
- end
-
- def destructive?
- environment.config_db.local['destructive'] == 'true'
- end
- end
- end
-
- class ManifestSet
- private
-
- # Check if module doesn't exist and fail fast
- def dependencies_of(names)
- names = Array === names ? names.dup : names.to_a
- assert_strings!(names)
-
- deps = Set.new
- until names.empty?
- name = names.shift
- next if deps.include?(name)
-
- deps << name
- raise(Error, "Unable to find module #{name}") if index[name].nil?
- names.concat index[name].dependencies.map(&:name)
- end
- deps.to_a
- end
- end
-
- class Manifest
-
- class PreReleaseVersion
-
- # Compares pre-release component ids using Semver 2.0.0 spec
- def self.compare_components(this_id,other_id)
- case # Strings have higher precedence than numbers
- when (this_id.is_a?(Integer) and other_id.is_a?(String))
- -1
- when (this_id.is_a?(String) and other_id.is_a?(Integer))
- 1
- else
- this_id <=> other_id
- end
- end
-
- # Parses pre-release components `a.b.c` into an array ``[a,b,c]`
- # Converts numeric components into +Integer+
- def self.parse(prerelease)
- if prerelease.nil?
- []
- else
- prerelease.split('.').collect do |id|
- id = Integer(id) if /^[0-9]+$/ =~ id
- id
- end
- end
- end
-
- include Comparable
-
- attr_reader :components
-
- def initialize(prerelease)
- @prerelease = prerelease
- @components = PreReleaseVersion.parse(prerelease)
- end
-
- def to_s
- @prerelease
- end
-
- def <=>(other)
- # null-fill zip array to prevent loss of components
- z = Array.new([components.length,other.components.length])
-
- # Compare each component against the other
- comp = z.zip(components,other.components).collect do |ids|
- case # All components being equal, the version with more of them takes precedence
- when ids[1].nil? # Self has less elements, other wins
- -1
- when ids[2].nil? # Other has less elements, self wins
- 1
- else
- PreReleaseVersion.compare_components(ids[1],ids[2])
- end
- end
- # Chose the first non-zero comparison or return 0
- comp.delete_if {|c| c == 0}[0] || 0
- end
- end
- class Version
- @@SEMANTIC_VERSION_PATTERN = /^([0-9]+\.[0-9]+(?:\.[0-9]+)?)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
- def self.parse_semver(version_string)
- parsed = @@SEMANTIC_VERSION_PATTERN.match(version_string.strip)
- if parsed
- {
- :full_version => parsed[0],
- :version => parsed[1],
- :prerelease => (PreReleaseVersion.new(parsed[2]) if parsed[2]),
- :build => parsed[3]
- }
- end
- end
-
- attr_reader :prerelease
-
- def initialize(*args)
- args = initialize_normalize_args(args)
- semver = Version.parse_semver(*args)
- if semver
- self.backing = Gem::Version.new(semver[:version])
- @prerelease = semver[:prerelease]
- @full_version = semver[:full_version]
- else
- self.backing = Gem::Version.new(*args)
- @full_version = to_gem_version.to_s
- end
- end
-
- def <=>(other)
- cmp = to_gem_version <=> other.to_gem_version
-
- # Should compare pre-release versions?
- if cmp == 0 and not (prerelease.nil? and other.prerelease.nil?)
- case # Versions without prerelease take precedence
- when (prerelease.nil? and not other.prerelease.nil?)
- 1
- when (not prerelease.nil? and other.prerelease.nil?)
- -1
- else
- prerelease <=> other.prerelease
- end
- else
- cmp
- end
- end
-
- def to_s
- @full_version
- end
- end
- end
-
- # Fixes for librarian not yet released in their gem
- module Mock
- module Source
- class Mock
- alias :eql? :==
-
- def hash
- self.to_s.hash
- end
- end
- end
- end
- module Source
- class Git
- alias :eql? :==
-
- def hash
- self.to_s.hash
- end
- end
-
- class Path
- alias :eql? :==
-
- def hash
- self.to_s.hash
- end
- end
- end
-
-
module Action
class Install < Base
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/librarian-puppet.git
More information about the Pkg-ruby-extras-commits
mailing list