magellan-cli 0.7.5 → 0.7.6

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: 66841e41672c874e98cec2d212f62a2c58ef7f35
4
- data.tar.gz: 7791ac28ef42d6184070379ecd71a9518c555ec3
3
+ metadata.gz: 39a2518f311bac8449c9a2deb205ace8b022ab89
4
+ data.tar.gz: ddb7b05fa8d5e68601e5aa36d3646a29fbc2727f
5
5
  SHA512:
6
- metadata.gz: 5cc5fd4b7abbd7aeed50e36368a98fc2135b7c0cbd722c435fbededdfbc718f35d8cc4aad960482f93543d0d91289e6e3ac0729b8bf164f6cfd27211ad8dca43
7
- data.tar.gz: 52cce928eba021a3859028bc5e10ce3f6f7dad3cb2171129880ad85ed1558a0d6b6c9f755b1d389cdff3073ebb62ac81332923b943e41bcdda0fb2d5744cc055
6
+ metadata.gz: d8f7923f9c7810cd2a759b360ba34e0766c5a20cbced5ca1398f6f0a8ceff4d46dc3453e64d547da0ea78f2bca622c04112d75513f42e0f3d33ddc8748eb64e6
7
+ data.tar.gz: 931bac737533317d2278d247a085257e6c8a6c13b9a09732569932c7978ae6980b9827917b77d139dcfd31f04d472f3de3e5d347b8ebd0c119794ac51e6e93e9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.7.5)
4
+ magellan-cli (0.7.6)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
@@ -151,6 +151,12 @@ module Magellan
151
151
  end
152
152
  end
153
153
 
154
+ def process_error_response(res)
155
+ obj = JSON.parse(res.body) rescue nil
156
+ if obj and obj.is_a?(Hash) and msg = obj["message"]
157
+ fatal(msg)
158
+ end
159
+ end
154
160
  end
155
161
 
156
162
 
@@ -180,10 +180,7 @@ module Magellan
180
180
  end
181
181
  r
182
182
  else
183
- obj = JSON.parse(res.body) rescue nil
184
- if obj and obj.is_a?(Hash) and obj["message"]
185
- cmd.fatal(obj["message"])
186
- end
183
+ cmd.process_error_response(res)
187
184
  end
188
185
  end
189
186
 
@@ -194,6 +194,18 @@ module Magellan
194
194
  end
195
195
  end
196
196
 
197
+ def process_error_response(res)
198
+ obj = JSON.parse(res.body) rescue nil
199
+ if obj and obj.is_a?(Hash) and msg = obj["message"]
200
+ res_name = self.class.name.split(/::/).last.underscore
201
+ msg.gsub!(/#{Regexp.escape(self.class.model_class_name)}/, res_name)
202
+ if msg =~ /\A#{Regexp.escape(res_name)}/
203
+ msg = "The #{msg}"
204
+ end
205
+ fatal(msg)
206
+ end
207
+ end
208
+
197
209
  def self.inherited(klass)
198
210
  base_name = klass.name.split(/::/).last
199
211
  res_name = Magellan::Cli::Resources::MAPPING[base_name] or raise "resource not found for #{base_name}"
@@ -219,6 +231,9 @@ module Magellan
219
231
  def parameter_name
220
232
  self.class.parameter_name
221
233
  end
234
+ def self.model_class_name
235
+ resource_key.split(/~/).map(&:camelize).join('::')
236
+ end
222
237
  end
223
238
 
224
239
  desc "list", "#{I18n.t(:list, scope: [:resources, :common, :cmd], res_names: res_name.pluralize)}"
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.7.5"
3
+ VERSION = "0.7.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm2000
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient