mobile_workflow 0.6.31 → 0.7.3

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: 37eb1d708549f31b01aca9e6cb6c68b2e0778f647c326c6f2ed54e55f64c58c0
4
- data.tar.gz: 5b23a0cd92a3b8c3a9931651c9eb37322fdd693f44700aac1da684764fc8b5ef
3
+ metadata.gz: 026fc97366b9da9d1cdd8c27935c9c120a872fc0f666e3e8dec8ebe881e36c8e
4
+ data.tar.gz: 2963f07f4173b235411a1256a5ab716805edebc78cd82c60603603316a861284
5
5
  SHA512:
6
- metadata.gz: 1c345303b25a33807e58ca50e4ea1cea90853c896361f90b492f80d55306e45552fea574a28b0e548f1318e225519e478d3bb102e8a5f36d06ee773750aacded
7
- data.tar.gz: 232110a1e208baddf77c246e4d7727cb6fb4f21ae06689e54a2e43be2db2fab0b3e48a99a25bf64a9759e1b904584b707d6bf2e0c134da616459dee6b8c0e3b6
6
+ metadata.gz: 297c0feb073d5172064eb35168aff8864b7d523e91bc9f0bcbede72ad16c2fb2e4507aea89b52f21fc921dbef299f00b2b9d8765c595f1e1435392bbd84a2693
7
+ data.tar.gz: 9d3442386b9f5846dca8124f2bdb878302992bb42142b6ac3601abd3fd14d3c556051c261f210faf98bc24e21adf8edb5ff2b16ead759dccfb6fe0878c7b755c
@@ -12,13 +12,17 @@ module MobileWorkflow
12
12
 
13
13
  {
14
14
  "identifier" => binary["identifier"],
15
- "url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}.#{extension}"),
15
+ "url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}/#{s3_object_uuid}.#{extension}"),
16
16
  "method" => "PUT"
17
17
  }
18
18
  end
19
19
  end
20
20
 
21
21
  private
22
+ def s3_object_uuid
23
+ SecureRandom.uuid
24
+ end
25
+
22
26
  def presigned_url(key)
23
27
  presigner.presigned_url(:put_object, bucket: ENV['AWS_BUCKET_NAME'], key: key, metadata: {})
24
28
  end
@@ -56,10 +56,6 @@ module MobileWorkflow
56
56
  end
57
57
 
58
58
  def attribute_name
59
- file_name.split(".")[0] # remove the extension
60
- end
61
-
62
- def file_name
63
59
  key_identifiers[2]
64
60
  end
65
61
 
@@ -67,13 +63,10 @@ module MobileWorkflow
67
63
  object_class_name, object_id, attribute_name = object_key.split("/")
68
64
  return object_class_name, object_id, attribute_name
69
65
  end
70
-
66
+
71
67
  def object_key
72
- @object_key ||= message['Records'][0]['s3']['object']['key']
73
- end
74
-
75
- def message
76
68
  message = JSON.parse(message_body['Message'])
69
+ message['Records'][0]['s3']['object']['key']
77
70
  end
78
71
 
79
72
  def message_body
@@ -151,11 +151,13 @@ module MobileWorkflow
151
151
  def attachment_url(attachment)
152
152
  return nil unless attachment.attached?
153
153
 
154
- Rails.application.routes.url_helpers.rails_blob_url(attachment, host: attachment_host)
154
+ Rails.application.routes.url_helpers.rails_blob_url(attachment, host: heroku_attachment_host)
155
155
  end
156
156
 
157
- def attachment_host
158
- "https://#{ENV.fetch('HEROKU_APP_NAME')}.herokuapp.com"
157
+ def heroku_attachment_host
158
+ # TODO: MBS - move this to a configuration property
159
+ app_name = Rails.env.test? ? 'test' : ENV.fetch('HEROKU_APP_NAME')
160
+ "https://#{app_name}.herokuapp.com"
159
161
  end
160
162
  end
161
163
  end
@@ -24,10 +24,6 @@ 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
-
31
27
  def generate_doorkeeper
32
28
  return unless options[:doorkeeper_oauth]
33
29
  say "Generating Doorkeeper OAuth"
@@ -0,0 +1,12 @@
1
+ desc "Add S3 storage to a Heroku app"
2
+ namespace :mw do
3
+ task add_heroku_s3_storage: :environment do
4
+ require 'mobile_workflow/cli'
5
+ app_name = ENV['APP_NAME']
6
+ aws_region = ENV['AWS_REGION'] || 'us-east-1'
7
+ aws = MobileWorkflow::Cli::AwsBackend.new(app_name: app_name, region: aws_region)
8
+ heroku = MobileWorkflow::Cli::HerokuBackend.new(app_name: app_name)
9
+ aws.create
10
+ aws.create_topic_subscription(heroku.notifications_endpoint)
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.31'
2
+ VERSION = '0.7.3'
3
3
  RUBY_VERSION = '2.7.3'
4
4
  RAILS_VERSION = '6.1.3.1'
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.31
4
+ version: 0.7.3
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-07-14 00:00:00.000000000 Z
11
+ date: 2021-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,8 +116,6 @@ files:
116
116
  - lib/generators/mobile_workflow/install/templates/app/views/layouts/application.html.erb
117
117
  - lib/generators/mobile_workflow/install/templates/app/views/sessions/new.html.erb
118
118
  - lib/generators/mobile_workflow/install/templates/create_users.rb
119
- - lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_doorkeeper.rake
120
- - lib/generators/mobile_workflow/install/templates/lib/tasks/mobile_workflow_s3.rake
121
119
  - lib/generators/mobile_workflow/install/templates/seeds.rb.erb
122
120
  - lib/generators/mobile_workflow/install/templates/sessions_controller.rb.erb
123
121
  - lib/generators/mobile_workflow/install/templates/spec/factories/users.rb
@@ -138,6 +136,7 @@ files:
138
136
  - lib/mobile_workflow/engine.rb
139
137
  - lib/mobile_workflow/open_api_spec/parser.rb
140
138
  - lib/mobile_workflow/railtie.rb
139
+ - lib/mobile_workflow/tasks/s3.rake
141
140
  - lib/mobile_workflow/tasks/set_env.rake
142
141
  - lib/mobile_workflow/version.rb
143
142
  homepage: https://github.com/futureworkshops/mobile_workflow
@@ -1,5 +0,0 @@
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,10 +0,0 @@
1
- desc "Add S3 storage to a Heroku app"
2
- task add_heroku_s3_storage: :environment do
3
- require 'mobile_workflow/cli'
4
- app_name = ENV['APP_NAME']
5
- aws_region = ENV['AWS_REGION'] || 'us-east-1'
6
- aws = MobileWorkflow::Cli::AwsBackend.new(app_name: app_name, region: aws_region)
7
- heroku = MobileWorkflow::Cli::HerokuBackend.new(app_name: app_name)
8
- aws.create
9
- aws.create_topic_subscription(heroku.notifications_endpoint)
10
- end