capistrano-harrow 0.4.0 → 0.5.0

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: 65e8e793ccd1dc35faf097eab9b91efa4998814e
4
- data.tar.gz: e8bff1060e533c53a5d48e349a439715d5f078bf
3
+ metadata.gz: 7348d2fff68dd4c25e1c96fd59de412db7058f73
4
+ data.tar.gz: 1ed8bd7185262d7c0501cadf7f7af095d158489b
5
5
  SHA512:
6
- metadata.gz: 085035cbc8f19ba9250483ca635b6d3637a93435c513d2f3b8bd79806731b0c9dbfdb9991d36e7cd17fa145c056d39fa82411dd23ad36bc90ff240b47d8f2031
7
- data.tar.gz: f59340879926938d78723f55d68abf54525c881bf656514314849241d19fc8e1e319402dd5f3356288143e738c167757a242edee9061edb45af38d1d2cf5dae1
6
+ metadata.gz: 23e220496e00e4ad0877cf7346aa306cc1f586f122c7eb25c50bf83fe67654271b83a3c0ab3f5964fbe8fe5d9cb3a107929a4bd809dfd7682cf5fca9de088cc4
7
+ data.tar.gz: 418470ac85cf41759192517462757521e527817d542cc4456b3c34a23a3a6008c416808754942feba56ac365ca1deaef800bf3dad48abf3e56e98a5b5f1289ad
@@ -35,7 +35,11 @@ module Capistrano
35
35
 
36
36
  case response
37
37
  when Net::HTTPSuccess
38
- return ::JSON.parse(response.body, symbolize_names: true).fetch(:participating, false)
38
+ parsed_body = ::JSON.parse(response.body, symbolize_names: true)
39
+ is_participating = parsed_body.delete(:participating)
40
+ return false unless is_participating
41
+
42
+ return parsed_body
39
43
  end
40
44
 
41
45
  false
@@ -65,10 +65,7 @@ For this repository with the URL:
65
65
  %<repository_url>s
66
66
 
67
67
  },
68
- }
69
-
70
- def self.preinstall_message
71
- %q{
68
+ preinstall: %q{
72
69
  - Free for small projects!
73
70
 
74
71
  - Test, deploy and collaborate online easily
@@ -80,11 +77,16 @@ For this repository with the URL:
80
77
  - Works seamlessly for PHP, Node.js, Ansible, Python, Go,
81
78
  Capistrano and more!
82
79
 
83
- }
80
+ },
81
+
82
+ }
83
+
84
+ def message(tag, format_data)
85
+ sprintf(@messages.fetch(tag, tag.to_s), format_data)
84
86
  end
85
87
 
86
- def self.message(tag, format_data)
87
- sprintf(MESSAGES.fetch(tag, tag.to_s), format_data)
88
+ def prompt(tag)
89
+ @prompts.fetch(tag, tag.to_s)
88
90
  end
89
91
 
90
92
  def initialize(params={ui: UI::TTY, api: API, config: Config::Git})
@@ -93,18 +95,22 @@ For this repository with the URL:
93
95
  @api = params.fetch(:api)
94
96
  @quit = false
95
97
  @password = nil
98
+ update_message_catalog!({messages: MESSAGES,
99
+ prompts: PROMPTS})
96
100
  end
97
101
 
98
102
  def install!
99
103
  return if @config.disabled?
100
104
  return if @config.installed?
101
- return unless @api.participating?(signup_data)
105
+ messages = @api.participating?(signup_data)
106
+ return unless messages
107
+ update_message_catalog!(messages)
102
108
 
103
109
  @ui.show Banner.new.to_s
104
- @ui.show self.class.preinstall_message
110
+ @ui.show message(:preinstall, {})
105
111
 
106
112
  begin
107
- if @ui.prompt(PROMPTS[:want_install]).downcase == 'no'
113
+ if @ui.prompt(prompt(:want_install)).downcase == 'no'
108
114
  quit!
109
115
  return
110
116
  end
@@ -116,16 +122,16 @@ For this repository with the URL:
116
122
  data = signup_data
117
123
  if data[:email].to_s.empty? or data[:name].to_s.empty?
118
124
  begin
