listen 2.8.1 → 2.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 564ec4894c98d82d45f5fe13552779dc82a99aef
4
- data.tar.gz: 564f4150846dd6a22741af85af7576b474f878b1
3
+ metadata.gz: 82833c1dcd0ed421fcb93115f1c764492148b1f4
4
+ data.tar.gz: 407619ca1bdba240ae918e4e3e73e237f129f132
5
5
  SHA512:
6
- metadata.gz: 69319e63efa594a612acae069cba16a0df900e2ba92ba0c110ef088833929d82197b0c7ff03f549c4b27d9db211093f2278a02e56ee57b5f541f53ebad926985
7
- data.tar.gz: 645d9ed317278c3abee4df7f2ded2810d46f9bacb42514fe8deeb37b9898b294aaf59975e786cb16b0832b94dd7a5560a664603d9243f20bdb83a66c75a54c0e
6
+ metadata.gz: 03f0ba222830c725718adf106e479a559b183d663009c7482c35bf252c9c41799d3d824692ac30716ddf62ada053610400391b67c3d8caa82eb9a715ad3d16d7
7
+ data.tar.gz: eaa55b1eaae113d97e621f6de5fb657186f584f0d1c6cd1051c17368702867e6b816047d9868114863118addbc73f413f7850b040d49c2631eb0699ae6b84763
data/Rakefile CHANGED
@@ -10,3 +10,142 @@ if ENV["CI"] != "true"
10
10
  else
11
11
  task default: [:spec]
12
12
  end
