peacock 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84ea91580dc4505136482f503da3b8bc0fb36749
4
- data.tar.gz: 1feb55166e087b89c66fa7684debe05f636b1070
3
+ metadata.gz: 33e4a22c408e35b4468b963ed395cb1eefd3dda9
4
+ data.tar.gz: 911e6d77543c8bfa6a65ddd62ea2dc5347e9d041
5
5
  SHA512:
6
- metadata.gz: 7356035129eec6ba016805660e380f278cab400e7e22f047dbbed419e7ade6402372eec6bd680e96f4076d3d69933555f1b3ad23c9584d4406ec64522739d582
7
- data.tar.gz: 28e4d4a38b0a25b201b6374146bfb807af7bba7d16ba87599b0c3b1dce0781e85676dad571b117c8ef602e2649aee69130c18a8b3b72395633314b0794d0d5b7
6
+ metadata.gz: a94e7f27752af85eab92a233cdd265571e8c41da79081f75166491f48070ddcd7eedd0aafabb9fb593661eda98fa5564cf9e3a2973eabb8eb9e65eb752b39645
7
+ data.tar.gz: 95ce5a06d6714f5e9120d04ace27c7d0285f010468c41625c45711dd6f7ff04314d196afe2c4f2544c6150236cb5c6ed0c5b4b57e0c3ce13c316c4ac483bdc4e
data/README.md CHANGED
@@ -2,11 +2,7 @@
2
2
 
3
3
  Peacock is a small tool to easily manage your .gitignore written in ruby.
4
4
 
5
- It lets you ignore and extract files and directories using .gitignore in your current git repository.
6
-
7
- Note that while ignoring files and directories peacock will perform safety commits to make sure your work is not lost. It will commit all your uncommited work (if there is any) before and after adding files to .gitignore.
8
-
9
- While extracting, peacock leaves everything untouched.
5
+ It lets you extract files and directories from .gitignore files as well as inserting new files to .gitignore
10
6
 
11
7
  Note that at the moment you can't combine options with one hyphen (e.g.: -ev for --extract and --verbose) but you have to pass them separated (e.g.: -e -v)
12
8
 
@@ -26,7 +22,7 @@ Options:
26
22
 
27
23
  -h, [--help] # show this text
28
24
  -r, [--root] # use root .gitignore
29
- -v, [--verbose] # surpress output
25
+ -s, [--silent] # suppress output
30
26
  -e, [--extract] # extract file from .gitignore
31
27
 
32
28
  ## Example
@@ -44,8 +40,10 @@ Options:
44
40
  added some to .gitignore
45
41
 
46
42
  $ git status
47
- On branch master
48
- nothing to commit, working directory clean
43
+ ...
44
+ Untracked files:
45
+ these
46
+ files
49
47
 
50
48
  $ peacock -e are
51
49
  removed are from .gitignore
@@ -53,15 +51,14 @@ Options:
53
51
  $ git status
54
52
  ...
55
53
  Untracked files:
54
+ these
56
55
  are
56
+ files
57
57
 
58
58
 
59
59
  ## TODO
60
60
 
61
- - add functionalities
62
- - custom commit messages
63
- - comments in .gitignore
64
- - options can't be combined (e.g. -ev for extract and surpress)
61
+ Issues are used for TODOs
65
62
 
66
63
  ## Contributing
67
64
 
data/lib/git.rb CHANGED
@@ -38,6 +38,10 @@ module Git
38
38
  def self.commit_all(message)
39
39
  Git::Lib.commit_all(message)
40
40
  end
41
+
42
+ def self.remove_from_cache(file)
43
+ Git::Lib.remove_from_cache(file)
44
+ end
41
45
 
42
46
  def self.clear_cache
43
47
  Git::Lib.clear_cache
@@ -23,6 +23,10 @@ module Git
23
23
  def self.clear_cache
24
24
  Git::Base.command_output('rm', '-r --cached .')
25
25
  end
26
+
27
+ def self.remove_from_cache(path)
28
+ Git::Base.command_output('rm', "-rf --cached #{path}")
29
+ end
26
30
 
