capistrano-stats 1.0.3 → 1.1.1

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: dc8cf50b960c70118fc2b7124c2768666a05ad6d
4
- data.tar.gz: 1c99193aba071befb56c6128cd7478b67dbece36
3
+ metadata.gz: 52515a16e3df21ab213463d1840931b39d946a50
4
+ data.tar.gz: 7ca3fe990c9b274507d3d0dcc0edc5d0f926399c
5
5
  SHA512:
6
- metadata.gz: 737a01568351215515d012738a5353f6da532125f266c826345ecd0f49e8793f2c27d9186b84d688cb606078dbd7c4b401e064c71e20d475e001f76717987fcf
7
- data.tar.gz: c1e73a8fa0d11f853925599043104bc18b0831aadedf2a45a25dcf99c614d7eb4c13b4efd03c43f91a2df4e6b4e2749617e34bb7a1c6e2cbfaa0db2a93d92f9d
6
+ metadata.gz: cd70b66c4971c2fba9647bbdd5a0f24dd979bbe44d616933b36545be05cd5579ccf42775429f1342fef097f0eaba8af438a943cb49fdf8709640e1f5211c9f77
7
+ data.tar.gz: bc24902af73f05881c60fc5a5a979625a0fbc9d35baf35f32af91497a16c3a2f9f6fb11d4a090301f6f0b87878284d1a5f67b7e8dec47a96f7017e66c78f69a9
@@ -12,16 +12,31 @@ module Capistrano
12
12
  @pwd = Pathname.new(pwd)
13
13
  end
14
14
 
15
- def enabled?
15
+ def user_preference
16
16
  ask_to_enable unless File.exists?(sentry_file)
17
- File.read(sentry_file).chomp == "true"
17
+ pref = File.read(sentry_file)
18
+ if pref.chomp == "true"
19
+ :full
20
+ elsif pref.chomp == "false"
21
+ :ping
22
+ else
23
+ pref && pref.to_sym
24
+ end
18
25
  end
19
26
 
20
27
  def collect
28
+ return if user_preference == :none
21
29
  socket = UDPSocket.new
22
- message.anonymize! unless enabled?
30
+ message.anonymize! unless user_preference == :full
23
31
  socket.send(message.to_s, 0, *destination)
24
- rescue SocketError
32
+ rescue SocketError, Errno::EACCES, Errno::EADDRINUSE, Errno::EADDRNOTAVAIL,
33
+ Errno::EAFNOSUPPORT, Errno::EALREADY, Errno::EBADF, Errno::ECONNREFUSED,
34
+ Errno::ECONNRESET, Errno::EFAULT, Errno::EHOSTUNREACH, Errno::EINPROGRESS,
35
+ Errno::EINTR, Errno::EINVAL, Errno::EIO, Errno::EISCONN, Errno::ELOOP,
36
+ Errno::ENAMETOOLONG, Errno::ENETDOWN,
37
+ Errno::ENETUNREACH, Errno::ENOBUFS, Errno::ENOENT, Errno::ENOSR,
38
+ Errno::ENOTDIR, Errno::ENOTSOCK, Errno::EOPNOTSUPP, Errno::EPROTOTYPE,
39
+ Errno::ETIMEDOUT, Errno::EWOULDBLOCK
25
40
  warn "There was a problem tracking statistics, please report to https://github.com/capistrano/stats"
26
41
  end
27
42
 
@@ -52,7 +67,12 @@ module Capistrano
52
67
  def ask_to_enable
53
68
  return false unless $stdin.tty?
54
69
  show_prompt
55
- result = ask_to_confirm("Do you want to enable statistics? (y/N): ")
70
+ result = ask_to_confirm("Do you want to enable statistics? (y/N): ") ? :full : :ping
71
+ if result != :full
72
+ if ask_to_confirm("Do you also want to disable the UDP ping to the metrics server? (y/N): ")
73
+ result = :none
74
+ end
75
+ end
56
76
  show_thank_you_note(result)
57
77
  write_setting(result)
58
78
  end
@@ -62,15 +82,15 @@ module Capistrano
62
82
  Would you like to enable statistics? Here is an example message we would
63
83
  send:
64
84
 
65
- #{message}
85
+ #{message}
66
86
 
67
87
  EOF
68
88
  end
69
89
 
70
90
  def show_thank_you_note(result)
71
- puts(result ? "Thank you, you may wish to add .capistrano/ to your source
72
- control database to avoid future prompts" : "Your preferences have
73
- been saved.")
91
+ puts(result == :full ?
92
+ "Thank you, you may wish to add .capistrano/ to your source control database to avoid future prompts" :
93
+ "Your preferences have been saved.")
74
94
  end
75
95
 
76
96
  def message
@@ -95,7 +115,7 @@ module Capistrano
95
115
  def write_setting(value)
96
116
  Dir.mkdir(sentry_file.dirname) rescue nil
97
117
  File.open(sentry_file, "wb") do |f|
98
- f.write(value)
118
+ f.write(value.to_sym)
99
119
  end
100
120
  end
101
121
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Stats
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-27 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Collects anonymous usage statistics about Capistrano to aid with platform
14
14
  support and ruby version targeting.