textualize 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/textualize/tasks/helpers/route_hash_creator.rb +11 -8
- data/lib/textualize/tasks/helpers/route_hashes.rb +6 -3
- data/lib/textualize/tasks/http_backend.rb +30 -31
- data/lib/textualize/tasks/request_specs.rb +18 -13
- data/lib/textualize/tasks/server.rb +13 -11
- data/lib/textualize/templates/new/circle.yml +3 -0
- data/lib/textualize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40b4378d74aad501c4231d65040a3891d7e69020
|
4
|
+
data.tar.gz: c4a2ed367f25aa1ec7a559c00d52316dda47a295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a00aea0eeb0e2cf4f398e1d0dac0481d08f38c819326b2ea0606d4aaf4f40ce60cb7d27aa06a4e52cbf5dc8d2e2fe828df19f42aedda8bda023bef58bd264a3
|
7
|
+
data.tar.gz: 8cc879704f2a2841682b6963fa4cb5c80545aa0e3a53088f3d5dd2b0a7db6829fe80965fb438aa4ad9dcef3c98fe96726ac4ce89a1e36e02990a35a8a4126b0e
|
@@ -26,6 +26,12 @@ module Textualize
|
|
26
26
|
method_hash = Hashie::Mash.new
|
27
27
|
|
28
28
|
method_hash.verb = method.fetch('method')
|
29
|
+
method_hash.url = base_path + relative_path
|
30
|
+
method_hash.relative_path = relative_path
|
31
|
+
method_hash.type = resource.fetch('type').keys.first
|
32
|
+
method_hash.name = relative_path.split('/').last.gsub(
|
33
|
+
/{|}|_id/, ''
|
34
|
+
)
|
29
35
|
|
30
36
|
if method_hash.verb == 'post'
|
31
37
|
method_hash.schema = method.fetch('body').
|
@@ -33,14 +39,11 @@ module Textualize
|
|
33
39
|
fetch('schema')
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
method_hash.name = relative_path.split('/').last.gsub(
|
42
|
-
/{|}|_id/, ''
|
43
|
-
)
|
42
|
+
if method.has_key?('securedBy')
|
43
|
+
method_hash.secured_by = method.fetch('securedBy').first.
|
44
|
+
fetch('oauth_2_0').fetch('scopes')
|
45
|
+
end
|
46
|
+
|
44
47
|
method_hash.merge!(transformed_response(method))
|
45
48
|
end
|
46
49
|
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module Textualize
|
2
2
|
class RouteHashes
|
3
3
|
class << self
|
4
|
-
def
|
4
|
+
def filenames_and_hashes
|
5
5
|
fail 'run gulp first' if raml_json_files.empty?
|
6
6
|
|
7
|
-
raml_json_files.
|
7
|
+
raml_json_files.map do |json_file|
|
8
8
|
json = JSON.parse(File.read(json_file))
|
9
9
|
|
10
|
-
|
10
|
+
[
|
11
|
+
File.basename(json_file, '.*'),
|
12
|
+
RouteHashCreator.new(json).create_route_hashes
|
13
|
+
]
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
@@ -8,32 +8,34 @@ module Textualize
|
|
8
8
|
'Creates an angular 1.x module based off ngMockE2E that stubs a backend'
|
9
9
|
)
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def create_backend_angular_modules
|
12
|
+
RouteHashes.filenames_and_hashes.each do |(filename, hashes)|
|
13
|
+
puts hashes
|
14
|
+
puts filename
|
13
15
|
|
14
|
-
|
15
|
-
end
|
16
|
+
FileUtils.mkdir_p("dist/#{filename}/angular/backend")
|
16
17
|
|
17
|
-
|
18
|
+
File.open(dist_file(filename), 'w') do |file|
|
19
|
+
file.write(
|
20
|
+
File.read("#{template_directory}/module.js")
|
21
|
+
)
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
hashes.each do |route_hash|
|
25
|
+
modified_hash = replace_sample_id_with_1(route_hash)
|
26
|
+
File.open(dist_file(filename), 'a') do |file|
|
27
|
+
file.write(
|
28
|
+
http_backend_template(modified_hash)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
27
|
-
|
28
|
-
FileUtils.mkdir_p('dist/angular/backend')
|
29
|
-
|
30
|
-
'dist/angular/backend/fake_http_backend.min.js'
|
31
|
-
end
|
35
|
+
private
|
32
36
|
|
33
|
-
def
|
34
|
-
|
35
|
-
File.read("#{template_directory}/#{route_hash.verb}.js.erb")
|
36
|
-
).result(route_hash.instance_eval { binding })
|
37
|
+
def dist_file(filename)
|
38
|
+
"dist/#{filename}/angular/backend/fake_http_backend.min.js"
|
37
39
|
end
|
38
40
|
|
39
41
|
def template_directory
|
@@ -41,19 +43,16 @@ module Textualize
|
|
41
43
|
File.expand_path(path)
|
42
44
|
end
|
43
45
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
modified_hash.url.gsub!(/{.*}/, '1')
|
46
|
+
def replace_sample_id_with_1(route_hash)
|
47
|
+
route_hash.relative_path.gsub!(/{.*}/, '1')
|
48
|
+
route_hash.url.gsub!(/{.*}/, '1')
|
49
|
+
return route_hash
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
52
|
+
def http_backend_template(route_hash)
|
53
|
+
ERB.new(
|
54
|
+
File.read("#{template_directory}/#{route_hash.verb}.js.erb")
|
55
|
+
).result(route_hash.instance_eval { binding })
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end
|
@@ -4,33 +4,31 @@ module Textualize
|
|
4
4
|
class RequestSpecs < Thor::Group
|
5
5
|
include Thor::Actions
|
6
6
|
|
7
|
-
RS_DIRECTORY = 'dist/spec/requests/'
|
8
|
-
|
9
7
|
desc(
|
10
8
|
'Creates request specs for an api using airborne, a ruby gem'
|
11
9
|
)
|
12
10
|
|
13
11
|
def create_airborne_specs
|
14
|
-
FileUtils.mkdir_p(RS_DIRECTORY)
|
15
|
-
|
16
12
|
add_airborne_specs
|
17
13
|
end
|
18
14
|
|
19
15
|
private
|
20
16
|
|
21
17
|
def add_airborne_specs
|
22
|
-
RouteHashes.
|
18
|
+
RouteHashes.filenames_and_hashes.each do |(filename, hashes)|
|
19
|
+
request_directory = "dist/#{filename}/spec/requests/"
|
23
20
|
|
24
|
-
|
25
|
-
modified_hash = route_hash
|
21
|
+
FileUtils.mkdir_p(request_directory)
|
26
22
|
|
27
|
-
|
28
|
-
|
23
|
+
hashes.each do |route_hash|
|
24
|
+
modified_hash = replace_ids_with_interpolated_ruby(route_hash)
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
file
|
26
|
+
File.open(
|
27
|
+
"#{request_directory}#{route_hash.verb}_"\
|
28
|
+
"#{route_hash.name}_spec.rb", 'w'
|
29
|
+
) do |file|
|
30
|
+
file.write(request_spec_template(modified_hash))
|
31
|
+
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
@@ -51,5 +49,12 @@ module Textualize
|
|
51
49
|
def non_ro_type(route_hash)
|
52
50
|
route_hash.type.gsub(/-ro$/, '')
|
53
51
|
end
|
52
|
+
|
53
|
+
def replace_ids_with_interpolated_ruby(route_hash)
|
54
|
+
modified_hash = route_hash
|
55
|
+
modified_hash.relative_path.gsub!(/({|_id)/, '{' => '#{', '_id' => '.id')
|
56
|
+
modified_hash.url.gsub!(/({|_id)/, '{' => '#{', '_id' => '.id')
|
57
|
+
modified_hash
|
58
|
+
end
|
54
59
|
end
|
55
60
|
end
|
@@ -10,26 +10,28 @@ module Textualize
|
|
10
10
|
)
|
11
11
|
|
12
12
|
def create_method_files
|
13
|
-
RouteHashes.
|
14
|
-
|
15
|
-
next if route_hash.body.empty?
|
13
|
+
RouteHashes.filenames_and_hashes.each do |(filename, hashes)|
|
14
|
+
FileUtils.mkdir_p("dist/#{filename}/server")
|
16
15
|
|
17
|
-
|
16
|
+
hashes.each do |route_hash|
|
17
|
+
next unless route_hash.verb == 'get'
|
18
|
+
next if route_hash.body.empty?
|
18
19
|
|
19
|
-
|
20
|
+
route_directory = "#{dist_dir(filename)}#{route_hash.url}"
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
FileUtils.mkdir_p(route_directory)
|
23
|
+
|
24
|
+
File.open("#{route_directory}/#{route_hash.verb}.json", 'w') do |file|
|
25
|
+
file.write route_hash.body.to_json
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
private
|
28
32
|
|
29
|
-
def dist_dir
|
30
|
-
|
31
|
-
|
32
|
-
'dist/server'
|
33
|
+
def dist_dir(filename)
|
34
|
+
"dist/#{filename}/server"
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
data/lib/textualize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textualize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Q-Centrix Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|