cocoa-hookup 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/cocoa-hookup +6 -0
- data/lib/cocoa-hookup.rb +82 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 58cd124f6968a74ae0729cccce4c05dddda92ea1
|
4
|
+
data.tar.gz: 2d184f926307049b85d46d61cf507b0e788f6734
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 391aa23fdc4eb5832bdc6999ac3d9787be97dee80d1345474d0dbf3118b1cad75444e46a2c6a828a3e5eb87fd698867dbc000b052a3eaa6a675f2583e533dbb0
|
7
|
+
data.tar.gz: 874026502450a2f126d57cd664d4bf7dd52b8f26b02271a1cf1fe253061246c6593a8e3aac70869d252cadda4b2c6945318878d16ecb7906a18e66b7e8a731ea
|
data/bin/cocoa-hookup
ADDED
data/lib/cocoa-hookup.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Largely based on code from Tim Pope's Hookup Gem(https://github.com/tpope/hookup)
|
2
|
+
class CocoaHookup
|
3
|
+
|
4
|
+
class Error < RuntimeError
|
5
|
+
end
|
6
|
+
|
7
|
+
class Failure < Error
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.run(*argv)
|
11
|
+
new.run(*argv)
|
12
|
+
rescue Failure => e
|
13
|
+
puts e
|
14
|
+
exit 1
|
15
|
+
rescue Error => e
|
16
|
+
puts e
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(*argv)
|
21
|
+
if argv.first =~ /install/i
|
22
|
+
install
|
23
|
+
elsif argv.first =~ /post-checkout/i
|
24
|
+
post_checkout(*argv)
|
25
|
+
elsif argv.length == 0
|
26
|
+
puts "Usage: 'cocoa-hookup install' to install the git hook"
|
27
|
+
else
|
28
|
+
raise Error, "Invalid arguments for 'cocoa-hookup'"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def git_dir
|
33
|
+
unless @git_dir
|
34
|
+
@git_dir = %x{git rev-parse --git-dir}.chomp
|
35
|
+
raise Error unless $?.success?
|
36
|
+
end
|
37
|
+
@git_dir
|
38
|
+
end
|
39
|
+
|
40
|
+
def post_checkout_file
|
41
|
+
File.join(git_dir, 'hooks', 'post-checkout')
|
42
|
+
end
|
43
|
+
|
44
|
+
def post_checkout(*argv)
|
45
|
+
if argv.length != 4
|
46
|
+
puts "Invalid arguments for 'cocoa-hookup post-checkout'. Usage: 'cocoa-hookup post-checkout old-rev new-rev branching-flag'"
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
old = argv[1]
|
51
|
+
new = argv[2]
|
52
|
+
branch_checkout = argv[3]
|
53
|
+
|
54
|
+
return unless branch_checkout == "1" # Ignore if not a branch checkout
|
55
|
+
|
56
|
+
if %x{git diff --name-only #{old} #{new}} =~ /^Podfile/
|
57
|
+
puts "Podfile is different from last branch, updating Cocoapods..."
|
58
|
+
system('pod install')
|
59
|
+
system("terminal-notifier -title '#{`pwd`}' -message 'Cocoapods Updated' ")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def install
|
64
|
+
append(post_checkout_file, 0777) do |body, f|
|
65
|
+
f.puts "#!/bin/bash" unless body
|
66
|
+
f.puts "echo Running post-checkout script"
|
67
|
+
f.puts %(cocoa-hookup post-checkout "$@") if body !~ /cocoa-hookup/ #TODO: Remove ./
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "CocoaHookup Installed"
|
71
|
+
end
|
72
|
+
|
73
|
+
def append(file, *args)
|
74
|
+
Dir.mkdir(File.dirname(file)) unless File.directory?(File.dirname(file))
|
75
|
+
body = File.read(file) if File.exist?(file)
|
76
|
+
File.open(file, 'a', *args) do |f|
|
77
|
+
yield body, f
|
78
|
+
end
|
79
|
+
end
|
80
|
+
protected :append
|
81
|
+
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoa-hookup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sendhil Panchadsaram
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: terminal-notifier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.1
|
27
|
+
description: Simplify the Cocoapods dance that occurs when switching between branches
|
28
|
+
email: sendhilp@gmail.com
|
29
|
+
executables:
|
30
|
+
- cocoa-hookup
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/cocoa-hookup.rb
|
35
|
+
- bin/cocoa-hookup
|
36
|
+
homepage: http://rubygems.org/gems/cocoa-hookup
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.0.3
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Simplify the Cocoapods dance that occurs when switching between branches
|
60
|
+
test_files: []
|