gemignore 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/.gitignore +31 -0
- data/bin/gemignore +8 -0
- data/lib/gemignore.rb +4 -0
- data/lib/gemignore/main.rb +113 -0
- data/spec/gemignore_spec.rb +5 -0
- data/spec/spec_helper.rb +12 -0
- metadata +150 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "json", ">= 1.5.1"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "rspec", "~> 2.3.0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.6.0"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Lucas Jenß
|
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.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= gemignore
|
2
|
+
|
3
|
+
This is a handy little tool for all people who work with Git. It allows you to easily add .gitignore snippets to the .gitignore file in your current working directory. The snippets are taken from https://github.com/github/gitignore , so if there is anything missing, feel free to fork that repository and create a pull request :)
|
4
|
+
|
5
|
+
= Usage
|
6
|
+
|
7
|
+
To search for a .gitignore snippet, simply type
|
8
|
+
|
9
|
+
$ gemignore searchword
|
10
|
+
|
11
|
+
To list all available snippets run
|
12
|
+
|
13
|
+
$ gemignore
|
14
|
+
|
15
|
+
And finally, to add a snippet to the .gitignore file in the <b>current working directory</b>:
|
16
|
+
|
17
|
+
$ gemignore add Global/OSX
|
18
|
+
|
19
|
+
== Copyright
|
20
|
+
|
21
|
+
Copyright (c) 2011 Lucas Jenß. See LICENSE.txt for
|
22
|
+
further details.
|
23
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "gemignore"
|
18
|
+
gem.homepage = "http://github.com/x3ro/gemignore"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A command-line tool which ought to simplify your daily .gitignore hassle}
|
21
|
+
gem.description = %Q{gemignore allows you to automatically insert a wide range of preset .gitignore snippets into your .gitignore files}
|
22
|
+
gem.email = "lucas@x3ro.de"
|
23
|
+
gem.authors = ["Lucas Jenss"]
|
24
|
+
gem.executables = ['gemignore']
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "gemignore #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bin/.gitignore
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
/CVS/*
|
4
|
+
*/CVS/*
|
5
|
+
.cvsignore
|
6
|
+
*/.cvsignore
|
7
|
+
#Added by gemignore. Snippet 'Global/CVS'
|
8
|
+
/CVS/*
|
9
|
+
*/CVS/*
|
10
|
+
.cvsignore
|
11
|
+
*/.cvsignore
|
12
|
+
|
13
|
+
#Added by gemignore. Snippet 'Global/CVS'
|
14
|
+
/CVS/*
|
15
|
+
*/CVS/*
|
16
|
+
.cvsignore
|
17
|
+
*/.cvsignore
|
18
|
+
|
19
|
+
# Added by gemignore. Snippet 'C++'
|
20
|
+
# Compiled Object files
|
21
|
+
*.slo
|
22
|
+
*.lo
|
23
|
+
*.o
|
24
|
+
|
25
|
+
# Compiled Dynamic libraries
|
26
|
+
*.so
|
27
|
+
|
28
|
+
# Compiled Static libraries
|
29
|
+
*.lai
|
30
|
+
*.la
|
31
|
+
*.a
|
data/bin/gemignore
ADDED
data/lib/gemignore.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'json'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
|
7
|
+
module GemIgnore
|
8
|
+
|
9
|
+
#--
|
10
|
+
# FIXME: Not a good name, but for now its okay
|
11
|
+
# FIXME: Add documentation
|
12
|
+
# FIXME: Cleanup code
|
13
|
+
#++
|
14
|
+
class Main
|
15
|
+
|
16
|
+
def dispatch
|
17
|
+
list if ARGV.length === 0
|
18
|
+
search if ARGV.length === 1
|
19
|
+
add if ARGV.length === 2 and ARGV[0] === "add"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Displays a list of available .gitignore snippets
|
23
|
+
def list
|
24
|
+
puts "-> Available .gitignore snippets:"
|
25
|
+
fetch().each do |f|
|
26
|
+
puts "---> " + f
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Searches for a given snippet name
|
31
|
+
def search
|
32
|
+
puts "-> Snippets found for '#{ARGV[0]}':"
|
33
|
+
fetch(regexpForInput(ARGV[0])).each do |f|
|
34
|
+
puts "---> " + f
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Adds the snippet to the .gitignore file in the current working
|
39
|
+
# directory in case it exists and the given snippet identifier matched
|
40
|
+
# exactly one snippet.
|
41
|
+
def add
|
42
|
+
snippets = fetch(regexpForInput(ARGV[1]))
|
43
|
+
if snippets.length < 1
|
44
|
+
puts "-> No snippets found"
|
45
|
+
elsif snippets.length > 1
|
46
|
+
puts "-> Multiple possible snippets found:"
|
47
|
+
snippets.each do |f|
|
48
|
+
puts "---> " + f
|
49
|
+
end
|
50
|
+
else
|
51
|
+
performAdd(snippets.first)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Adds the given snippet in case the .gitignore file exists.
|
56
|
+
def performAdd(snippet)
|
57
|
+
if not File.exists?(".gitignore")
|
58
|
+
puts "No .gitignore file found in working directory"
|
59
|
+
else
|
60
|
+
|
61
|
+
puts "Adding Snippet '#{snippet}'"
|
62
|
+
|
63
|
+
f = File.new(".gitignore", "a")
|
64
|
+
snippetData = fetchFile(snippet)
|
65
|
+
f.write("\n\n# Added by gemignore. Snippet '#{snippet}'\n" + snippetData)
|
66
|
+
f.close
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Creates a case-insensitive Regexp for the given string. Wildcards are
|
71
|
+
# added before and after the input, so the regex will match anything containing
|
72
|
+
# the input, or the input itself.
|
73
|
+
def regexpForInput(input)
|
74
|
+
input = Regexp.escape(input)
|
75
|
+
Regexp.new("(.*#{input}.*)", Regexp::IGNORECASE)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Fetches the list of available snippets via the GitHub API
|
79
|
+
#--
|
80
|
+
# FIXME: Do some (url) refactoring
|
81
|
+
#++
|
82
|
+
def fetch(search = nil)
|
83
|
+
search = /(.*)/ if search === nil
|
84
|
+
|
85
|
+
data = Net::HTTP.get( URI.parse('http://github.com/api/v2/json/blob/all/github/gitignore/master') )
|
86
|
+
response = JSON.parse(data)
|
87
|
+
files = response["blobs"].map { |k,v| k.split('.gitignore')[0] =~ search; $1 }
|
88
|
+
files.compact
|
89
|
+
end
|
90
|
+
|
91
|
+
# Fetches a snippet file from GitHub
|
92
|
+
#--
|
93
|
+
# FIXME: Do some (url) refactoring
|
94
|
+
#++
|
95
|
+
def fetchFile(snippet)
|
96
|
+
url = URI.parse("https://github.com/github/gitignore/raw/master/#{snippet}.gitignore")
|
97
|
+
|
98
|
+
http = Net::HTTP.new(url.host, url.port)
|
99
|
+
http.use_ssl = true if url.scheme == "https" # enable SSL/TLS
|
100
|
+
|
101
|
+
data = ""
|
102
|
+
http.start {
|
103
|
+
http.request_get(url.path) {|res|
|
104
|
+
data = res.body
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
data
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'gemignore'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemignore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Lucas Jenss
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-26 00:00:00 +02:00
|
18
|
+
default_executable: gemignore
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 5
|
30
|
+
- 1
|
31
|
+
version: 1.5.1
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 2
|
44
|
+
- 3
|
45
|
+
- 0
|
46
|
+
version: 2.3.0
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: bundler
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 0
|
60
|
+
- 0
|
61
|
+
version: 1.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: jeweler
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 6
|
75
|
+
- 0
|
76
|
+
version: 1.6.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rcov
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id005
|
93
|
+
description: gemignore allows you to automatically insert a wide range of preset .gitignore snippets into your .gitignore files
|
94
|
+
email: lucas@x3ro.de
|
95
|
+
executables:
|
96
|
+
- gemignore
|
97
|
+
extensions: []
|
98
|
+
|
99
|
+
extra_rdoc_files:
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.rdoc
|
102
|
+
files:
|
103
|
+
- .document
|
104
|
+
- .rspec
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.rdoc
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- bin/.gitignore
|
111
|
+
- bin/gemignore
|
112
|
+
- lib/gemignore.rb
|
113
|
+
- lib/gemignore/main.rb
|
114
|
+
- spec/gemignore_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
has_rdoc: true
|
117
|
+
homepage: http://github.com/x3ro/gemignore
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 3835635056973709115
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
version: "0"
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 1.3.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: A command-line tool which ought to simplify your daily .gitignore hassle
|
149
|
+
test_files: []
|
150
|
+
|