mate 2.1.1 → 2.2.0

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
  SHA256:
3
- metadata.gz: c775458d416142a253db083e4d9c60a0f54d826cca9b02b4529a95b52a679b86
4
- data.tar.gz: 2b80d97ceaf6f1dffb92666cbe5bd35178ac5f018ea44c0008ce18570b3c12fc
3
+ metadata.gz: 48e7e1cb9ee23a719cdc6b634dc2639e5afa0cfc1d622354bd602c741a1c3f92
4
+ data.tar.gz: 32d0efa02bb8d71116c59f900244bbaedd8fd0c334ca9c8099feb69d28fab3a8
5
5
  SHA512:
6
- metadata.gz: 32f73c550e6dd223f666bef6bf245d33827cddba3622a2a2a71033cc9a4c129636c036fc9f33a004ab055cf2290a5e5c3eadc38e2d91c5bc030c5576a19297b5
7
- data.tar.gz: 13d6e400fef725d92257084a779b63bce93b6186e83ed7705208041f61932f8785e6a083fff42cc5c8f451b59867aa6bece381c567f12f39616e9d462675a137
6
+ metadata.gz: a9ebac2d8bd91e393a61201c8697837aff27bfde035272b60ddb4c41ae45a9a2bcade929ad54ff8524b0752442a65bc1582c78f861b9c35da3deeefa6b061aa3
7
+ data.tar.gz: 8d837dfb721952669be640fb453d9c45ee115de7ca6ee68398277524cf4002fe0e0f03a7e7547aa2af8e5e9275dd2ad7f99d1f28b46d79ac8a2ab08ed7d3e49a
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2019 Ivan Kuchin
1
+ Copyright (c) 2010-2020 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -8,4 +8,4 @@ When `tm` command (or `mate` if aliased) is called with one or more paths and an
8
8
 
9
9
  ## Copyright
10
10
 
11
- Copyright (c) 2010-2019 Ivan Kuchin. See LICENSE.txt for details.
11
+ Copyright (c) 2010-2020 Ivan Kuchin. See LICENSE.txt for details.
data/bin/tm2 CHANGED
@@ -5,7 +5,7 @@ require 'mate/tm_properties'
5
5
 
6
6
  ARGV.each do |arg|
7
7
  if File.directory?(arg)
8
- Mate::TmProperties.new(arg).save
8
+ Mate::TmProperties.create(arg)
9
9
  end
10
10
  end
11
11
 
