Class: ProjectGroup::Repo

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/project_group/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/project_group/repo.rb', line 4

def path
  @path
end

Instance Method Details

#changes?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/project_group/repo.rb', line 68

def changes?
  changed_files.values.any? { |x| x.size > 0 }
end

#cmd(str) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/project_group/repo.rb', line 8

def cmd(str)
  c = "cd #{path} && #{str}"
  puts c
  res = ProjectGroup.ec(c)
  puts res
  res
end

#current?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/project_group/repo.rb', line 91

def current?
  !changes? && pushed?
end

#git(*args) ⇒ Object



15
16
17
18
19
# File 'lib/project_group/repo.rb', line 15

def git(*args)
  raise "no git repo for #{path}" unless FileTest.exist?("#{path}/.git")
  str = args.join(" ")
  cmd "git #{str}"
end

#nameObject



5
6
7
# File 'lib/project_group/repo.rb', line 5

def name
  raise "name call"
end

#print!Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/project_group/repo.rb', line 27

def print!
  puts "Gem: #{name}".color(:white)
  if !current?
    changed_files.each do |type,files|
      files.each do |f|
        puts "#{type}: #{f}"
      end
    end
    puts "Needs Push #{local_ref} -> #{remote_ref}" unless pushed?
  else
    puts "No Changes"
  end
end

#push_check!Object



95
96
97
98
99
100
101
102
103
# File 'lib/project_group/repo.rb', line 95

def push_check!
  repo!; local_ref!
  return if pushed?
  print "Push? "
  resp = STDIN.gets.to_s.strip.downcase
  if resp == 'y'
    git "push origin master"
  end
end

#pushed?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/project_group/repo.rb', line 87

def pushed?
  remote_ref == local_ref
end

#use_file?(f) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/project_group/repo.rb', line 41

def use_file?(f)
  return false if %w(build tmp log pkg vendor junk).any? { |x| x == f.split("/").first }
  return false if f =~ /public\/assets/
  return false if f.split(".").last == "log"
  return false if f =~ /testflight_launcher/
  true
end