active_storage_base64 0.1.4 → 2.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: a89024b9798e7c3adfef588638e62623c6891eb52ad0d6ba2aebfa1a603dd6ce
4
- data.tar.gz: 405e6a9a85a3b3755e06e8f4b958d5731d0558b73bc41ff71dc048dcd5b630c3
3
+ metadata.gz: 7f6c1d529089b0f279a3772aa6dd1aa44dce8bc5b0eca8cbca52433a786bbc98
4
+ data.tar.gz: fd92fb0cae792e16221301f59d346a73df4d60579f1f4dbb36235f29f6f242ae
5
5
  SHA512:
6
- metadata.gz: 39d2cbb297b0e4cabc48543917b1c2c4ec7c5f1b12578f384cebd8ea1824a369a0561aac0ead6e72a8f4e28669e56c053d2dc59f242bf63d9bf526be7c7f49a6
7
- data.tar.gz: d1910ba15650555ece8837356b2c580a22a214f7357918422eaf38d6bdfebb88b8e4d452250d51bfab7be8f3b2fb4e141f45c625988dd2afd09491b059536b72
6
+ metadata.gz: c1def5ffac22e0f855862672df7f629d5bf0cbe77b1c5ceec49dc08aad849d9957a84f82357e664fb2d2d2feb2f7750416a340f4b0bcd5f90e4eb5fc8667d583
7
+ data.tar.gz: bbf89ca79423cb55dca6ac6f8dbe4a4769725fcfa5d42dc85c842eb86e965336ef7a57d85bfaf296fd75959d6f79e3f0c1c2784b61d3dd425b8ef7dab735d270
data/README.md CHANGED
@@ -1,29 +1,25 @@
1
- [![Build Status](https://travis-ci.org/rootstrap/active-storage-base64.svg?branch=master)](https://travis-ci.org/rootstrap/active-storage-base64)
1
+ [![CI](https://github.com/rootstrap/active-storage-base64/actions/workflows/ci.yml/badge.svg)](https://github.com/rootstrap/active-storage-base64/actions/workflows/ci.yml)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/0da0a0901cedd72aeb10/maintainability)](https://codeclimate.com/github/rootstrap/active-storage-base64/maintainability)
3
3
  [![Test Coverage](https://api.codeclimate.com/v1/badges/0da0a0901cedd72aeb10/test_coverage)](https://codeclimate.com/github/rootstrap/active-storage-base64/test_coverage)
4
4
 
5
5
  # ActiveStorageBase64
6
6
 
7
- Gem used to add support for base64 images for Rails's ActiveStorage.
7
+ Adds support for base64 attachments to ActiveStorage.
8
8
 
9
- ## Getting Started
9
+ ## Installation
10
10
 
11
11
  In order to get the gem working on your project you just need to add the gem to your project like this:
12
12
  ```ruby
13
13
  gem 'active_storage_base64'
14
14
  ```
15
15
 
16
- ### Prerequisites
16
+ ## Prerequisites
17
17
 
18
- The only two prerequisites for using this gem are having Rails version 5.2.0 or higher installed on your project and having ActiveStorage setup properly (for more information on how to do this, check this [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html))
18
+ The only prerequisites for using this gem are having Rails version 6.1 or higher installed on your project and having ActiveStorage properly set up (for more information on how to do this, check [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html))
19
19
 
20
- ```ruby
21
- gem 'rails', '5.2.0'
22
- ```
23
-
24
- ### Installing
20
+ ## Usage
25
21
 
26
- In order to use the gem's functionality, you'll need to include the module into your ActiveRecord inheriting class.
22
+ In order to use the gem's functionality, you need to include the `ActiveStorageSupport::SupportForBase64` module in your ActiveRecord models.
27
23
  For example:
28
24
  ```ruby
29
25
  class User < ActiveRecord::Base
@@ -32,7 +28,7 @@ end
32
28
  ```
33
29
 
34
30
  Note:
35
- We highly recomment using an alternative class that inherits from ActiveRecord and includes the module so instead of including the module for each of your classes, you make them inherit from this new class, check below:
31
+ We highly recommend using an alternative class that inherits from `ActiveRecord::Base` and includes the module so instead of including the module for each of your classes, you make them inherit from this new class, check below:
36
32
  ```ruby
37
33
  class ApplicationRecord < ActiveRecord::Base
38
34
  include ActiveStorageSupport::SupportForBase64
@@ -43,7 +39,7 @@ class User < ApplicationRecord
43
39
  end
44
40
  ```
45
41
 
46
- After you have the module included in your class you'll be able to use the following two helper methods for working with base64 files:
42
+ After you have the module included in your class you'll be able to use the following two helper methods to work with base64 files:
47
43
  When you need a single image attached:
48
44
  ```ruby
49
45
  has_one_base64_attached
@@ -54,7 +50,7 @@ has_many_base64_attached
54
50
  ```
55
51
  These helpers will work just like the `has_one_attached` and `has_many_attached` helper methods from ActiveStorage.
56
52
 
57
- A working example for this, assuming we have a model `User` with only an `avatar` attached would be:
53
+ A working example for this, assuming we have a model `User` with an `avatar` attached would be:
58
54
  ```ruby
59
55
  class User < ActiveRecord::Base
60
56
  include ActiveStorageSupport::SupportForBase64
@@ -63,7 +59,7 @@ class User < ActiveRecord::Base
63
59
  end
64
60
  ```
65
61
 
66
- on your controller you could do something like this:
62
+ on your controller you could do any of the following:
67
63
  ```ruby
68
64
  class UsersController < ApplicationController
69
65
  def create
@@ -73,17 +69,16 @@ class UsersController < ApplicationController
73
69
  private
74
70
 
75
71
  def user_params
76
- params.require(:user).permit(avatar: [:data], :username, :email)
72
+ params.require(:user).permit(avatar: :data, :username, :email)
77
73
  end
78
74
  end
79
75
  ```
80
76
 
81
- Or you could also do:
82
77
  ```ruby
83
78
  class UsersController < ApplicationController
84
79
  def create
85
80
  user = User.create(user_params)
86
- user.avatar.attach(params[:avatar])
81
+ user.avatar.attach(data: params[:avatar]) # params[:avatar] => 'data:image/png;base64,[base64 data]'
87
82
  end
88
83
 
89
84
  private
@@ -94,12 +89,11 @@ class UsersController < ApplicationController
94
89
  end
95
90
  ```
96
91
 
97
- Here's another option to achieve the same:
98
92
  ```ruby
99
93
  class UsersController < ApplicationController
100
94
  def create
101
95
  user = User.create(user_params)
102
- user.avatar = { data: params[:avatar] }
96
+ user.avatar.attach(avatar_params) # avatar_params => { data: 'data:image/png;base64,[base64 data]' }
103
97
  end
104
98
 
105
99
  private
@@ -107,18 +101,38 @@ class UsersController < ApplicationController
107
101
  def user_params
108
102
  params.require(:user).permit(:username, :email)
109
103
  end
104
+
105
+ def avatar_params
106
+ params.require(:avatar).permit(:data)
107
+ end
110
108
  end
111
109
  ```
112
110
 
113
- ## Specifying a filename or content_type
111
+ ```ruby
112
+ class UsersController < ApplicationController
113
+ def create
114
+ user = User.create(user_params)
115
+ user.avatar = { data: params[:avatar] } # params[:avatar] => 'data:image/png;base64,[base64 data]'
116
+ user.save
117
+ end
118
+
119
+ private
114
120
 
115
- If you are willing to add a specific filename to your attachment, or send in a specific content_type for your file, you can use `data:` to attach the base64 data and specify your `filename:`, `content_type:` and/or `identify:` hash keys.
121
+ def user_params
122
+ params.require(:user).permit(:username, :email)
123
+ end
124
+ end
125
+ ```
126
+
127
+ ### Specifying a filename or content type
128
+
129
+ If you are willing to add a specific filename to your attachment, or send in a specific content type for your file, you can use `data:` to attach the base64 data and specify your `filename:`, `content_type:` and/or `identify:` hash keys.
116
130
  Check the following example:
117
131
  ```ruby
118
132
  class UsersController < ApplicationController
119
133
  def create
120
134
  user = User.create(user_params)
121
- user.avatar.attach(data: params[:avatar], filename: 'your_filename', content_type: 'content/type', identify: 'false')
135
+ user.avatar.attach(data: params[:avatar], filename: 'your_filename', content_type: 'content/type', identify: 'false') # params[:avatar] => 'data:image/png;base64,[base64 data]'
122
136
  end
123
137
 
124
138
  private
@@ -147,7 +161,13 @@ class UsersController < ApplicationController
147
161
  end
148
162
  ```
149
163
 
150
- For more information on how to work with ActiveStorage, please check the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) mentioned above, all points in there apply to this gem as well.
164
+ ### Data Format
165
+
166
+ To attach base64 data it is required to come in the form of [Data URIs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) .
167
+ For example:
168
+ ```
169
+ data:image/png;base64,[base64 data]
170
+ ```
151
171
 
152
172
  ## Contributing
153
173
 
@@ -4,6 +4,8 @@ module ActiveStorageSupport
4
4
  module_function
5
5
 
6
6
  def attachment_from_data(attachment)
7
+ attachment = attachment.to_h if attachment.is_a?(ActionController::Parameters)
8
+
7
9
  if attachment.is_a?(Hash)
8
10
  attachment = attachment.symbolize_keys
9
11
  fill_attachment_data(attachment, attachment.delete(:data))
@@ -12,6 +14,7 @@ module ActiveStorageSupport
12
14
  attachment
13
15
  end
14
16
 
17
+ # rubocop:disable Metrics/AbcSize
15
18
  def fill_attachment_data(attachment, base64_data)
16
19
  return unless base64_data.try(:is_a?, String) && base64_data.strip.start_with?('data')
17
20
 
@@ -22,6 +25,7 @@ module ActiveStorageSupport
22
25
  attachment[:content_type] ||= content_type(headers)
23
26
  attachment[:filename] ||= Time.current.to_i.to_s
24
27
  end
28
+ # rubocop:enable Metrics/AbcSize
25
29
 
26
30
  def content_type(headers)
27
31
  headers =~ /^data:(.*?)$/
@@ -1,12 +1,14 @@
1
1
  module ActiveStorageSupport
2
2
  class Base64Many < ActiveStorage::Attached::Many
3
3
  def attach(*attachables)
4
- super base64_attachments(attachables)
4
+ super self.class.from_base64(attachables)
5
5
  end
6
6
 
7
- def base64_attachments(attachments)
8
- attachments.flatten.map do |attachment|
9
- ActiveStorageSupport::Base64Attach.attachment_from_data(attachment)
7
+ def self.from_base64(attachables)
8
+ attachables = [attachables] unless attachables.is_a?(Array)
9
+
10
+ attachables.flatten.map do |attachable|
11
+ ActiveStorageSupport::Base64Attach.attachment_from_data(attachable)
10
12
  end
11
13
  end
12
14
  end
@@ -1,8 +1,11 @@
1
1
  module ActiveStorageSupport
2
2
  class Base64One < ActiveStorage::Attached::One
3
3
  def attach(attachable)
4
- attachment = ActiveStorageSupport::Base64Attach.attachment_from_data(attachable)
5
- super attachment
4
+ super self.class.from_base64(attachable)
5
+ end
6
+
7
+ def self.from_base64(attachable)
8
+ ActiveStorageSupport::Base64Attach.attachment_from_data(attachable)
6
9
  end
7
10
  end
8
11
  end
@@ -5,27 +5,63 @@ module ActiveStorageSupport
5
5
  module SupportForBase64
6
6
  extend ActiveSupport::Concern
7
7
  class_methods do
8
- def has_one_base64_attached(name, dependent: :purge_later)
9
- has_one_attached name, dependent: dependent
8
+ def has_one_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false, &block)
9
+ has_one_attached name, dependent: dependent, service: service, strict_loading: strict_loading, &block
10
10
 
11
- add_helper_method(ActiveStorageSupport::Base64One, name, dependent: dependent)
12
- end
13
-
14
- def has_many_base64_attached(name, dependent: :purge_later)
15
- has_many_attached name, dependent: dependent
11
+ generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
12
+ # frozen_string_literal: true
13
+ def #{name}
14
+ @active_storage_attached ||= {}
15
+ @active_storage_attached[:#{name}] ||= ActiveStorageSupport::Base64One.new("#{name}", self)
16
+ end
16
17
 
17
- add_helper_method(ActiveStorageSupport::Base64Many, name, dependent: dependent)
18
+ def #{name}=(attachable)
19
+ attachment_changes["#{name}"] =
20
+ if attachable.nil?
21
+ ActiveStorage::Attached::Changes::DeleteOne.new("#{name}", self)
22
+ else
23
+ ActiveStorage::Attached::Changes::CreateOne.new(
24
+ "#{name}", self, ActiveStorageSupport::Base64One.from_base64(attachable)
25
+ )
26
+ end
27
+ end
28
+ CODE
18
29
  end
19
30
 
20
- def add_helper_method(type, name, dependent:)
21
- class_eval <<-CODE, __FILE__, __LINE__ + 1
31
+ def has_many_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false, &block)
32
+ has_many_attached name, dependent: dependent, service: service, strict_loading: strict_loading, &block
33
+
34
+ generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
35
+ # frozen_string_literal: true
22
36
  def #{name}
23
- @active_storage_attached_#{name} ||=
24
- #{type}.new("#{name}", self, dependent: #{dependent == :purge_later ? ':purge_later' : 'false'})
37
+ @active_storage_attached ||= {}
38
+ @active_storage_attached[:#{name}] ||= ActiveStorageSupport::Base64Many.new("#{name}", self)
25
39
  end
26
40
 
27
- def #{name}=(data)
28
- #{name}.attach(data)
41
+ def #{name}=(attachables)
42
+ if ActiveStorage.replace_on_assign_to_many
43
+ attachment_changes["#{name}"] =
44
+ if Array(attachables).none?
45
+ ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
46
+ else
47
+ ActiveStorage::Attached::Changes::CreateMany.new(
48
+ "#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables)
49
+ )
50
+ end
51
+ else
52
+ ActiveSupport::Deprecation.warn \
53
+ "config.active_storage.replace_on_assign_to_many is deprecated and will be removed in Rails 7.1. " \
54
+ "Make sure that your code works well with config.active_storage.replace_on_assign_to_many set to true before upgrading. " \
55
+ "To append new attachables to the Active Storage association, prefer using `attach`. " \
56
+ "Using association setter would result in purging the existing attached attachments and replacing them with new ones."
57
+
58
+ if Array(attachables).any?
59
+ attachment_changes["#{name}"] =
60
+ ActiveStorage::Attached::Changes::CreateMany.new(
61
+ "#{name}", self, #{name}.blobs + ActiveStorageSupport::Base64Many.from_base64(attachables)
62
+ )
63
+ end
64
+ end
29
65
  end
30
66
  CODE
31
67
  end
metadata CHANGED
@@ -1,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Cortio
8
+ - Santiago Bartesaghi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-05-08 00:00:00.000000000 Z
12
+ date: 2021-12-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
- version: '5.2'
20
+ version: '7.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - "~>"
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
- version: '5.2'
27
+ version: '7.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: pry-rails
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +45,14 @@ dependencies:
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: 4.8.1
48
+ version: 6.0.6
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: 4.8.1
55
+ version: 6.0.6
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: rspec-rails
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -72,61 +73,66 @@ dependencies:
72
73
  requirements:
73
74
  - - "~>"
74
75
  - !ruby/object:Gem::Version
75
- version: 0.56.0
76
+ version: 1.22.0
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - "~>"
81
82
  - !ruby/object:Gem::Version
82
- version: 0.56.0
83
+ version: 1.22.0
83
84
  - !ruby/object:Gem::Dependency
84
85
  name: simplecov
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
- - - ">="
88
+ - - "~>"
88
89
  - !ruby/object:Gem::Version
89
- version: '0'
90
+ version: 0.17.1
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - ">="
95
+ - - "~>"
95
96
  - !ruby/object:Gem::Version
96
- version: '0'
97
+ version: 0.17.1
97
98
  - !ruby/object:Gem::Dependency
98
99
  name: sqlite3
99
100
  requirement: !ruby/object:Gem::Requirement
100
101
  requirements:
101
102
  - - '='
102
103
  - !ruby/object:Gem::Version
103
- version: 1.3.13
104
+ version: 1.4.2
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - '='
109
110
  - !ruby/object:Gem::Version
110
- version: 1.3.13
111
+ version: 1.4.2
112
+ - !ruby/object:Gem::Dependency
113
+ name: image_processing
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.2'
111
126
  description: Base64 support for ActiveStorage
112
- email: ricardo@rootstrap.com
127
+ email:
128
+ - ricardo@rootstrap.com
129
+ - santiago.bartesaghi@rootstrap.com
113
130
  executables: []
114
131
  extensions: []
115
132
  extra_rdoc_files: []
116
133
  files:
117
- - ".gitignore"
118
- - ".rspec"
119
- - ".rubocop.yml"
120
- - ".travis.yml"
121
- - CODE_OF_CONDUCT.md
122
- - CONTRIBUTING.md
123
- - Gemfile
124
134
  - LICENSE.txt
125
135
  - README.md
126
- - Rakefile
127
- - active_storage_base64.gemspec
128
- - config.reek
129
- - gemfiles/RailsHeadGemfile
130
136
  - lib/active_storage_base64.rb
131
137
  - lib/active_storage_support/base64_attach.rb
132
138
  - lib/active_storage_support/base64_many.rb
@@ -144,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
150
  requirements:
145
151
  - - ">="
146
152
  - !ruby/object:Gem::Version
147
- version: 2.2.2
153
+ version: 2.7.0
148
154
  required_rubygems_version: !ruby/object:Gem::Requirement
149
155
  requirements:
150
156
  - - ">="
151
157
  - !ruby/object:Gem::Version
152
158
  version: '0'
153
159
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.7.6
160
+ rubygems_version: 3.0.3
156
161
  signing_key:
157
162
  specification_version: 4
158
163
  summary: Base64 support for ActiveStorage
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- Gemfile.lock
2
- spec/dummy/log
3
- spec/dummy/db/**.sqlite3
4
- /coverage/
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --format d
data/.rubocop.yml DELETED
@@ -1,67 +0,0 @@
1
- Documentation:
2
- Enabled: false
3
-
4
- Layout/SpaceBeforeFirstArg:
5
- Exclude:
6
-
7
- Lint/AmbiguousBlockAssociation:
8
- Exclude:
9
- - spec/**/*
10
-
11
- Metrics/AbcSize:
12
- # The ABC size is a calculated magnitude, so this number can be an Integer or
13
- # a Float.
14
- Max: 15
15
-
16
- Metrics/BlockLength:
17
- CountComments: false # count full line comments?
18
- Max: 25
19
- Exclude:
20
- - config/**/*
21
- - spec/**/*
22
-
23
- Metrics/BlockNesting:
24
- Max: 4
25
-
26
- Metrics/ClassLength:
27
- CountComments: false # count full line comments?
28
- Max: 200
29
-
30
- # Avoid complex methods.
31
- Metrics/CyclomaticComplexity:
32
- Max: 7
33
-
34
- Metrics/MethodLength:
35
- CountComments: false # count full line comments?
36
- Max: 24
37
-
38
- Metrics/ModuleLength:
39
- CountComments: false # count full line comments?
40
- Max: 200
41
-
42
- Metrics/LineLength:
43
- Max: 100
44
- # To make it possible to copy or click on URIs in the code, we allow lines
45
- # containing a URI to be longer than Max.
46
- AllowURI: true
47
- URISchemes:
48
- - http
49
- - https
50
- Exclude:
51
- - spec/dummy/db/schema.rb
52
-
53
- Metrics/ParameterLists:
54
- Max: 5
55
- CountKeywordArgs: true
56
-
57
- Metrics/PerceivedComplexity:
58
- Max: 12
59
-
60
- Style/FrozenStringLiteralComment:
61
- Enabled: false
62
-
63
- Style/ModuleFunction:
64
- Enabled: false
65
-
66
- Naming/PredicateName:
67
- Enabled: false
data/.travis.yml DELETED
@@ -1,29 +0,0 @@
1
- language: ruby
2
-
3
- before_install:
4
- - gem install bundler -v "~> 1.17"
5
-
6
- rvm:
7
- - 2.2.8
8
- - 2.3.5
9
- - 2.4.2
10
- - 2.5.0
11
- - ruby-head
12
-
13
- sudo: false
14
-
15
- env:
16
- global:
17
- - CC_TEST_REPORTER_ID=7196b4aa257fde33f24463218af32db6a6efd23d9148204822f757fa614a093e
18
-
19
- before_script:
20
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
21
- - chmod +x ./cc-test-reporter
22
- - ./cc-test-reporter before-build
23
-
24
- script:
25
- - bundle exec rake code_analysis
26
- - bundle exec rspec
27
-
28
- after_script:
29
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CODE_OF_CONDUCT.md DELETED
@@ -1,78 +0,0 @@
1
- Contributor Covenant Code of Conduct
2
-
3
- Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, sex characteristics, gender identity and expression,
9
- level of experience, education, socio-economic status, nationality, personal
10
- appearance, race, religion, or sexual identity and orientation.
11
-
12
- Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
-
18
- * Using welcoming and inclusive language
19
- * Being respectful of differing viewpoints and experiences
20
- * Gracefully accepting constructive criticism
21
- * Focusing on what is best for the community
22
- * Showing empathy towards other community members
23
-
24
-
25
- Examples of unacceptable behavior by participants include:
26
-
27
-
28
- * The use of sexualized language or imagery and unwelcome sexual attention or
29
- advances
30
- * Trolling, insulting/derogatory comments, and personal or political attacks
31
- * Public or private harassment
32
- * Publishing others’ private information, such as a physical or electronic
33
- address, without explicit permission
34
- * Other conduct which could reasonably be considered inappropriate in a
35
- professional setting
36
-
37
-
38
- Our Responsibilities
39
-
40
- Project maintainers are responsible for clarifying the standards of acceptable
41
- behavior and are expected to take appropriate and fair corrective action in
42
- response to any instances of unacceptable behavior.
43
-
44
- Project maintainers have the right and responsibility to remove, edit, or
45
- reject comments, commits, code, wiki edits, issues, and other contributions
46
- that are not aligned to this Code of Conduct, or to ban temporarily or
47
- permanently any contributor for other behaviors that they deem inappropriate,
48
- threatening, offensive, or harmful.
49
-
50
- Scope
51
-
52
- This Code of Conduct applies both within project spaces and in public spaces
53
- when an individual is representing the project or its community. Examples of
54
- representing a project or community include using an official project e-mail
55
- address, posting via an official social media account, or acting as an appointed
56
- representative at an online or offline event. Representation of a project may be
57
- further defined and clarified by project maintainers.
58
-
59
- Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported by contacting the project team at ricardo@rootstrap.com. All
63
- complaints will be reviewed and investigated and will result in a response that
64
- is deemed necessary and appropriate to the circumstances. The project team is
65
- obligated to maintain confidentiality with regard to the reporter of an incident.
66
- Further details of specific enforcement policies may be posted separately.
67
-
68
- Project maintainers who do not follow or enforce the Code of Conduct in good
69
- faith may face temporary or permanent repercussions as determined by other
70
- members of the project’s leadership.
71
-
72
- Attribution
73
-
74
- This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
75
- available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
76
-
77
- For answers to common questions about this code of conduct, see
78
- https://www.contributor-covenant.org/faq
data/CONTRIBUTING.md DELETED
@@ -1,42 +0,0 @@
1
- ## Contributing ##
2
-
3
- You can contribute to this repo if you have an issue, found a bug or think there's some functionality required that would add value to the gem. To do so, please check if there's not already an [issue](https://github.com/rootstrap/active-storage-base64/issues) for that, if you find there's not, create a new one with as much detail as possible.
4
-
5
- If you want to contribute with code as well, please follow the next steps:
6
-
7
- 1. Read, understand and agree to our [code of conduct](https://github.com/rootstrap/active-storage-base64/blob/master/CODE_OF_CONDUCT.md)
8
- 2. [Fork the repo](https://help.github.com/articles/about-forks/)
9
- 3. Clone the project into your machine:
10
- `$ git clone git@github.com:[YOUR GITHUB USERNAME]/active-storage-base64.git`
11
- 4. Access the repo:
12
- `$ cd active-storage-base64`
13
- 5. Create your feature/bugfix branch:
14
- `$ git checkout -b your_new_feature`
15
- or
16
- `$ git checkout -b fix/your_fix` in case of a bug fix
17
- (if your PR is to address an existing issue, it would be good to name the branch after the issue, for example: if you are trying to solve issue 182, then a good idea for the branch name would be `182_your_new_feature`)
18
- 6. Write tests for your changes (feature/bug)
19
- 7. Code your (feature/bugfix)
20
- 8. Run the code analysis tool by doing:
21
- `$ rake code_analysis`
22
- 9. Run the tests:
23
- `$ bundle exec rspec`
24
- All tests must pass. If all tests (both code analysis and rspec) do pass, then you are ready to go to the next step:
25
- 10. Commit your changes:
26
- `$ git commit -m 'Your feature or bugfix title'`
27
- 11. Push to the branch `$ git push origin your_new_feature`
28
- 12. Create a new [pull request](https://help.github.com/articles/creating-a-pull-request/)
29
-
30
- Some helpful guides that will help you know how we work:
31
- 1. [Code review](https://github.com/rootstrap/tech-guides/tree/master/code-review)
32
- 2. [GIT workflow](https://github.com/rootstrap/tech-guides/tree/master/git)
33
- 3. [Ruby style guide](https://github.com/rootstrap/tech-guides/tree/master/ruby)
34
- 4. [Rails style guide](https://github.com/rootstrap/tech-guides/blob/master/ruby/rails.md)
35
- 5. [RSpec style guide](https://github.com/rootstrap/tech-guides/blob/master/ruby/rspec/README.md)
36
-
37
- For more information or guides like the ones mentioned above, please check our [tech guides](https://github.com/rootstrap/tech-guides). Keep in mind that the more you know about these guides, the easier it will be for your code to get approved and merged.
38
-
39
- Note: We work with one commit per pull request, so if you make your commit and realize you were missing something or want to add something more to it, don't create a new commit with the changes, but use `$ git commit --amend` instead. This same principle also applies for when changes are requested on an open pull request.
40
-
41
-
42
- Thank you very much for your time and for considering helping in this project.
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,4 +0,0 @@
1
- task :code_analysis do
2
- sh 'bundle exec rubocop lib spec'
3
- sh 'bundle exec reek lib'
4
- end
@@ -1,29 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'active_storage_base64'
3
- s.version = '0.1.4'
4
- s.summary = 'Base64 support for ActiveStorage'
5
- s.description = s.summary
6
-
7
- s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
8
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
9
- end
10
-
11
- s.require_paths = ['lib']
12
- s.authors = ['Ricardo Cortio']
13
- s.license = 'MIT'
14
- s.homepage = 'https://github.com/rootstrap/active-storage-base64'
15
- s.email = 'ricardo@rootstrap.com'
16
-
17
- s.required_ruby_version = '>= 2.2.2'
18
-
19
- # Dependencies
20
- s.add_dependency 'rails', '~> 5.2'
21
-
22
- # Development dependencies
23
- s.add_development_dependency 'pry-rails', '~> 0.3.6'
24
- s.add_development_dependency 'reek', '~> 4.8.1'
25
- s.add_development_dependency 'rspec-rails', '~> 3.8.0'
26
- s.add_development_dependency 'rubocop', '~> 0.56.0'
27
- s.add_development_dependency 'simplecov'
28
- s.add_development_dependency 'sqlite3', '1.3.13'
29
- end
data/config.reek DELETED
@@ -1,83 +0,0 @@
1
- Attribute:
2
- enabled: false
3
- exclude: []
4
- BooleanParameter:
5
- enabled: true
6
- exclude: []
7
- ClassVariable:
8
- enabled: false
9
- exclude: []
10
- ControlParameter:
11
- enabled: true
12
- exclude: ['ActiveStorageSupport::SupportForBase64#add_helper_method']
13
- DataClump:
14
- enabled: true
15
- exclude: ['ActiveStorageSupport::SupportForBase64']
16
- max_copies: 2
17
- min_clump_size: 2
18
- DuplicateMethodCall:
19
- enabled: true
20
- exclude: []
21
- max_calls: 1
22
- allow_calls: []
23
- FeatureEnvy:
24
- enabled: true
25
- exclude: []
26
- InstanceVariableAssumption:
27
- enabled: false
28
- IrresponsibleModule:
29
- enabled: false
30
- exclude: []
31
- LongParameterList:
32
- enabled: true
33
- exclude: []
34
- max_params: 4
35
- overrides:
36
- initialize:
37
- max_params: 5
38
- LongYieldList:
39
- enabled: true
40
- exclude: []
41
- max_params: 3
42
- NestedIterators:
43
- enabled: true
44
- exclude: []
45
- max_allowed_nesting: 2
46
- ignore_iterators: []
47
- NilCheck:
48
- enabled: false
49
- exclude: []
50
- PrimaDonnaMethod:
51
- enabled: false
52
- exclude: []
53
- RepeatedConditional:
54
- enabled: true
55
- exclude: []
56
- max_ifs: 3
57
- TooManyInstanceVariables:
58
- enabled: true
59
- exclude: []
60
- max_instance_variables: 9
61
- TooManyMethods:
62
- enabled: true
63
- exclude: []
64
- max_methods: 25
65
- TooManyStatements:
66
- enabled: true
67
- exclude: []
68
- max_statements: 12
69
- UncommunicativeMethodName:
70
- enabled: false
71
- UncommunicativeModuleName:
72
- enabled: false
73
- UncommunicativeParameterName:
74
- enabled: false
75
- UncommunicativeVariableName:
76
- enabled: false
77
- UnusedParameters:
78
- enabled: true
79
- exclude: []
80
- UnusedPrivateMethod:
81
- enabled: false
82
- UtilityFunction:
83
- enabled: false
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
-
5
- gem "rails", github: "rails/rails", branch: "master", require: false
6
-
7
- group :test do
8
- gem 'rubocop', '~> 0.56.0'
9
- gem 'reek', '~> 4.8.1'
10
- gem 'rspec-rails', '~> 3.8.0'
11
- gem 'sqlite3', '1.3.13'
12
- gem 'pry-rails', '~> 0.3.6'
13
- end