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 +4 -4
- data/lib/blueprint/api/rails/version.rb +1 -1
- data/lib/blueprint/api/rails.rb +85 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd69fecfafc263457f71226574e988cbf5c046f9
|
4
|
+
data.tar.gz: c2396ddb00cf85ba8eb12c7a91c7e4d10697c8a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffa146bee921db725fae60b231320757e1ad90dc16d444ad567478261c85b61b8b4f5936ac64d7bbb1bfe67ea0413138c391432e4c9228f1d800840c9b213fa7
|
7
|
+
data.tar.gz: e380daf5929d7d198f583f08a2a75fc21c5764b05606d7ef178a3e50a422ee92d159eb8df6ff677853ac35638edb8809a1e3e90bfe611b03e5b4311d714bce88
|
data/lib/blueprint/api/rails.rb
CHANGED
@@ -14,7 +14,9 @@ module Blueprint
|
|
14
14
|
|
15
15
|
MESSAGE = 'message'
|
16
16
|
CLASSIFIER_NEW = 'classifier-new'
|
17
|
-
|
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.
|
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.
|
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
|
-
|
128
|
-
|
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
|
##
|