guard-git 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dc0c3f3652cb23728f23322b379ff06b3127ef5
4
+ data.tar.gz: 5bebdf6476fc16d384fd3a74095ab40a6e002029
5
+ SHA512:
6
+ metadata.gz: b537965d8cc47c7e31d86d338db6d085f15390b5659e3218c5b19ef4af0a046120b0b357e4b79186d53f9625728c3f6317cf1cac47ed14dd2719b57b7cfb47c7
7
+ data.tar.gz: ef88243bde5d8d0256c2eda77a5e561c2f60d0f78d224bf2f994383cfe5b629e9620f70e103f617e56cba871d27bb15609a04e48567ff07c5bc246f50e12c2ee
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ running_test_project/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ NewCops: enable
4
+
5
+ Style/Documentation:
6
+ Enabled: false
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in guard-git.gemspec
8
+ gemspec
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-git (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.1)
10
+ coderay (1.1.3)
11
+ diff-lcs (1.4.4)
12
+ ffi (1.13.1)
13
+ formatador (0.2.5)
14
+ guard (2.16.2)
15
+ formatador (>= 0.2.4)
16
+ listen (>= 2.7, < 4.0)
17
+ lumberjack (>= 1.0.12, < 2.0)
18
+ nenv (~> 0.1)
19
+ notiffany (~> 0.0)
20
+ pry (>= 0.9.12)
21
+ shellany (~> 0.0)
22
+ thor (>= 0.18.1)
23
+ guard-compat (1.2.1)
24
+ guard-rspec (4.7.3)
25
+ guard (~> 2.1)
26
+ guard-compat (~> 1.1)
27
+ rspec (>= 2.99.0, < 4.0)
28
+ guard-rubocop (1.3.0)
29
+ guard (~> 2.0)
30
+ rubocop (~> 0.20)
31
+ listen (3.2.1)
32
+ rb-fsevent (~> 0.10, >= 0.10.3)
33
+ rb-inotify (~> 0.9, >= 0.9.10)
34
+ lumberjack (1.2.7)
35
+ method_source (1.0.0)
36
+ nenv (0.3.0)
37
+ notiffany (0.1.3)
38
+ nenv (~> 0.1)
39
+ shellany (~> 0.0)
40
+ parallel (1.19.2)
41
+ parser (2.7.1.4)
42
+ ast (~> 2.4.1)
43
+ pry (0.13.1)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ rainbow (3.0.0)
47
+ rake (10.5.0)
48
+ rb-fsevent (0.10.4)
49
+ rb-inotify (0.10.1)
50
+ ffi (~> 1.0)
51
+ rb-readline (0.5.5)
52
+ regexp_parser (1.7.1)
53
+ rexml (3.2.4)
54
+ rspec (3.9.0)
55
+ rspec-core (~> 3.9.0)
56
+ rspec-expectations (~> 3.9.0)
57
+ rspec-mocks (~> 3.9.0)
58
+ rspec-core (3.9.2)
59
+ rspec-support (~> 3.9.3)
60
+ rspec-expectations (3.9.2)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.9.0)
63
+ rspec-mocks (3.9.1)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.9.0)
66
+ rspec-support (3.9.3)
67
+ rubocop (0.89.0)
68
+ parallel (~> 1.10)
69
+ parser (>= 2.7.1.1)
70
+ rainbow (>= 2.2.2, < 4.0)
71
+ regexp_parser (>= 1.7)
72
+ rexml
73
+ rubocop-ast (>= 0.1.0, < 1.0)
74
+ ruby-progressbar (~> 1.7)
75
+ unicode-display_width (>= 1.4.0, < 2.0)
76
+ rubocop-ast (0.3.0)
77
+ parser (>= 2.7.1.4)
78
+ ruby-progressbar (1.10.1)
79
+ shellany (0.0.1)
80
+ thor (1.0.1)
81
+ unicode-display_width (1.7.0)
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bundler (~> 1.16)
88
+ guard (~> 2.16)
89
+ guard-git!
90
+ guard-rspec (~> 4.7)
91
+ guard-rubocop (~> 1.3)
92
+ rake (~> 10.0)
93
+ rb-readline (~> 0.5)
94
+ rspec (~> 3.0)
95
+ rubocop (~> 0.89.0)
96
+
97
+ BUNDLED WITH
98
+ 1.16.2
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ ignore(%r{.*test_project/.*})
4
+
5
+ group :red_green_refactor, halt_on_fail: true do
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # lib files
17
+ watch(%r{^lib/(.*)\.rb$}) { |m| "#{rspec.spec_dir}/#{m}_spec.rb" }
18
+ watch(%r{^lib/.*\.rb$}) { 'spec/guard/git_integration_spec.rb' }
19
+ end
20
+
21
+ guard :rubocop, cli: ['--auto-correct'] do
22
+ watch(/.+\.rb$/)
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Daniel Patterson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,117 @@
1
+ # Guard::Git
2
+
3
+ Stops [Guard](https://github.com/guard/guard/) triggering plugins whenever
4
+ you change branches.
5
+
6
+ ## Installation
7
+
8
+ **NOTE:** This has not yet been released, so cannot be installed without
9
+ cloning this repo.
10
+
11
+ ~Add this line to your application's Gemfile:~
12
+
13
+ ```ruby
14
+ gem 'guard-git'
15
+ ```
16
+
17
+ ~And then execute:~
18
+
19
+ $ bundle
20
+
21
+ ~Or install it yourself as:~
22
+
23
+ $ gem install guard-git
24
+
25
+ ## Usage
26
+
27
+ There are two ways to use this gem:
28
+
29
+ ### Make all `watch` calls git aware
30
+
31
+ This is the simplest way to get started and the default way to use this gem.
32
+
33
+ Add the following to the top of your `Guardfile`:
34
+
35
+ ```ruby
36
+ require `guard/git`
37
+
38
+ Guard::Git.enable!
39
+ ```
40
+
41
+ All of the calls to `watch` will now only be triggered if the file changes on
42
+ disk and one of the follwing is true:
43
+
44
+ - The file has changed since `HEAD`
45
+ - The file is untracked
46
+ - The file is gitignored
47
+
48
+ ### Explicitly use the git matcher
49
+
50
+ If you only want to use git-aware matchers for a subset of `watch` calls or
51
+ you'd prefer not to monkeypatch Guard, you can use the
52
+ `Guard::Git::ChangedFilesMatcher` instead.
53
+
54
+ For example, if you had the follwing `Guardfile`:
55
+
56
+ ```ruby
57
+ guard :shell do
58
+ watch(/.*/) do
59
+ # do something
60
+ end
61
+ end
62
+ ```
63
+
64
+ you can make that single `watch` git-aware by changing the file to:
65
+
66
+ ```ruby
67
+ require `guard/git`
68
+
69
+ guard :shell do
70
+ watch(Guard::Git::ChangedFilesMatcher.new(/.*/)) do
71
+ # do something
72
+ end
73
+ end
74
+ ```
75
+
76
+ ## Development
77
+
78
+ After checking out the repo, run `bin/setup` to install dependencies.
79
+
80
+ You can also run `bin/console` for an interactive prompt that will allow you
81
+ to experiment.
82
+
83
+ To install this gem onto your local machine, run `bundle exec rake install`.
84
+
85
+ ### Testing
86
+
87
+ To properly end-to-end test this gem it's necessary to have a process running
88
+ `guard` to verify which file changes cause plugins to be triggered. `guard`
89
+ needs to run in a tty rather than a background process. Therefore, before
90
+ running any specs, run `bin/setup_integration_test` in a terminal to create a
91
+ test guard process.
92
+
93
+ Once you have the test `guard` process set up, run `bundle exec rake spec`
94
+ to run all the tests once, or `bin/guard` to start a guard process that will
95
+ run relevant tests and linting on any file change.
96
+
97
+ You may need to restart `bin/setup_integration_test` between some test runs
98
+ during development as the test `guard` process only loads the gem at the start
99
+ rather than before each test (it `require`s the files in
100
+ [the `Guardfile`](test_project/Guardfile)).
101
+
102
+ ### Releasing new versions
103
+
104
+ To release a new version, update the version number in `version.rb`, and then
105
+ run `bundle exec rake release`, which will create a git tag for the version,
106
+ push git commits and tags, and push the `.gem` file to
107
+ [rubygems.org](https://rubygems.org).
108
+
109
+ ## Contributing
110
+
111
+ Bug reports and pull requests are welcome on GitHub at
112
+ https://github.com/dp28/guard-git.
113
+
114
+ ## License
115
+
116
+ The gem is available as open source under the terms of the
117
+ [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'guard/git/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'guard-git'
9
+ spec.version = Guard::Git::VERSION
10
+ spec.authors = ['Daniel Patterson']
11
+ spec.email = ['apps.djpdev@gmail.com']
12
+
13
+ spec.summary = 'Make Guard git-aware'
14
+ spec.homepage = 'https://github.com/dp28/guard-git'
15
+ spec.license = 'MIT'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features|test_project|bin|Rakefile)/})
22
+ end
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.required_ruby_version = '>= 2.4'
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.16'
31
+ spec.add_development_dependency 'guard', '~> 2.16'
32
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
33
+ spec.add_development_dependency 'guard-rubocop', '~> 1.3'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rb-readline', '~> 0.5'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rubocop', '~> 0.89.0'
38
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'guard/git/version'
4
+ require 'guard/git/dsl_extensions'
5
+ require 'guard/git/changed_files_matcher'
6
+
7
+ module Guard
8
+ module Git
9
+ def self.enable!
10
+ ::Guard::Dsl.prepend Guard::Git::DslExtensions
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module Git
5
+ # Only matches files that both:
6
+ #
7
+ # * Match the passed-in pattern AND
8
+ # * Are either ignored by git or identified as changed
9
+ class ChangedFilesMatcher
10
+ def initialize(pattern)
11
+ @pattern = pattern
12
+ end
13
+
14
+ def match(filename_or_pathname)
15
+ path = filename_or_pathname.to_s
16
+ result = @pattern.match(path)
17
+ return nil if result.nil? || skip_file?(path)
18
+
19
+ result
20
+ end
21
+
22
+ private
23
+
24
+ def skip_file?(path)
25
+ !changed?(path) && !always_allowed?(path)
26
+ end
27
+
28
+ def changed?(path)
29
+ changed_files.include?(path)
30
+ end
31
+
32
+ def always_allowed?(path)
33
+ ignored_files.include?(path)
34
+ end
35
+
36
+ def ignored_files
37
+ `git ls-files --others -i --exclude-standard`.lines.map(&:chomp)
38
+ end
39
+
40
+ def changed_files
41
+ `git status --porcelain`.lines.map do |line|
42
+ line.chomp.split(' ').last
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'guard/git/changed_files_matcher'
4
+
5
+ module Guard
6
+ module Git
7
+ module DslExtensions
8
+ def watch(pattern, &action)
9
+ super(ChangedFilesMatcher.new(pattern), &action)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module Git
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-git
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Patterson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rb-readline
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.89.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.89.0
125
+ description:
126
+ email:
127
+ - apps.djpdev@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - Gemfile.lock
138
+ - Guardfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - guard-git.gemspec
143
+ - lib/guard/git.rb
144
+ - lib/guard/git/changed_files_matcher.rb
145
+ - lib/guard/git/dsl_extensions.rb
146
+ - lib/guard/git/version.rb
147
+ homepage: https://github.com/dp28/guard-git
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '2.4'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.6.14
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Make Guard git-aware
171
+ test_files: []