grapethor 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/grapethor/generators/resource.rb +5 -0
- data/lib/grapethor/templates/resource/api/%api_version%/%res_name_plural%.rb.tt +2 -2
- data/lib/grapethor/templates/resource_minitest/test/api/%api_version%/%res_name_plural%_test.rb.tt +6 -6
- data/lib/grapethor/utils/utils.rb +73 -5
- data/lib/grapethor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c7bfe6c0b3508813bab9aea15e96b0a1f339c5886a481ecd50b90ea59cd2f4
|
4
|
+
data.tar.gz: 2344f087f0b824e8d88a247e44162c2a74f62405ccd43c7bbcb6601f9c1e3260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85c34d5ae4c5e74952c4aa7571b21e2e6817398f09e6cdb911b83089b770bf0c6c5030d258a6a5c2f87125b450080fe255180fab839f5bc1b3ca7ce2d874516
|
7
|
+
data.tar.gz: 5797c222847696c98bd67e1bd9418a2a36fd9043564c20b19834eff2a07d654d46528c3915e4e33255479e1b24193976277046e728362cce44e970056e7e03f2
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.2.1] - 2020-01-16
|
11
|
+
### Fixed
|
12
|
+
+ fix resource generator and utils tests
|
13
|
+
|
14
|
+
|
15
|
+
## [0.2.0] - 2019-04-17
|
16
|
+
### Changed
|
17
|
+
+ improve support for resource generator options
|
18
|
+
|
10
19
|
|
11
20
|
## [0.1.0] - 2019-04-10
|
12
21
|
###Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -115,7 +115,7 @@ Multiple RESOURCES may be created for single API version
|
|
115
115
|
|
116
116
|
Note: ':id' request path parameter is implicitly used as primary key. There is no need to include it with '-a' option.
|
117
117
|
|
118
|
-
Model attribute types available specific ORM:
|
118
|
+
Model attribute types available for specific ORM:
|
119
119
|
|
120
120
|
- activerecord: `bigint, binary, boolean, date, datetime, decimal, float, integer, numeric, string, text, time`
|
121
121
|
|
@@ -50,9 +50,9 @@ module API<%= api_version %>
|
|
50
50
|
desc 'Creates new <%= res_name %>'
|
51
51
|
<% unless res_attrs.empty? -%>
|
52
52
|
params do
|
53
|
-
|
53
|
+
<% res_attrs.each do |name, type| -%>
|
54
54
|
requires :<%= name %>, type: <%= param_to_type(type) %>
|
55
|
-
|
55
|
+
<% end -%>
|
56
56
|
end
|
57
57
|
<% end -%>
|
58
58
|
post do
|
data/lib/grapethor/templates/resource_minitest/test/api/%api_version%/%res_name_plural%_test.rb.tt
CHANGED
@@ -21,7 +21,7 @@ class API<%= api_version %><%= res_name.classify.pluralize %>Test < TestCase
|
|
21
21
|
|
22
22
|
|
23
23
|
def test_get_all_<%= res_name.pluralize %>
|
24
|
-
get '/<%= api_version %>/<%= res_name.pluralize %>'
|
24
|
+
get '/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>'
|
25
25
|
|
26
26
|
assert_equal 200, last_response.status
|
27
27
|
assert_equal @all_<%= res_name.pluralize %>.to_json, last_response.body
|
@@ -29,14 +29,14 @@ class API<%= api_version %><%= res_name.classify.pluralize %>Test < TestCase
|
|
29
29
|
|
30
30
|
|
31
31
|
def test_get_<%= res_name %>
|
32
|
-
get "/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}"
|
32
|
+
get "/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}"
|
33
33
|
|
34
34
|
assert_equal 200, last_response.status
|
35
35
|
assert_equal @<%= res_name %>1.to_json, last_response.body
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_get_<%= res_name %>_by_id_not_found
|
39
|
-
get "/<%= api_version %>/<%= res_name.pluralize %>/1000"
|
39
|
+
get "/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>/1000"
|
40
40
|
|
41
41
|
assert_equal 404, last_response.status
|
42
42
|
assert_equal @not_found_response.to_json, last_response.body
|
@@ -50,7 +50,7 @@ class API<%= api_version %><%= res_name.classify.pluralize %>Test < TestCase
|
|
50
50
|
<% end -%>
|
51
51
|
}
|
52
52
|
<%= res_name %>_count = <%= res_name.classify %>.count
|
53
|
-
post '/<%= api_version %>/<%= res_name.pluralize %>', body, { 'Content-Type' => 'application/json' }
|
53
|
+
post '/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>', body, { 'Content-Type' => 'application/json' }
|
54
54
|
|
55
55
|
assert_equal 201, last_response.status
|
56
56
|
assert_equal <%= res_name %>_count + 1, <%= res_name.classify %>.count
|
@@ -63,7 +63,7 @@ class API<%= api_version %><%= res_name.classify.pluralize %>Test < TestCase
|
|
63
63
|
<%= name %>: <%= sample_value(type) %>,
|
64
64
|
<% end -%>
|
65
65
|
}
|
66
|
-
put "/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}", body, { 'Content-Type' => 'application/json' }
|
66
|
+
put "/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}", body, { 'Content-Type' => 'application/json' }
|
67
67
|
|
68
68
|
assert_equal 204, last_response.status
|
69
69
|
<% res_attrs.each do |name, type| -%>
|
@@ -74,7 +74,7 @@ class API<%= api_version %><%= res_name.classify.pluralize %>Test < TestCase
|
|
74
74
|
|
75
75
|
def test_delete_<%= res_name %>
|
76
76
|
<%= res_name %>_count = <%= res_name.classify %>.count
|
77
|
-
delete "/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}"
|
77
|
+
delete "/<%= app_prefix %>/<%= api_version %>/<%= res_name.pluralize %>/#{@<%= res_name %>1.id}"
|
78
78
|
|
79
79
|
assert_equal 204, last_response.status
|
80
80
|
assert_equal <%= res_name %>_count - 1, <%= res_name.classify %>.count
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'bigdecimal'
|
2
|
+
require 'date'
|
2
3
|
|
3
4
|
module Grapethor
|
4
5
|
module Utils
|
@@ -21,11 +22,11 @@ module Grapethor
|
|
21
22
|
},
|
22
23
|
date: {
|
23
24
|
type: 'Date',
|
24
|
-
sample:
|
25
|
+
sample: Date.today
|
25
26
|
},
|
26
27
|
datetime: {
|
27
28
|
type: 'DateTime',
|
28
|
-
sample:
|
29
|
+
sample: DateTime.now
|
29
30
|
},
|
30
31
|
decimal: {
|
31
32
|
type: 'BigDecimal',
|
@@ -45,19 +46,86 @@ module Grapethor
|
|
45
46
|
},
|
46
47
|
string: {
|
47
48
|
type: 'String',
|
48
|
-
sample:
|
49
|
+
sample: 'MyString'
|
49
50
|
},
|
50
51
|
text: {
|
51
52
|
type: 'String',
|
52
|
-
sample: "
|
53
|
+
sample: "MyText"
|
53
54
|
},
|
54
55
|
time: {
|
55
56
|
type: 'Time',
|
56
|
-
sample:
|
57
|
+
sample: Time.now
|
57
58
|
}
|
59
|
+
},
|
60
|
+
mongoid: {
|
61
|
+
# Array: {
|
62
|
+
# type:,
|
63
|
+
# sample:
|
64
|
+
# },
|
65
|
+
BigDecimal: {
|
66
|
+
type: 'BigDecimal',
|
67
|
+
sample: BigDecimal(123.45, 2)
|
68
|
+
},
|
69
|
+
# BSON::ObjectId: {
|
70
|
+
# type:,
|
71
|
+
# sample:
|
72
|
+
# },
|
73
|
+
Boolean: {
|
74
|
+
type: 'Boolean',
|
75
|
+
sample: true
|
76
|
+
},
|
77
|
+
Date: {
|
78
|
+
type: 'Date',
|
79
|
+
sample: Date.today
|
80
|
+
},
|
81
|
+
DateTime: {
|
82
|
+
type: 'DateTime',
|
83
|
+
sample: DateTime.now
|
84
|
+
},
|
85
|
+
Float: {
|
86
|
+
type: 'Float',
|
87
|
+
sample: 123.45
|
88
|
+
},
|
89
|
+
# Hash: {
|
90
|
+
# type:,
|
91
|
+
# sample:
|
92
|
+
# },
|
93
|
+
Integer: {
|
94
|
+
type: 'Integer',
|
95
|
+
sample: 123
|
96
|
+
},
|
97
|
+
# Moped::BSON::Binary: {
|
98
|
+
# type:,
|
99
|
+
# sample:
|
100
|
+
# },
|
101
|
+
# Range: {
|
102
|
+
# type:,
|
103
|
+
# sample:
|
104
|
+
# },
|
105
|
+
# Regexp: {
|
106
|
+
# type:,
|
107
|
+
# sample:
|
108
|
+
# },
|
109
|
+
String: {
|
110
|
+
type: 'String',
|
111
|
+
sample: 'MyString'
|
112
|
+
},
|
113
|
+
Symbol: {
|
114
|
+
type: 'Symbol',
|
115
|
+
sample: :mysymbol
|
116
|
+
},
|
117
|
+
Time: {
|
118
|
+
type: 'Time',
|
119
|
+
sample: Time.now
|
120
|
+
}
|
121
|
+
# TimeWithZone: {
|
122
|
+
# type: 'Time',
|
123
|
+
# sample:
|
124
|
+
# },
|
58
125
|
}
|
59
126
|
}
|
60
127
|
|
128
|
+
|
61
129
|
TEST_FRAMEWORK_DIRNAME = {
|
62
130
|
minitest: 'test',
|
63
131
|
rspec: 'spec'
|
data/lib/grapethor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grapethor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafal Wrzochol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|