ey_services_api 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,16 @@ EY::ServicesAPI.connection.register_service(
20
20
  :vars => ["MY_SERVICE_API_KEY"] })
21
21
  ```
22
22
 
23
+ # Using this gem in your project
24
+
25
+ This codebase really contains 2 gems:
26
+
27
+ * ey_services_api is the Gem for communicating with services.engineyard.com. Include this in your Gemfile.
28
+ * ey_services_fake is a Gem for helping you to write tests with a working "Fake" in place of talking directly to services.engineyard.com. Include this in your Gemfile inside the "test" group.
29
+
30
+ For examples of using the gem in a sinatra app, and in tests see: https://github.com/engineyard/chronatog
31
+
32
+
23
33
  ## To run the tests
24
34
 
25
35
  To run specs mocked:
@@ -36,11 +46,11 @@ To run against tresfiestas codebase: (internal only)
36
46
 
37
47
  ## Releasing
38
48
 
39
- $ rvm use 1.8.7
40
- $ gem install gem-release
41
- $ gem bump
42
- $ gem release
43
- $ git push
49
+ $ rvm use 1.8.7
50
+ $ gem install gem-release
51
+ $ gem bump
52
+ $ gem release
53
+ $ git push
44
54
 
45
55
  This should bump the versions of both ey_services_api and ey_services_fake. Push both to rubygems, and then push your version bump commits to github.
46
56
 
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency "sinatra"
22
22
  s.add_dependency "cubbyhole", ">= 0.2.0"
23
+ s.add_dependency "request_visualizer"
23
24
  end
@@ -21,6 +21,43 @@ module EyServicesFake
21
21
  new(actors)
22
22
  end
23
23
 
24
+ def app_for(actor_name)
25
+ this = self
26
+ @apps ||= {}
27
+ @apps[actor_name] ||= Rack::Builder.new do
28
+ this.actors.each do |k, actor|
29
+ if actor.respond_to?(:extra_middlewares)
30
+ self.instance_eval(&actor.extra_middlewares)
31
+ end
32
+ end
33
+ if ENV["REQUEST_DEBUG"]
34
+ require 'request_visualizer'
35
+ use RequestVisualizer do |str|
36
+ found = str
37
+ this.actors.each do |k, actor|
38
+ if str.match(actor.base_url)
39
+ found = k.to_s
40
+ end
41
+ end
42
+ found
43
+ end
44
+ end
45
+ run this.actors[actor_name].app
46
+ end
47
+ end
48
+
49
+ def app
50
+ this = self
51
+ @app ||= Rack::Builder.new do
52
+ this.actors.each do |k, actor|
53
+ map "#{actor.base_url}/" do
54
+ run this.app_for(k)
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ attr_reader :actors
24
61
  def initialize(actors)
25
62
  @actors = actors
26
63
  end
@@ -38,8 +75,8 @@ module EyServicesFake
38
75
  def awsm
39
76
  awsm_hash = actor(:tresfiestas).find_awsm
40
77
  unless awsm_hash
41
- awsm_hash = actor(:tresfiestas).create_awsm(actor(:awsm).base_url, actor(:awsm).app)
42
- actor(:awsm).setup(awsm_hash[:auth_id], awsm_hash[:auth_key], actor(:tresfiestas).base_url, actor(:tresfiestas).app)
78
+ awsm_hash = actor(:tresfiestas).create_awsm(actor(:awsm).base_url, app_for(:awsm))
79
+ actor(:awsm).setup(awsm_hash[:auth_id], awsm_hash[:auth_key], actor(:tresfiestas).base_url, app_for(:tresfiestas))
43
80
  end
44
81
  awsm_hash
45
82
  end
@@ -47,13 +84,13 @@ module EyServicesFake
47
84
  def partner
48
85
  partner_hash = actor(:tresfiestas).find_partner(sso_user)
49
86
  unless partner_hash
50
- partner_hash = actor(:tresfiestas).create_partner(sso_user, actor(:service_provider).base_url, actor(:service_provider).app)
87
+ partner_hash = actor(:tresfiestas).create_partner(sso_user, actor(:service_provider).base_url, app_for(:service_provider))
51
88
  @actors.values.each do |actor|
52
89
  if actor.respond_to?(:service_provider_setup)
53
- actor.service_provider_setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:service_provider).base_url, actor(:service_provider).app)
90
+ actor.service_provider_setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:service_provider).base_url, app_for(:service_provider))
54
91
  end
55
92
  end
56
- actor(:service_provider).setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:tresfiestas).base_url, actor(:tresfiestas).app)
93
+ actor(:service_provider).setup(partner_hash[:auth_id], partner_hash[:auth_key], actor(:tresfiestas).base_url, app_for(:tresfiestas))
57
94
  end
58
95
  partner_hash
59
96
  end
@@ -12,6 +12,10 @@ module EyServicesFake
12
12
  {}.to_json
13
13
  end
14
14
 
15
+ get '/dashboard' do
16
+ "Hello this is fake AWSM dashboard"
17
+ end
18
+
15
19
  end
16
20
 
17
21
  def app
@@ -1,3 +1,3 @@
1
1
  module EyServicesFake
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -26,6 +26,7 @@ module EY
26
26
 
27
27
  def self.enable_mock!(service_provider, tresfiestas = nil, awsm = nil)
28
28
  unless @mock_backend
29
+ #TODO: rescue load error and log the need to include ey_services_fake gem
29
30
  require "ey_services_fake/mock_backend"
30
31
  @mock_backend = EyServicesFake::MockBackend.setup!(
31
32
  :awsm => awsm,
@@ -1,3 +1,4 @@
1
+ #TODO: list services should populate the URL of this object
1
2
  module EY
2
3
  module ServicesAPI
3
4
  class Service < APIStruct.new(:name, :label, :description, :home_url, :service_accounts_url, :terms_and_conditions_url, :vars)
@@ -1,5 +1,5 @@
1
1
  module EY
2
2
  module ServicesAPI
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_services_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 5
10
- version: 0.3.5
9
+ - 6
10
+ version: 0.3.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob & Thorben & David & mkb & Josh & Others
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-02 00:00:00 Z
18
+ date: 2012-03-16 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec