filepond-rails 0.1.0 → 1.0.0

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: 1d4db40f90628c511fd73a636ce3c513fd01d9db16249bf99ceb5966ea9c4469
4
- data.tar.gz: ff09c1019e75f8c9aaa002397e8b797f88848e94ea4ce4deee80eaa7f6125050
3
+ metadata.gz: 3371b4f31b36a228ececa27ed2d98c2a5a1db0464ef699ee04f8d33024fa6c66
4
+ data.tar.gz: cf05bcc5c842119fefa32ccb135fe04470182f141f7ea141c98d1e0fb6922188
5
5
  SHA512:
6
- metadata.gz: b57aa9177e77918141ec1bfd2fc694f7d5ace8d37c00d7f46c6637d981f3280e6196b65447042d981f480ae825fa89323ee1fbe19b28d7e6a15804fcffec64bb
7
- data.tar.gz: 135ff06a64a2c6135d524644e5597a68416f2bd3ba1a824d8e8e9ebcbf96f1d51ecf633d1c2d7f32d1ee2031d925692e7a1d40592fa766f00acdd4eab61d0677
6
+ metadata.gz: a147658ff35f3fdac1827daa0d7a25e9ca7d4a3186f8ef4a262a9b76e806fbebd1542ee8d3e2c0a42a7d5da58fd3b686af46276f4d91b60d0b916de618450c38
7
+ data.tar.gz: df0bfab28be9c3dbca0ae60c8099650bf598a03cdc6133ade8077929f1f7c6d56530b45ffaaedb057b4144f062eae5ba139c864b65b4b9e1fd667f953fc0f1cf
data/README.md CHANGED
@@ -1,28 +1,26 @@
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
+
3
6
  This gem allows you to quickly integrate [FilePond](https://github.com/pqina/filepond) with your Ruby on Rails app.
4
7
 
5
8
  ## Requirements
6
9
  * Rails 7.0.x and above
7
- * Use of [importmap-rails](https://github.com/rails/importmap-rails) (optional)
10
+ * Use of [importmap-rails](https://github.com/rails/importmap-rails)
8
11
 
9
12
  ## Installation
10
13
  Add this line to your application's Gemfile:
11
14
 
12
15
  ```ruby
13
- gem "filepond-rails"
16
+ gem 'filepond-rails'
14
17
  ```
15
18
 
16
- And then execute:
19
+ And then run:
17
20
  ```bash
18
21
  $ bundle
19
22
  ```
20
23
 
21
- Or install it yourself as:
22
- ```bash
23
- $ gem install filepond-rails
24
- ```
25
-
26
24
  Add the following to your `application.css`:
27
25
  ```css
28
26
  *= require 'filepond'
@@ -77,5 +75,33 @@ The gem's JavaScript provide two available exports:
77
75
  1. `FilePond` (which corresponds to the original FilePond library)
78
76
  2. `FilePondRails` (which is a convenience helper that integrates and sets up FilePond to work with our `FilePond::Rails::IngressController`
79
77
 
78
+ ## Development
79
+
80
+ filepond-rails is configured with Docker to help developer-contributors be able to easily work on this gem locally.
81
+
82
+ To get started:
83
+
84
+ 1. Fork this repository
85
+ 2. git clone it to your local machine and cd into it
86
+ 3. Run `docker compose build`
87
+
88
+ To run the gem through the "dummy" app, run:
89
+
90
+ ```bash
91
+ docker compose up
92
+ ```
93
+
94
+ To enter the development environment where you can run `bin/rails g controller` and other commands:
95
+
96
+ ```bash
97
+ docker compose run app bash
98
+ ```
99
+
100
+ You should now be able to run tests locally within this bash container:
101
+
102
+ ```bash
103
+ bin/rails test
104
+ ```
105
+
80
106
  ## License
81
107
  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.0'
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.0
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: 2022-12-29 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>