mobile_workflow 0.5.6 → 0.5.11

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: a2a4d13fe23a8f256052b54fa14424c54d847bb327bf57128159b9dd8ffd334a
4
- data.tar.gz: 0aa96388f99ac5f8ae69a1e6a06559c58c9eab58c355f877b259137472a3b176
3
+ metadata.gz: 24e4161405736a8da53f830ee7f46f84a58930a3f4d7e5fd28456005f4d1f99f
4
+ data.tar.gz: 9f13aa23db9a97150e0c0bd9c3a64b6b5161460df709c14a56a2af87ce3db784
5
5
  SHA512:
6
- metadata.gz: 7f5890bf8381f177530fe3607e5ec4fe276258638f4a28213665c7c2dab5724ed14fb4a9f3ea3027581c41499c4fb995701e4b08138d0d31466f4781aa8f279e
7
- data.tar.gz: 7b5c52f4a9b754078eb0c1a70b6213bf5b33f9825f1c67ce0325199b5c2bc1038cde0044b951baccdb6120c7fa2b46546349258c444cca4db7b438a96dbd5b3f
6
+ metadata.gz: 2e6056e6a06c99156d2106114ea885caedf5eb5ec83d62a02469aa645b7fb2498ab4ccf5fcc73bd1de5def857f64b8532fc65e669c870ed073d865e7c228d7e5
7
+ data.tar.gz: 8e6fc1fd000da48eddc130b84dec03ee8c1db5a0a1e95a5783d544a0fd720e364800b2c9b8cd769e222817a1304e4d32892664b61e159ae63c5520f1be132e71
@@ -8,7 +8,7 @@ module MobileWorkflow
8
8
 
9
9
  def mw_list_item(id: self.id, text:, detail_text: nil, sf_symbol_name: nil, image_attachment: nil)
10
10
  mw_list_item = {id: id, text: text, detailText: detail_text, sfSymbolName: sf_symbol_name}
11
- mw_list_item[:imageURL] = preview_url(image_attachment, height: 100, width: 100) if image_attachment
11
+ mw_list_item[:imageURL] = preview_url(image_attachment, options: { resize_to_fill: [100, 100] }) if image_attachment
12
12
  mw_list_item.compact
13
13
  end
14
14
 
@@ -16,8 +16,8 @@ module MobileWorkflow
16
16
  {type: :text, label: label, text: text.to_s}.compact
17
17
  end
18
18
 
19
- def mw_display_image(attachment)
20
- {type: :image, previewURL: preview_url(attachment, height: 600, width: 1200), url: attachment_url(attachment)}
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)}
21
21
  end
22
22
 
23
23
  def mw_display_unsplash_image(image_url)
@@ -29,8 +29,8 @@ module MobileWorkflow
29
29
  {type: :image, previewURL: image_url, url: image_url}
30
30
  end
31
31
 
32
- def mw_display_video(attachment)
33
- {type: :video, previewURL: preview_url(attachment, height: 600, width: 1200), url: attachment_url(attachment)}
32
+ def mw_display_video(attachment, preview_options: { resize_to_fill: [600, 1200] })
33
+ {type: :video, previewURL: preview_url(attachment, options: preview_options), url: attachment_url(attachment)}
34
34
  end
35
35
 
36
36
  def mw_display_button(label:, style: :primary, on_success: :forward)
@@ -69,12 +69,12 @@ module MobileWorkflow
69
69
  def validate_button_style!(style)
70
70
  raise 'Unknown style' unless BUTTON_STYLES.include?(style)
71
71
  end
72
-
73
- def preview_url(attachment, height:, width:, options: { resize_to_fill: [height, width]} )
72
+
73
+ def preview_url(attachment, options:)
74
74
  return nil unless attachment.attached?
75
75
 
76
76
  if attachment.image?
77
- Rails.application.routes.url_helpers.rails_representation_url(attachment.variant(combine_options: options), host: attachment_host)
77
+ Rails.application.routes.url_helpers.rails_representation_url(attachment.variant(options), host: attachment_host)
78
78
  elsif attachment.previewable?
79
79
  Rails.application.routes.url_helpers.rails_representation_url(attachment.preview(options), host: attachment_host)
80
80
  else
@@ -8,13 +8,18 @@ module MobileWorkflow
8
8
 
9
9
  class_option :attributes, type: :array, default: [], banner: "field:type field:type"
10
10
  class_option :actions, type: :array, default: [], banner: "index create update destroy"
11
+ class_option :doorkeeper_oauth, type: :boolean, default: false
11
12
 
12
13
  def copy_controller_and_spec_files
13
14
  template "controller.rb.erb", File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
14
15
  template "controller_spec.rb.erb", File.join("spec/controllers", controller_class_path, "#{controller_file_name}_controller_spec.rb")
15
16
  end
16
17
 
17
- private
18
+ private
19
+ def doorkeeper_oauth?
20
+ options[:doorkeeper_oauth]
21
+ end
22
+
18
23
  def attributes_names
19
24
  options[:attributes].map{ |attribute| attribute.split(":").first }
20
25
  end
@@ -32,6 +32,11 @@ module MobileWorkflow
32
32
  template("user.rb.erb", "app/models/user.rb")
33
33
  template("sessions_controller.rb.erb", "app/controllers/sessions_controller.rb")
34
34
  route "resources :sessions, only: [:new, :create]"
35
+
36
+ # View related for login screen
37
+ copy_file("views/layouts/application.html.erb")
38
+ copy_file("views/sessions/new.html.erb")
39
+ copy_file("helpers/application_helper.rb")
35
40
  end
36
41
 
37
42
  def generate_models
@@ -1,23 +1,21 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- ruby '2.6.6'
4
+ ruby '<%= MobileWorkflow::RUBY_VERSION %>'
5
5
 
6
6
  # Core Gems
7
- gem 'rails', '~> 6.1.0'
7
+ gem 'rails', '~> <%= MobileWorkflow::RAILS_VERSION %>'
8
8
  gem 'puma', '~> 5.0'
9
9
  gem 'sass-rails', '>= 6'
10
10
  gem 'turbolinks', '~> 5'
11
11
 
12
12
  # Mobile Workflow
13
- #gem 'mobile_workflow', path: '../mobile_workflow'
14
- #gem 'mobile_workflow', github: 'FutureWorkshops/mobile_workflow'
15
- gem 'mobile_workflow', '0.5.5'
13
+ gem 'mobile_workflow', '~> <%= MobileWorkflow::VERSION %>'
16
14
 
17
15
  # Authorisation / Authentication
18
16
  <%- if options[:doorkeeper_oauth] %>
19
17
  gem 'doorkeeper'
20
- gem 'bcrypt-ruby'
18
+ gem 'bcrypt'
21
19
  <%- end %>
22
20
  gem 'cancancan', '~> 3.1'
23
21
 
@@ -8,7 +8,7 @@ class ApiController < ActionController::API
8
8
  before_action :doorkeeper_authorize!, unless: :anonymous_action?
9
9
 
10
10
  def current_resource_owner
11
- User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
11
+ @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
12
12
  end
13
13
  alias_method :current_user, :current_resource_owner
14
14
 
@@ -0,0 +1,13 @@
1
+ module ApplicationHelper
2
+
3
+ def bootstrap_class_for(flash_type)
4
+ { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }.stringify_keys[flash_type.to_s] || flash_type.to_s
5
+ end
6
+
7
+ def flash_messages
8
+ flash.each do |flash_type, message|
9
+ concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(flash_type)}", role: 'alert'))
10
+ end
11
+ nil
12
+ end
13
+ end
@@ -3,7 +3,7 @@ class SessionsController < ApplicationController
3
3
  end
4
4
 
5
5
  def create
6
- @user = User.find_by(email: params[:email])
6
+ @user = User.find_by("LOWER(email)= ?", params[:email].downcase)
7
7
  if @user && @user.authenticate(params[:password])
8
8
  session[:user_id] = @user.id
9
9
  redirect_to params[:return_to] || root_url, notice: "Logged in!"
@@ -1,4 +1,4 @@
1
1
  class User < ApplicationRecord
2
2
  has_secure_password
3
- validates :email, presence: true
3
+ validates :email, presence: true, uniqueness: true
4
4
  end
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <!-- Required meta tags -->
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+
8
+ <!-- Bootstrap CSS -->
9
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
10
+
11
+ <title>MW Project</title>
12
+ </head>
13
+ <body>
14
+ <div class="container">
15
+ <%= yield %>
16
+ </div>
17
+ </body>
18
+ </html>
@@ -0,0 +1,20 @@
1
+ <h1>Sign In</h1>
2
+
3
+ <%= flash_messages %>
4
+
5
+ <%= form_tag sessions_path, method: :post do %>
6
+ <%= hidden_field_tag :return_to, params[:return_to] %>
7
+
8
+ <div class="form-group">
9
+ <%= label_tag :email %>
10
+ <%= email_field_tag :email, nil, class: "form-control" %>
11
+ </div>
12
+
13
+ <div class="form-group">
14
+ <%= label_tag :password %>
15
+ <%= password_field_tag :password, nil, class: "form-control" %>
16
+ </div>
17
+
18
+ <%= submit_tag 'Sign In', class: "btn btn-primary" %>
19
+ <% end %>
20
+
@@ -6,10 +6,19 @@ require 'json'
6
6
  RSpec.describe <%= controller_class_name %>Controller do
7
7
  let(:params) { {} }
8
8
  let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
9
+ <% if doorkeeper_oauth? -%>
10
+ let(:user) { create(:user) }
11
+ let(:token) { instance_double('Doorkeeper::AccessToken', :accessible? => true, :acceptable? => true, resource_owner_id: user.id) }
12
+ <% end -%>
9
13
 
10
14
  describe 'GET #index' do
11
15
  let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
12
- before(:each) { get :index, params: params }
16
+ before(:each) do
17
+ <% if doorkeeper_oauth? -%>
18
+ allow(subject).to receive(:doorkeeper_token) { token }
19
+ <% end -%>
20
+ get :index, params: params
21
+ end
13
22
 
14
23
  context 'ok' do
15
24
  it { expect(json_response[0][:id]).to eq <%= controller_class_name.singularize.underscore %>.id }
@@ -20,7 +29,12 @@ RSpec.describe <%= controller_class_name %>Controller do
20
29
  describe 'GET #show' do
21
30
  let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
22
31
  let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
23
- before(:each) { get :show, params: params }
32
+ before(:each) do
33
+ <% if doorkeeper_oauth? -%>
34
+ allow(subject).to receive(:doorkeeper_token) { token }
35
+ <% end -%>
36
+ get :show, params: params
37
+ end
24
38
 
25
39
  context 'ok' do
26
40
  it { expect(response.status).to eq 200 }
@@ -30,7 +44,12 @@ RSpec.describe <%= controller_class_name %>Controller do
30
44
  describe 'POST #create' do
31
45
  let(:payload_params) { {text: 'OK'} }
32
46
  let(:params) { { payload: payload_params, binaries: [{identifier: 'record', mimetype: 'video/mp4'}] } }
33
- before(:each) { post :create, params: params }
47
+ before(:each) do
48
+ <% if doorkeeper_oauth? -%>
49
+ allow(subject).to receive(:doorkeeper_token) { token }
50
+ <% end -%>
51
+ post :create, params: params
52
+ end
34
53
 
35
54
  context 'ok' do
36
55
  it { expect(<%= controller_class_name.singularize %>.count).to eq 1 }
@@ -53,9 +53,9 @@ module MobileWorkflow::Cli
53
53
  def destroy
54
54
  aws_command "aws s3api delete-bucket --bucket #{@aws_name} --region #{@region}"
55
55
 
56
- aws_command("aws sns list-topics")["Topics"].each do |topic|
56
+ aws_command("aws sns list-topics --region #{@region}")["Topics"].each do |topic|
57
57
  topic_arn = topic["TopicArn"]
58
- aws_command "aws sns delete-topic --topic-arn '#{topic_arn}'" if topic_arn.end_with?(@aws_name)
58
+ aws_command "aws sns delete-topic --topic-arn '#{topic_arn}' --region #{@region}" if topic_arn.end_with?(@aws_name)
59
59
  end
60
60
 
61
61
  aws_command "aws iam delete-user-policy --user-name #{@aws_name} --policy-name s3"
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.5.6'
3
- RUBY_VERSION = '2.5.5'
2
+ VERSION = '0.5.11'
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.5.6
4
+ version: 0.5.11
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: 2020-12-30 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,10 +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
116
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
116
117
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
117
118
  - lib/generators/mobile_workflow/install/templates/storage.s3.yml
118
119
  - 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
119
122
  - lib/generators/mobile_workflow/templates/controller.rb.erb
120
123
  - lib/generators/mobile_workflow/templates/controller_spec.rb.erb
121
124
  - lib/mobile_workflow.rb
@@ -141,14 +144,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
144
  requirements:
142
145
  - - ">="
143
146
  - !ruby/object:Gem::Version
144
- version: 2.5.5
147
+ version: 2.7.2
145
148
  required_rubygems_version: !ruby/object:Gem::Requirement
146
149
  requirements:
147
150
  - - ">="
148
151
  - !ruby/object:Gem::Version
149
152
  version: '0'
150
153
  requirements: []
151
- rubygems_version: 3.0.8
154
+ rubygems_version: 3.1.4
152
155
  signing_key:
153
156
  specification_version: 4
154
157
  summary: A Rails engine to provide API support for Mobile Workflow Apps.