gitstagram 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -13,6 +13,8 @@ test/version_tmp
13
13
  tmp
14
14
  .rspec
15
15
  Gemfile.lock
16
+ .rbenv-version
17
+ .DS_Store
16
18
 
17
19
  # YARD artifacts
18
20
  .yardoc
data/bin/gitstagram CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/gitstagram/cli.rb'
3
+ require File.join(File.dirname(__FILE__), '../lib/gitstagram/cli.rb')
4
4
 
5
5
  begin
6
6
  cli = Gitstagram::CLI.new
data/gitstagram.gemspec CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.email = ["g.marcilhacy@gmail.com"]
6
6
  gem.description = gem.summary = "Take a snapshot after each commit."
7
7
  gem.homepage = "https://github.com/gregorym/gitstagram"
8
-
8
+
9
9
  gem.executables = ['gitstagram']
10
10
  gem.files = `git ls-files | grep -v myapp`.split("\n")
11
11
  gem.test_files = `git ls-files -- spec/*`.split("\n")
@@ -1,12 +1,16 @@
1
1
  module Gitstagram
2
2
  class GitDir < Dir
3
3
 
4
+ def initialize(path)
5
+ @path = path
6
+ end
7
+
4
8
  #
5
9
  # Returns true if the current directory is a git directory.
6
10
  ## Check the presence of .git in the folder
7
11
  #
8
12
  def is_git_directory?
9
- Dir.glob('.git').include? '.git'
13
+ Dir.entries('.').include? '.git'
10
14
  end
11
15
  alias_method :is_git_dir?, :is_git_directory?
12
16
 
@@ -15,14 +19,14 @@ module Gitstagram
15
19
  # Returns true if the git directory already has a post-commit hook.
16
20
  #
17
21
  def has_post_commit_hook?
18
- Dir.glob('.git/hooks/*').include? '.git/hooks/post-commit'
22
+ Dir.entries('.git/hooks').include? 'post-commit'
19
23
  end
20
24
 
21
25
  #
22
26
  # Remove post-commit file from .git/hooks
23
27
  #
24
28
  def delete_post_commit
25
- file_path = path + '/.git/hooks/post-commit'
29
+ file_path = @path + '/.git/hooks/post-commit'
26
30
  if File.exists? file_path
27
31
  File.delete file_path
28
32
  end
@@ -37,4 +41,15 @@ module Gitstagram
37
41
  File.open('./.git/hooks/post-commit', 'w', 0755) {|f| f.write(file) }
38
42
  end
39
43
  end
44
+ end
45
+
46
+ if RUBY_VERSION =~ /^1\.8/
47
+ class Dir
48
+ class << self
49
+ def exists? (path)
50
+ File.directory?(path)
51
+ end
52
+ alias_method :exist?, :exists?
53
+ end
54
+ end
40
55
  end
@@ -4,12 +4,12 @@ require 'rubygems'
4
4
  begin
5
5
  require 'gitstagram'
6
6
  rescue LoadError
7
- STDERR.puts 'Gistagram is not install. Run: gem install gitstgram'
7
+ STDERR.puts 'Gistagram is not install. Run: gem install gitstagram'
8
8
  end
9
9
 
10
10
  begin
11
11
  Gitstagram::Snapshot.smile
12
- rescue e
12
+ rescue Exception => e
13
13
  STDERR.puts e.message
14
14
  STDERR.puts e.backtrace.join(', ')
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module Gitstagram
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/git_dir_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Gitstagram::GitDir do
8
8
  describe "#is_git_directory?" do
9
9
  context 'folder contains a .git directory' do
10
10
  before do
11
- stub(Dir).glob { ['.git'] }
11
+ stub(Dir).entries { ['.git'] }
12
12
  end
13
13
 
14
14
  it 'should return true' do
@@ -18,7 +18,7 @@ describe Gitstagram::GitDir do
18
18
 
19
19
  context 'folder does not contain a .git directory' do
20
20
  before do
21
- stub(Dir).glob { ['hello', 'world'] }
21
+ stub(Dir).entries { ['hello', 'world'] }
22
22
  end
23
23
 
24
24
  it 'should return false' do
@@ -30,7 +30,7 @@ describe Gitstagram::GitDir do
30
30
  describe "#has_post_commit_hook" do
31
31
  context "hooks folder contains a post-commit file" do
32
32
  before do
33
- stub(Dir).glob { ['.git/hooks/post-commit', '.git/hooks/pre-commit.sample'] }
33
+ stub(Dir).entries { ['post-commit', 'pre-commit.sample'] }
34
34
  end
35
35
 
36
36
  it "should return true" do
@@ -41,7 +41,7 @@ describe Gitstagram::GitDir do
41
41
 
42
42
  context "hooks folder does not contain a post-commit file" do
43
43
  before do
44
- stub(Dir).glob { ['post-commit.sample', 'pre-commit.sample'] }
44
+ stub(Dir).entries { ['post-commit.sample', 'pre-commit.sample'] }
45
45
  end
46
46
 
47
47
  it "should return true" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitstagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,6 +38,7 @@ files:
38
38
  - .gitignore
39
39
  - Gemfile
40
40
  - README.md
41
+ - bin/gitstagram
41
42
  - gitstagram.gemspec
42
43
  - lib/gitstagram.rb
43
44
  - lib/gitstagram/cli.rb
@@ -56,7 +57,6 @@ files:
56
57
  - tools/.DS_Store
57
58
  - tools/imagesnap
58
59
  - tools/tlassemble
59
- - bin/gitstagram
60
60
  homepage: https://github.com/gregorym/gitstagram
61
61
  licenses: []
62
62
  post_install_message: