active_storage_base64 0.1.2 → 1.2.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
- SHA256:
3
- metadata.gz: 3f06ab3b77fc8bc3dd993d1313ad0136d2ab2bdf6a776a0dc7414c5af9fd75c3
4
- data.tar.gz: 5f00568a8b09f02018bb6049203d4a02ffaca06ba7769ac04b8c001e0061fa2b
2
+ SHA1:
3
+ metadata.gz: 8467d90fdcbc07a9672049395a208a4a10d32391
4
+ data.tar.gz: 961a61666f9a74011ab564875c013ec6461e402e
5
5
  SHA512:
6
- metadata.gz: 74e9c1008d1f9dad166133f44014ae715d779eca9d03d1177d4923de2d54db4389840756fac7aadcd09f87beb0eae8b0603f39f520660dc380313557f245107f
7
- data.tar.gz: cdc6293595a7187c91b2543bc67893ba05b605506072686002e123f02ad47d671876399d16acfa26fe1bcea7dfd17c8723db895dac9f23198de5f8d20ea1dead
6
+ metadata.gz: af92f7ff33c42eba9cc2fdecabd06c36adb967a672df2b77e4bc047ff2dd65d907bd9d6de08f801cb5c84e0f94cbe32fd4bd61b5db8ed9ed3e063ea49ebf7c9e
7
+ data.tar.gz: f5638f30bf22ff55b917f2ed816711d3c351c9c5810953b2b1d035486860f075af389ab6f72fcdf2db2bc2ab91bd3ab3308471678ef7b670743dfc3d4a17cd8b
data/README.md CHANGED
@@ -4,26 +4,22 @@
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
- gem 'active-storage-base64'
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 5.2.0 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
- ```
20
+ ## Usage
23
21
 
24
- ### Installing
25
-
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,12 +59,41 @@ 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:
63
+ ```ruby
64
+ class UsersController < ApplicationController
65
+ def create
66
+ user = User.create(user_params)
67
+ end
68
+
69
+ private
70
+
71
+ def user_params
72
+ params.require(:user).permit(avatar: :data, :username, :email)
73
+ end
74
+ end
75
+ ```
76
+
77
+ ```ruby
78
+ class UsersController < ApplicationController
79
+ def create
80
+ user = User.create(user_params)
81
+ user.avatar.attach(data: params[:avatar]) # params[:avatar] => 'data:image/png;base64,[base64 data]'
82
+ end
83
+
84
+ private
85
+
86
+ def user_params
87
+ params.require(:user).permit(:username, :email)
88
+ end
89
+ end
90
+ ```
91
+
67
92
  ```ruby
68
93
  class UsersController < ApplicationController
69
94
  def create
70
95
  user = User.create(user_params)
71
- user.avatar.attach(data: params[:avatar])
96
+ user.avatar.attach(avatar_params) # avatar_params => { data: 'data:image/png;base64,[base64 data]' }
72
97
  end
73
98
 
74
99
  private
@@ -76,15 +101,19 @@ class UsersController < ApplicationController
76
101
  def user_params
77
102
  params.require(:user).permit(:username, :email)
78
103
  end
104
+
105
+ def avatar_params
106
+ params.require(:avatar).permit(:data)
107
+ end
79
108
  end
80
109
  ```
81
110
 
82
- Here's another option to achieve the same:
83
111
  ```ruby
84
112
  class UsersController < ApplicationController
85
113
  def create
86
114
  user = User.create(user_params)
87
- user.avatar = { data: params[:avatar] }
115
+ user.avatar = { data: params[:avatar] } # params[:avatar] => 'data:image/png;base64,[base64 data]'
116
+ user.save
88
117
  end
89
118
 
90
119
  private
@@ -95,15 +124,15 @@ class UsersController < ApplicationController
95
124
  end
96
125
  ```
97
126
 
98
- ## Specifying a filename or content_type
127
+ ### Specifying a filename or content type
99
128
 
100
- 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.
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.
101
130
  Check the following example:
102
131
  ```ruby
103
132
  class UsersController < ApplicationController
104
133
  def create
105
134
  user = User.create(user_params)
106
- 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]'
107
136
  end
108
137
 
109
138
  private
@@ -114,7 +143,31 @@ class UsersController < ApplicationController
114
143
  end
115
144
  ```
116
145
 
117
- 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.
146
+ Or, in case you want to have the avatar attached as soon as the user is created you can do:
147
+ ```ruby
148
+ class UsersController < ApplicationController
149
+ def create
150
+ user = User.create(user_params)
151
+ end
152
+
153
+ private
154
+
155
+ def user_params
156
+ params.require(:user).permit(:username, :email, avatar: [:data,
157
+ :filename,
158
+ :content_type,
159
+ :identify])
160
+ end
161
+ end
162
+ ```
163
+
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
+ ```
118
171
 
119
172
  ## Contributing
120
173
 
@@ -132,3 +185,10 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
132
185
 
133
186
  Special thanks to the people who helped with guidance and ensuring code quality in this project:
134
187
  *Santiago Bartesaghi, Santiago Vidal and Matias Mansilla.*
188
+
189
+ ## Credits
190
+
191
+ Active Storage Base64 is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our
192
+ [contributors](https://github.com/rootstrap/active-storage-base64/contributors).
193
+
194
+ [<img src="https://s3-us-west-1.amazonaws.com/rootstrap.com/img/rs.png" width="100"/>](http://www.rootstrap.com)
@@ -4,17 +4,30 @@ module ActiveStorageSupport
4
4
  module_function
5
5
 
6
6
  def attachment_from_data(attachment)
7
- fill_attachment_data(attachment, attachment.delete(:data)) if attachment.is_a?(Hash)
7
+ attachment = attachment.to_h if attachment.is_a?(ActionController::Parameters)
8
+
9
+ if attachment.is_a?(Hash)
10
+ attachment = attachment.symbolize_keys
11
+ fill_attachment_data(attachment, attachment.delete(:data))
12
+ end
8
13
 
9
14
  attachment
10
15
  end
11
16
 
12
17
  def fill_attachment_data(attachment, base64_data)
13
- return unless base64_data.try(:is_a?, String) && base64_data =~ /^data:(.*?);(.*?),(.*)$/
18
+ return unless base64_data.try(:is_a?, String) && base64_data.strip.start_with?('data')
19
+
20
+ headers, data = base64_data.split(',')
21
+ decoded_data = Base64.decode64(data)
14
22
 
15
- attachment[:io] = StringIO.new(Base64.decode64(Regexp.last_match(3)))
16
- attachment[:content_type] ||= Regexp.last_match(1)
23
+ attachment[:io] = StringIO.new(decoded_data)
24
+ attachment[:content_type] ||= content_type(headers)
17
25
  attachment[:filename] ||= Time.current.to_i.to_s
18
26
  end
27
+
28
+ def content_type(headers)
29
+ headers =~ /^data:(.*?)$/
30
+ Regexp.last_match(1).split(';base64').first
31
+ end
19
32
  end
20
33
  end
@@ -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,55 @@ 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)
9
+ has_one_attached name, dependent: dependent, service: service, strict_loading: strict_loading
10
10
 
11
- add_helper_method(ActiveStorageSupport::Base64One, 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
17
+ def #{name}=(attachable)
18
+ attachment_changes["#{name}"] =
19
+ if attachable.nil?
20
+ ActiveStorage::Attached::Changes::DeleteOne.new("#{name}", self)
21
+ else
22
+ ActiveStorage::Attached::Changes::CreateOne.new(
23
+ "#{name}", self, ActiveStorageSupport::Base64One.from_base64(attachable)
24
+ )
25
+ end
26
+ end
27
+ CODE
12
28
  end
13
29
 
14
- def has_many_base64_attached(name, dependent: :purge_later)
15
- has_many_attached name, dependent: dependent
30
+ def has_many_base64_attached(name, dependent: :purge_later, service: nil, strict_loading: false)
31
+ has_many_attached name, dependent: dependent, service: service, strict_loading: strict_loading
16
32
 
17
- add_helper_method(ActiveStorageSupport::Base64Many, name, dependent: dependent)
18
- end
19
-
20
- def add_helper_method(type, name, dependent:)
21
- class_eval <<-CODE, __FILE__, __LINE__ + 1
33
+ generated_association_methods.class_eval <<-CODE, __FILE__, __LINE__ + 1
34
+ # frozen_string_literal: true
22
35
  def #{name}
23
- @active_storage_attached_#{name} ||=
24
- #{type}.new("#{name}", self, dependent: #{dependent == :purge_later ? ':purge_later' : 'false'})
36
+ @active_storage_attached ||= {}
37
+ @active_storage_attached[:#{name}] ||= ActiveStorageSupport::Base64Many.new("#{name}", self)
25
38
  end
26
-
27
- def #{name}=(data)
28
- #{name}.attach(data)
39
+ def #{name}=(attachables)
40
+ if ActiveStorage.replace_on_assign_to_many
41
+ attachment_changes["#{name}"] =
42
+ if Array(attachables).none?
43
+ ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
44
+ else
45
+ ActiveStorage::Attached::Changes::CreateMany.new(
46
+ "#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables)
47
+ )
48
+ end
49
+ else
50
+ if Array(attachables).any?
51
+ attachment_changes["#{name}"] =
52
+ ActiveStorage::Attached::Changes::CreateMany.new(
53
+ "#{name}", self, #{name}.blobs + ActiveStorageSupport::Base64Many.from_base64(attachables)
54
+ )
55
+ end
56
+ end
29
57
  end
30
58
  CODE
31
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Cortio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-17 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,48 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
20
- - - "<="
21
- - !ruby/object:Gem::Version
22
- version: 5.2.2
19
+ version: '6.1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 5.2.0
30
- - - "<="
31
- - !ruby/object:Gem::Version
32
- version: 5.2.2
26
+ version: '6.1'
33
27
  - !ruby/object:Gem::Dependency
34
- name: rubocop
28
+ name: pry-rails
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 0.56.0
33
+ version: 0.3.6
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: 0.56.0
40
+ version: 0.3.6
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: reek
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 4.8.1
47
+ version: 5.5.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: 4.8.1
54
+ version: 5.5.0
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: rspec-rails
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -73,66 +67,55 @@ dependencies:
73
67
  - !ruby/object:Gem::Version
74
68
  version: 3.8.0
75
69
  - !ruby/object:Gem::Dependency
76
- name: sqlite3
70
+ name: rubocop
77
71
  requirement: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - '='
73
+ - - "~>"
80
74
  - !ruby/object:Gem::Version
81
- version: 1.3.13
75
+ version: 0.56.0
82
76
  type: :development
83
77
  prerelease: false
84
78
  version_requirements: !ruby/object:Gem::Requirement
85
79
  requirements:
86
- - - '='
80
+ - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: 1.3.13
82
+ version: 0.56.0
89
83
  - !ruby/object:Gem::Dependency
90
- name: pry-rails
84
+ name: simplecov
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: 0.3.6
89
+ version: 0.17.1
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: 0.3.6
96
+ version: 0.17.1
103
97
  - !ruby/object:Gem::Dependency
104
- name: simplecov
98
+ name: sqlite3
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - ">="
101
+ - - '='
108
102
  - !ruby/object:Gem::Version
109
- version: '0'
103
+ version: 1.4.1
110
104
  type: :development
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - ">="
108
+ - - '='
115
109
  - !ruby/object:Gem::Version
116
- version: '0'
110
+ version: 1.4.1
117
111
  description: Base64 support for ActiveStorage
118
112
  email: ricardo@rootstrap.com
119
113
  executables: []
120
114
  extensions: []
121
115
  extra_rdoc_files: []
122
116
  files:
123
- - ".gitignore"
124
- - ".rspec"
125
- - ".rubocop.yml"
126
- - ".travis.yml"
127
- - CODE_OF_CONDUCT.md
128
- - CONTRIBUTING.md
129
- - Gemfile
130
117
  - LICENSE.txt
131
118
  - README.md
132
- - Rakefile
133
- - active_storage_base64.gemspec
134
- - config.reek
135
- - gemfiles/RailsHeadGemfile
136
119
  - lib/active_storage_base64.rb
137
120
  - lib/active_storage_support/base64_attach.rb
138
121
  - lib/active_storage_support/base64_many.rb
@@ -150,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
133
  requirements:
151
134
  - - ">="
152
135
  - !ruby/object:Gem::Version
153
- version: 2.2.2
136
+ version: 2.5.0
154
137
  required_rubygems_version: !ruby/object:Gem::Requirement
155
138
  requirements:
156
139
  - - ">="
@@ -158,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
141
  version: '0'
159
142
  requirements: []
160
143
  rubyforge_project:
161
- rubygems_version: 2.7.7
144
+ rubygems_version: 2.5.2.3
162
145
  signing_key:
163
146
  specification_version: 4
164
147
  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
@@ -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
@@ -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
@@ -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
@@ -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.2'
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.0', '<= 5.2.2'
21
-
22
- # Development dependencies
23
- s.add_development_dependency 'rubocop', '~> 0.56.0'
24
- s.add_development_dependency 'reek', '~> 4.8.1'
25
- s.add_development_dependency 'rspec-rails', '~> 3.8.0'
26
- s.add_development_dependency 'sqlite3', '1.3.13'
27
- s.add_development_dependency 'pry-rails', '~> 0.3.6'
28
- s.add_development_dependency 'simplecov'
29
- end
@@ -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