mate 2.2.0 → 3.0.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: 48e7e1cb9ee23a719cdc6b634dc2639e5afa0cfc1d622354bd602c741a1c3f92
4
- data.tar.gz: 32d0efa02bb8d71116c59f900244bbaedd8fd0c334ca9c8099feb69d28fab3a8
3
+ metadata.gz: a711bce5d45e59407c4f0d6e035f90adeba73720e7e48c9a294277f4cea9feb2
4
+ data.tar.gz: 355ae26696d775c4b4839bfe554d950a64e166e5f847bbf800bd2d5607f18ee4
5
5
  SHA512:
6
- metadata.gz: a9ebac2d8bd91e393a61201c8697837aff27bfde035272b60ddb4c41ae45a9a2bcade929ad54ff8524b0752442a65bc1582c78f861b9c35da3deeefa6b061aa3
7
- data.tar.gz: 8d837dfb721952669be640fb453d9c45ee115de7ca6ee68398277524cf4002fe0e0f03a7e7547aa2af8e5e9275dd2ad7f99d1f28b46d79ac8a2ab08ed7d3e49a
6
+ metadata.gz: c395940fd1aa663fa41b313341a044b40eb6fe457a3dd77ff37e14abae6b79ce94c8c3f079e85fd83251ca6cc86546a2cad72085cd763c7dcb2b39ec6afe30de
7
+ data.tar.gz: '049d6a9ac5c97ad7c64b91326d238f52ca2c12487b611913662d8beb45f63226a706c5df518353cecf00c65109c70fb8aace5df0051b0d7e98a57d19f14860ef'
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2020 Ivan Kuchin
1
+ Copyright (c) 2010-2021 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
data/README.markdown CHANGED
@@ -1,11 +1,11 @@
1
1
  # mate
2
2
 
3
- TextMate project builder and TextMate 2 properties builder using git ignores for exclusions.
3
+ TextMate 2 properties builder using git ignores for exclusions.
4
4
 
5
- You can add `alias mate='tm'` or `alias mate='tm2'` to your `.profile`, `.bash_profile` …
5
+ You can add `alias mate='tm2'` to your `.profile`, `.bash_profile` …
6
6
 
7
- When `tm` command (or `mate` if aliased) is called with one or more paths and any of them is a directory, than project is created in `~/.tmprojs/` and opened. When `tm2` command (or `mate` if aliased) is called with one or more paths, for all directories a `.tm_properties` file is generated or changed and mate is called. Its file and folder filters are built based on all types of git ignores (global, `.gitignore` and `.git/info/exclude`) and special `.tmignore` which works like other ignore files for project but doesn't affect git itself (you can use global `~/.tmignore` file), also `.git` folder and certain files (images, archives, media files, logs and some other binary files) are filtered.
7
+ When `tm2` command (or `mate` if aliased) is called with one or more paths, for all directories a `.tm_properties` file is generated or changed and mate is called. Its file and folder filters are built based on all types of git ignores (global, `.gitignore` and `.git/info/exclude`) and special `.tmignore` which works like other ignore files for project but doesn't affect git itself (you can use global `~/.tmignore` file), also `.git` folder and certain files (images, archives, media files, logs and some other binary files) are filtered.
8
8
 
9
9
  ## Copyright
10
10
 
11
- Copyright (c) 2010-2020 Ivan Kuchin. See LICENSE.txt for details.
11
+ Copyright (c) 2010-2021 Ivan Kuchin. See LICENSE.txt for details.
data/bin/tm2 CHANGED
@@ -1,11 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
4
+
3
5
  require 'mate/bin'
4
6
  require 'mate/tm_properties'
5
7
 
8
+ options = {}
9
+ OptionParser.new do |op|
10
+ op.banner = "Usage: #{op.program_name} [options] dir [...]"
11
+
12
+ op.on('--no-info-exclude', 'Skip reading .git/info/exclude') do
13
+ options[:skip_info_exclude] = true
14
+ end
15
+ end.order!
16
+
6
17
  ARGV.each do |arg|
7
18
  if File.directory?(arg)
