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 +4 -4
- data/lib/spaceship/base.rb +5 -6
- data/lib/spaceship/client.rb +44 -1
- data/lib/spaceship/ui/select_team.rb +3 -2
- data/lib/spaceship/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fafd78ad44e1ebeaf7fe1ee2342bfddb3d6155b
|
4
|
+
data.tar.gz: a33cf9b21faab673c3d30f3b41d768d9f7731ab6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa86fd5d437df47047a977313093b315c9e297b758e1f6a8d729735c5eee9e4d11c6a3cb77695f4804c60ba485b1d72d0459006e429ece534be8a39578da998
|
7
|
+
data.tar.gz: 7bf6d93ef0e595048b141bb8f6351c66b4e104d15f450a9617d35c8d315a2d85b7ae90ddc46d7ffe4cc0b3d891e8e747fff9d03ea99bb37a62de79fe72b9e54b
|
data/lib/spaceship/base.rb
CHANGED
@@ -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
|
-
|
56
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
58
|
+
else
|
59
|
+
super
|
60
|
+
end
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
data/lib/spaceship/client.rb
CHANGED
@@ -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
|
-
|
46
|
-
return
|
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
|
data/lib/spaceship/version.rb
CHANGED
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
|
+
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-
|
12
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: credentials_manager
|