mobile_workflow 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bceba9fe508e85d21cd026ac5b26d49f06cec0eb18127a250745d902268b761b
4
- data.tar.gz: 311c915a764228757fe6f16bfbf382fb6710092a77ad075670de8b1a6548bf45
3
+ metadata.gz: 61148da6dc89a23fb998f41ff2ff838c4bc0c9645e8f2b5b580d917ef170c470
4
+ data.tar.gz: 8c9c1b8d272e722ddf124aeecc4c9ce9bb63e8f44a7f8cc6422595cf65db34cc
5
5
  SHA512:
6
- metadata.gz: 0df8bee9d328897f6b8b92448d0b8df828896b386fd4494453589f21c8321f1db5aef0497396e9f4b0d10430e6f8be57815a16bc84e05a4fef1cdaf2a58d8e54
7
- data.tar.gz: e7e5ce8cb555596c9c6f856ecee3b553dab36159951b3012a4a74646353b3ffbca5d32deb69501599fae14fd1ff0916ac2a71c4a9289185b9c044ab68cf40b05
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
@@ -82,6 +82,7 @@ CODE
82
82
  heroku_backend.create
83
83
  heroku_backend.configure_activestorage if options[:s3_storage]
84
84
  heroku_backend.deploy
85
+ heroku_backend.seed_db
85
86
  heroku_backend.sync_dotenv
86
87
  end
87
88
 
@@ -21,6 +21,10 @@ module MobileWorkflow::Cli
21
21
  def deploy
22
22
  heroku_command "git push"
23
23
  end
24
+
25
+ def seed_db
26
+ heroku_command "heroku run rails db:seed"
27
+ end
24
28
 
25
29
  def sync_dotenv
26
30
  env = File.read(".env").split.join(" ")
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.6'
2
+ VERSION = '0.6.7'
3
3
  RUBY_VERSION = '2.7.2'
4
4
  RAILS_VERSION = '6.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith