Class: GitNotify
- Inherits:
-
Object
- Object
- GitNotify
- Defined in:
- lib/gitnotify.rb
Class Method Summary collapse
- .applied_hook? ⇒ Boolean
- .disable_notify ⇒ Object
- .enable_notify ⇒ Object
- .exit_with!(message) ⇒ Object
- .git_repo? ⇒ Boolean
- .help ⇒ Object
- .post_commit ⇒ Object
- .post_commit_script ⇒ Object
-
.repo_path ⇒ Object
Just a standard helper.
- .run(*args) ⇒ Object
Class Method Details
.applied_hook? ⇒ Boolean
56 57 58 |
# File 'lib/gitnotify.rb', line 56 def self.applied_hook? File.read(post_commit).include?('growlnotify') end |
.disable_notify ⇒ Object
28 29 30 31 |
# File 'lib/gitnotify.rb', line 28 def self.disable_notify FileUtils.chmod 0664, post_commit puts "Gitnotify: Disabled post-commit" end |
.enable_notify ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gitnotify.rb', line 16 def self.enable_notify exit_with! "You're not within a git repository" unless git_repo? FileUtils.touch post_commit FileUtils.chmod 0775, post_commit unless applied_hook? File.open(post_commit, "w+") do |f| f << File.read(post_commit_script) end end puts "Gitnotify: Enabled post-commit" end |
.exit_with!(message) ⇒ Object
73 74 75 76 |
# File 'lib/gitnotify.rb', line 73 def self.exit_with!() STDERR.puts exit! end |
.git_repo? ⇒ Boolean
52 53 54 |
# File 'lib/gitnotify.rb', line 52 def self.git_repo? File.exists?(repo_path) end |
.help ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gitnotify.rb', line 33 def self.help puts "\n=========================\nGitnotify, railscamp love\n=========================\n\nTell your peeps about your commits using growl\n \nUsage: (from within a git repo): gitnotify <command>\n \nenable-hook\n Enables a post-commit hook\n \ndisable-hook\n Disables a post-commit hook\n" end |
.post_commit ⇒ Object
65 66 67 |
# File 'lib/gitnotify.rb', line 65 def self.post_commit File.join(repo_path, "hooks", "post-commit") end |
.post_commit_script ⇒ Object
69 70 71 |
# File 'lib/gitnotify.rb', line 69 def self.post_commit_script File.join(File.dirname(__FILE__), "..", "supports", "post-commit") end |
.repo_path ⇒ Object
Just a standard helper
61 62 63 |
# File 'lib/gitnotify.rb', line 61 def self.repo_path File.join(Dir.pwd, ".git") end |
.run(*args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/gitnotify.rb', line 4 def self.run(*args) case args.shift when "enable-hook" enable_notify when "disable-hook" disable_notify else help end end |