mobile_workflow 0.6.6 → 0.6.7
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/generators/mobile_workflow/controller_generator.rb +16 -0
- data/lib/generators/mobile_workflow/install/install_generator.rb +13 -3
- data/lib/generators/mobile_workflow/templates/controller.rb.erb +12 -3
- data/lib/generators/mobile_workflow/templates/controller_spec.rb.erb +8 -3
- data/lib/mobile_workflow/cli/app_builder.rb +1 -0
- data/lib/mobile_workflow/cli/heroku_backend.rb +4 -0
- data/lib/mobile_workflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61148da6dc89a23fb998f41ff2ff838c4bc0c9645e8f2b5b580d917ef170c470
|
4
|
+
data.tar.gz: 8c9c1b8d272e722ddf124aeecc4c9ce9bb63e8f44a7f8cc6422595cf65db34cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1a9c667c486a760b837f77ad15da942d0a098adb883357e69fdc9b2365772caeffe085622dfc0b0288368110e54b68e10b7efbb86ff877169e24d53b2b8955
|
7
|
+
data.tar.gz: 547f8800085d32cdaeda268e09a6448c3c460f8ef5ed488fde9f03d6df0da401b38cc0169b2759ab1dae1ea5bfc47a85539d36d7474c29975223d80cea0bd5bb
|
@@ -33,6 +33,22 @@ module MobileWorkflow
|
|
33
33
|
params = attributes_names.map{ |name| ":#{name}" }
|
34
34
|
params.join(", ")
|
35
35
|
end
|
36
|
+
|
37
|
+
def index_action?
|
38
|
+
actions.include?("index")
|
39
|
+
end
|
40
|
+
|
41
|
+
def show_action?
|
42
|
+
actions.include?("show")
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_action?
|
46
|
+
actions.include?("create")
|
47
|
+
end
|
48
|
+
|
49
|
+
def actions
|
50
|
+
options[:actions]
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
@@ -41,13 +41,19 @@ module MobileWorkflow
|
|
41
41
|
def generate_models
|
42
42
|
say "Loading OpenAPI Spec: #{open_api_spec_path}"
|
43
43
|
say "Generating models"
|
44
|
-
model_name_to_properties.each_pair do |model_name, model_properties|
|
44
|
+
model_name_to_properties.each_pair do |model_name, model_properties|
|
45
|
+
|
46
|
+
if doorkeeper_oauth?
|
47
|
+
model_properties = "#{model_properties} user:reference"
|
48
|
+
@model_name_to_properties[model_name] = model_properties
|
49
|
+
end
|
50
|
+
|
45
51
|
if interactive? && !yes?("Use generated schema #{model_name}(#{model_properties})[yn]?")
|
46
52
|
model_properties = ask "Specify schema for #{model_name}: (e.g. text:string image:attachment region:reference)"
|
53
|
+
@model_name_to_properties[model_name] = model_properties
|
47
54
|
end
|
48
55
|
|
49
56
|
generate_model(model_name, model_properties)
|
50
|
-
@model_name_to_properties[model_name] = model_properties
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
@@ -67,7 +73,7 @@ module MobileWorkflow
|
|
67
73
|
generate_model(controller_name, model_properties)
|
68
74
|
end
|
69
75
|
|
70
|
-
generate "mobile_workflow:controller #{controller_name} #{actions.join(" ")} --attributes #{model_properties} #{s3_storage? ? '--s3-storage' : ''}".strip
|
76
|
+
generate "mobile_workflow:controller #{controller_name} --actions #{actions.join(" ")} --attributes #{model_properties} #{s3_storage? ? '--s3-storage' : ''}".strip
|
71
77
|
route "resources :#{plural_controller_name}, only: [#{actions.map{|a| ":#{a}"}.join(", ")}]"
|
72
78
|
end
|
73
79
|
end
|
@@ -89,6 +95,10 @@ module MobileWorkflow
|
|
89
95
|
def open_api_spec
|
90
96
|
@open_api_spec ||= ::MobileWorkflow::OpenApiSpec::Parser.new(File.read(open_api_spec_path))
|
91
97
|
end
|
98
|
+
|
99
|
+
def doorkeeper_oauth?
|
100
|
+
options[:doorkeeper_oauth]
|
101
|
+
end
|
92
102
|
|
93
103
|
def s3_storage?
|
94
104
|
options[:s3_storage]
|
@@ -4,16 +4,24 @@ class <%= controller_class_name %>Controller < ApiController
|
|
4
4
|
before_action :rewrite_payload, only: :create
|
5
5
|
|
6
6
|
load_and_authorize_resource
|
7
|
-
|
7
|
+
|
8
|
+
<% if index_action? -%>
|
8
9
|
def index
|
9
10
|
render json: @<%= plural_table_name %>.collect(&:list_item_as_json)
|
10
11
|
end
|
11
|
-
|
12
|
+
|
13
|
+
<% end -%>
|
14
|
+
<% if show_action? -%>
|
12
15
|
def show
|
13
16
|
render json: @<%= singular_table_name %>.display_as_json
|
14
17
|
end
|
15
|
-
|
18
|
+
|
19
|
+
<% end -%>
|
20
|
+
<% if create_action? -%>
|
16
21
|
def create
|
22
|
+
<% if doorkeeper_oauth? -%>
|
23
|
+
@<%= singular_table_name %> = current_user
|
24
|
+
<% end -%>
|
17
25
|
if @<%= singular_table_name %>.save
|
18
26
|
<% if s3_storage? -%>
|
19
27
|
render json: { binary_urls: binary_urls(@<%= singular_table_name %>), response: @<%= singular_table_name %> }, status: :created
|
@@ -39,5 +47,6 @@ class <%= controller_class_name %>Controller < ApiController
|
|
39
47
|
def <%= singular_table_name.underscore %>_params
|
40
48
|
params.require(:payload).permit(<%= permitted_params %>)
|
41
49
|
end
|
50
|
+
<% end -%>
|
42
51
|
end
|
43
52
|
<% end %>
|
@@ -10,7 +10,8 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
10
10
|
let(:user) { create(:user) }
|
11
11
|
let(:token) { instance_double('Doorkeeper::AccessToken', :accessible? => true, :acceptable? => true, resource_owner_id: user.id) }
|
12
12
|
<% end -%>
|
13
|
-
|
13
|
+
|
14
|
+
<% if index_action? -%>
|
14
15
|
describe 'GET #index' do
|
15
16
|
let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
|
16
17
|
before(:each) do
|
@@ -25,7 +26,8 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
25
26
|
it { expect(response.status).to eq 200 }
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
29
|
+
<% end -%>
|
30
|
+
<% if show_action? -%>
|
29
31
|
describe 'GET #show' do
|
30
32
|
let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
|
31
33
|
let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
|
@@ -40,7 +42,9 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
40
42
|
it { expect(response.status).to eq 200 }
|
41
43
|
end
|
42
44
|
end
|
43
|
-
|
45
|
+
|
46
|
+
<% end -%>
|
47
|
+
<% if create_action? -%>
|
44
48
|
describe 'POST #create' do
|
45
49
|
let(:payload_params) { {text: 'OK'} }
|
46
50
|
let(:params) { { payload: payload_params, binaries: [{identifier: 'record', mimetype: 'video/mp4'}] } }
|
@@ -59,4 +63,5 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
59
63
|
<% end %>
|
60
64
|
end
|
61
65
|
end
|
66
|
+
<% end -%>
|
62
67
|
end
|