mate 1.1.1-darwin
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.markdown +11 -0
- data/Rakefile +28 -0
- data/VERSION +1 -0
- data/bin/tm +16 -0
- data/lib/mate/tmproj/ignores.rb +76 -0
- data/lib/mate/tmproj.rb +66 -0
- data/lib/mate.rb +1 -0
- data/mate.gemspec +49 -0
- metadata +89 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Boba Fat
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# mate
|
2
|
+
|
3
|
+
TextMate project builder using git ignores for exclusions
|
4
|
+
|
5
|
+
You can add `alias mate='tm'` to your `.profile`, `.bash_profile` …
|
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. Its file and folder filters are built based on all types of git ignores (global, `.gitignore` and `.git/info/exclude`), also `.git` folder and certain files (images, archives, media files, logs and some other binary files) are filtered.
|
8
|
+
|
9
|
+
## Copyright
|
10
|
+
|
11
|
+
Copyright (c) 2010 Boba Fat. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
name = 'mate'
|
5
|
+
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = name
|
8
|
+
gem.summary = %Q{TextMate project builder using git ignores for exclusions}
|
9
|
+
gem.homepage = "http://github.com/toy/#{name}"
|
10
|
+
gem.authors = ['Boba Fat']
|
11
|
+
gem.platform = 'darwin'
|
12
|
+
gem.add_dependency 'plist'
|
13
|
+
end
|
14
|
+
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
|
17
|
+
require 'pathname'
|
18
|
+
desc "Replace system gem with symlink to this folder"
|
19
|
+
task 'ghost' do
|
20
|
+
gem_path = Pathname(Gem.searcher.find(name).full_gem_path)
|
21
|
+
current_path = Pathname('.').expand_path
|
22
|
+
system('rm', '-r', gem_path)
|
23
|
+
system('ln', '-s', current_path, gem_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
rescue LoadError
|
27
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.1
|
data/bin/tm
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'mate'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'mate'
|
8
|
+
end
|
9
|
+
|
10
|
+
mate = (IO.popen('which -a mate', &:readlines).map(&:strip) - [__FILE__]).first
|
11
|
+
|
12
|
+
if !ARGV.empty? && ARGV.all?(&File.method(:exist?)) && ARGV.any?(&File.method(:directory?))
|
13
|
+
Mate::Tmproj.new(ARGV).open
|
14
|
+
else
|
15
|
+
system mate, *ARGV
|
16
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Mate
|
2
|
+
class Tmproj::Ignores
|
3
|
+
BINARY_EXTENSIONS = [
|
4
|
+
%w[jpe?g png gif psd], # images
|
5
|
+
%w[zip tar t?(?:g|b)z], # archives
|
6
|
+
%w[mp3 mov], # media
|
7
|
+
%w[log tmp swf fla pdf], # other
|
8
|
+
]
|
9
|
+
DOUBLE_ASTERISK_R = '(?:.+/)?'
|
10
|
+
|
11
|
+
attr_reader :dir, :file_pattern, :folder_pattern
|
12
|
+
def initialize(dir)
|
13
|
+
@dir = dir
|
14
|
+
@file_pattern = ["#{DOUBLE_ASTERISK_R}.+\\.(?:#{BINARY_EXTENSIONS.flatten.join('|')})"]
|
15
|
+
@folder_pattern = ["#{DOUBLE_ASTERISK_R}.git"]
|
16
|
+
|
17
|
+
add(dir, Pathname(`git config --get core.excludesfile`.strip))
|
18
|
+
|
19
|
+
dir.find do |path|
|
20
|
+
Find.prune if ignore?(path)
|
21
|
+
if path.directory?
|
22
|
+
%w[.gitignore .tmignore .git/info/exclude].each do |ignore_file_name|
|
23
|
+
if (ignore_file = path + ignore_file_name).file?
|
24
|
+
add(path, ignore_file)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def ignore?(path)
|
32
|
+
case
|
33
|
+
when path.file?
|
34
|
+
path.to_s =~ /#{file_r}/
|
35
|
+
when path.directory?
|
36
|
+
path.to_s =~ /#{folder_r}/
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def file_r
|
41
|
+
"^#{Regexp.escape(dir)}/(?:#{file_pattern.join('|')})$"
|
42
|
+
end
|
43
|
+
def folder_r
|
44
|
+
"^#{Regexp.escape(dir)}/(?:#{folder_pattern.join('|')})$"
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def add(parent, ignore_file)
|
50
|
+
current_file_pattern = []
|
51
|
+
current_folder_pattern = []
|
52
|
+
ignore_file.readlines.map do |line|
|
53
|
+
line.lstrip[/(.*?)(\r?\n)?$/, 1] # this strange stuff strips line, but allows mac Icon\r files to be ignored
|
54
|
+
end.reject do |line|
|
55
|
+
line.empty? || %w[# !].include?(line[0, 1])
|
56
|
+
end.each do |line|
|
57
|
+
pattern = Regexp.escape(line).gsub(/\\\*+/, '[^/]*') # understand only * pattern
|
58
|
+
pattern = "#{DOUBLE_ASTERISK_R}#{pattern}" unless line['/']
|
59
|
+
pattern.sub!(/^\//, '')
|
60
|
+
unless pattern.sub!(/\/$/, '')
|
61
|
+
current_file_pattern << pattern
|
62
|
+
end
|
63
|
+
current_folder_pattern << pattern
|
64
|
+
end
|
65
|
+
current_file_pattern = current_file_pattern.join('|')
|
66
|
+
current_folder_pattern = current_folder_pattern.join('|')
|
67
|
+
unless parent == dir
|
68
|
+
parent_pattern = Regexp.escape(parent.relative_path_from(dir))
|
69
|
+
current_file_pattern = "#{parent_pattern}/(?:#{current_file_pattern})"
|
70
|
+
current_folder_pattern = "#{parent_pattern}/(?:#{current_folder_pattern})"
|
71
|
+
end
|
72
|
+
file_pattern << current_file_pattern
|
73
|
+
folder_pattern << current_folder_pattern
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/mate/tmproj.rb
ADDED
@@ -0,0 +1,66 @@
|
|
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
|
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'
|
data/lib/mate.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mate/tmproj'
|
data/mate.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{mate}
|
8
|
+
s.version = "1.1.1"
|
9
|
+
s.platform = %q{darwin}
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Boba Fat"]
|
13
|
+
s.date = %q{2010-12-03}
|
14
|
+
s.default_executable = %q{tm}
|
15
|
+
s.executables = ["tm"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.markdown"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"LICENSE",
|
22
|
+
"README.markdown",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"bin/tm",
|
26
|
+
"lib/mate.rb",
|
27
|
+
"lib/mate/tmproj.rb",
|
28
|
+
"lib/mate/tmproj/ignores.rb",
|
29
|
+
"mate.gemspec"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/toy/mate}
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.7}
|
34
|
+
s.summary = %q{TextMate project builder using git ignores for exclusions}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_runtime_dependency(%q<plist>, [">= 0"])
|
42
|
+
else
|
43
|
+
s.add_dependency(%q<plist>, [">= 0"])
|
44
|
+
end
|
45
|
+
else
|
46
|
+
s.add_dependency(%q<plist>, [">= 0"])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
|
+
platform: darwin
|
12
|
+
authors:
|
13
|
+
- Boba Fat
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-03 00:00:00 +03:00
|
19
|
+
default_executable: tm
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: plist
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description:
|
36
|
+
email:
|
37
|
+
executables:
|
38
|
+
- tm
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.markdown
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README.markdown
|
47
|
+
- Rakefile
|
48
|
+
- VERSION
|
49
|
+
- bin/tm
|
50
|
+
- lib/mate.rb
|
51
|
+
- lib/mate/tmproj.rb
|
52
|
+
- lib/mate/tmproj/ignores.rb
|
53
|
+
- mate.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/toy/mate
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: TextMate project builder using git ignores for exclusions
|
88
|
+
test_files: []
|
89
|
+
|