textualize 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +28 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +1 -0
- data/README.md +76 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/textualize +7 -0
- data/circle.yml +8 -0
- data/lib/textualize.rb +33 -0
- data/lib/textualize/tasks/helpers/route_hash_creator.rb +62 -0
- data/lib/textualize/tasks/helpers/route_hashes.rb +21 -0
- data/lib/textualize/tasks/helpers/transformers/two_hundred.rb +30 -0
- data/lib/textualize/tasks/helpers/transformers/two_hundred_four.rb +17 -0
- data/lib/textualize/tasks/http_backend.rb +59 -0
- data/lib/textualize/tasks/new.rb +44 -0
- data/lib/textualize/tasks/request_specs.rb +48 -0
- data/lib/textualize/tasks/server.rb +35 -0
- data/lib/textualize/templates/http_backend/delete.js.erb +10 -0
- data/lib/textualize/templates/http_backend/get.js.erb +10 -0
- data/lib/textualize/templates/http_backend/module.js +1 -0
- data/lib/textualize/templates/http_backend/patch.js.erb +10 -0
- data/lib/textualize/templates/http_backend/post.js.erb +10 -0
- data/lib/textualize/templates/new/.gitignore +3 -0
- data/lib/textualize/templates/new/.ruby-version +1 -0
- data/lib/textualize/templates/new/Gemfile +5 -0
- data/lib/textualize/templates/new/Gemfile.lock +28 -0
- data/lib/textualize/templates/new/Readme.md +10 -0
- data/lib/textualize/templates/new/apis/base.raml +26 -0
- data/lib/textualize/templates/new/apis/base/routes/items.yaml +8 -0
- data/lib/textualize/templates/new/apis/base/routes/orders.yaml +8 -0
- data/lib/textualize/templates/new/apis/base/samples/item.json +12 -0
- data/lib/textualize/templates/new/apis/base/samples/items.json +34 -0
- data/lib/textualize/templates/new/apis/base/samples/order.json +43 -0
- data/lib/textualize/templates/new/apis/base/samples/orders.json +70 -0
- data/lib/textualize/templates/new/apis/base/schemas/item.json +17 -0
- data/lib/textualize/templates/new/apis/base/schemas/order.json +25 -0
- data/lib/textualize/templates/new/apis/documentation/authentication.yaml +21 -0
- data/lib/textualize/templates/new/apis/documentation/http_statuses.md +26 -0
- data/lib/textualize/templates/new/apis/errors.yaml +6 -0
- data/lib/textualize/templates/new/apis/resourceTypes/collection-item-ro.yaml +20 -0
- data/lib/textualize/templates/new/apis/resourceTypes/collection-item.yaml +20 -0
- data/lib/textualize/templates/new/apis/resourceTypes/collection-ro.yaml +18 -0
- data/lib/textualize/templates/new/apis/resourceTypes/collection.yaml +18 -0
- data/lib/textualize/templates/new/apis/responses/200.yaml +3 -0
- data/lib/textualize/templates/new/apis/responses/204.yaml +1 -0
- data/lib/textualize/templates/new/apis/responses/400.yaml +8 -0
- data/lib/textualize/templates/new/apis/responses/401.yaml +4 -0
- data/lib/textualize/templates/new/apis/responses/403.yaml +4 -0
- data/lib/textualize/templates/new/apis/responses/404.yaml +4 -0
- data/lib/textualize/templates/new/apis/responses/422.yaml +8 -0
- data/lib/textualize/templates/new/apis/responses/500.yaml +4 -0
- data/lib/textualize/templates/new/gulpfile.js +93 -0
- data/lib/textualize/templates/new/package.json +38 -0
- data/lib/textualize/templates/new/server/api/v1/items/get.json +1 -0
- data/lib/textualize/templates/new/server/api/v1/items/{item_id}/get.json +1 -0
- data/lib/textualize/templates/new/server/api/v1/orders/get.json +1 -0
- data/lib/textualize/templates/new/server/api/v1/orders/{order_id}/get.json +1 -0
- data/lib/textualize/templates/request_specs/delete_collection-item.rb.erb +0 -0
- data/lib/textualize/templates/request_specs/get_collection-item.rb.erb +16 -0
- data/lib/textualize/templates/request_specs/get_collection.rb.erb +16 -0
- data/lib/textualize/templates/request_specs/patch_collection-item.rb.erb +0 -0
- data/lib/textualize/templates/request_specs/post_collection.rb.erb +13 -0
- data/lib/textualize/version.rb +3 -0
- data/sample_item.rb +43 -0
- data/textualize.gemspec +41 -0
- metadata +259 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Textualize
|
4
|
+
class RequestSpecs < Thor::Group
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
RS_DIRECTORY = 'dist/spec/requests/'
|
8
|
+
|
9
|
+
desc(
|
10
|
+
'Creates request specs for an api using airborne, a ruby gem'
|
11
|
+
)
|
12
|
+
|
13
|
+
def create_airborne_specs
|
14
|
+
FileUtils.mkdir_p(RS_DIRECTORY)
|
15
|
+
|
16
|
+
add_airborne_specs
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def add_airborne_specs
|
22
|
+
RouteHashes.hashes.each do |route_hash|
|
23
|
+
File.open(
|
24
|
+
"#{RS_DIRECTORY}#{route_hash.verb}_#{route_hash.name}_spec.rb", 'w'
|
25
|
+
) do |file|
|
26
|
+
file.write(request_spec_template(route_hash))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def request_spec_template(route_hash)
|
32
|
+
ERB.new(
|
33
|
+
File.read(
|
34
|
+
"#{template_directory}#{route_hash.verb}"\
|
35
|
+
"_#{non_ro_type(route_hash)}.rb.erb"
|
36
|
+
)
|
37
|
+
).result(route_hash.instance_eval { binding })
|
38
|
+
end
|
39
|
+
|
40
|
+
def template_directory
|
41
|
+
@_directory ||= __dir__.chomp('tasks') + 'templates/request_specs/'
|
42
|
+
end
|
43
|
+
|
44
|
+
def non_ro_type(route_hash)
|
45
|
+
route_hash.type.gsub(/-ro$/, '')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Textualize
|
4
|
+
class Server < Thor::Group
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc(
|
8
|
+
'Creates a server directory with json files corresponding to the '\
|
9
|
+
"'happy path' responses to a url and http-verb"
|
10
|
+
)
|
11
|
+
|
12
|
+
def create_method_files
|
13
|
+
RouteHashes.hashes.each do |route_hash|
|
14
|
+
next unless route_hash.verb == 'get'
|
15
|
+
next if route_hash.body.empty?
|
16
|
+
|
17
|
+
route_directory = "#{dist_dir}#{route_hash.url}"
|
18
|
+
|
19
|
+
FileUtils.mkdir_p(route_directory)
|
20
|
+
|
21
|
+
File.open("#{route_directory}/#{route_hash.verb}.json", 'w') do |file|
|
22
|
+
file.write route_hash.body.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def dist_dir
|
30
|
+
FileUtils.mkdir_p('dist/server')
|
31
|
+
|
32
|
+
'dist/server'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
angular.module('textualize_http_backend', ['ngMockE2E'])
|
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git@github.com:currica/textualize.git
|
3
|
+
revision: 5d6a9915dcd5c62e88d12b8b298b58b8ab22d1a9
|
4
|
+
branch: request_specs
|
5
|
+
specs:
|
6
|
+
textualize (0.1.0)
|
7
|
+
attr_extras (~> 4)
|
8
|
+
hashie (~> 3)
|
9
|
+
thor (~> 0)
|
10
|
+
uglifier (~> 2)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
attr_extras (4.4.0)
|
16
|
+
execjs (2.5.2)
|
17
|
+
hashie (3.4.1)
|
18
|
+
json (1.8.2)
|
19
|
+
thor (0.19.1)
|
20
|
+
uglifier (2.7.1)
|
21
|
+
execjs (>= 0.3.0)
|
22
|
+
json (>= 1.8.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
textualize!
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#%RAML 0.8
|
2
|
+
---
|
3
|
+
title: Menu API
|
4
|
+
version: v1
|
5
|
+
baseUri: https://app.my-awesome-restaurant.com/api/{version}
|
6
|
+
mediaType: application/json
|
7
|
+
|
8
|
+
documentation:
|
9
|
+
- title: HTTP Status Codes
|
10
|
+
content: !include ./documentation/http_statuses.md
|
11
|
+
|
12
|
+
securitySchemes:
|
13
|
+
- oauth_2_0: !include ./documentation/authentication.yaml
|
14
|
+
|
15
|
+
schemas:
|
16
|
+
- items: !include ./base/schemas/item.json
|
17
|
+
- orders: !include ./base/schemas/order.json
|
18
|
+
|
19
|
+
resourceTypes:
|
20
|
+
- !include ./resourceTypes/collection.yaml
|
21
|
+
- !include ./resourceTypes/collection-ro.yaml
|
22
|
+
- !include ./resourceTypes/collection-item.yaml
|
23
|
+
- !include ./resourceTypes/collection-item-ro.yaml
|
24
|
+
|
25
|
+
/items: !include ./base/routes/items.yaml
|
26
|
+
/orders: !include ./base/routes/orders.yaml
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": "1",
|
5
|
+
"type": "item",
|
6
|
+
"created_at": "1430407103",
|
7
|
+
"updated_at": "1430407180",
|
8
|
+
"name": "Hamburger",
|
9
|
+
"links": {
|
10
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/1"
|
11
|
+
}
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"id": "2",
|
15
|
+
"type": "item",
|
16
|
+
"created_at": "1430407103",
|
17
|
+
"updated_at": "1430407180",
|
18
|
+
"name": "Cheese burger",
|
19
|
+
"links": {
|
20
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/2"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"id": "3",
|
25
|
+
"type": "item",
|
26
|
+
"created_at": "1430407103",
|
27
|
+
"updated_at": "1430407180",
|
28
|
+
"name": "French Fries",
|
29
|
+
"links": {
|
30
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/3"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"id": "1",
|
4
|
+
"type": "order",
|
5
|
+
"created_at": "1430407203",
|
6
|
+
"updated_at": "1430407280",
|
7
|
+
"links": {
|
8
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/orders/1",
|
9
|
+
"items": {
|
10
|
+
"related": "https://app.my-awesome-restaurant.com/api/v1/orders/1/items",
|
11
|
+
"linkage": [
|
12
|
+
{ "type": "items", "id": "1" },
|
13
|
+
{ "type": "items", "id": "3" }
|
14
|
+
]
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"included": {
|
19
|
+
"items": {
|
20
|
+
"1": {
|
21
|
+
"id": 1,
|
22
|
+
"type": "item",
|
23
|
+
"created_at": "1430407103",
|
24
|
+
"updated_at": "1430407180",
|
25
|
+
"name": "Hamburger",
|
26
|
+
"links": {
|
27
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/1"
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"3": {
|
31
|
+
"id": 3,
|
32
|
+
"type": "item",
|
33
|
+
"created_at": "1430407103",
|
34
|
+
"updated_at": "1430407180",
|
35
|
+
"name": "French Fries",
|
36
|
+
"links": {
|
37
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/3"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": "1",
|
5
|
+
"type": "order",
|
6
|
+
"created_at": "1430407203",
|
7
|
+
"updated_at": "1430407280",
|
8
|
+
"links": {
|
9
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/orders/1",
|
10
|
+
"items": {
|
11
|
+
"related": "https://app.my-awesome-restaurant.com/api/v1/orders/1/items",
|
12
|
+
"linkage": [
|
13
|
+
{ "type": "items", "id": "1" },
|
14
|
+
{ "type": "items", "id": "3" }
|
15
|
+
]
|
16
|
+
}
|
17
|
+
}
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"id": "2",
|
21
|
+
"type": "order",
|
22
|
+
"created_at": "1430407203",
|
23
|
+
"updated_at": "1430407280",
|
24
|
+
"links": {
|
25
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/orders/1",
|
26
|
+
"items": {
|
27
|
+
"related": "https://app.my-awesome-restaurant.com/api/v1/orders/2/items",
|
28
|
+
"linkage": [
|
29
|
+
{ "type": "items", "id": "2" },
|
30
|
+
{ "type": "items", "id": "3" }
|
31
|
+
]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
],
|
36
|
+
"included": {
|
37
|
+
"items": {
|
38
|
+
"1": {
|
39
|
+
"id": 1,
|
40
|
+
"type": "item",
|
41
|
+
"created_at": "1430407103",
|
42
|
+
"updated_at": "1430407180",
|
43
|
+
"name": "Hamburger",
|
44
|
+
"links": {
|
45
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/1"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"2": {
|
49
|
+
"id": 2,
|
50
|
+
"type": "item",
|
51
|
+
"created_at": "1430407103",
|
52
|
+
"updated_at": "1430407180",
|
53
|
+
"name": "Cheese burger",
|
54
|
+
"links": {
|
55
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/2"
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"3": {
|
59
|
+
"id": 3,
|
60
|
+
"type": "item",
|
61
|
+
"created_at": "1430407103",
|
62
|
+
"updated_at": "1430407180",
|
63
|
+
"name": "French Fries",
|
64
|
+
"links": {
|
65
|
+
"self": "https://app.my-awesome-restaurant.com/api/v1/items/3"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"id": "http://jsonschema.net",
|
4
|
+
"type": "object",
|
5
|
+
"properties": {
|
6
|
+
"id": {
|
7
|
+
"type": "string"
|
8
|
+
},
|
9
|
+
"name": {
|
10
|
+
"type": "string",
|
11
|
+
"description": "The name of the item for sale"
|
12
|
+
},
|
13
|
+
"required": [
|
14
|
+
"name"
|
15
|
+
]
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"id": "http://jsonschema.net",
|
4
|
+
"type": "object",
|
5
|
+
"properties": {
|
6
|
+
"id": {
|
7
|
+
"type": "string"
|
8
|
+
},
|
9
|
+
"user_id": {
|
10
|
+
"type": "string",
|
11
|
+
"description": "Person who placed the order"
|
12
|
+
},
|
13
|
+
"order_ids": {
|
14
|
+
"type": "array",
|
15
|
+
"orders_id": {
|
16
|
+
"type": "string"
|
17
|
+
},
|
18
|
+
"minItems": 1,
|
19
|
+
"uniqueItems": true
|
20
|
+
},
|
21
|
+
"required": [
|
22
|
+
"user_id"
|
23
|
+
]
|
24
|
+
}
|
25
|
+
}
|