Class: CommitPhoto

Inherits:
Object
  • Object
show all
Defined in:
lib/commitphotos.rb,
lib/commitphotos/version.rb

Direct Known Subclasses

Image, Video

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.hook(global, video) ⇒ Object

This will setup Commitphotos for the user.



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

def self.hook(global, video)
  if global
    destination = File.expand_path(`git config --get init.templatedir`.chomp)
    if destination.empty?
      destination = '~/.gittemplates'
      mkdir_p(destination) unless File.exist?(destination)
      `git config --global init.templatedir #{destination}`
    end
  else
    destination = File.expand_path(File.join(Dir.pwd, '.git/hooks'))
    abort 'Error: not a git repository.' unless File.exist? File.join(Dir.pwd, '.git')
  end

  type = video ? 'video' : 'image'

  local_post_commit = "#{File.expand_path(File.dirname(__FILE__))}/commitphotos/hooks/post-commit-#{type}"
  
  FileUtils.mkdir_p(destination)
  FileUtils.copy(local_post_commit, File.join(destination, 'post-commit'))
end

.imageObject



33
34
35
36
# File 'lib/commitphotos.rb', line 33

def self.image
  puts "Say cheese!"
  Image.new
end

.videoObject



38
39
40
41
# File 'lib/commitphotos.rb', line 38

def self.video
  puts "Say cheese!"
  Video.new
end