spaceship 0.0.4 → 0.0.5

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: 86c6e8217bad88bfdb0c32ab0e02fd732a95ca36
4
- data.tar.gz: 606504429db1051598fd6e7b0bcfeab99c477ab2
3
+ metadata.gz: 9fafd78ad44e1ebeaf7fe1ee2342bfddb3d6155b
4
+ data.tar.gz: a33cf9b21faab673c3d30f3b41d768d9f7731ab6
5
5
  SHA512:
6
- metadata.gz: d3f690107bdde045e9db60a376260adfe6b78e11a06483ca08022971e3aa523d1cb7f1399683f4cd6f60164bce86a8c3edf95ef7e391709c96c9df6d8e84769a
7
- data.tar.gz: b59835d27eeb8024631863ac30891bbf60a451e4a419573ffb74224249cb8cb22ac373d878b71e7f3cc39170326b7a5da41fb1c99d19a7752b5158b10fd7c056
6
+ metadata.gz: 0aa86fd5d437df47047a977313093b315c9e297b758e1f6a8d729735c5eee9e4d11c6a3cb77695f4804c60ba485b1d72d0459006e429ece534be8a39578da998
7
+ data.tar.gz: 7bf6d93ef0e595048b141bb8f6351c66b4e104d15f450a9617d35c8d315a2d85b7ae90ddc46d7ffe4cc0b3d891e8e747fff9d03ea99bb37a62de79fe72b9e54b
@@ -52,13 +52,12 @@ module Spaceship
52
52
  module_name = method_sym.to_s
53
53
  module_name.sub!(/^[a-z\d]/) { $&.upcase }
54
54
  module_name.gsub!(/(?:_|(\/))([a-z\d])/) { $2.upcase }
55
- const_name = "#{self.name}::#{module_name}"
56
- # if const_defined?(const_name)
57
- klass = const_get(const_name)
55
+ if const_defined?(module_name)
56
+ klass = const_get(module_name)
58
57
  klass.set_client(@client)
59
- # else
60
- # super
61
- # end
58
+ else
59
+ super
60
+ end
62
61
  end
63
62
  end
64
63
 
@@ -1,4 +1,5 @@
1
1
  require 'faraday' # HTTP Client
2
+ require 'logger'
2
3
  require 'faraday_middleware'
3
4
  require 'spaceship/ui'
4
5
  require 'spaceship/helper/plist_middleware'
@@ -18,6 +19,10 @@ module Spaceship
18
19
  attr_reader :client
19
20
  attr_accessor :cookie
20
21
 
22
+ # The logger in which all requests are logged
23
+ # /tmp/spaceship.log by default
24
+ attr_accessor :logger
25
+
21
26
  class InvalidUserCredentialsError < StandardError; end
22
27
  class UnexpectedResponse < StandardError; end
23
28
 
@@ -65,6 +70,24 @@ module Spaceship
65
70
  end
66
71
  end
67
72
 
73
+ # The logger in which all requests are logged
74
+ # /tmp/spaceship.log by default
75
+ def logger
76
+ unless @logger
77
+ if $verbose || ENV["VERBOSE"]
78
+ @logger = Logger.new(STDOUT)
79
+ else
80
+ # Log to file by default
81
+ @logger = Logger.new("/tmp/spaceship.log")
82
+ end
83
+ @logger.formatter = proc do |severity, datetime, progname, msg|
84
+ string = "[#{datetime.strftime('%H:%M:%S')}]: #{msg}\n"
85
+ end
86
+ end
87
+
88
+ @logger
89
+ end
90
+
68
91
  # Automatic paging
69
92
 
70
93
  def page_size
@@ -350,13 +373,33 @@ module Spaceship
350
373
  end
351
374
  headers.merge!({'User-Agent' => 'spaceship'})
352
375
 
376
+ # Before encoding the parameters, log them
377
+ log_request(method, url_or_path, params)
378
+
353
379
  # form-encode the params only if there are params, and the block is not supplied.
354
380
  # this is so that certain requests can be made using the block for more control
355
381
  if method == :post && params && !block_given?
356
382
  params, headers = encode_params(params, headers)
357
383
  end
358
384
 
359
- send_request(method, url_or_path, params, headers, &block)
385
+ response = send_request(method, url_or_path, params, headers, &block)
386
+
387
+ log_response(method, url_or_path, response)
388
+
389
+ return response
390
+ end
391
+
392
+ def log_request(method, url, params)
393
+ params_to_log = Hash(params).dup # to also work with nil
394
+ params_to_log.delete(:accountPassword)
395
+ params_to_log = params_to_log.collect do |key, value|
396
+ "{#{key}: #{value}}"
397
+ end
398
+ logger.info("#{method.upcase}: #{url} #{params_to_log.join(', ')}")
399
+ end
400
+
401
+ def log_response(method, url, response)
402
+ logger.debug("#{method.upcase}: #{url}: #{response.body}")
360
403
  end
361
404
 
362
405
  # Actually sends the request to the remote server
@@ -42,8 +42,9 @@ module Spaceship
42
42
  if team_id.length > 0
43
43
  # User provided a value, let's see if it's valid
44
44
  teams.each_with_index do |team, i|
45
- return team_id if (team['teamId'].strip == team_id)
46
- return team_id if (team['currentTeamMember']['teamMemberId'].to_s.strip == team_id)
45
+ # There are 2 different values - one from the login page one from the Dev Team Page
46
+ return team['teamId'] if (team['teamId'].strip == team_id)
47
+ return team['teamId'] if (team['currentTeamMember']['teamMemberId'].to_s.strip == team_id)
47
48
  end
48
49
  puts "Couldn't find team with ID '#{team_id}'"
49
50
  end
@@ -1,3 +1,3 @@
1
1
  module Spaceship
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Natchev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-28 00:00:00.000000000 Z
12
+ date: 2015-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: credentials_manager