Module: Polisher::HasState

Defined in:
lib/polisher/gem_state.rb

Instance Method Summary collapse

Instance Method Details

#distgitObject



27
28
29
# File 'lib/polisher/gem_state.rb', line 27

def distgit
  @distgit ||= Git::Pkg.new :name => name
end

#distgit_branchesObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/polisher/gem_state.rb', line 31

def distgit_branches
  tags = []

  koji_tags.each do |tag, version|
    tag = TagMapper.map(tag)
    tags << tag unless tag.nil?
  end

  tags.empty? ? distgit.valid_branches : tags
end

#distgit_state(args = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/polisher/gem_state.rb', line 49

def distgit_state(args = {})
  check_dep = args.key?(:check)

  begin
    distgit.clone
  rescue
    return :missing_repo
  end

  return :missing_branch if distgit.valid_branches.empty?
  return :missing_spec   if distgit_versions.empty?
  return :available      unless check_dep

  distgit_versions.each do |version|
    return :available if args[:check].match?(name, version)
  end

  return :missing
end

#distgit_versionsObject



42
43
44
45
46
47
# File 'lib/polisher/gem_state.rb', line 42

def distgit_versions
  distgit_branches.collect do |branch|
    distgit.fetch branch
    distgit.spec.version if distgit.spec?
  end.compact
end

#koji_state(args = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/polisher/gem_state.rb', line 14

def koji_state(args = {})
  check_dep = args.key?(:check)

  return :missing   if koji_tags.empty?
  return :available unless check_dep

  koji_tags.each do |tag, version|
    return :available if !version.nil? && args[:check].match?(name, version)
  end

  return :missing
end

#koji_tagsObject



10
11
12
# File 'lib/polisher/gem_state.rb', line 10

def koji_tags
  Koji.tagged_version_for(name)
end

#state(args = {}) ⇒ Object

Return the ‘state’ of the gem as inferred by the targets which there are versions for.

If optional :check argument is specified, version analysis will be restricted to targets satisfying the specified gem dependency requirements



75
76
77
78
79
80
81
82
83
84
# File 'lib/polisher/gem_state.rb', line 75

def state(args = {})
  return :available if koji_state(args) == :available

  state = distgit_state(args)
  return :needs_repo   if state == :missing_repo
  return :needs_branch if state == :missing_branch 
  return :needs_spec   if state == :missing_spec
  return :needs_build  if state == :available
  return :needs_update
end