8
- Mate::TmProperties.create(arg)
19
+ Mate::TmProperties.create(arg, options)
9
20
  end
10
21
  end
11
22
 
data/lib/mate/bin.rb CHANGED
@@ -3,10 +3,6 @@ require 'shellwords'
3
3
  module Mate
4
4
  module Bin
5
5
  class << self
6
- def v1
7
- mate_version(/^mate r\d+/) or abort 'Can\'t find mate binary v1'
8
- end
9
-
10
6
  def v2
11
7
  mate_version(/^mate 2.\d+/) or abort 'Can\'t find mate binary v2'
12
8
  end
@@ -3,19 +3,20 @@ require 'mate/git'
3
3
 
4
4
  module Mate
5
5
  class TmProperties
6
- def self.create(dir)
7
- new(Git.toplevel(dir) || dir).save
6
+ def self.create(dir, options)
7
+ new(Git.toplevel(dir) || dir, options).save
8
8
  end
9
9
 
10
- def initialize(dir)
10
+ def initialize(dir, options)
11
11
  @dir = Pathname(dir).expand_path
12
12
  @file = @dir + '.tm_properties'
13
13
  @lines = @file.exist? ? @file.read.split("\n") : []
14
14
  @other_lines = @lines.reject{ |line| line =~ Ignores::GENERATED_R }
15
+ @options = options
15
16
  end
16
17
 
17
18
  def save
18
- ignores = Ignores.new(@dir)
19
+ ignores = Ignores.new(@dir, @options)
19
20
 
20
21
  write(ignores.lines + @other_lines)
21
22
  end
@@ -6,14 +6,14 @@ module Mate
6
6
  GENERATED_R = /^exclude(?:Directories)? = .* #{Regexp.escape(GENERATED_SUFFIX)}$/
7
7
 
8
8
  attr_reader :dir
9
- def initialize(dir)
9
+ def initialize(dir, options)
10
10
  @dir = dir
11
11
  @exclude = ['**/.git']
12
12
  @exclude_directories = []
13
13
 
14
14
  process('.', Git.excludesfile(dir))
15
15
  process('.', Git.global_tmignore)
16
- if (git_dir = Git.git_dir(dir))
16
+ if !options[:skip_info_exclude] && (git_dir = Git.git_dir(dir))
17
17
  process('.', git_dir + 'info/exclude')
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ module Mate
23
23
  toplevel = dir == path
24
24
 
25
25
  if !toplevel && (path + '.git').exist?
26
- TmProperties.new(path).save
26
+ TmProperties.new(path, options).save
27
27
  Find.prune
28
28
  else
29
29
  relative_path = path.relative_path_from(dir).to_s
@@ -33,7 +33,7 @@ module Mate
33
33
  end
34
34
 
35
35
  if !toplevel && (path + '.tm_properties').exist?
36
- TmProperties.new(path).cleanup
36
+ TmProperties.new(path, options).cleanup
37
37
  end
38
38
  end
39
39
  end
data/mate.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'mate'
5
- s.version = '2.2.0'
6
- s.summary = %q{TextMate project builder and TextMate 2 properties builder using git ignores for exclusions}
5
+ s.version = '3.0.0'
6
+ s.summary = %q{TextMate 2 properties builder using git ignores for exclusions}
7
7
  s.homepage = "https://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
9
9
  s.license = 'MIT'
@@ -18,6 +18,4 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = %w[lib]
21
-
22
- s.add_runtime_dependency 'plist'
23
21
  end
metadata CHANGED
@@ -1,33 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-03 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: plist
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- description:
28
- email:
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
29
15
  executables:
30
- - tm
31
16
  - tm2
32
17
  extensions: []
33
18
  extra_rdoc_files: []
@@ -35,23 +20,20 @@ files:
35
20
  - ".gitignore"
36
21
  - LICENSE.txt
37
22
  - README.markdown
38
- - bin/tm
39
23
  - bin/tm2
40
24
  - lib/mate/bin.rb
41
25
  - lib/mate/git.rb
