sonar-client 0.0.2 → 0.0.3

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: 5880f8913b5f5cde97f0ec7bbc57db5ab17e4c03
4
- data.tar.gz: f42f280930382afc000aaae0f77081dbf908805e
3
+ metadata.gz: 5dd2ef2da6cb21be5643f246fb559a984400639b
4
+ data.tar.gz: 1304d5edaaab17637bcbe18362d14b2c23a65581
5
5
  SHA512:
6
- metadata.gz: 81d8366866002b3e468ccfd8e93011a3eb7e7fa67ddf07223c346d5141f906a45922572fec455ca101317ae639f44c685e04e556b4695f6604517b406e0f4679
7
- data.tar.gz: e72e00fc42c7bca8055a8dc6d093e1fcc43f1d5c97ee4299b18e60e1a57b351277fdb50e3812d810b421a09e78f83a711e5e833ca372b1a647b992bee6f15a7f
6
+ metadata.gz: cf3270d0d080e0f39b09501ce6c104a029ea1fa140314af14f6e44a3ed26988edc1b4ae0848fef793887127b67ab25b3975fa394695a15685148c547e779ced2
7
+ data.tar.gz: 2df2543baa5d5bb6a0e87c52f7f1663392f4cd0cbc16904e26ce814d2b14859c6527c18dc090624d19c2eb1cba2759a06069f639f523bcfcac9fd9e5674b8b20
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sonar-client (0.0.2)
4
+ sonar-client (0.0.3)
5
5
  awesome_print
6
6
  faraday_middleware (~> 0.9.0)
7
7
  hashie (~> 2.0.3)
@@ -33,7 +33,7 @@ module Sonar
33
33
  @query[type.to_sym] = term
34
34
  @query[:limit] = options['record_limit']
35
35
  @client.search(@query).each do |data|
36
- print_json(data, options['format'])
36
+ print_json(cleanup_data(data), options['format'])
37
37
  end
38
38
  end
39
39
 
@@ -60,6 +60,35 @@ module Sonar
60
60
  end
61
61
  end
62
62
 
63
+ # Clean up whitespace and parse JSON values in responses
64
+ def cleanup_data(data)
65
+ ndata = {}
66
+ if data[0] != 'collection'
67
+ return data
68
+ end
69
+
70
+ ncoll = []
71
+
72
+ data[1].each do |item|
73
+ nitem = {}
74
+ item.each_pair do |k,v|
75
+
76
+ # Purge whitespace within values
77
+ nval = v.kind_of?(::String) ? v.strip : v
78
+ nkey = k.strip
79
+
80
+ # Parse JSON values
81
+ if nval && nval.index('{') == 0
82
+ nval = JSON.parse(nval) rescue nval
83
+ end
84
+
85
+ nitem[nkey] = nval
86
+ end
87
+ ncoll << nitem
88
+ end
89
+ [ data[0], ncoll ]
90
+ end
91
+
63
92
  # Merge Thor options with those stored in sonar.rc file
64
93
  # where all default options are set.
65
94
  def options
@@ -1,3 +1,3 @@
1
1
  module Sonar
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonar-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Deardorff & HD Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-14 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware