gitignores 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +32 -0
- data/README.md +5 -5
- data/README.rdoc +23 -0
- data/Rakefile +27 -0
- data/bin/gitignores +87 -45
- data/gitignores.gemspec +24 -0
- data/lib/gitignores.rb +7 -9
- data/lib/gitignores/builder.rb +4 -7
- data/lib/gitignores/fetcher.rb +14 -19
- data/lib/gitignores/version.rb +1 -1
- data/spec/fake_ignores/Global/bar.gitignore +1 -0
- data/spec/fake_ignores/foo.gitignore +1 -0
- data/spec/gitignore_builder_spec.rb +53 -0
- data/spec/gitignore_fetcher_spec.rb +55 -0
- data/spec/spec_helper.rb +8 -0
- metadata +35 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0edda6b894e24e50cafe41003380171ab0157e65
|
4
|
+
data.tar.gz: 953d0f542005a7a3ca37dc0bb35f4892f83455d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f6b60527d67e26f41e1160e8a6efa7c44b27fd89f5af17a8dbd0d41fa42e399174fde330785493cec9f2eabf1b71d4da4cfacce89ffbb332a54853ce80e816e
|
7
|
+
data.tar.gz: 003054f16f0868964e2a8275339fc55acb3e011f3d9d85f87aff73f9cb2e8c5e77c58b13ffa33426e5427fa225f2d1d7cdd991e933c73f40be32f88dd40cebb4
|
data/.gitignore
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
# Ruby
|
3
|
+
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
## Documentation cache and generated files:
|
16
|
+
/.yardoc/
|
17
|
+
/_yardoc/
|
18
|
+
/doc/
|
19
|
+
/rdoc/
|
20
|
+
|
21
|
+
## Environment normalisation:
|
22
|
+
/.bundle/
|
23
|
+
/lib/bundler/man/
|
24
|
+
|
25
|
+
# for a library or gem, you might want to ignore these files since the code is
|
26
|
+
# intended to run in multiple environments; otherwise, check them in:
|
27
|
+
# Gemfile.lock
|
28
|
+
# .ruby-version
|
29
|
+
# .ruby-gemset
|
30
|
+
|
31
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
32
|
+
.rvmrc
|
33
|
+
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gitignores (0.1.0)
|
5
|
+
gli (= 2.13.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
gli (2.13.3)
|
12
|
+
json (1.8.3)
|
13
|
+
rake (10.4.2)
|
14
|
+
rdoc (4.2.0)
|
15
|
+
json (~> 1.4)
|
16
|
+
rspec (2.13.0)
|
17
|
+
rspec-core (~> 2.13.0)
|
18
|
+
rspec-expectations (~> 2.13.0)
|
19
|
+
rspec-mocks (~> 2.13.0)
|
20
|
+
rspec-core (2.13.1)
|
21
|
+
rspec-expectations (2.13.0)
|
22
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
+
rspec-mocks (2.13.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
gitignores!
|
30
|
+
rake
|
31
|
+
rdoc
|
32
|
+
rspec
|
data/README.md
CHANGED
@@ -10,15 +10,15 @@ Tool for building a .gitignore from community templates at [github/gitignore](ht
|
|
10
10
|
|
11
11
|
**add** append a list of .gitignores to the `.gitignore` in the current directory. Example:
|
12
12
|
|
13
|
-
gitignores add Java
|
13
|
+
gitignores add Java JetBrains Eclipse
|
14
14
|
|
15
|
-
Adds gitignores for Java,
|
15
|
+
Adds gitignores for Java, JetBrains, Eclipse to `CURRENT_DIR/.gitignore`
|
16
16
|
|
17
|
-
**show** prints a concatenation of .gitignores to
|
17
|
+
**show** prints a concatenation of .gitignores to standard out
|
18
18
|
|
19
|
-
gitignores show Java
|
19
|
+
gitignores show Java JetBrains Eclipse
|
20
20
|
|
21
|
-
Prints gitignores for Java,
|
21
|
+
Prints gitignores for Java, JetBrains, Eclipse to standard out
|
22
22
|
|
23
23
|
**list** prints a list of available gitignores
|
24
24
|
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= gitignores - .gitignore builder
|
2
|
+
|
3
|
+
Author:: Johnathan Gilday (me@johnathangilday.com)
|
4
|
+
Copyright:: Copyright (c) 2013 Johnathan Gilday
|
5
|
+
|
6
|
+
|
7
|
+
License:: apache, see LICENSE.txt
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
Tool for building a .gitignore from community templates at {github/gitignore}(https://github.com/github/gitignore)
|
12
|
+
|
13
|
+
== Links
|
14
|
+
|
15
|
+
* {Source on Github}[https://github.com/gilday/gitignore-builder]
|
16
|
+
|
17
|
+
== Install
|
18
|
+
|
19
|
+
gem install gitignores
|
20
|
+
|
21
|
+
== Examples
|
22
|
+
|
23
|
+
gitignores add Java JetBrains
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
CLEAN << 'tmp'
|
8
|
+
|
9
|
+
Rake::RDocTask.new do |rd|
|
10
|
+
rd.main = "README.rdoc"
|
11
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
12
|
+
rd.title = 'gitignores'
|
13
|
+
end
|
14
|
+
|
15
|
+
include Rake::DSL
|
16
|
+
|
17
|
+
Bundler::GemHelper.install_tasks
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new do |t|
|
20
|
+
end
|
21
|
+
|
22
|
+
spec = eval(File.read('gitignores.gemspec'))
|
23
|
+
|
24
|
+
Gem::PackageTask.new(spec) do |pkg|
|
25
|
+
end
|
26
|
+
|
27
|
+
task :default => [:spec]
|
data/bin/gitignores
CHANGED
@@ -1,60 +1,102 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'optparse'
|
4
|
-
require 'methadone'
|
2
|
+
require 'gli'
|
5
3
|
require 'gitignores'
|
6
|
-
require 'gitignores/version'
|
7
|
-
require 'gitignores/exceptions'
|
8
4
|
|
9
|
-
|
10
|
-
include Methadone::Main
|
11
|
-
include Methadone::CLILogging
|
12
|
-
include Methadone::ExitNow
|
5
|
+
include GLI::App
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
program_desc Gitignores::SUMMARY
|
8
|
+
version Gitignores::VERSION
|
9
|
+
subcommand_option_handling :normal
|
10
|
+
arguments :strict
|
11
|
+
config_file '.gitignoresrc'
|
19
12
|
|
20
|
-
|
13
|
+
desc 'the directory in which to store the gitlab/gitignore repository'
|
14
|
+
default_value ENV['HOME'] + '/.gitignores'
|
15
|
+
flag ['local-repository'], :desc => 'path to the local github/gitignore repository',
|
16
|
+
:arg_name => 'path'
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
18
|
+
desc 'the remote github/gitignores repository'
|
19
|
+
long_desc %q(
|
20
|
+
change the remote github/gitignores repository to use a fork or an intranet
|
21
|
+
repository behind the firewall
|
22
|
+
)
|
23
|
+
default_value 'https://github.com/github/gitignore.git'
|
24
|
+
flag ['remote-repository'], :desc => 'URL for the remote github/gitignore repository',
|
25
|
+
:arg_name => 'url'
|
26
|
+
|
27
|
+
|
28
|
+
desc 'appends a new gitignore snippet to the .gitignore in the current working directory'
|
29
|
+
long_desc %q(
|
30
|
+
Appends one or more snippets to the .gitignore file in the current working directory.
|
31
|
+
Each snippet name is space separated e.g. "Java JetBrains".
|
32
|
+
Use the list command to show possible values for snippet names.
|
33
|
+
)
|
34
|
+
arg 'snippet', :multiple
|
35
|
+
command :add do |c|
|
36
|
+
c.desc 'include snippets for operating systems OSX, Windows, Linux'
|
37
|
+
c.switch :os, :negatable => false
|
38
|
+
c.action do |global_options,options,args|
|
39
|
+
if (options[:os])
|
40
|
+
args.concat ['OSX', 'Windows', 'Linux']
|
42
41
|
end
|
42
|
+
args.uniq!
|
43
|
+
$gitignores.add(args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
desc 'lists gitignore snippet names'
|
49
|
+
command :list do |c|
|
50
|
+
c.action do |global_options,options,args|
|
51
|
+
$gitignores.list
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
desc 'dumps the given snippet(s) to standard out'
|
57
|
+
long_desc %q(
|
58
|
+
Dumps one or more snippets to standard out.
|
59
|
+
Each snippet name is space separated e.g. "Java JetBrains".
|
60
|
+
Use the list command to show possible values for snippet names.
|
61
|
+
)
|
62
|
+
arg 'snippet', :multiple
|
63
|
+
command :show do |c|
|
64
|
+
c.action do |global_options,options,args|
|
65
|
+
$gitignores.show(args)
|
43
66
|
end
|
67
|
+
end
|
44
68
|
|
45
|
-
options['use-directory'] = ENV['HOME'] + '/.gitignores'
|
46
|
-
on("-d ignore-repository", "--use-directory", "The directory in which to store the github/gitignore directory")
|
47
|
-
on("--update", "Update the github/gitignore repository")
|
48
|
-
on("--os", "Include ignores for all operating systems")
|
49
69
|
|
50
|
-
|
51
|
-
|
70
|
+
desc 'pulls the latest from github/gitignore'
|
71
|
+
long_desc %q(
|
72
|
+
Pulls the latest version of github/gitignore to update the local repository of snippets
|
73
|
+
)
|
74
|
+
command :update do |c|
|
75
|
+
c.action do |global_options,options,args|
|
76
|
+
$gitignores.update
|
77
|
+
end
|
78
|
+
end
|
52
79
|
|
53
|
-
description Gitignores::DESCRIPTION
|
54
80
|
|
55
|
-
|
81
|
+
pre do |global,command,options,args|
|
82
|
+
opts = {
|
83
|
+
:local_repository => global['local-repository'],
|
84
|
+
:remote_repository => global['remote-repository']
|
85
|
+
}
|
86
|
+
$gitignores = Gitignores::Gitignores.new(opts)
|
87
|
+
true
|
88
|
+
end
|
56
89
|
|
57
|
-
|
90
|
+
post do |global,command,options,args|
|
91
|
+
# Post logic here
|
92
|
+
# Use skips_post before a command to skip this
|
93
|
+
# block on that command only
|
94
|
+
end
|
58
95
|
|
59
|
-
|
96
|
+
on_error do |exception|
|
97
|
+
# Error logic here
|
98
|
+
# return false to skip default error handling
|
99
|
+
true
|
60
100
|
end
|
101
|
+
|
102
|
+
exit run(ARGV)
|
data/gitignores.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# Ensure we require the local version and not one we might have installed already
|
3
|
+
require File.join([File.dirname(__FILE__),'lib','gitignores','version.rb'])
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'gitignores'
|
6
|
+
gem.version = Gitignores::VERSION
|
7
|
+
gem.author = 'Johnathan Gilday'
|
8
|
+
gem.email = 'me@johnathangilday.com'
|
9
|
+
gem.platform = Gem::Platform::RUBY
|
10
|
+
gem.summary = Gitignores::SUMMARY
|
11
|
+
gem.homepage = 'https://github.com/gilday/gitignore-builder'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("
|
14
|
+
")
|
15
|
+
gem.require_paths << 'lib'
|
16
|
+
gem.has_rdoc = true
|
17
|
+
gem.bindir = 'bin'
|
18
|
+
gem.executables << 'gitignores'
|
19
|
+
gem.add_development_dependency('rake')
|
20
|
+
gem.add_development_dependency('rdoc')
|
21
|
+
gem.add_development_dependency('rspec')
|
22
|
+
gem.add_runtime_dependency('gli','2.13.3')
|
23
|
+
end
|
24
|
+
|
data/lib/gitignores.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'methadone'
|
3
1
|
require 'gitignores/builder'
|
2
|
+
require 'gitignores/exceptions'
|
4
3
|
require 'gitignores/fetcher'
|
4
|
+
require 'gitignores/version'
|
5
|
+
|
5
6
|
|
6
7
|
module Gitignores
|
7
8
|
class Gitignores
|
8
|
-
include Methadone::CLILogging
|
9
9
|
|
10
10
|
def initialize(options = {})
|
11
11
|
options = {
|
12
|
-
:
|
13
|
-
:ignores_dir => ENV['HOME'] + '/.gitignores'
|
12
|
+
:local_repository => ENV['HOME'] + '/.gitignores'
|
14
13
|
}.merge(options)
|
15
14
|
|
16
15
|
@builder = GitignoreBuilder.new
|
17
|
-
@builder.
|
18
|
-
@fetcher = GitignoreFetcher.new(options[:
|
19
|
-
@fetcher.update_ignores = options[:update_ignores]
|
16
|
+
@builder.local_repository = options[:local_repository]
|
17
|
+
@fetcher = GitignoreFetcher.new(options[:local_repository], options[:remote_repository])
|
20
18
|
|
21
19
|
@fetcher.fetch_gitignores
|
22
20
|
end
|
@@ -32,7 +30,7 @@ module Gitignores
|
|
32
30
|
|
33
31
|
def list()
|
34
32
|
@fetcher.list_gitignores.each { |x|
|
35
|
-
|
33
|
+
puts x
|
36
34
|
}
|
37
35
|
end
|
38
36
|
|
data/lib/gitignores/builder.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'gitignores/exceptions'
|
2
|
-
require 'methadone'
|
3
2
|
|
4
3
|
module Gitignores
|
5
4
|
class GitignoreBuilder
|
6
|
-
include Methadone::CLILogging
|
7
5
|
|
8
|
-
attr_writer :
|
6
|
+
attr_writer :local_repository
|
9
7
|
|
10
8
|
def initialize
|
11
|
-
@
|
9
|
+
@local_repository = ENV['HOME'] + '/.gitignores'
|
12
10
|
end
|
13
11
|
|
14
12
|
def build(ignores, out)
|
@@ -17,11 +15,10 @@ module Gitignores
|
|
17
15
|
|
18
16
|
def find_gitignores_by_name(ignores)
|
19
17
|
ignores.collect { |x|
|
20
|
-
path = File.exists?("#{@
|
18
|
+
path = File.exists?("#{@local_repository}/#{x}.gitignore") ? "#{@local_repository}/#{x}.gitignore" : "#{@local_repository}/Global/#{x}.gitignore"
|
21
19
|
unless File.exists? path
|
22
20
|
raise GitignoreNotFoundException.new(x), "File #{path} does not exist"
|
23
21
|
end
|
24
|
-
debug "Found file #{path}"
|
25
22
|
File.expand_path(path)
|
26
23
|
}
|
27
24
|
end
|
@@ -37,4 +34,4 @@ module Gitignores
|
|
37
34
|
}
|
38
35
|
end
|
39
36
|
end
|
40
|
-
end
|
37
|
+
end
|
data/lib/gitignores/fetcher.rb
CHANGED
@@ -1,36 +1,33 @@
|
|
1
|
-
require 'methadone'
|
2
1
|
require 'gitignores'
|
3
2
|
|
4
3
|
module Gitignores
|
5
4
|
class GitignoreFetcher
|
6
|
-
include Methadone::CLILogging
|
7
5
|
|
8
|
-
attr_writer :git, :update_ignores, :
|
6
|
+
attr_writer :git, :update_ignores, :local_repository, :remote_repository
|
9
7
|
|
10
|
-
def initialize(
|
11
|
-
@
|
8
|
+
def initialize(local_repository, remote_repository)
|
9
|
+
@local_repository = local_repository
|
10
|
+
@remote_repository = remote_repository
|
12
11
|
@update_ignores = false
|
13
12
|
@git = Git.new
|
14
13
|
end
|
15
14
|
|
16
|
-
# If needed, retrieves gitignores from Github and places them in @
|
15
|
+
# If needed, retrieves gitignores from Github and places them in @local_repository
|
17
16
|
# If @update_ignores? is set, will try to update the latest gitignores
|
18
|
-
# Will store all gitignores in the @
|
17
|
+
# Will store all gitignores in the @local_repository
|
19
18
|
def fetch_gitignores()
|
20
|
-
unless (Dir.exists?(@
|
21
|
-
|
22
|
-
@git.clone 'https://github.com/github/gitignore.git', @ignores_dir
|
19
|
+
unless (Dir.exists?(@local_repository))
|
20
|
+
@git.clone @remote_repository, @local_repository
|
23
21
|
end
|
24
22
|
if @update_ignores
|
25
|
-
|
26
|
-
@git.pull @ignores_dir
|
23
|
+
@git.pull @local_repository
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
30
27
|
def list_gitignores()
|
31
28
|
fetch_gitignores
|
32
29
|
|
33
|
-
Dir.glob(@
|
30
|
+
Dir.glob(@local_repository + "/**/*.gitignore").collect { |x|
|
34
31
|
File.basename x, ".gitignore"
|
35
32
|
}
|
36
33
|
end
|
@@ -38,17 +35,15 @@ module Gitignores
|
|
38
35
|
|
39
36
|
# Encapsulate Git commands in this helper class in order to help mock the command line
|
40
37
|
class Git
|
41
|
-
include Methadone::SH
|
42
|
-
include Methadone::CLILogging
|
43
38
|
|
44
|
-
def clone(
|
45
|
-
|
39
|
+
def clone(repository, directory)
|
40
|
+
`git clone #{repository} #{directory}`
|
46
41
|
end
|
47
42
|
|
48
43
|
def pull(directory)
|
49
44
|
Dir.chdir(directory) {
|
50
|
-
|
45
|
+
`git pull`
|
51
46
|
}
|
52
47
|
end
|
53
48
|
end
|
54
|
-
end
|
49
|
+
end
|
data/lib/gitignores/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
bar
|
@@ -0,0 +1 @@
|
|
1
|
+
foo
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
include Gitignores
|
4
|
+
|
5
|
+
describe GitignoreBuilder do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@builder = GitignoreBuilder.new
|
9
|
+
end
|
10
|
+
|
11
|
+
# Really simple test because I'm a Ruby newb
|
12
|
+
describe "#new" do
|
13
|
+
it "creates a new GitignoreBuilder" do
|
14
|
+
@builder.should be_an_instance_of GitignoreBuilder
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#find_gitignores_by_name" do
|
19
|
+
it "finds corresponding file paths for gitignores by name" do
|
20
|
+
@builder.local_repository = FAKE_IGNORES
|
21
|
+
paths = @builder.find_gitignores_by_name ["foo", "bar"]
|
22
|
+
|
23
|
+
fake_ignores_root = File.expand_path(FAKE_IGNORES)
|
24
|
+
paths.should include("#{fake_ignores_root}/foo.gitignore")
|
25
|
+
paths.should include("#{fake_ignores_root}/Global/bar.gitignore")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises GitignoreNotFound exception if it cannot find a Gitignore" do
|
29
|
+
@builder.local_repository = FAKE_IGNORES
|
30
|
+
expect { @builder.find_gitignores_by_name ["baz"] }.to raise_error(GitignoreNotFoundException)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#concatenate_files" do
|
35
|
+
|
36
|
+
it "concatenates files to a stream and provides a header before each one" do
|
37
|
+
out = StringIO.new
|
38
|
+
@builder.concatenate_files(["#{FAKE_IGNORES}/foo.gitignore", "#{FAKE_IGNORES}/Global/bar.gitignore"], out)
|
39
|
+
|
40
|
+
out.string.should eq(
|
41
|
+
"
|
42
|
+
\# foo
|
43
|
+
|
44
|
+
foo
|
45
|
+
|
46
|
+
\# bar
|
47
|
+
|
48
|
+
bar
|
49
|
+
"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include Gitignores
|
3
|
+
|
4
|
+
describe Git do
|
5
|
+
before :each do
|
6
|
+
@git = Git.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "downloads the repository to the given directory" do
|
10
|
+
test_repository = 'tmp/test-repo'
|
11
|
+
FileUtils.rm_rf(test_repository)
|
12
|
+
@git.clone '.', test_repository
|
13
|
+
|
14
|
+
File.exists?(test_repository).should be_true
|
15
|
+
Dir[test_repository].empty?.should be_false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe GitignoreFetcher do
|
20
|
+
|
21
|
+
before :each do
|
22
|
+
@fetcher = GitignoreFetcher.new(LOCAL_REPO, REMOTE_REPO)
|
23
|
+
@mockGit = double('Git')
|
24
|
+
@fetcher.git = @mockGit
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#fetch_gitignores" do
|
28
|
+
|
29
|
+
it "downloads the github/gitignore repository" do
|
30
|
+
@mockGit.should_receive(:clone)
|
31
|
+
|
32
|
+
@fetcher.fetch_gitignores
|
33
|
+
end
|
34
|
+
|
35
|
+
it "updates the repository when given update flag" do
|
36
|
+
@fetcher.update_ignores = true
|
37
|
+
@mockGit.stub(:clone)
|
38
|
+
@mockGit.should_receive(:pull).with(anything())
|
39
|
+
|
40
|
+
@fetcher.fetch_gitignores
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#list_gitignores" do
|
45
|
+
|
46
|
+
it "finds all gitignores in the directory and returns their names in a list" do
|
47
|
+
@mockGit.stub(:clone)
|
48
|
+
@fetcher.local_repository = FAKE_IGNORES
|
49
|
+
ignores = @fetcher.list_gitignores
|
50
|
+
|
51
|
+
ignores.should include("foo", "bar")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative '../lib/gitignores'
|
2
|
+
require_relative '../lib/gitignores/fetcher'
|
3
|
+
require_relative '../lib/gitignores/builder'
|
4
|
+
require_relative '../lib/gitignores/exceptions'
|
5
|
+
|
6
|
+
LOCAL_REPO = 'tmp/gitignores'
|
7
|
+
REMOTE_REPO = 'bogus'
|
8
|
+
FAKE_IGNORES = 'spec/fake_ignores'
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitignores
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnathan Gilday
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
@@ -25,63 +25,74 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: gli
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
61
|
+
version: 2.13.3
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
70
|
-
email:
|
71
|
-
- me@johnathangilday.com
|
68
|
+
version: 2.13.3
|
69
|
+
description:
|
70
|
+
email: me@johnathangilday.com
|
72
71
|
executables:
|
73
72
|
- gitignores
|
74
73
|
extensions: []
|
75
74
|
extra_rdoc_files: []
|
76
75
|
files:
|
76
|
+
- .gitignore
|
77
|
+
- CHANGELOG.md
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
77
80
|
- LICENSE.txt
|
78
81
|
- README.md
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
79
84
|
- bin/gitignores
|
85
|
+
- gitignores.gemspec
|
80
86
|
- lib/gitignores.rb
|
81
87
|
- lib/gitignores/builder.rb
|
82
88
|
- lib/gitignores/exceptions.rb
|
83
89
|
- lib/gitignores/fetcher.rb
|
84
90
|
- lib/gitignores/version.rb
|
91
|
+
- spec/fake_ignores/Global/bar.gitignore
|
92
|
+
- spec/fake_ignores/foo.gitignore
|
93
|
+
- spec/gitignore_builder_spec.rb
|
94
|
+
- spec/gitignore_fetcher_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
85
96
|
homepage: https://github.com/gilday/gitignore-builder
|
86
97
|
licenses: []
|
87
98
|
metadata: {}
|
@@ -89,6 +100,7 @@ post_install_message:
|
|
89
100
|
rdoc_options: []
|
90
101
|
require_paths:
|
91
102
|
- lib
|
103
|
+
- lib
|
92
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
105
|
requirements:
|
94
106
|
- - '>='
|