gitkeep 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. data/bin/gitkeep +13 -0
  2. data/lib/gitkeep.rb +28 -4
  3. metadata +2 -2
@@ -1,5 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ if !ARGV.delete('-h').nil?
4
+ put 'gitkeep version 0.2.3'
5
+ put 'options:'
6
+ put "-d \t drymode"
7
+ put "-i \t interactive"
8
+ put "-a \t adding .gitkeep files to your git index"
9
+ exit
10
+ end
11
+
3
12
  require 'gitkeep'
4
13
 
5
14
  gitkeep = Gitkeep.new
@@ -7,6 +16,10 @@ gitkeep = Gitkeep.new
7
16
  # set options
8
17
  gitkeep.dryrun = !ARGV.delete('-d').nil?
9
18
  gitkeep.interactive = !ARGV.delete('-i').nil?
19
+ if !ARGV.delete('-a').nil?
20
+ gitkeep.search(".")
21
+ exit
22
+ end
10
23
 
11
24
  if ARGV.size == 0
12
25
  # no options, create in current path
@@ -11,6 +11,8 @@ class Gitkeep
11
11
  @interactive = false
12
12
  @file_count = 0
13
13
  @error_count = 0
14
+
15
+ @@ignores = ['.git']
14
16
  end
15
17
 
16
18
  def create(path)
@@ -23,13 +25,11 @@ class Gitkeep
23
25
 
24
26
  puts "gitkeep is creating files..."
25
27
 
26
- ignores = ['.git']
27
-
28
28
  Find.find(path) do |p|
29
29
  name = File.basename(p)
30
30
  if File.directory?(p)
31
31
  if File.readable?(p)
32
- if ignores.include?(name)
32
+ if @@ignores.include?(name)
33
33
  Find.prune
34
34
  else
35
35
  if Dir.entries(p).size == 2
@@ -40,7 +40,7 @@ class Gitkeep
40
40
  puts red("[error] could not READ in #{p}/ -> check permissions")
41
41
  @error_count += 1
42
42
  end
43
- end
43
+ end
44
44
  end
45
45
 
46
46
  puts "finished. #{@file_count} file(s) created!"
@@ -48,6 +48,30 @@ class Gitkeep
48
48
  true if @error_count == 0
49
49
  end
50
50
 
51
+ def search(path)
52
+ files = []
53
+
54
+ Find.find(path) do |p|
55
+ name = File.basename(p)
56
+ if @@ignores.include?(name)
57
+ Find.prune
58
+ else
59
+ files << p if name == '.gitkeep'
60
+ end
61
+ end
62
+
63
+ add_to_index(files)
64
+ end
65
+
66
+ def add_to_index(files)
67
+ puts "adding files to git index..."
68
+ puts files
69
+ files = files.join(' ') if files.kind_of?(Array)
70
+ `git add -f #{files}`
71
+ puts green("files were added!")
72
+ puts `git status`
73
+ end
74
+
51
75
  protected if @__test == false
52
76
 
53
77
  def save(path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitkeep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: create .gitkeep files in all empty directories in your project
15
15
  email: arthurz.mobile@gmail.com