filepond-rails 0.1.0 → 1.0.1

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: 1d4db40f90628c511fd73a636ce3c513fd01d9db16249bf99ceb5966ea9c4469
4
- data.tar.gz: ff09c1019e75f8c9aaa002397e8b797f88848e94ea4ce4deee80eaa7f6125050
3
+ metadata.gz: 65d7df9190660aec85b162da3fc1f36c1bed56603c83629fcf99ac7ea3ba357a
4
+ data.tar.gz: 4e1786689556648f036cb00d911519af881ccfabc67bf364a919287b954113e5
5
5
  SHA512:
6
- metadata.gz: b57aa9177e77918141ec1bfd2fc694f7d5ace8d37c00d7f46c6637d981f3280e6196b65447042d981f480ae825fa89323ee1fbe19b28d7e6a15804fcffec64bb
7
- data.tar.gz: 135ff06a64a2c6135d524644e5597a68416f2bd3ba1a824d8e8e9ebcbf96f1d51ecf633d1c2d7f32d1ee2031d925692e7a1d40592fa766f00acdd4eab61d0677
6
+ metadata.gz: 405d98436dc4cbdebf1226ef2daf9daa18cf98de424e5e5736b96c4161509268d8adb2938ee233a4ad299e6ea97e0321ae832c251f7ca3c4c3615181e9d661b8
7
+ data.tar.gz: e9acc6c60e3744595eb5280312baafc70769b7be8915d2980bfeb3f2e32123c877d8eb432f7f9be6765cee3af1559468279a28d39cd0ab3c12dd00d97715f202
data/README.md CHANGED
@@ -1,28 +1,27 @@
1
1
  # filepond-rails
2
2
 
