blueprint-api-rails 0.2.1 → 0.2.2

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: 0712641c936532f8bd09734df458db6d7662de83
4
- data.tar.gz: 108907594ff4ee043be3ee9d2c1744aa635df9c8
3
+ metadata.gz: fd69fecfafc263457f71226574e988cbf5c046f9
4
+ data.tar.gz: c2396ddb00cf85ba8eb12c7a91c7e4d10697c8a6
5
5
  SHA512:
6
- metadata.gz: 1270c614358c61e1e0eb0a7666fab7d09b9b7b975b545ffbbad8e3d78984f1a55eec2f2c09d32fb03563f82889159592b61e2e9815b2d94e0fcb8f6db2607f29
7
- data.tar.gz: a351791069d1f37094aac2a5563f11bd7819eeeccbcd0da6ce69bf3a099ea52b2e2ebbcff1cc09ca5a4e152a2d2ca769d22715f58f145f7c6d5ea3839421a07d
6
+ metadata.gz: ffa146bee921db725fae60b231320757e1ad90dc16d444ad567478261c85b61b8b4f5936ac64d7bbb1bfe67ea0413138c391432e4c9228f1d800840c9b213fa7
7
+ data.tar.gz: e380daf5929d7d198f583f08a2a75fc21c5764b05606d7ef178a3e50a422ee92d159eb8df6ff677853ac35638edb8809a1e3e90bfe611b03e5b4311d714bce88
@@ -1,7 +1,7 @@
1
1
  module Blueprint
2
2
  module Api
3
3
  module Rails
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
6
6
  end
7
7
  end
@@ -14,7 +14,9 @@ module Blueprint
14
14
 
15
15
  MESSAGE = 'message'
16
16
  CLASSIFIER_NEW = 'classifier-new'
17
- DESCRIBE = 'describe'
17
+
18
+ DESCRIBE_ELEMENT = 'describe-element'
19
+ DESCRIBE_CONCEPT = 'describe-concept'
18
20
 
19
21
  # allow users to set the API key
20
22
  def self.set_api_key api_key
@@ -102,7 +104,8 @@ module Blueprint
102
104
 
103
105
  # send the controllers to Blueprint
104
106
  controllers.each { |c|
105
- self.log nil, nil, nil, c
107
+ self.element(c) # register the element
108
+ # self.log nil, nil, nil, c
106
109
  }
107
110
 
108
111
  # now scan for models
@@ -113,26 +116,28 @@ module Blueprint
113
116
  p "Found #{models.length} models - sending to Blueprint"
114
117
 
115
118
  models.each { |m|
116
- self.log nil, nil, m
119
+ self.concept(m) # register the concept
120
+ # self.log nil, nil, m
117
121
  }
118
122
 
119
123
  p 'Scan complete'
120
124
  end
121
125
 
126
+ def element(name)
127
+ StructuralElementDesignContext.new(@api_key, @structure_id, name)
128
+ end
129
+
130
+ def concept(name)
131
+ ConceptDesignContext.new(@api_key, @structure_id, name)
132
+ end
133
+
122
134
  # creates a design context between source and target
123
135
  def link(source, target)
124
136
  LinkDesignContext.new(@api_key, @structure_id, source, target)
125
137
  end
126
138
 
127
- # applies a description to the (structural or conceptual) element
128
- def describe(element, description = nil, stereotype = nil)
129
- self.send DESCRIBE,
130
- {
131
- :element => element,
132
- :description => description,
133
- :stereotype => stereotype
134
- }
135
- nil
139
+ def begin(name)
140
+ ActivityDesignContext.new(@api_key, @structure_id, name)
136
141
  end
137
142
 
138
143
  # creates a new message classifier
@@ -146,10 +151,6 @@ module Blueprint
146
151
  nil
147
152
  end
148
153
 
149
- def begin(name)
150
- ActivityDesignContext.new(@api_key, @structure_id, name)
151
- end
152
-
153
154
  # logs a message between two nodes in the structure
154
155
  def log(message = { }, extras = { }, type = nil, source = nil, target = nil)
155
156
  properties = Hash.new.tap do |h|
@@ -175,6 +176,74 @@ module Blueprint
175
176
 
176
177
  end
177
178
 
179
+ class StructuralElementDesignContext < DesignContext
180
+
181
+ def initialize(api_key, structure_id, name)
182
+ @api_key = api_key
183
+ @structure_id = structure_id
184
+ @instance_id = SecureRandom.uuid
185
+ @name = name
186
+
187
+ # initialise faraday
188
+ @conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
189
+ # faraday.response :logger # log requests to STDOUT
190
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
191
+ end
192
+
193
+ # we register the structural element immediately (so that it appears on the structural even though it has no description / messages)
194
+ self.send DESCRIBE_ELEMENT,
195
+ {
196
+ :name => @name
197
+ }
198
+ end
199
+
200
+ # applies a description to the (structural) element
201
+ def describe(description = nil, stereotype = nil)
202
+ self.send DESCRIBE_ELEMENT,
203
+ {
204
+ :name => @name,
205
+ :description => description,
206
+ :stereotype => stereotype
207
+ }
208
+ nil
209
+ end
210
+
211
+ end
212
+
213
+ class ConceptDesignContext < DesignContext
214
+
215
+ def initialize(api_key, structure_id, name)
216
+ @api_key = api_key
217
+ @structure_id = structure_id
218
+ @instance_id = SecureRandom.uuid
219
+ @name = name
220
+
221
+ # initialise faraday
222
+ @conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
223
+ # faraday.response :logger # log requests to STDOUT
224
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
225
+ end
226
+
227
+ # we register the concept immediately (so that it appears on the structural even though it has no description / messages)
228
+ self.send DESCRIBE_CONCEPT,
229
+ {
230
+ :name => @name
231
+ }
232
+ end
233
+
234
+ # applies a description to the (conceptual) element
235
+ def describe(description = nil, stereotype = nil)
236
+ self.send DESCRIBE_CONCEPT,
237
+ {
238
+ :name => @name,
239
+ :description => description,
240
+ :stereotype => stereotype
241
+ }
242
+ nil
243
+ end
244
+
245
+ end
246
+
178
247
  ##
179
248
  # Design context for a group of messages (steps)
180
249
  ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprint-api-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjii