mobile_workflow 0.6.4 → 0.6.6

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: 2d3b107beb896ad8c143fe376e7532d3f7d3093435f1b0b59a15401dba17d752
4
- data.tar.gz: '097097c10f64a32065c90e42779b672fecd4b964a15eb43e887d686718c3acfb'
3
+ metadata.gz: bceba9fe508e85d21cd026ac5b26d49f06cec0eb18127a250745d902268b761b
4
+ data.tar.gz: 311c915a764228757fe6f16bfbf382fb6710092a77ad075670de8b1a6548bf45
5
5
  SHA512:
6
- metadata.gz: c8fea51abb663711210ef86a67a8a2b5bcaaedd95d8772fb1297d6deaa10ee4142af6a0a2a6948db56f088da31aa26833b580c6ed7be994c16df6884338394dd
7
- data.tar.gz: 41fee4840d3925030a310530cca5f778a1b989d5f37bea0c8fc7440d3947d04fade3ac3abf040b0f6bf6a0e3508b492b840871c7c73c50fb7b9201decf8703b7
6
+ metadata.gz: 0df8bee9d328897f6b8b92448d0b8df828896b386fd4494453589f21c8321f1db5aef0497396e9f4b0d10430e6f8be57815a16bc84e05a4fef1cdaf2a58d8e54
7
+ data.tar.gz: e7e5ce8cb555596c9c6f856ecee3b553dab36159951b3012a4a74646353b3ffbca5d32deb69501599fae14fd1ff0916ac2a71c4a9289185b9c044ab68cf40b05
@@ -33,9 +33,9 @@ module MobileWorkflow
33
33
  route "resources :sessions, only: [:new, :create]"
34
34
 
35
35
  # View related for login screen
36
- copy_file("views/layouts/application.html.erb")
37
- copy_file("views/sessions/new.html.erb")
38
- copy_file("helpers/application_helper.rb")
36
+ copy_file("app/views/layouts/application.html.erb")
37
+ copy_file("app/views/sessions/new.html.erb")
38
+ copy_file("app/helpers/application_helper.rb")
39
39
  end
40
40
 
41
41
  def generate_models
@@ -53,9 +53,10 @@ module MobileWorkflow
53
53
 
54
54
  def generate_controllers_and_routes
55
55
  say "Generating controllers"
56
- route "root to: 'admin/#{open_api_spec.controller_names.first}#index'"
56
+ controller_name_to_actions = open_api_spec.controller_name_to_actions
57
+ route "root to: 'admin/#{controller_name_to_actions.keys.first}#index'"
57
58
 
58
- open_api_spec.controller_names.each do |plural_controller_name|
59
+ controller_name_to_actions.each_pair do |plural_controller_name, actions|
59
60
  controller_name = plural_controller_name.singularize
60
61
  model_properties = model_name_to_properties[controller_name]
61
62
 
@@ -66,8 +67,8 @@ module MobileWorkflow
66
67
  generate_model(controller_name, model_properties)
67
68
  end
68
69
 
69
- generate "mobile_workflow:controller #{controller_name} --attributes #{model_properties} #{s3_storage? ? '--s3-storage' : ''}".strip
70
- route "resources :#{plural_controller_name}, only: [:index, :show, :create]"
70
+ generate "mobile_workflow:controller #{controller_name} #{actions.join(" ")} --attributes #{model_properties} #{s3_storage? ? '--s3-storage' : ''}".strip
71
+ route "resources :#{plural_controller_name}, only: [#{actions.map{|a| ":#{a}"}.join(", ")}]"
71
72
  end
72
73
  end
73
74
 
@@ -21,9 +21,9 @@ module MobileWorkflow
21
21
  end
22
22
  @model_properties
23
23
  end
24
-
25
- def controller_names
26
- @controller_names ||= paths.collect{|url_path| url_path.split('/')[1] }.uniq
24
+
25
+ def controller_name_to_actions
26
+ @controller_name_to_actions ||= parse_controller_names_to_actions
27
27
  end
28
28
 
29
29
  def paths
@@ -35,6 +35,22 @@ module MobileWorkflow
35
35
  end
36
36
 
37
37
  private
38
+ def parse_controller_names_to_actions
39
+ controllers = {}
40
+ paths.each do |path|
41
+ path_items = path.split('/')
42
+ controller_name = path_items[1]
43
+ controllers[controller_name] = [] unless controllers.key?(controller_name)
44
+
45
+ open_api_spec[:paths][path].keys.each do |method|
46
+ controllers[controller_name] << 'create' if path_items.count == 2 && method == 'post'
47
+ controllers[controller_name] << 'index' if path_items.count == 2 && method == 'get'
48
+ controllers[controller_name] << 'show' if path_items.count == 3 && method == 'get'
49
+ end
50
+ end
51
+ controllers
52
+ end
53
+
38
54
  def open_api_spec
39
55
  @open_api_spec ||= read_openapi_spec
40
56
  end
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.4'
2
+ VERSION = '0.6.6'
3
3
  RUBY_VERSION = '2.7.2'
4
4
  RAILS_VERSION = '6.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-27 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,13 +112,13 @@ files:
112
112
  - lib/generators/mobile_workflow/install/templates/README.md.erb
113
113
  - lib/generators/mobile_workflow/install/templates/ability.rb
114
114
  - lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
115
- - lib/generators/mobile_workflow/install/templates/helpers/application_helper.rb
115
+ - lib/generators/mobile_workflow/install/templates/app/helpers/application_helper.rb
116
+ - lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
117
+ - lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
116
118
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
117
119
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
118
120
  - lib/generators/mobile_workflow/install/templates/storage.s3.yml
119
121
  - lib/generators/mobile_workflow/install/templates/user.rb.erb
120
- - lib/generators/mobile_workflow/install/templates/views/layouts/application.html.erb
121
- - lib/generators/mobile_workflow/install/templates/views/sessions/new.html.erb
122
122
  - lib/generators/mobile_workflow/model_generator.rb
123
123
  - lib/generators/mobile_workflow/templates/controller.rb.erb
124
124
  - lib/generators/mobile_workflow/templates/controller_spec.rb.erb