27
31
  def self.log
28
32
  Git::Base.command_output('log')
@@ -50,13 +50,13 @@ module Peacock
50
50
  Options:
51
51
  \t-h, [--help] # show this text
52
52
  \t-r, [--root] # use root .gitignore
53
- \t-v, [--verbose] # surpress output
53
+ \t-s, [--silent] # surpress output
54
54
  \t-e, [--extract] # extract file from .gitignore
55
55
  EOF
56
56
  end
57
57
 
58
58
  def options
59
- %w(-r --root -e --extract -v --verbose)
59
+ %w(-r --root -e --extract -s --silent)
60
60
  end
61
61
 
62
62
  end
@@ -40,8 +40,8 @@ module Peacock
40
40
  opts.include?('-r') || opts.include?('--root')
41
41
  end
42
42
 
43
- def verbose?
44
- opts.include?('-v') || opts.include?('--verbose')
43
+ def silent?
44
+ opts.include?('-s') || opts.include?('--silent')
45
45
  end
46
46
 
47
47
  def engine
@@ -12,7 +12,7 @@ module Peacock
12
12
 
13
13
  def initialize(opt_hash)
14
14
  @hash = check_and_return_hash(opt_hash)
15
- @logger = Peacock::Logger.new(@hash.verbose?)
15
+ @logger = Peacock::Logger.new(@hash.silent?)
16
16
  path = determine_git_ignore_path
17
17
  git_ignore_exists?(path)
18
18
 
@@ -12,16 +12,13 @@ module Peacock
12
12
 
13
13
  def initialize(opt_hash)
14
14
  @hash = check_and_return_hash(opt_hash)
15
- @logger = Peacock::Logger.new(@hash.verbose?)
15
+ @logger = Peacock::Logger.new(@hash.silent?)
16
16
  path = determine_git_ignore_path
17
17
  @git_ignore = File.open(path, 'a+')
18
18
  end
19
19
 
20
20
  def workflow
21
- Git.commit_all('peacock: before .gitignore commit')
22
21
  ignore_files_and_directories
23
- Git.clear_cache
24
- Git.commit_all('peacock: after .gitignore commit')
25
22
  @git_ignore.close
26
23
  end
27
24
 
@@ -44,10 +41,9 @@ module Peacock
44
41
 
45
42
  def check_and_write(str)
46
43
  unless entry_exists?(str)
47
- @git_ignore.write(str + "\n")
48
- @logger.ignore(str)
44
+ insert_in_gitignore(str)
49
45
  end
50
-
46
+
51
47
  @git_ignore.rewind
52
48
  end
53
49
 
@@ -57,6 +53,21 @@ module Peacock
57
53
  end
58
54
  false
59
55
  end
56
+
57
+ def insert_in_gitignore(str)
58
+ @git_ignore.write(str + "\n")
59
+ Git.remove_from_cache(prepare_arg(str))
60
+ @logger.ignore(str)
61
+ end
62
+
63
+ # if directory then remove leading slash
64
+ def prepare_arg(str)
65
+ if str.start_with?('/')
66
+ str[1..-1]
67
+ else
68
+ str
69
+ end
70
+ end
60
71
 
61
72
  end
62
73
 
@@ -2,16 +2,16 @@ module Peacock
2
2
 
3
3
  class Logger
4
4
 
5
- def initialize(verbose)
6
- @verbose = verbose
5
+ def initialize(silent)
6
+ @silent = silent
7
7
  end
8
8
 
9
9
  def ignore(string)
10
- puts "added #{string} to .gitignore" unless @verbose
10
+ puts "added #{string} to .gitignore" unless @silent
11
11
  end
12
12
 
13
13
  def extract(string)
14
- puts "removed #{string} from .gitignore" unless @verbose
14
+ puts "removed #{string} from .gitignore" unless @silent
15
15
  end
16
16
 
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Peacock
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peacock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Paling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.5.1
105
+ rubygems_version: 2.5.1
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Peacock is a small tool to easily manage your .gitignore