119
- data[:name] = @ui.prompt(PROMPTS[:enter_name], [])
120
- data[:email] = @ui.prompt(PROMPTS[:enter_email], [])
125
+ data[:name] = @ui.prompt(prompt(:enter_name), [])
126
+ data[:email] = @ui.prompt(prompt(:enter_email), [])
121
127
  rescue UI::TimeoutError
122
128
  quit!("timeout")
123
129
  end
124
130
  end
125
131
 
126
- @ui.show self.class.message(:signup_data, data)
132
+ @ui.show message(:signup_data, data)
127
133
  unless data[:repository_url].to_s.empty?
128
- @ui.show self.class.message(:repository, data)
134
+ @ui.show message(:repository, data)
129
135
  end
130
136
 
131
137
  @password = prompt_password!
@@ -152,7 +158,7 @@ For this repository with the URL:
152
158
  end
153
159
 
154
160
  @quit = true
155
- @ui.show(self.class.message(:aborting,{reason: reason}))
161
+ @ui.show(message(:aborting,{reason: reason}))
156
162
  end
157
163
 
158
164
  def quit?
@@ -168,21 +174,21 @@ For this repository with the URL:
168
174
  @config.organization_uuid = response_data[:organization_uuid]
169
175
  if response_data.fetch(:reason, 'ok') == 'invalid'
170
176
  if response_data.fetch(:errors, {}).fetch(:email, []).first == 'not_unique'
171
- @ui.show self.class.message(:existing_account_found, {})
177
+ @ui.show message(:existing_account_found, {})
172
178
  return :account_exists
173
179
  else
174
- @ui.show self.class.message(:api_fatal_error, {})
180
+ @ui.show message(:api_fatal_error, {})
175
181
  return response_data
176
182
  end
177
183
  else
178
- @ui.show self.class.message(:installation_successful, response_data)
184
+ @ui.show message(:installation_successful, response_data)
179
185
  return :signed_up
180
186
  end
181
187
  rescue API::NetworkError
182
- @ui.show self.class.message(:api_network_error, {})
188
+ @ui.show message(:api_network_error, {})
183
189
  should_retry = false
184
190
  begin
185
- if @ui.prompt(PROMPTS[:retry_request], [:no, :yes]) == :yes
191
+ if @ui.prompt(prompt(:retry_request), [:no, :yes]) == :yes
186
192
  should_retry = true
187
193
  end
188
194
  rescue UI::TimeoutError
@@ -192,10 +198,10 @@ For this repository with the URL:
192
198
 
193
199
  retry if should_retry
194
200
  rescue API::ProtocolError
195
- quit! self.class.message(:api_protocol_error, {})
201
+ quit! message(:api_protocol_error, {})
196
202
  return
197
203
  rescue API::FatalError
198
- quit! self.class.message(:api_fatal_error, {})
204
+ quit! message(:api_fatal_error, {})
199
205
  return
200
206
  end
201
207
  end
@@ -203,22 +209,31 @@ For this repository with the URL:
203
209
  def prompt_password!
204
210
  tries = 3
205
211
  while tries > 0
206
- password = @ui.prompt_password(PROMPTS[:enter_password])
207
- confirmed_password = @ui.prompt_password(PROMPTS[:confirm_password])
212
+ password = @ui.prompt_password(prompt(:enter_password))
213
+ confirmed_password = @ui.prompt_password(prompt(:confirm_password))
208
214
 
209
215
 
210
216
  if password == confirmed_password && password.to_s.length >= 10
211
217
  return password
212
218
  elsif password.to_s.length < 10
213
- @ui.show self.class.message(:password_too_short, {})
219
+ @ui.show message(:password_too_short, {})
214
220
  else
215
- @ui.show self.class.message(:password_mismatch, {})
221
+ @ui.show message(:password_mismatch, {})
216
222
  end
217
223
 
218
224
  tries = tries - 1
219
225
  end
220
226
  end
221
227
 
228
+ def update_message_catalog!(new_messages)
229
+ return unless new_messages.respond_to? :fetch
230
+ @messages = {} unless @messages
231
+ @prompts = {} unless @prompts
232
+
233
+ @messages.merge!(new_messages.fetch(:messages, {}))
234
+ @prompts.merge!(new_messages.fetch(:prompts, {}))
235
+ end
236
+
222
237
  end
223
238
  end
224
239
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Harrow
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-harrow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-04-28 00:00:00.000000000 Z
12
+ date: 2016-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler