converse 1.0.23 → 1.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +29 -7
  2. data/lib/converse/version.rb +1 -1
  3. metadata +4 -4
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Converse
2
2
 
3
- Converse is an architectural / design tool that facilitates dependency inversion, seperation of concerns and decoupling
3
+ Converse is an architectural / design tool that facilitates dependency inversion, separation of concerns and decoupling
4
4
  by providing a conversation-based API boundary.
5
5
 
6
6
  Brokers know how to talk the language of a provider, and converses with such a provider using Interactions.
7
7
  Interactions discuss topics using technology specific conversations. Brokers speak two languages: the application's and
8
8
  a provider's. A broker is taught how to speak a provider's language by defining a set of interactions, which
9
- use provider-specific conversations to communicate. Responses from providers are processed in the interactions.
9
+ use provider-specific conversations to communicate. Responses from providers are processed / translated in the
10
+ interactions. Formatting of responses and error handling are also processed in the interactions.
10
11
  Each interaction can interpret a response in a provider-specific way and translate the response into the
11
12
  application's domain language.
12
13
 
@@ -46,9 +47,9 @@ want to swap the RESTful provider out for a SQL provider, or some other provider
46
47
 
47
48
  The application specifies the API it wants to talk, and teaches a broker how to discuss transactions:
48
49
 
49
- class ApplicationApi < API
50
+ class ApplicationApi < Converse::API
50
51
  def get_transactions(client_id)
51
- substance = { 'client_id' => client_id }
52
+ substance = { :client_id => client_id }
52
53
  o = GetTransactions.new(@broker, substance)
53
54
  o.discuss
54
55
  end
@@ -57,8 +58,9 @@ The application specifies the API it wants to talk, and teaches a broker how to
57
58
  The GetTransactions interaction faces towards the provider, and uses a TransactionTranslator to turn JSON responses
58
59
  into a list of transactions that the application understands.
59
60
 
60
- class GetTransactions < ProviderInteraction
61
+ class GetTransactions < Converse::Interaction
61
62
  def initialize(broker, substance)
63
+ ensure_that(substance).includes [:client_id]
62
64
  ask_broker(broker).concerning("transactions").about("<client_id>/transactions.json").detailed_by(substance)
63
65
  end
64
66
 
@@ -80,7 +82,27 @@ Generically, the provider interaction knows how to say and ask the provider for
80
82
  end
81
83
  end
82
84
 
83
- The ProviderBroker is taught how to talk the provider's language by using an HTMLConversation:
85
+ The RESTInteraction class provides some additional interpretation of responses. Interactions can rely on the
86
+ RESTInteraction to call handle_error if "200 OK" is not received, and a formatting hook is provided:
87
+
88
+ class GetRevisions < Converse::RESTInteraction
89
+ def initialize(broker, substance)
90
+ ensure_that(substance).includes [:server]
91
+ ask_broker(broker).concerning("get_revision_list").about(substance)
92
+ end
93
+
94
+ def format_response(response_body)
95
+ RevisionFormatter::format_revisions_for_html(JSON.parse(response_body))
96
+ end
97
+
98
+ def handle_error!(response)
99
+ raise RuntimeError.new "#{response.code}, #{response.body}"
100
+ end
101
+ end
102
+
103
+ The ProviderBroker is taught how to talk the provider's language by using an HTMLConversation (or a technology specific
104
+ conversation, e.g. SQL, Redis, etc.). The broker provides the mapping of concerns, actions and detail (substance) to the
105
+ technology / domain specific format:
84
106
 
85
107
  class ProviderBroker < Broker
86
108
  attr_accessor :host
@@ -122,5 +144,5 @@ interaction with the provider:
122
144
 
123
145
  ## Contributing
124
146
 
125
- 1. Please send me feedback by email on this project and ideas around improving the architectural facilities
147
+ 1. Please send me feedback by email (ernst.van.graan@hetzner.co.za) on this project and ideas around improving the architectural facilities
126
148
  provided by this gem.
@@ -1,3 +1,3 @@
1
1
  module Converse
2
- VERSION = "1.0.23"
2
+ VERSION = "1.0.24"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: converse
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 23
10
- version: 1.0.23
9
+ - 24
10
+ version: 1.0.24
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ernst van Graan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-30 00:00:00 Z
18
+ date: 2012-10-31 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Converse provides Broker/Translator classes to facilitate communication across an API by means of conversations