13
+
14
+ class Releaser
15
+ def initialize(options = {})
16
+ @project_name = options.delete(:project_name) do
17
+ fail "project_name is needed!"
18
+ end
19
+
20
+ @gem_name = options.delete(:gem_name) do
21
+ fail "gem_name is needed!"
22
+ end
23
+
24
+ @github_repo = options.delete(:github_repo) do
25
+ fail "github_repo is needed!"
26
+ end
27
+
28
+ @version = options.delete(:version) do
29
+ fail "version is needed!"
30
+ end
31
+ end
32
+
33
+ def full
34
+ rubygems
35
+ github
36
+ end
37
+
38
+ def rubygems
39
+ begin
40
+ STDOUT.puts "Release #{@project_name} #{@version} to RubyGems? (y/n)"
41
+ input = STDIN.gets.chomp.downcase
42
+ end while !%w(y n).include?(input)
43
+
44
+ exit if input == "n"
45
+
46
+ Rake::Task["release"].invoke
47
+ end
48
+
49
+ def github
50
+ tag_name = "v#{@version}"
51
+
52
+ require "gems"
53
+
54
+ _verify_released
55
+ _verify_tag_pushed
56
+
57
+ require "octokit"
58
+ gh_client = Octokit::Client.new(netrc: true)
59
+
60
+ gh_release = _detect_gh_release(gh_client, tag_name, true)
61
+ return unless gh_release
62
+
63
+ STDOUT.puts "Draft release for #{tag_name}:\n"
64
+ STDOUT.puts gh_release.body
65
+ STDOUT.puts "\n-------------------------\n\n"
66
+
67
+ _confirm_publish
68
+
69
+ return unless _update_release(gh_client, gh_release, tag_name)
70
+
71
+ gh_release = _detect_gh_release(gh_client, tag_name, false)
72
+
73
+ _success_summary(gh_release, tag_name)
74
+ end
75
+
76
+ private
77
+
78
+ def _verify_released
79
+ if @version != Gems.info(@gem_name)["version"]
80
+ STDOUT.puts "#{@project_name} #{@version} is not yet released."
81
+ STDOUT.puts "Please release it first with: rake release:gem"
82
+ exit
83
+ end
84
+ end
85
+
86
+ def _verify_tag_pushed
87
+ tags = `git ls-remote --tags origin`.split("\n")
88
+ return if tags.detect { |tag| tag =~ /v#{@version}$/ }
89
+
90
+ STDOUT.puts "The tag v#{@version} has not yet been pushed."
91
+ STDOUT.puts "Please push it first with: rake release:gem"
92
+ exit
93
+ end
94
+
95
+ def _success_summary(gh_release, tag_name)
96
+ href = gh_release.rels[:html].href
97
+ STDOUT.puts "GitHub release #{tag_name} has been published!"
98
+ STDOUT.puts "\nPlease enjoy and spread the word!"
99
+ STDOUT.puts "Lack of inspiration? Here's a tweet you could improve:\n\n"
100
+ STDOUT.puts "Just released #{@project_name} #{@version}! #{href}"
101
+ end
102
+
103
+ def _detect_gh_release(gh_client, tag_name, draft)
104
+ gh_releases = gh_client.releases(@github_repo)
105
+ gh_releases.detect { |r| r.tag_name == tag_name && r.draft == draft }
106
+ end
107
+
108
+ def _confirm_publish
109
+ begin
110
+ STDOUT.puts "Would you like to publish this GitHub release now? (y/n)"
111
+ input = STDIN.gets.chomp.downcase
112
+ end while !%w(y n).include?(input)
113
+
114
+ exit if input == "n"
115
+ end
116
+
117
+ def _update_release(gh_client, gh_release, tag_name)
118
+ result = gh_client.update_release(gh_release.rels[:self].href, draft: false)
119
+ return true if result
120
+ STDOUT.puts "GitHub release #{tag_name} couldn't be published!"
121
+ false
122
+ end
123
+ end
124
+
125
+ PROJECT_NAME = "Listen"
126
+ CURRENT_VERSION = Listen::VERSION
127
+
128
+ def releaser
129
+ $releaser ||= Releaser.new(
130
+ project_name: PROJECT_NAME,
131
+ gem_name: "guard",
132
+ github_repo: "guard/guard",
133
+ version: CURRENT_VERSION)
134
+ end
135
+
136
+ namespace :release do
137
+ desc "Push #{PROJECT_NAME} #{CURRENT_VERSION} to RubyGems and publish"\
138
+ " its GitHub release"
139
+
140
+ task full: ["release:gem", "release:github"]
141
+
142
+ desc "Push #{PROJECT_NAME} #{CURRENT_VERSION} to RubyGems"
143
+ task :gem do
144
+ releaser.rubygems
145
+ end
146
+
147
+ desc "Publish #{PROJECT_NAME} #{CURRENT_VERSION} GitHub release"
148
+ task :github do
149
+ releaser.github
150
+ end
151
+ end
@@ -115,12 +115,12 @@ module Listen
115
115
 
116
116
  def _fast_build_dir(remaining, symlink_detector)
117
117
  entry = remaining.pop
118
- entry.children.each { |child| remaining << child }
119
118
  symlink_detector.verify_unwatched!(entry)
119
+ entry.children.each { |child| remaining << child }
120
120
  add_dir(entry.root, entry.record_dir_key)
121
121
  rescue Errno::ENOTDIR
122
122
  _fast_try_file(entry)
123
- rescue SystemCallError
123
+ rescue SystemCallError, SymlinkDetector::Error
124
124
  _fast_unset_path(entry.root, entry.relative, entry.name)
125
125
  end
126
126
 
@@ -4,43 +4,21 @@ module Listen
4
4
  # @private api
5
5
  class Record
6
6
  class SymlinkDetector
7
- SYMLINK_LOOP_ERROR = <<-EOS
8
- ** ERROR: Listen detected a duplicate directory being watched! **
9
-
10
- (This may be due to multiple symlinks pointing to already watched dirs).
11
-
12
- Duplicate: %s
13
-
14
- which already is added as: %s
15
-
16
- Listen is refusing to continue, because it may cause an infinite loop,
17
- a crash or confusing results.
18
-
19
- Suggestions:
7
+ WIKI = 'https://github.com/guard/listen/wiki/Duplicate-directory-errors'
20
8
 
21
- 1) (best option) watch only directories you care about (e.g.
22
- either symlinked folders or folders with the real directories,
23
- but not both).
24
-
25
- IMPORTANT: The `:ignore` options DO NOT HELP here
26
- (see: https://github.com/guard/listen/issues/274)
27
-
28
- NOTE: If you are using Listen through some other application
29
- (like Guard, Compass, Jekyll, Vagrant), check the documentation on
30
- selecting watched directories (e.g. Guard has a `-w` option, Compass
31
- allows you to specify multiple input/output directories, etc.)
9
+ SYMLINK_LOOP_ERROR = <<-EOS
10
+ ** ERROR: directory is already being watched! **
32
11
 
33
- 2) reorganize your project so that watched directories do not
34
- contain symlinked directories
12
+ Directory: %s
35
13
 
