Class: Releasecop::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/releasecop/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, envs, working_dir = Releasecop::CONFIG_DIR) ⇒ Checker

Returns a new instance of Checker.



5
6
7
8
9
# File 'lib/releasecop/checker.rb', line 5

def initialize(name, envs, working_dir = Releasecop::CONFIG_DIR)
  self.name = name
  self.envs = envs.map { |e| Releasecop::ManifestItem.new(name, e) }
  self.working_dir = working_dir
end

Instance Attribute Details

#envsObject

Returns the value of attribute envs.



3
4
5
# File 'lib/releasecop/checker.rb', line 3

def envs
  @envs
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/releasecop/checker.rb', line 3

def name
  @name
end

#working_dirObject

Returns the value of attribute working_dir.



3
4
5
# File 'lib/releasecop/checker.rb', line 3

def working_dir
  @working_dir
end

Instance Method Details

#checkObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/releasecop/checker.rb', line 11

def check
  Dir.chdir(working_dir) do
    `git clone #{envs.first.git} #{'--bare' if envs.all?(&:bare_clone?)} #{name} > /dev/null 2>&1`

    Dir.chdir(name) do
      envs.each do |env|
        `git remote add #{env.name} #{env.git} > /dev/null 2>&1`
        `git fetch #{env.name} > /dev/null 2>&1`
      end

      comparisons = []
      envs.each_cons(2) do |ahead, behind|
        comparisons << Releasecop::Comparison.new(ahead, behind)
      end

      comparisons.each &:check
      @result = Releasecop::Result.new(name, comparisons)
    end
  end
end

#puts_message(verbose_flag) ⇒ Object



32
33
34
# File 'lib/releasecop/checker.rb', line 32

def puts_message(verbose_flag)
  @result.puts_message(verbose_flag)
end

#unreleasedObject



36
37
38
# File 'lib/releasecop/checker.rb', line 36

def unreleased
  @result.unreleased
end