spaceship 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02178127118d73630e027800cd0c2c759145444c
4
- data.tar.gz: d74fd79faf660145dceacfe275b59db20f24067d
3
+ metadata.gz: c2eeb8fbd4efa37ca93d8d46cd37f89581a00b08
4
+ data.tar.gz: 40a38a219fb822a734860cf834b522288e9eb975
5
5
  SHA512:
6
- metadata.gz: 53c9952a624da716a1777b4ec5cff8d4a80c166bf8f2e710f956a231adfc77b2f254025da34473c3fd48a4ffced5ab821412e20e6417be100c3970b28c51c9e1
7
- data.tar.gz: 884cc41a088ed45f6e257bd5f9355685cd6c95c1962272d0595ce844047b4dc46e168db0df0b5c05180daf538242ff21e8daeac132155b31d3daf66020c47f94
6
+ metadata.gz: 3143acb445f65780d6188d9281bf2fc68ec1e3c831f486c27152a4129eebcbc3c39bbcf7141e6c2db0730fb9b07143e38db895c3767b2fce9fe7160e8332b9f4
7
+ data.tar.gz: a7a4738fa19e112b008119517423e14e933171e018c73e7e00064b4f2747def35ec6089b6a00f39a2134976bd26325b985779ecdb12f04f5fd7b892ff35b021b
data/README.md CHANGED
@@ -23,10 +23,10 @@
23
23
  -------
24
24
 
25
25
  [![Twitter: @KauseFx](https://img.shields.io/badge/contact-@KrauseFx-blue.svg?style=flat)](https://twitter.com/KrauseFx)
26
- [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/KrauseFx/spaceship/blob/master/LICENSE)
27
- [![Coverage Status](https://coveralls.io/repos/KrauseFx/spaceship/badge.svg?branch=master&t=ldL8gg)](https://coveralls.io/r/KrauseFx/spaceship?branch=master)
26
+ [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/fastlane/spaceship/blob/master/LICENSE)
27
+ [![Coverage Status](https://coveralls.io/repos/fastlane/spaceship/badge.svg?branch=master&t=ldL8gg)](https://coveralls.io/r/fastlane/spaceship?branch=master)
28
28
  [![Gem](https://img.shields.io/gem/v/spaceship.svg?style=flat)](http://rubygems.org/gems/spaceship)
29
- [![Codeship Status for KrauseFx/spaceship](https://img.shields.io/codeship/96bb1040-c2b6-0132-4c5b-22f8b41c2618/master.svg)](https://codeship.com/projects/73801)
29
+ [![Build Status](https://img.shields.io/travis/fastlane/spaceship/master.svg?style=flat)](https://travis-ci.org/fastlane/spaceship)
30
30
 
31
31
 
32
32
  Get in contact with the developers on Twitter: [@snatchev](https://twitter.com/snatchev/) and [@KrauseFx](https://twitter.com/KrauseFx)
@@ -1,20 +1,50 @@
1
1
  module Spaceship
2
+ ##
3
+ # Spaceship::Base is the superclass for models in Apple Developer Portal.
4
+ # It's mainly responsible for mapping responses to objects.
5
+ #
6
+ # A class-level attribute `client` is used to maintain the which spaceship we
7
+ # are using to talk to ADP.
8
+ #
9
+ # Example of creating a new ADP model:
10
+ #
11
+ # class Widget < Spaceship::Base
12
+ # attr_accessor :id, :name, :foo_bar, :wiz_baz
13
+ # attr_mapping({
14
+ # 'name' => :name,
15
+ # 'fooBar' => :foo_bar,
16
+ # 'wizBaz' => :wiz_baz
17
+ # })
18
+ # end
19
+ #
20
+ # When you want to instantiate a model pass in the parsed response: `Widget.new(widget_json)`
2
21
  class Base
3
22
  class << self
4
23
  attr_accessor :client
5
24
 
25
+ ##
26
+ # The client used to make requests.
27
+ # @return (Spaceship::Client) Defaults to the singleton `Spaceship.client`
6
28
  def client
7
29
  @client || Spaceship.client
8
30
  end
9
31
 
10
- #set client and return self for chaining
32
+ ##
33
+ # Sets client and returns self for chaining.
34
+ # @return (Spaceship::Base)
11
35
  def set_client(client)
12
36
  self.client = client
13
37
  self
14
38
  end
15
39
 
16
40
  ##
17
- # bang method since it changes the parameter in-place
41
+ # Remaps the attributes passed into the initializer to the model
42
+ # attributes using the map defined by `attr_map`.
43
+ #
44
+ # This method consumes the input parameter meaning attributes that were
45
+ # remapped are deleted.
46
+ #
47
+ # @return (Hash) the attribute mapping used by `remap_keys!`
18
48
  def remap_keys!(attrs)
19
49
  return if attr_mapping.nil?
20
50
 
@@ -23,6 +53,20 @@ module Spaceship
23
53
  end
24
54
  end
25
55
 
56
+ ##
57
+ # Defines the attribute mapping between the response from Apple and our model objects.
58
+ # Keys are to match keys in the response and the values are to match attributes on the model.
59
+ #
60
+ # Example of using `attr_mapping`
61
+ #
62
+ # class Widget < Spaceship::Base
63
+ # attr_accessor :id, :name, :foo_bar, :wiz_baz
64
+ # attr_mapping({
65
+ # 'name' => :name,
66
+ # 'fooBar' => :foo_bar,
67
+ # 'wizBaz' => :wiz_baz
68
+ # })
69
+ # end
26
70
  def attr_mapping(attr_map = nil)
27
71
  if attr_map
28
72
  @attr_mapping = attr_map
@@ -61,6 +105,11 @@ module Spaceship
61
105
  end
62
106
  end
63
107
 
108
+ ##
109
+ # The initialize method accepts a parsed response from Apple and sets all
110
+ # attributes that are defined by `attr_mapping`
111
+ #
112
+ # Do not override `initialize` in your own models.
64
113
  def initialize(attrs = {})
65
114
  self.class.remap_keys!(attrs)
66
115
  attrs.each do |key, val|
@@ -69,6 +118,8 @@ module Spaceship
69
118
  @client = self.class.client
70
119
  end
71
120
 
121
+ ##
122
+ # @return (Spaceship::Client) The current spaceship client used by the model to make requests.
72
123
  def client
73
124
  @client
74
125
  end
@@ -207,6 +207,19 @@ module Spaceship
207
207
  @current_team_id = team_id
208
208
  end
209
209
 
210
+ # @return (Hash) Fetches all information of the currently used team
211
+ def team_information
212
+ teams.find do |t|
213
+ t['teamId'] == team_id
214
+ end
215
+ end
216
+
217
+ # Is the current session from an Enterprise In House account?
218
+ def in_house?
219
+ return @in_house unless @in_house.nil?
220
+ @in_house = (team_information['type'] == 'In-House')
221
+ end
222
+
210
223
  #####################################################
211
224
  # @!group Apps
212
225
  #####################################################
@@ -1,3 +1,3 @@
1
1
  module Spaceship
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
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.7
4
+ version: 0.0.8
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-06-09 00:00:00.000000000 Z
12
+ date: 2015-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: credentials_manager