36
- 3) submit patches so that Listen can reliably and quickly (!)
37
- detect symlinks to already watched read directories, skip
38
- them, and then reasonably choose which symlinked paths to
39
- report as changed (if any)
14
+ is already begin watched through: %s
40
15
 
41
- Issue: https://github.com/guard/listen/issues/259
16
+ MORE INFO: #{WIKI}
42
17
  EOS
43
18
 
19
+ class Error < RuntimeError
20
+ end
21
+
44
22
  def initialize
45
23
  @real_dirs = Set.new
46
24
  end
@@ -54,9 +32,7 @@ module Listen
54
32
 
55
33
  def _fail(symlinked, real_path)
56
34
  STDERR.puts format(SYMLINK_LOOP_ERROR, symlinked, real_path)
57
-
58
- # Note Celluloid eats up abort message anyway
59
- fail 'Failed due to looped symlinks'
35
+ fail Error, 'Failed due to looped symlinks'
60
36
  end
61
37
  end
62
38
  end
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.8.1'
2
+ VERSION = '2.8.2'
3
3
  end
@@ -232,6 +232,10 @@ describe Listen::Record do
232
232
 
233
233
  allow(::File).to receive(:realpath).with('/dir1').and_return('/dir1')
234
234
  allow(::File).to receive(:realpath).with('/dir2').and_return('/dir2')
235
+ allow(::File).to receive(:realpath).with('/dir1/foo').
236
+ and_return('/dir1/foo')
237
+ allow(::File).to receive(:realpath).with('/dir1/bar').
238
+ and_return('/dir1/bar')
235
239
  end
236
240
 
237
241
  it 'builds record' do
@@ -256,6 +260,8 @@ describe Listen::Record do
256
260
  allow(::File).to receive(:realpath).with('/dir2').and_return('/dir2')
257
261
  allow(::File).to receive(:realpath).with('/dir1/foo').
258
262
  and_return('/dir1/foo')
263
+ allow(::File).to receive(:realpath).with('/dir1/foo/bar').
264
+ and_return('/dir1/foo/bar')
259
265
  end
260
266
 
261
267
  it 'builds record' do
@@ -295,15 +301,19 @@ describe Listen::Record do
295
301
  before do
296
302
  allow(::Dir).to receive(:entries).with('/dir1') { %w(foo) }
297
303
  allow(::Dir).to receive(:entries).with('/dir1/foo') { %w(foo) }
304
+ allow(::Dir).to receive(:entries).with('/dir2') { [] }
298
305
  allow(::File).to receive(:realpath).with('/dir1').and_return('/bar')
299
306
  allow(::File).to receive(:realpath).with('/dir1/foo').and_return('/bar')
307
+ allow(::File).to receive(:realpath).with('/dir2').and_return('/dir2')
300
308
  end
301
309
 
302
310
  it 'shows message and aborts with error' do
303
- expect(STDERR).to receive(:puts).with(/detected a duplicate directory/)
311
+ expect(STDERR).to receive(:puts).
312
+ with(/directory is already being watched/)
304
313
 
305
- expect { record.build }.to raise_error(RuntimeError,
306
- /Failed due to looped symlinks/)
314
+ record.build
315
+ # expect { record.build }.
316
+ # to raise_error(RuntimeError, /Failed due to looped symlinks/)
307
317
  end
308
318
  end
309
319
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid