mobile_workflow 0.6.10 → 0.6.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1e72adcc8d3a21ec01476098c7f16fe849c2ab8348f0164fe15ffde1872b156
4
- data.tar.gz: 5c361e5591040d4a5636aa425dbf77ec533cddbad38e150a6f1f94a1fdca360e
3
+ metadata.gz: 70b47d5100717238d1b3a8251f6f4d12ea3b3238574bcfa3d5e1f93fc9ba6147
4
+ data.tar.gz: d752174d98519ec5ebdd98007b8d8956c9e0b40f845df1200ee50c8a915fb7b5
5
5
  SHA512:
6
- metadata.gz: 5b66dbaa49b726bc92618c6405af04e3cac7476809ffafeda4d7d444ec3275a993fae2c4a4b6c534ecd5569467c3c8fb4402c97a7b96d1238d1f0c5c34190148
7
- data.tar.gz: 67bd8a5575e05e1ec46653b42eadf089a81c05e64ea0c1e6f9702b6e0621e9fd6212e577f13ccbf085a299f53fd1bf288df2db01fd46b2b52d9a748f07aa0518
6
+ metadata.gz: aaf8809dae9ad487dda543d0619a272aa174dc881c2cb6b941701c0eda093798eadbf46808d05a2a2a828163e3f0068e45d17f099ec149865e72424da75ce9f6
7
+ data.tar.gz: e7948f530072740a2e7716dafc6b95c5a1176a07be0b6f640332ca23b404edc1bf61a8718736aac7e49a09faae176b73b6393ec0c1c7188e5dfff9c299d2bf90
@@ -4,20 +4,27 @@ module MobileWorkflow
4
4
  include Rails.application.routes.url_helpers
5
5
 
6
6
  ON_SUCCESS_OPTIONS = [:none, :reload, :backward, :forward]
7
- BUTTON_STYLES = [:primary, :outline, :danger]
8
-
7
+ BUTTON_STYLES = [:primary, :outline, :danger]
8
+ CONTENT_MODE_OPTIONS = [:scale_aspect_fill, :scale_aspect_fit]
9
+
9
10
  def mw_list_item(id: self.id, text:, detail_text: nil, sf_symbol_name: nil, image_attachment: nil)
10
11
  mw_list_item = {id: id, text: text, detailText: detail_text, sfSymbolName: sf_symbol_name}
11
12
  mw_list_item[:imageURL] = preview_url(image_attachment, options: { resize_to_fill: [100, 100] }) if image_attachment
12
- mw_list_item.compact
13
+ mw_list_item.compact
14
+ end
15
+
16
+ def mw_map_item(id: self.id, text:, detail_text: nil, latitude:, longitude:)
17
+ {id: id, text: text, detailText: detail_text, latitude: latitude, longitude: longitude}.compact
13
18
  end
14
19
 
15
20
  def mw_display_text(text:, label: nil)
16
21
  {type: :text, label: label, text: text.to_s}.compact
17
22
  end
18
23
 
19
- def mw_display_image(attachment, options: { resize_to_fill: [600, 1200] })
20
- {type: :image, previewURL: preview_url(attachment, options: options), url: attachment_url(attachment)}
24
+ def mw_display_image(attachment, content_mode: :scale_aspect_fill, options: { resize_to_fill: [600, 1200] })
25
+ validate_content_mode!(content_mode)
26
+
27
+ {type: :image, contentMode: content_mode.to_s.camelize(:lower), previewURL: preview_url(attachment, options: options), url: attachment_url(attachment)}
21
28
  end
22
29
 
23
30
  def mw_display_unsplash_image(image_url)
@@ -54,6 +61,13 @@ module MobileWorkflow
54
61
  {type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
55
62
  end
56
63
 
64
+ def mw_display_button_for_system_url(label:, apple_system_url:, method: :put, style: :primary, on_success: :none)
65
+ validate_on_success!(on_success)
66
+ validate_button_style!(style)
67
+
68
+ {type: :button, label: label, appleSystemURL: apple_system_url, method: method, style: style, onSuccess: on_success}
69
+ end
70
+
57
71
  def mw_display_button_for_modal_workflow(label:, modal_workflow_name:, style: :primary, on_success: :none)
58
72
  validate_on_success!(on_success)
59
73
  validate_button_style!(style)
@@ -66,6 +80,10 @@ module MobileWorkflow
66
80
  raise 'Unknown on_success action' unless ON_SUCCESS_OPTIONS.include?(on_success)
67
81
  end
68
82
 
83
+ def validate_content_mode!(on_success)
84
+ raise 'Unknown content_mode' unless CONTENT_MODE_OPTIONS.include?(on_success)
85
+ end
86
+
69
87
  def validate_button_style!(style)
70
88
  raise 'Unknown style' unless BUTTON_STYLES.include?(style)
71
89
  end
@@ -24,6 +24,10 @@ module MobileWorkflow
24
24
  route "mount MobileWorkflow::Engine => '/'"
25
25
  end
26
26
 
27
+ def copy_rake_tasks
28
+ copy_file("lib/tasks/mobile_workflow_doorkeeper.rake") if options[:doorkeeper_oauth]
29
+ end
30
+
27
31
  def generate_doorkeeper
28
32
  return unless options[:doorkeeper_oauth]
29
33
  say "Generating Doorkeeper OAuth"
@@ -0,0 +1,5 @@
1
+ desc "Log the first Doorkeeper App details"
2
+ task print_oauth_app: :environment do
3
+ puts Doorkeeper::Application.first.uid
4
+ puts Doorkeeper::Application.first.secret
5
+ end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :user do
3
- email { 'jo@example.com' }
3
+ sequence(:email) { |n| "person#{n}@example.com" }
4
4
  password { 'Password123' }
5
5
  end
6
6
  end
@@ -29,7 +29,7 @@ class <%= controller_class_name %>Controller < ApiController
29
29
  render json: { response: @<%= singular_table_name %> }, status: :created
30
30
  <% end -%>
31
31
  else
32
- head :unprocessable_entity
32
+ render json: { message: @<%= singular_table_name %>.errors.full_messages.to_sentence }, status: :unprocessable_entity
33
33
  end
34
34
  end
35
35
 
@@ -8,7 +8,7 @@ RSpec.describe <%= controller_class_name %>Controller do
8
8
  let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
9
9
  <% if doorkeeper_oauth? -%>
10
10
  let(:user) { create(:user) }
11
- let(:token) { instance_double('Doorkeeper::AccessToken', :accessible? => true, :acceptable? => true, resource_owner_id: user.id) }
11
+ let(:token) { instance_double(Doorkeeper::AccessToken, accessible?: true, acceptable?: true, resource_owner_id: user.id) }
12
12
  <% end -%>
13
13
 
14
14
  <% if index_action? -%>
@@ -66,7 +66,22 @@ CODE
66
66
  end
67
67
 
68
68
  def format_source
69
- run 'rufo .'
69
+ `rufo .`
70
+ end
71
+
72
+ def generate_dot_env
73
+ admin_user = 'admin'
74
+ admin_password = SecureRandom.base64(12)
75
+
76
+ file '.env', <<-CODE
77
+ ADMIN_USER=#{admin_user}
78
+ ADMIN_PASSWORD=#{admin_password}
79
+ CODE
80
+ end
81
+
82
+ def git_commit(message = 'Initial commit')
83
+ git add: "."
84
+ git commit: %Q{ -m '#{message}'}
70
85
  end
71
86
 
72
87
  def s3_backend(region)
@@ -40,10 +40,8 @@ module MobileWorkflow::Cli
40
40
  build :migrate_db
41
41
  build :administrate_generator
42
42
  build :format_source
43
-
44
- generate_dot_env
45
- initial_git_commit
46
-
43
+ build :generate_dot_env
44
+ build :git_commit
47
45
  build :heroku if options[:heroku]
48
46
  build :dokku, options[:dokku_host] if options[:dokku]
49
47
  build :s3_backend, options[:aws_region] if options[:s3_storage]
@@ -56,22 +54,5 @@ module MobileWorkflow::Cli
56
54
  ::MobileWorkflow::Cli::AppBuilder
57
55
  end
58
56
 
59
- # Todo: MBS - move these methods to the builder class
60
- # Ideally override RailsBuilder methods
61
- private
62
- def initial_git_commit
63
- git add: "."
64
- git commit: %Q{ -m 'Initial commit' }
65
- end
66
-
67
- def generate_dot_env
68
- admin_user = 'admin'
69
- admin_password = SecureRandom.base64(12)
70
-
71
- file '.env', <<-CODE
72
- ADMIN_USER=#{admin_user}
73
- ADMIN_PASSWORD=#{admin_password}
74
- CODE
75
- end
76
57
  end
77
58
  end
@@ -5,7 +5,7 @@ module MobileWorkflow::Cli
5
5
 
6
6
  attr_accessor :access_id, :secret_key, :region, :bucket_name
7
7
 
8
- def initialize(app_name:, region:)
8
+ def initialize(app_name:, region: 'us-east-1')
9
9
  @app_name = app_name
10
10
  @aws_name = @app_name.gsub("_", "-")
11
11
  @region = region
@@ -2,9 +2,6 @@ module MobileWorkflow
2
2
  module OpenApiSpec
3
3
  class Parser
4
4
 
5
- # Schemas to avoid generating models for (static items from MW)
6
- SKIP_SCHEMAS = ["attachment", "ListItem", "DisplayItem", "DisplayText", "DisplayButton", "DisplayImage", "DisplayVideo"]
7
-
8
5
  def initialize(open_api_spec_string)
9
6
  @open_api_spec_string = open_api_spec_string
10
7
  end
@@ -12,7 +9,7 @@ module MobileWorkflow
12
9
  def model_name_to_properties
13
10
  @model_properties = {}
14
11
  schemas.each_pair do |model_name, schema|
15
- next if SKIP_SCHEMAS.include? model_name # Don't generate schemas for MW schemas
12
+ next if model_name.start_with?("MW")
16
13
 
17
14
  model_name = model_name.underscore
18
15
  model_properties = schema_model_properties(model_name, schema)
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.10'
2
+ VERSION = '0.6.15'
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.10
4
+ version: 0.6.15
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-02-01 00:00:00.000000000 Z
11
+ date: 2021-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -115,6 +115,7 @@ files:
115
115
  - lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
116
116
  - lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
117
117
  - lib/generators/mobile_workflow/install/templates/create_users.rb
118
+ - lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_doorkeeper.rake
118
119
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
119
120
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
120
121
  - lib/generators/mobile_workflow/install/templates/spec/factories/users.rb