ignorance 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +4 -0
- data/ignorance.gemspec +5 -5
- data/lib/ignorance/git_ignore_file.rb +2 -2
- data/lib/ignorance/ignore_file.rb +5 -5
- data/lib/ignorance/version.rb +1 -1
- data/spec/lib/ignorance/git_ignore_file_spec.rb +3 -3
- data/spec/shared_examples/for_ignorance.rb +5 -5
- data/spec/shared_examples/for_ignore_files.rb +26 -18
- data/spec/spec_helper.rb +1 -1
- metadata +27 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6fed72f749cca9fe2ce55acdace2c685d3dc0db5b79c2ee82a28c2c56040f9a4
|
4
|
+
data.tar.gz: 987d1ad544356035f1ef2d6e4ff6dbb50f3ae8fc26c9a98e6003cfb8994d4de6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abdeacaa9126a09eba512a0229c10ab6943375b2a8969a3617418340b7798832069f6f3590d681b0b788751444a9e86f7db63316a093a9b4598b44dcef9691ba
|
7
|
+
data.tar.gz: 59d96b4c5b3a92657293479895e0be63c99a06b9e4f602b9af1431d0d933f809f9157991b591858b9dbd1341b1a18c7383172d547ed1480a08f577c0ae06e1f1
|
data/.travis.yml
ADDED
data/ignorance.gemspec
CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency 'highline', '~>
|
20
|
+
gem.add_dependency 'highline', '~> 2.0'
|
21
21
|
|
22
|
-
gem.add_development_dependency 'rspec', '~>
|
23
|
-
gem.add_development_dependency 'fakefs', '~>
|
24
|
-
gem.add_development_dependency 'rake', '
|
25
|
-
gem.add_development_dependency 'pry', '~> 0.
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.9'
|
23
|
+
gem.add_development_dependency 'fakefs', '~> 1.2'
|
24
|
+
gem.add_development_dependency 'rake', '13.0.1'
|
25
|
+
gem.add_development_dependency 'pry', '~> 0.13'
|
26
26
|
end
|
@@ -16,7 +16,7 @@ module Ignorance
|
|
16
16
|
|
17
17
|
def ignored
|
18
18
|
(file_contents + user_ignore_file_contents).reject do |t|
|
19
|
-
t.match
|
19
|
+
t.match(/^\#/)
|
20
20
|
end.map(&:chomp)
|
21
21
|
end
|
22
22
|
|
@@ -25,7 +25,7 @@ module Ignorance
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def user_ignore_file
|
28
|
-
@user_ignore_file ||= `git config --global --get core.excludesfile`.chomp
|
28
|
+
@user_ignore_file ||= `git config --global --get core.excludesfile || echo '~/.gitignore'`.chomp
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
@@ -18,14 +18,14 @@ module Ignorance
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def included?(token)
|
21
|
-
file_contents.include?
|
21
|
+
file_contents.include?(token)
|
22
22
|
end
|
23
23
|
|
24
24
|
def ignore!(token, comment=nil)
|
25
25
|
return true if ignored?(token)
|
26
26
|
if comment
|
27
27
|
anchor = commentified comment
|
28
|
-
if included?
|
28
|
+
if included?(anchor)
|
29
29
|
insert_after anchor, token
|
30
30
|
else
|
31
31
|
append "\n"
|
@@ -42,11 +42,11 @@ module Ignorance
|
|
42
42
|
private
|
43
43
|
|
44
44
|
def ignored
|
45
|
-
file_contents.reject{ |t| t.match
|
45
|
+
file_contents.reject{ |t| t.match(/^\#/) }.map(&:chomp)
|
46
46
|
end
|
47
47
|
|
48
48
|
def file_contents
|
49
|
-
@file_contents ||= exists? ? File.readlines(ignore_file) : []
|
49
|
+
@file_contents ||= exists? ? File.readlines(ignore_file).map{|line| line.chomp} : []
|
50
50
|
end
|
51
51
|
|
52
52
|
def insert_at(index, token)
|
@@ -72,7 +72,7 @@ module Ignorance
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def blank_line_at?(insert_index)
|
75
|
-
file_contents[insert_index].match(/^[\s
|
75
|
+
file_contents[insert_index].match(/^[\s]*$/)
|
76
76
|
end
|
77
77
|
|
78
78
|
def commentified(comment)
|
data/lib/ignorance/version.rb
CHANGED
@@ -15,15 +15,15 @@ module Ignorance
|
|
15
15
|
let(:user_ignore_file) { '~/.gitignore' }
|
16
16
|
before do
|
17
17
|
ignorefile_write %w[other stuff here].join("\n")
|
18
|
+
Dir.mkdir('~/')
|
18
19
|
File.open(user_ignore_file, 'w') do |fh|
|
19
20
|
fh.write "#{token}\n"
|
20
21
|
end
|
21
|
-
subject.stub(:user_ignore_file).and_return(user_ignore_file)
|
22
22
|
end
|
23
23
|
|
24
24
|
specify "then the file is ignored" do
|
25
|
-
File.read('~/.gitignore').
|
26
|
-
subject.
|
25
|
+
expect(File.read('~/.gitignore')).to match(/#{token}/)
|
26
|
+
expect(subject).to be_ignored(token)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -18,7 +18,7 @@ shared_examples Ignorance do
|
|
18
18
|
before { ignorefile_write "something-else.txt\n" }
|
19
19
|
|
20
20
|
it "prints warn (STDERR)" do
|
21
|
-
expect( stderr_from { Ignorance.advise token } ).to match
|
21
|
+
expect( stderr_from { Ignorance.advise token } ).to match(/WARNING:.*add "#{token}" to .*#{ignore_file}/)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -56,13 +56,13 @@ shared_examples Ignorance do
|
|
56
56
|
|
57
57
|
context "user agrees (y)" do
|
58
58
|
specify do
|
59
|
-
expect( user_types("y") { Ignorance.negotiate token } ).to match
|
59
|
+
expect( user_types("y") { Ignorance.negotiate token } ).to match(/added "#{token}"/i)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context "user disagrees (n)" do
|
64
64
|
specify do
|
65
|
-
expect( user_types("n") { Ignorance.negotiate token } ).to match
|
65
|
+
expect( user_types("n") { Ignorance.negotiate token } ).to match(/WARNING:.*add "#{token}" to .*#{ignore_file}/)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -74,7 +74,7 @@ shared_examples Ignorance do
|
|
74
74
|
|
75
75
|
it "does not change the ignore file" do
|
76
76
|
Ignorance.guarantee! token, "a comment"
|
77
|
-
ignorefile_contents.
|
77
|
+
expect(ignorefile_contents).to eq("#{token}\n")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -83,7 +83,7 @@ shared_examples Ignorance do
|
|
83
83
|
|
84
84
|
it "adds to the ignore file" do
|
85
85
|
Ignorance.guarantee! token, "a comment"
|
86
|
-
ignorefile_contents.
|
86
|
+
expect(ignorefile_contents).to eq("stuff.txt\n\n# a comment\n#{token}\n")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -2,7 +2,9 @@ module Ignorance
|
|
2
2
|
shared_examples "an ignore file" do
|
3
3
|
|
4
4
|
it { should respond_to :name, :exists?, :its_a_repo?, :ignored?, :ignore! }
|
5
|
-
|
5
|
+
it "has a name" do
|
6
|
+
expect(subject.name).to eq(ignore_file)
|
7
|
+
end
|
6
8
|
|
7
9
|
describe "#exists?" do
|
8
10
|
|
@@ -21,12 +23,16 @@ module Ignorance
|
|
21
23
|
describe "#its_a_repo?" do
|
22
24
|
|
23
25
|
context "when the repo subdirectory does NOT exist" do
|
24
|
-
it
|
26
|
+
it "is not a repo" do
|
27
|
+
expect(subject).to_not be_its_a_repo
|
28
|
+
end
|
25
29
|
end
|
26
30
|
|
27
31
|
context "when the repo subdirectory DOES exist" do
|
28
32
|
before { Dir.mkdir repo_dir }
|
29
|
-
it
|
33
|
+
it "is a repo" do
|
34
|
+
expect(subject).to be_its_a_repo
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
end
|
@@ -36,8 +42,8 @@ module Ignorance
|
|
36
42
|
|
37
43
|
context "when the ignore file doesn't exist" do
|
38
44
|
specify "then the file is not ignored, duh" do
|
39
|
-
subject.
|
40
|
-
subject.ignored?(token).
|
45
|
+
expect(subject).to_not exist
|
46
|
+
expect(subject.ignored?(token)).to be_falsy
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -45,7 +51,9 @@ module Ignorance
|
|
45
51
|
|
46
52
|
context "when the ignore file doesn't include the token" do
|
47
53
|
before { ignorefile_write %w[other stuff here].join("\n") }
|
48
|
-
it
|
54
|
+
it "is not ignored" do
|
55
|
+
expect(subject).to_not be_ignored(token)
|
56
|
+
end
|
49
57
|
end
|
50
58
|
|
51
59
|
context "when the ignore file DOES include the token" do
|
@@ -62,18 +70,18 @@ module Ignorance
|
|
62
70
|
|
63
71
|
context "there is no ignore file" do
|
64
72
|
it "writes to the ignore file" do
|
65
|
-
subject.
|
73
|
+
expect(subject).to_not exist
|
66
74
|
subject.ignore! token
|
67
|
-
ignored_tokens.
|
75
|
+
expect(ignored_tokens).to include(token)
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
71
79
|
context "there is already an ignore file" do
|
72
80
|
before { ignorefile_write "*.swp\n" }
|
73
81
|
specify do
|
74
|
-
ignored_tokens.
|
82
|
+
expect(ignored_tokens).to include('*.swp')
|
75
83
|
subject.ignore! token
|
76
|
-
ignored_tokens.
|
84
|
+
expect(ignored_tokens).to include('*.swp')
|
77
85
|
end
|
78
86
|
end
|
79
87
|
|
@@ -82,9 +90,9 @@ module Ignorance
|
|
82
90
|
before { ignorefile_write content }
|
83
91
|
|
84
92
|
it "doesn't write to the ignore file" do
|
85
|
-
File.
|
93
|
+
expect_any_instance_of(File).to_not receive(:write)
|
86
94
|
subject.ignore!(token)
|
87
|
-
ignored_tokens.
|
95
|
+
expect(ignored_tokens).to include(token)
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
@@ -92,7 +100,7 @@ module Ignorance
|
|
92
100
|
context "when the comment wasn't already in the file" do
|
93
101
|
specify do
|
94
102
|
subject.ignore! token, "# hide these files!"
|
95
|
-
ignorefile_contents.
|
103
|
+
expect(ignorefile_contents).to match(/# hide these files!\n#{token}\n/)
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
@@ -104,7 +112,7 @@ module Ignorance
|
|
104
112
|
|
105
113
|
specify do
|
106
114
|
subject.ignore! token, comment
|
107
|
-
ignorefile_contents.
|
115
|
+
expect(ignorefile_contents).to match(/# #{comment}\n#{token}\n/)
|
108
116
|
end
|
109
117
|
end
|
110
118
|
|
@@ -117,11 +125,11 @@ barfile.md
|
|
117
125
|
other-things
|
118
126
|
IGNORE
|
119
127
|
end
|
120
|
-
let(:expected) { Regexp.new
|
128
|
+
let(:expected) { Regexp.new(/# #{comment}\nbarfile\.md\n#{token}\n\nother-things/) }
|
121
129
|
|
122
130
|
specify do
|
123
131
|
subject.ignore! token, comment
|
124
|
-
ignorefile_contents.
|
132
|
+
expect(ignorefile_contents).to match(expected)
|
125
133
|
end
|
126
134
|
end
|
127
135
|
|
@@ -132,11 +140,11 @@ other-things
|
|
132
140
|
barfile.md
|
133
141
|
IGNORE
|
134
142
|
end
|
135
|
-
let(:expected) { Regexp.new
|
143
|
+
let(:expected) { Regexp.new(/# #{comment}\nbarfile\.md\n#{token}\n/) }
|
136
144
|
|
137
145
|
specify do
|
138
146
|
subject.ignore! token, comment
|
139
|
-
ignorefile_contents.
|
147
|
+
expect(ignorefile_contents).to match(expected)
|
140
148
|
end
|
141
149
|
end
|
142
150
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pp'
|
1
2
|
require 'fakefs/spec_helpers'
|
2
3
|
require File.join(File.dirname(__FILE__), 'ignorefile_helpers')
|
3
4
|
require File.join(File.dirname(__FILE__), 'io_helpers')
|
@@ -9,7 +10,6 @@ $LOAD_PATH.unshift(File.expand_path(File.join(here, '..', '..', 'lib')))
|
|
9
10
|
Dir[File.join(here, "shared_examples") + "/**/*.rb"].sort.map{|f| File.basename f }.map{|f| "shared_examples/#{f}"}.each {|f| require f}
|
10
11
|
|
11
12
|
RSpec.configure do |cfg|
|
12
|
-
cfg.treat_symbols_as_metadata_keys_with_true_values = true
|
13
13
|
cfg.include FakeFS::SpecHelpers, fakefs: true
|
14
14
|
cfg.include IgnorefileHelpers, fakefs: true
|
15
15
|
cfg.include IOHelpers, capture_io: true
|
metadata
CHANGED
@@ -1,96 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ignorance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joel Helbling
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: highline
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: '2.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: '2.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '3.9'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '3.9'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: fakefs
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: '1.2'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: '1.2'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - '='
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
61
|
+
version: 13.0.1
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - '='
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
68
|
+
version: 13.0.1
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: pry
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- - ~>
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.
|
75
|
+
version: '0.13'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- - ~>
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
82
|
+
version: '0.13'
|
94
83
|
description: Ensures specified files are ignored by Git, Mercurial or SVN.
|
95
84
|
email:
|
96
85
|
- joel@joelhelbling.com
|
@@ -98,7 +87,8 @@ executables: []
|
|
98
87
|
extensions: []
|
99
88
|
extra_rdoc_files: []
|
100
89
|
files:
|
101
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
102
92
|
- Gemfile
|
103
93
|
- LICENSE.txt
|
104
94
|
- README.md
|
@@ -124,33 +114,25 @@ files:
|
|
124
114
|
- spec/spec_helper.rb
|
125
115
|
homepage: http://github.com/joelhelbling/ignorance
|
126
116
|
licenses: []
|
117
|
+
metadata: {}
|
127
118
|
post_install_message:
|
128
119
|
rdoc_options: []
|
129
120
|
require_paths:
|
130
121
|
- lib
|
131
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
123
|
requirements:
|
134
|
-
- -
|
124
|
+
- - ">="
|
135
125
|
- !ruby/object:Gem::Version
|
136
126
|
version: '0'
|
137
|
-
segments:
|
138
|
-
- 0
|
139
|
-
hash: -21553841
|
140
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
128
|
requirements:
|
143
|
-
- -
|
129
|
+
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
131
|
version: '0'
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
hash: -21553841
|
149
132
|
requirements: []
|
150
|
-
|
151
|
-
rubygems_version: 1.8.25
|
133
|
+
rubygems_version: 3.1.2
|
152
134
|
signing_key:
|
153
|
-
specification_version:
|
135
|
+
specification_version: 4
|
154
136
|
summary: Ignorance helps your code be considerate of its users by protecting sensitive
|
155
137
|
information from version control.
|
156
138
|
test_files:
|