3
+ ![example workflow](https://github.com/Code-With-Rails/filepond-rails/actions/workflows/ci.yml/badge.svg)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/filepond-rails.svg)](https://badge.fury.io/rb/filepond-rails)
6
+
3
7
  This gem allows you to quickly integrate [FilePond](https://github.com/pqina/filepond) with your Ruby on Rails app.
4
8
 
5
9
  ## Requirements
6
10
  * Rails 7.0.x and above
7
- * Use of [importmap-rails](https://github.com/rails/importmap-rails) (optional)
11
+ * Use of [importmap-rails](https://github.com/rails/importmap-rails)
8
12
 
9
13
  ## Installation
10
14
  Add this line to your application's Gemfile:
11
15
 
12
16
  ```ruby
13
- gem "filepond-rails"
17
+ gem 'filepond-rails'
14
18
  ```
15
19
 
16
- And then execute:
20
+ And then run:
17
21
  ```bash
18
22
  $ bundle
19
23
  ```
20
24
 
21
- Or install it yourself as:
22
- ```bash
23
- $ gem install filepond-rails
24
- ```
25
-
26
25
  Add the following to your `application.css`:
27
26
  ```css
28
27
  *= require 'filepond'
@@ -77,5 +76,33 @@ The gem's JavaScript provide two available exports:
77
76
  1. `FilePond` (which corresponds to the original FilePond library)
78
77
  2. `FilePondRails` (which is a convenience helper that integrates and sets up FilePond to work with our `FilePond::Rails::IngressController`
79
78
 
79
+ ## Development
80
+
81
+ filepond-rails is configured with Docker to help developer-contributors be able to easily work on this gem locally.
82
+
83
+ To get started:
84
+
85
+ 1. Fork this repository
86
+ 2. git clone it to your local machine and cd into it
87
+ 3. Run `docker compose build`
88
+
89
+ To run the gem through the "dummy" app, run:
90
+
91
+ ```bash
92
+ docker compose up
93
+ ```
94
+
95
+ To enter the development environment where you can run `bin/rails g controller` and other commands:
96
+
97
+ ```bash
98
+ docker compose run app bash
99
+ ```
100
+
101
+ You should now be able to run tests locally within this bash container:
102
+
103
+ ```bash
104
+ bin/rails test && bin/rails app:test:system
105
+ ```
106
+
80
107
  ## License
81
108
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -59,7 +59,7 @@ let FilePondRails = {
59
59
  FilePondRails.input = input
60
60
 
61
61
  // Initialize FilePond on our element
62
- FilePond.create(input, FilePondRails.default_options)
62
+ return FilePond.create(input, FilePondRails.default_options)
63
63
  }
64
64
  }
65
65
 
@@ -13,20 +13,24 @@ module Filepond
13
13
  # The alternative way would be to directly proxy the request to
14
14
  # the URL where the file is originally hosted.
15
15
  def fetch
16
- # We explicitly declare this for clarity of what is in the
17
- # raw_post value as sent by FilePond
18
- uri = URI.parse(raw_post)
19
- url = uri.to_s
20
- blob = ActiveStorage::Blob.create_and_upload!(
21
- io: URI.open(uri),
22
- filename: URI.parse(url).path.parameterize
23
- )
24
- if blob.persisted?
16
+ begin
17
+ # We explicitly declare this for clarity of what is in the
18
+ # raw_post value as sent by FilePond
19
+ uri = URI.parse(raw_post)
20
+ url = uri.to_s
21
+
22
+ blob = ActiveStorage::Blob.create_and_upload!(
23
+ io: URI.open(uri),
24
+ filename: URI.parse(url).path.parameterize
25
+ )
26
+
25
27
  redirect_to ::Rails.application.routes.url_helpers.rails_service_blob_path(
26
28
  blob.signed_id,
27
29
  blob.filename
28
30
  )
29
- else
31
+ # Why we casting such a wide net with StandardError (TL;DR: too many errors to catch):
32
+ # See https://stackoverflow.com/a/46979718/20551849
33
+ rescue StandardError
30
34
  head :unprocessable_entity
31
35
  end
32
36
  end
@@ -39,8 +43,7 @@ module Filepond
39
43
  signed_id = raw_post
40
44
 
41
45
  blob = ActiveStorage::Blob.find_signed(signed_id)
42
- if blob
43
- blob.purge
46
+ if blob && blob.purge
44
47
  head :ok
45
48
  else
46
49
  # If we cannot find the blob, then we'll just return 404
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Filepond
4
4
  module Rails
5
- VERSION = '0.1.0'
5
+ VERSION = '1.0.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filepond-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Chiu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-26 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: puma
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '6.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '6.0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: rubocop
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +51,6 @@ dependencies:
37
51
  - - "~>"
38
52
  - !ruby/object:Gem::Version
39
53
  version: '1.1'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.1.4
43
54
  type: :development
44
55
  prerelease: false
45
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +58,62 @@ dependencies:
47
58
  - - "~>"
48
59
  - !ruby/object:Gem::Version
49
60
  version: '1.1'
61
+ - !ruby/object:Gem::Dependency
62
+ name: webmock
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.18'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.18'
75
+ - !ruby/object:Gem::Dependency
76
+ name: capybara
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: dropybara
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: selenium-webdriver
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
50
114
  - - ">="
51
115
  - !ruby/object:Gem::Version
52
- version: 1.1.4
116
+ version: '0'
53
117
  description: Add FilePond server endpoints and form helpers for Rails
54
118
  email:
55
119
  - simon@furvur.com
@@ -66,11 +130,6 @@ files:
66
130
  - app/assets/stylesheets/filepond.min.css
67
131
  - app/controllers/filepond/rails/application_controller.rb
68
132
  - app/controllers/filepond/rails/ingress_controller.rb
69
- - app/helpers/filepond/rails/application_helper.rb
70
- - app/jobs/filepond/rails/application_job.rb
71
- - app/mailers/filepond/rails/application_mailer.rb
72
- - app/models/filepond/rails/application_record.rb
73
- - app/views/layouts/filepond/rails/application.html.erb
74
133
  - config/importmap.rb
75
134
  - config/routes.rb
76
135
  - lib/filepond/rails.rb
@@ -100,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
159
  - !ruby/object:Gem::Version
101
160
  version: '0'
102
161
  requirements: []
103
- rubygems_version: 3.3.3
162
+ rubygems_version: 3.4.1
104
163
  signing_key:
105
164
  specification_version: 4
106
165
  summary: FilePond integration for Rails
@@ -1,6 +0,0 @@
1
- module Filepond
2
- module Rails
3
- module ApplicationHelper
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Filepond
2
- module Rails
3
- class ApplicationJob < ActiveJob::Base
4
- end
5
- end
6
- end
@@ -1,8 +0,0 @@
1
- module Filepond
2
- module Rails
3
- class ApplicationMailer < ActionMailer::Base
4
- default from: "from@example.com"
5
- layout "mailer"
6
- end
7
- end
8
- end
@@ -1,7 +0,0 @@
1
- module Filepond
2
- module Rails
3
- class ApplicationRecord < ActiveRecord::Base
4
- self.abstract_class = true
5
- end
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Filepond rails</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <%= stylesheet_link_tag "filepond/rails/application", media: "all" %>
9
- </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
14
- </body>
15
- </html>