tupalo-gattica 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 3
4
+ :patch: 5
data/lib/gattica.rb CHANGED
@@ -11,7 +11,6 @@ require 'hpricot'
11
11
  require 'yaml'
12
12
 
13
13
  # internal
14
- require 'gattica/core_extensions'
15
14
  require 'gattica/convertible'
16
15
  require 'gattica/exceptions'
17
16
  require 'gattica/user'
@@ -26,7 +25,7 @@ require 'gattica/data_point'
26
25
 
27
26
  module Gattica
28
27
 
29
- VERSION = '0.3.4.for_tupalo'
28
+ VERSION = '0.3.5.for_tupalo'
30
29
 
31
30
  # Creates a new instance of Gattica::Engine and gets us going. Please see the README for usage docs.
32
31
  #
data/lib/gattica/auth.rb CHANGED
@@ -19,7 +19,7 @@ module Gattica
19
19
  def initialize(http, user)
20
20
  options = OPTIONS.merge(user.to_h)
21
21
 
22
- response, data = http.post(SCRIPT_NAME, options.to_query, HEADERS)
22
+ response, data = http.post(SCRIPT_NAME, hash_to_query(options), HEADERS)
23
23
  if response.code != '200'
24
24
  case response.code
25
25
  when '403'
@@ -47,6 +47,14 @@ module Gattica
47
47
  end
48
48
  return tokens
49
49
  end
50
+
51
+ def hash_to_query(hash)
52
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
53
+ hash.collect do |key, value|
54
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
55
+ end.sort * '&'
56
+ end
57
+
50
58
 
51
59
  end
52
60
  end
@@ -21,7 +21,14 @@ module Gattica
21
21
  alias inspect to_s
22
22
 
23
23
  def to_query
24
- to_h.to_query
24
+ hash_to_query(to_h)
25
+ end
26
+
27
+ def hash_to_query(hash)
28
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
29
+ hash.collect do |key, value|
30
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
31
+ end.sort * '&'
25
32
  end
26
33
 
27
34
  # Return the raw XML (if the object has a @xml instance variable, otherwise convert the object itself to xml)
@@ -37,10 +37,18 @@ module Gattica
37
37
  end
38
38
 
39
39
  # output all dimensions
40
- @dimensions.map {|d| d.value}.each { |c| columns << c }
40
+ @dimensions.map {|d|
41
+ (
42
+ d.values.first if d.length == 1
43
+ )
44
+ }.each { |c| columns << c }
41
45
 
42
46
  # output all metrics
43
- @metrics.map {|m| m.value}.each { |c| columns << c }
47
+ @metrics.map {|m|
48
+ (
49
+ m.values.first if d.length == 1
50
+ )
51
+ }.each { |c| columns << c }
44
52
 
45
53
  output = CSV.generate_line(columns)
46
54
  return output
@@ -34,8 +34,16 @@ module Gattica
34
34
  end
35
35
 
36
36
  unless @points.empty? # if there was at least one result
37
- @points.first.dimensions.map {|d| d.key}.each { |c| columns << c }
38
- @points.first.metrics.map {|m| m.key}.each { |c| columns << c }
37
+ @points.first.dimensions.map { |d|
38
+ (
39
+ d.keys.first if d.length == 1
40
+ )
41
+ }.each { |c| columns << c }
42
+ @points.first.metrics.map { |m|
43
+ (
44
+ m.keys.first if m.length == 1
45
+ )
46
+ }.each { |c| columns << c }
39
47
  end
40
48
 
41
49
  output = CSV.generate_line(columns) + "\n"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rob Cameron
@@ -39,7 +39,6 @@ files:
39
39
  - lib/gattica/account.rb
40
40
  - lib/gattica/auth.rb
41
41
  - lib/gattica/convertible.rb
42
- - lib/gattica/core_extensions.rb
43
42
  - lib/gattica/data_point.rb
44
43
  - lib/gattica/data_set.rb
45
44
  - lib/gattica/exceptions.rb
@@ -1,25 +0,0 @@
1
- class Hash
2
-
3
- def to_query
4
- require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
5
- self.collect do |key, value|
6
- "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}"
7
- end.sort * '&'
8
- end
9
-
10
- def key
11
- self.keys.first if self.length == 1
12
- end
13
-
14
- def value
15
- self.values.first if self.length == 1
16
- end
17
-
18
- # def stringify_keys
19
- # inject({}) do |options, (key, value)|
20
- # options[key.to_s] = value
21
- # options
22
- # end
23
- # end
24
-
25
- end