@@ -0,0 +1,32 @@
1
+ module Mate
2
+ module Git
3
+ class << self
4
+ def excludesfile(workind_dir)
5
+ expand_path IO.popen(%W[git -C #{workind_dir} config --get core.excludesfile], &:read)
6
+ end
7
+
8
+ def global_tmignore
9
+ expand_path '~/.tmignore'
10
+ end
11
+
12
+ def toplevel(workind_dir)
13
+ expand_path IO.popen(%W[git -C #{workind_dir} rev-parse --show-toplevel], err: '/dev/null', &:read)
14
+ end
15
+
16
+ def git_dir(workind_dir)
17
+ expand_path IO.popen(%W[git -C #{workind_dir} rev-parse --absolute-git-dir], err: '/dev/null', &:read)
18
+ end
19
+
20
+ private
21
+
22
+ def expand_path(path)
23
+ return unless path
24
+
25
+ path = path.strip
26
+ return if path == ''
27
+
28
+ Pathname(path).expand_path
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,26 +1,39 @@
1
1
  require 'pathname'
2
+ require 'mate/git'
2
3
 
3
4
  module Mate
4
5
  class TmProperties
5
- attr_reader :dir, :file
6
+ def self.create(dir)
7
+ new(Git.toplevel(dir) || dir).save
8
+ end
9
+
6
10
  def initialize(dir)
7
11
  @dir = Pathname(dir).expand_path
8
12
  @file = @dir + '.tm_properties'
13
+ @lines = @file.exist? ? @file.read.split("\n") : []
14
+ @other_lines = @lines.reject{ |line| line =~ Ignores::GENERATED_R }
9
15
  end
10
16
 
11
17
  def save
12
- ignores = Ignores.new(dir)
18
+ ignores = Ignores.new(@dir)
19
+
20
+ write(ignores.lines + @other_lines)
21
+ end
13
22
 
14
- lines = if file.exist?
15
- file.readlines.reject do |line|
16
- line =~ Ignores::GENERATED_R
17
- end
23
+ def cleanup
24
+ if @other_lines.empty?
25
+ @file.unlink if @file.exist?
18
26
  else
19
- []
27
+ write(@other_lines)
20
28
  end
29
+ end
30
+
31
+ private
32
+
33
+ def write(lines)
34
+ return if lines == @lines
21
35
 
22
36
  @file.open('w') do |f|
23
- f.puts ignores.lines
24
37
  f.puts lines
25
38
  end
26
39
  end
@@ -1,6 +1,8 @@
1
+ require 'mate/git'
2
+
1
3
  module Mate
2
4
  class TmProperties::Ignores
3
- GENERATED_SUFFIX = "## GENERATED ##"
5
+ GENERATED_SUFFIX = '## GENERATED ##'
4
6
  GENERATED_R = /^exclude(?:Directories)? = .* #{Regexp.escape(GENERATED_SUFFIX)}$/
5
7
 
6
8
  attr_reader :dir
@@ -9,17 +11,29 @@ module Mate
9
11
  @exclude = ['**/.git']
10
12
  @exclude_directories = []
11
13
 
12
- process(dir, '.', Pathname(`git config --get core.excludesfile`.strip).expand_path)
13
- process(dir, '.', Pathname('~/.tmignore').expand_path)
14
+ process('.', Git.excludesfile(dir))
15
+ process('.', Git.global_tmignore)
16
+ if (git_dir = Git.git_dir(dir))
17
+ process('.', git_dir + 'info/exclude')
18
+ end
14
19
 
15
20
  dir.find do |path|
16
- if path.directory?
21
+ next unless path.lstat.directory?
22
+
23
+ toplevel = dir == path
24
+
25
+ if !toplevel && (path + '.git').exist?
26
+ TmProperties.new(path).save
27
+ Find.prune
28
+ else
17
29
  relative_path = path.relative_path_from(dir).to_s
18
30
  Find.prune if ignore_dir?(relative_path)
19
- %w[.gitignore .tmignore .git/info/exclude].each do |ignore_file_name|
20
- if (ignore_file = path + ignore_file_name).file?
21
- process(dir, relative_path, ignore_file)
22
- end
31
+ %w[.gitignore .tmignore].each do |ignore_file_name|
32
+ process(relative_path, path + ignore_file_name)
33
+ end
34
+
35
+ if !toplevel && (path + '.tm_properties').exist?
36
+ TmProperties.new(path).cleanup
23
37
  end
24
38
  end
25
39
  end
@@ -43,8 +57,8 @@ module Mate
43
57
  end
44
58
  end
45
59
 
46
- def process(parent, subdirectory, ignore_file)
47
- return unless ignore_file.exist?
60
+ def process(subdirectory, ignore_file)
61
+ return unless ignore_file && ignore_file.exist?
48
62
 
49
63
  prefix = subdirectory == '.' ? '' : glob_escape("#{subdirectory}/")
50
64
 
@@ -1,3 +1,5 @@
1
+ require 'mate/git'
2
+
1
3
  module Mate
2
4
  class Tmproj::Ignores
3
5
  BINARY_EXTENSIONS = [
@@ -14,8 +16,8 @@ module Mate
14
16
  @file_pattern = ["#{DOUBLE_ASTERISK_R}.+\\.(?:#{BINARY_EXTENSIONS.flatten.join('|')})"]
15
17
  @folder_pattern = ["#{DOUBLE_ASTERISK_R}.git"]
16
18
 
17
- process(dir, Pathname(`git config --get core.excludesfile`.strip).expand_path)
18
- process(dir, Pathname('~/.tmignore').expand_path)
19
+ process(dir, Git.excludesfile(dir))
20
+ process(dir, Git.global_tmignore)
19
21
 
20
22
  dir.find do |path|
21
23
  Find.prune if ignore?(path)
@@ -2,9 +2,9 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'mate'
5
- s.version = '2.1.1'
5
+ s.version = '2.2.0'
6
6
  s.summary = %q{TextMate project builder and TextMate 2 properties builder using git ignores for exclusions}
7
- s.homepage = "http://github.com/toy/#{s.name}"
7
+ s.homepage = "https://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
9
9
  s.license = 'MIT'
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-14 00:00:00.000000000 Z
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plist
@@ -38,17 +38,18 @@ files:
38
38
  - bin/tm
39
39
  - bin/tm2
40
40
  - lib/mate/bin.rb
41
+ - lib/mate/git.rb
41
42
  - lib/mate/tm_properties.rb
42
43
  - lib/mate/tm_properties/ignores.rb
43
44
  - lib/mate/tmproj.rb
44
45
  - lib/mate/tmproj/ignores.rb
45
46
  - mate.gemspec
46
- homepage: http://github.com/toy/mate
47
+ homepage: https://github.com/toy/mate
47
48
  licenses:
48
49
  - MIT
49
50
  metadata:
50
51
  bug_tracker_uri: https://github.com/toy/mate/issues
51
- documentation_uri: https://www.rubydoc.info/gems/mate/2.1.1
52
+ documentation_uri: https://www.rubydoc.info/gems/mate/2.2.0
52
53
  source_code_uri: https://github.com/toy/mate
53
54
  post_install_message:
54
55
  rdoc_options: []
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  requirements: []
68
- rubygems_version: 3.0.3
69
+ rubygems_version: 3.1.2
69
70
  signing_key:
70
71
  specification_version: 4
71
72
  summary: TextMate project builder and TextMate 2 properties builder using git ignores