blueprint-api-rails 0.1.5 → 0.2.0
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 +46 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b0f56bd7d4e4ea721fed6a76878bd0588a27ae
|
4
|
+
data.tar.gz: 7962d53b3f5dbabd90fd40a4aedaf034f8579ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd38d01b74fad3df17ee1d45612242ca925a2352813cf866f14eae2fa1190a7879c97dfd6a52c8dc0f481d23cefdc83d60148dd5926849149a7367e07a0440a
|
7
|
+
data.tar.gz: 7311b41ee144e9476ad8a19e7cc3c7e1bfa393b4322a5ae9f900e0564d4562d843d3d72fc7b0644b37039a0949677b8e494fbdb10602586816babcbe0d3f1a7b
|
data/lib/blueprint/api/rails.rb
CHANGED
@@ -8,6 +8,7 @@ module Blueprint
|
|
8
8
|
|
9
9
|
# TODO deprecate all of the branch stuff
|
10
10
|
# TODO limit messages that are lists to a maximum of 10 elements
|
11
|
+
# TODO add support for getting the current user (so we can analysis log messages per user)
|
11
12
|
|
12
13
|
STRUCTURE_NEW = 'start'
|
13
14
|
|
@@ -20,8 +21,12 @@ module Blueprint
|
|
20
21
|
end
|
21
22
|
|
22
23
|
# call this to create a structure and get a design context
|
23
|
-
def self.start(structure_id, name)
|
24
|
-
StructureDesignContext.new(@api_key, structure_id).send STRUCTURE_NEW,
|
24
|
+
def self.start(structure_id, name, description = nil)
|
25
|
+
StructureDesignContext.new(@api_key, structure_id).send STRUCTURE_NEW,
|
26
|
+
{
|
27
|
+
:name => name,
|
28
|
+
:description => description
|
29
|
+
}
|
25
30
|
end
|
26
31
|
|
27
32
|
|
@@ -73,11 +78,45 @@ module Blueprint
|
|
73
78
|
|
74
79
|
# initialise faraday
|
75
80
|
@conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
|
76
|
-
faraday.response :logger # log requests to STDOUT
|
81
|
+
# faraday.response :logger # log requests to STDOUT
|
77
82
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
78
83
|
end
|
79
84
|
end
|
80
85
|
|
86
|
+
# performs an extract (that is, scans the code base for architectural elements)
|
87
|
+
# TODO this scan can be arbitrarily complex - we could scan for anything
|
88
|
+
# TODO add support of passing in custom scanners
|
89
|
+
def scan
|
90
|
+
|
91
|
+
p 'Scanning for controllers...'
|
92
|
+
|
93
|
+
# scan for all controllers (any file with the name *Controller)
|
94
|
+
controllers = Dir[Rails.root.join('app/controllers/*_controller.rb')].map { |path|
|
95
|
+
path.match(/(\w+_controller).rb/); $1.gsub!(/_/, ' ').titleize
|
96
|
+
}.reject { |clazz|
|
97
|
+
clazz.eql?('Application Controller') # ignore the ApplicationController superclass
|
98
|
+
}.compact
|
99
|
+
|
100
|
+
p "Found #{controllers.length} controllers - sending to Blueprint"
|
101
|
+
|
102
|
+
# send the controllers to Blueprint
|
103
|
+
controllers.each { |c|
|
104
|
+
self.log nil, nil, nil, c
|
105
|
+
}
|
106
|
+
|
107
|
+
# now scan for models
|
108
|
+
models = Dir[Rails.root.join('app/models/*.rb')].map { |path|
|
109
|
+
path.match(/(\w+).rb/); $1.titleize
|
110
|
+
}.compact
|
111
|
+
|
112
|
+
p "Found #{models.length} models - sending to Blueprint"
|
113
|
+
|
114
|
+
models.each { |m|
|
115
|
+
self.log nil, nil, m
|
116
|
+
}
|
117
|
+
|
118
|
+
p 'Scan complete'
|
119
|
+
end
|
81
120
|
|
82
121
|
# creates a design context between source and target
|
83
122
|
def link(source, target)
|
@@ -108,6 +147,7 @@ module Blueprint
|
|
108
147
|
|
109
148
|
payload = Hash.new.tap do |h|
|
110
149
|
h[:type] = type unless type.blank?
|
150
|
+
# h[:user] = current_user.id unless current_user.nil? || current_user.id.nil?
|
111
151
|
h[:payload] = {
|
112
152
|
:message => message,
|
113
153
|
:extras => extras
|
@@ -138,7 +178,7 @@ module Blueprint
|
|
138
178
|
|
139
179
|
# initialise faraday
|
140
180
|
@conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
|
141
|
-
faraday.response :logger # log requests to STDOUT
|
181
|
+
# faraday.response :logger # log requests to STDOUT
|
142
182
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
143
183
|
end
|
144
184
|
end
|
@@ -166,7 +206,7 @@ module Blueprint
|
|
166
206
|
|
167
207
|
# initialise faraday
|
168
208
|
@conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
|
169
|
-
faraday.response :logger # log requests to STDOUT
|
209
|
+
# faraday.response :logger # log requests to STDOUT
|
170
210
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
171
211
|
end
|
172
212
|
end
|
@@ -210,7 +250,7 @@ module Blueprint
|
|
210
250
|
|
211
251
|
# initialise faraday
|
212
252
|
@conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
|
213
|
-
faraday.response :logger # log requests to STDOUT
|
253
|
+
# faraday.response :logger # log requests to STDOUT
|
214
254
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
215
255
|
end
|
216
256
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprint-api-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,8 +95,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.2.2
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Rails client for the Anaxim Blueprint API
|
102
102
|
test_files: []
|
103
|
+
has_rdoc:
|