42
26
  - lib/mate/tm_properties.rb
43
27
  - lib/mate/tm_properties/ignores.rb
44
- - lib/mate/tmproj.rb
45
- - lib/mate/tmproj/ignores.rb
46
28
  - mate.gemspec
47
29
  homepage: https://github.com/toy/mate
48
30
  licenses:
49
31
  - MIT
50
32
  metadata:
51
33
  bug_tracker_uri: https://github.com/toy/mate/issues
52
- documentation_uri: https://www.rubydoc.info/gems/mate/2.2.0
34
+ documentation_uri: https://www.rubydoc.info/gems/mate/3.0.0
53
35
  source_code_uri: https://github.com/toy/mate
54
- post_install_message:
36
+ post_install_message:
55
37
  rdoc_options: []
56
38
  require_paths:
57
39
  - lib
@@ -66,9 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
48
  - !ruby/object:Gem::Version
67
49
  version: '0'
68
50
  requirements: []
69
- rubygems_version: 3.1.2
70
- signing_key:
51
+ rubygems_version: 3.2.16
52
+ signing_key:
71
53
  specification_version: 4
72
- summary: TextMate project builder and TextMate 2 properties builder using git ignores
73
- for exclusions
54
+ summary: TextMate 2 properties builder using git ignores for exclusions
74
55
  test_files: []
