restpack-core-client 0.1.13 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,13 +27,22 @@ module RestPack
27
27
 
28
28
  raise "host is not configured: #{host}" if result.empty?
29
29
 
30
- p "result: #{result}"
31
- p "found domains: #{result[:domains]}"
32
- p "first domain: #{result[:domains].first}"
33
-
34
30
  result[:domains].first
35
31
  end
36
32
 
33
+ def root_configurations
34
+ p "API.root_configurations(#{id})"
35
+ json = RestClient.get("http://:#{@access_key}@#{@domain}/api/v1/configurations/root.json")
36
+ data = Yajl::Parser.parse(json, :symbolize_keys => true)
37
+
38
+ configurations = []
39
+ data[:configurations].each do |configuration_data|
40
+ p "GJ: CONFIG: #{configuration_data}"
41
+ configurations << Configuration.new(configuration_data)
42
+ end
43
+ configuration
44
+ end
45
+
37
46
  def hydrate_channel(channel_response)
38
47
  channel = Channel.new(channel_response)
39
48
 
@@ -6,6 +6,7 @@ module RestPack
6
6
  @api = api
7
7
  @channel_ids = {}
8
8
  @channels = {}
9
+ @configurations = api.root_configurations
9
10
  end
10
11
 
11
12
  def self.create(domain, access_key)
@@ -14,14 +15,11 @@ module RestPack
14
15
  end
15
16
 
16
17
  def get_channel(host)
17
- p "get_channel(#{host})"
18
18
  channel_id = get_channel_id(host)
19
- p "channel_id = #{channel_id}"
20
19
  @channels[channel_id] ||= @api.get_channel(channel_id)
21
20
  end
22
21
 
23
22
  def get_channel_id(host)
24
- p "get_channel_id(#{host})"
25
23
  @channel_ids[host] ||= @api.get_domain(host)[:channel_id]
26
24
  end
27
25
 
@@ -16,16 +16,16 @@ module RestPack::Core::Client
16
16
  def get_configuration_by_key(key)
17
17
  @configurations.find { |c| c.key == key.to_s }
18
18
  end
19
-
19
+
20
20
  def known_domain_names
21
- configuration = get_configuration_by_key(:domains)
22
- configuration.nil? ? {} : configuration.value
21
+ configuration = get_configuration_by_key(:domains)
22
+ configuration.nil? ? {} : configuration.value
23
23
  end
24
-
24
+
25
25
  def home_domain #TODO: GJ: dynamic
26
26
  known_domain_names[:home]
27
27
  end
28
-
28
+
29
29
  def auth_domain
30
30
  known_domain_names[:auth]
31
31
  end
@@ -1,23 +1,22 @@
1
1
  module RestPack::Core::Client
2
2
  class Configuration
3
3
  attr_accessor :id, :key, :value, :channel, :application, :domain
4
-
5
- def initialize(data, channel)
4
+
5
+ def initialize(data, channel = nil)
6
6
  @id = data[:id]
7
7
  @key = data[:key]
8
8
  @value = data[:value]
9
+
10
+ if channel
11
+ @channel = channel
12
+ @application = channel.get_application(data[:application_id])
13
+ @domain = channel.get_domain(data[:domain_id])
9
14
 
10
- @channel = channel
11
- @application = channel.get_application(data[:application_id])
12
- @domain = channel.get_domain(data[:domain_id])
13
-
14
- @channel.configurations << self
15
- @application.configurations << self if @application
16
- @domain.configurations << self if @domain
17
- end
18
-
19
- def get_configuration_by_key(key)
20
- @configurations.find { |c| c.key == key.to_s }
15
+ @channel.configurations << self
16
+ @application.configurations << self if @application
17
+ @domain.configurations << self if @domain
18
+ end
21
19
  end
20
+
22
21
  end
23
22
  end
@@ -1,7 +1,7 @@
1
1
  module RestPack
2
2
  module Core
3
3
  module Client
4
- VERSION = "0.1.13"
4
+ VERSION = "0.1.16"
5
5
  end
6
6
  end
7
7
  end
@@ -20,6 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'rest-client', '~> 1.6.7'
21
21
  gem.add_dependency 'yajl-ruby', '~> 1.1.0'
22
22
 
23
- gem.add_development_dependency 'rspec', '~> 2.12.0'
23
+ gem.add_development_dependency 'rspec', '~> 2.12.1'
24
24
  gem.add_development_dependency 'rake', '~> 10.0.3'
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack-core-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 2.12.0
53
+ version: 2.12.1
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 2.12.0
61
+ version: 2.12.1
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rake
64
64
  requirement: !ruby/object:Gem::Requirement