data/bin/tm DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'mate/bin'
4
- require 'mate/tmproj'
5
-
6
- if !ARGV.empty? && ARGV.all?(&File.method(:exist?)) && ARGV.any?(&File.method(:directory?))
7
- Mate::Tmproj.new(ARGV).open
8
- else
9
- system Mate::Bin.v1, *ARGV
10
- end
data/lib/mate/tmproj.rb DELETED
@@ -1,66 +0,0 @@
1
- require 'pathname'
2
- require 'digest/sha2'
3
- require 'plist'
4
-
5
- module Mate
6
- class Tmproj
7
- TMPROJ_DIR = Pathname('~').expand_path + '.tmprojs'
8
-
9
- attr_reader :dirs, :file
10
- def initialize(dirs)
11
- @dirs = dirs.map{ |dir| Pathname(dir).expand_path }
12
- @file = TMPROJ_DIR + [
13
- Digest::SHA256.hexdigest(@dirs.join('-').downcase),
14
- "#{common_dir(@dirs).basename}.tmproj"
15
- ].join('/')
16
- end
17
-
18
- def open
19
- data = Plist::parse_xml(file) rescue {}
20
-
21
- data['documents'] = dirs.map do |dir|
22
- ignores = Ignores.new(dir)
23
- {
24
- :expanded => true,
25
- :name => dir.basename.to_s,
26
- :regexFileFilter => "!#{ignores.file_r}",
27
- :regexFolderFilter => "!#{ignores.folder_r}",
28
- :sourceDirectory => dir.to_s
29
- }
30
- end
31
- data['fileHierarchyDrawerWidth'] ||= 269
32
- data['metaData'] ||= {}
33
- data['showFileHierarchyDrawer'] = true unless data.has_key?('showFileHierarchyDrawer')
34
- dimensions = IO.popen(%q{osascript -e 'tell application "Finder" to get bounds of window of desktop'}, &:read).scan(/\d+/).map(&:to_i)
35
- data['windowFrame'] ||= "{{#{dimensions[0] + 100}, #{dimensions[1] + 50}}, {#{dimensions[2] - 200}, #{dimensions[3] - 100}}}"
36
-
37
- file.dirname.mkpath
38
- file.open('w'){ |f| f.write(data.to_plist) }
39
-
40
- system 'open', file.to_s
41
- end
42
-
43
- private
44
-
45
- def common_dir(paths)
46
- common = nil
47
- paths.each do |path|
48
- if path.file?
49
- path = path.dirname
50
- end
51
- ascendants = []
52
- path.ascend do |ascendant|
53
- ascendants << ascendant
54
- end
55
- unless common
56
- common = ascendants
57
- else
58
- common &= ascendants
59
- end
60
- end
61
- common && common.first
62
- end
63
- end
64
- end
65
-
66
- require 'mate/tmproj/ignores'
@@ -1,102 +0,0 @@
1
- require 'mate/git'
2
-
3
- module Mate
4
- class Tmproj::Ignores
5
- BINARY_EXTENSIONS = [
6
- %w[jpe?g png gif psd], # images
7
- %w[zip tar t?(?:g|b)z], # archives
8
- %w[mp3 mov], # media
9
- %w[log tmp swf fla pdf], # other
10
- ]
11
- DOUBLE_ASTERISK_R = '(?:.+/)?'
12
-
13
- attr_reader :dir, :file_pattern, :folder_pattern
14
- def initialize(dir)
15
- @dir = dir
16
- @file_pattern = ["#{DOUBLE_ASTERISK_R}.+\\.(?:#{BINARY_EXTENSIONS.flatten.join('|')})"]
17
- @folder_pattern = ["#{DOUBLE_ASTERISK_R}.git"]
18
-
19
- process(dir, Git.excludesfile(dir))
20
- process(dir, Git.global_tmignore)
21
-
22
- dir.find do |path|
23
- Find.prune if ignore?(path)
24
- if path.directory?
25
- %w[.gitignore .tmignore .git/info/exclude].each do |ignore_file_name|
26
- if (ignore_file = path + ignore_file_name).file?
27
- process(path, ignore_file)
28
- end
29
- end
30
- end
31
- end
32
- end
33
-
34
- def ignore?(path)
35
- case
36
- when path.file?
37
- path.to_s =~ /#{file_r}/
38
- when path.directory?
39
- path.to_s =~ /#{folder_r}/
40
- end
41
- end
42
-
43
- def file_r
44
- "^#{Regexp.escape(dir.to_s)}/(?:#{file_pattern.join('|')})$"
45
- end
46
- def folder_r
47
- "^#{Regexp.escape(dir.to_s)}/(?:#{folder_pattern.join('|')})$"
48
- end
49
-
50
- private
51
-
52
- def process(parent, ignore_file)
53
- return unless ignore_file.exist?
54
- current_file_pattern = []
55
- current_folder_pattern = []
56
- ignore_file.readlines.map do |line|
57
- line.lstrip[/(.*?)(\r?\n)?$/, 1] # this strange stuff strips line, but allows mac Icon\r files to be ignored
58
- end.reject do |line|
59
- line.empty? || %w[# !].include?(line[0, 1])
60
- end.each do |line|
61
- pattern = glob2regexp(line)
62
- unless pattern.sub!(/^\//, '')
63
- pattern = "#{DOUBLE_ASTERISK_R}#{pattern}"
64
- end
65
- unless pattern.sub!(/\/$/, '')
66
- current_file_pattern << pattern
67
- end
68
- current_folder_pattern << pattern
69
- end
70
- current_file_pattern = current_file_pattern.join('|')
71
- current_folder_pattern = current_folder_pattern.join('|')
72
- unless parent == dir
73
- parent_pattern = Regexp.escape(parent.relative_path_from(dir).to_s)
74
- current_file_pattern = "#{parent_pattern}/(?:#{current_file_pattern})"
75
- current_folder_pattern = "#{parent_pattern}/(?:#{current_folder_pattern})"
76
- end
77
- file_pattern << current_file_pattern
78
- folder_pattern << current_folder_pattern
79
- end
80
-
81
- def glob2regexp(glob)
82
- glob.gsub(/\[([^\]]*)\]|\{([^\}]*)\}|(\*+)|(\?+)|./) do |m|
83
- case
84
- when $1
85
- "[#{Regexp.escape($1)}]"
86
- when $2
87
- "(?:#{Regexp.escape($2).split(',').join('|')})"
88
- when $3 == '*'
89
- '[^/]*'
90
- when $3
91
- '.*'
92
- when $4 == '?'
93
- '[^/]'
94
- when $4
95
- "[^/]{#{$4.length}}"
96
- else
97
- Regexp.escape(m)
98
- end
99
- end
100
- end
101
- end
102
- end